-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new mode 2
to the LDC that allows to use the memory as a source for code
#849
Merged
Merged
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
de86a1a
allow ldc in predicates, still need to deal with storage and checked txs
Voxelot 4225346
checkpoint, plumbing storage and refactoring generics
Voxelot b4c4da3
plumbing of generics happy, now onto all the tests
Voxelot b0d0302
fix serde error in fuel-crypto
Voxelot 340f401
expose predicate storage module
Voxelot 2da51b1
avoid supertrait
Voxelot 3073daa
removing clone constraint, trying to reason through the async issues
Voxelot 74e7c3f
removed clone, made async happy
Voxelot 0b987e2
more alloc!
Voxelot bba89e4
disable alloc but keep serde in fuel-crypto
Voxelot e715fb1
Revert "disable alloc but keep serde in fuel-crypto"
Voxelot 090636c
battle of the feature flags
Voxelot 39eb13e
enable BSIZ and BLDD
Voxelot 156f2a8
Fixed compilation for tests.
xgreenx 4c43718
Removed `StorageUnavailable`
xgreenx d62ee4d
Updated CHANGELOG.md
xgreenx 6acc4ca
Add a new mode `2` to the LDC that allows to use the memory as a sour…
xgreenx ce1603a
Added more tests for mode 2
xgreenx a564f3f
Update fuel-asm/src/lib.rs
xgreenx 2a32a64
Updated CHANGELOG.md
xgreenx 5bbf301
Merge remote-tracking branch 'origin/feature/ldc-mode-2' into feature…
xgreenx 1b01a9d
Added tests that contract LDC is not allowed
xgreenx 4289674
Merge branch 'refs/heads/feature/predicate-ldc' into feature/ldc-mode-2
xgreenx 24e5b21
Merge branch 'refs/heads/master' into feature/ldc-mode-2
xgreenx d1c6283
Return back removed CHANGELOG.md
xgreenx 4e2d0df
Fix the comment
xgreenx 65c78d3
Apply comments
xgreenx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -321,7 +321,7 @@ mod tests { | |||||
Ok(()), | ||||||
), | ||||||
( | ||||||
// PC exceeding predicate bounds | ||||||
// Use `LDC` with mode `1` to load the blob into the predicate. | ||||||
vec![ | ||||||
// Allocate 32 byte on the heap. | ||||||
op::movi(0x10, 32), | ||||||
|
@@ -345,6 +345,41 @@ mod tests { | |||||
CORRECT_GAS, | ||||||
Ok(()), | ||||||
), | ||||||
( | ||||||
// Use `LDC` with mode `2` to load the part of the predicate from the | ||||||
// transaction. | ||||||
vec![ | ||||||
// Skip the return opcodes. One of two opcodes is a good opcode that | ||||||
// returns `0x1`. This opcode is our source for the `LDC` | ||||||
// opcode. We will copy return good opcode to the end | ||||||
// of the `ssp` via `LDC`. And jump there to | ||||||
// return `true` from the predicate. | ||||||
op::jmpf(ZERO, 2), | ||||||
// Bad return opcode that we want to skip. | ||||||
op::ret(0x0), | ||||||
// Good return opcode that we want to use for the `LDC`. | ||||||
op::ret(0x1), | ||||||
// This will be our zeroed blob id | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blob id? |
||||||
op::move_(0x10, IS), | ||||||
// We don't need to copy `jmpf` and bad `ret` opcodes via `LDC`. | ||||||
op::addi(0x10, 0x10, 2 * Instruction::SIZE as u16), | ||||||
// Store start of the code | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
op::move_(0x12, SSP), | ||||||
// Subtract the start of the code from the end of the code | ||||||
op::sub(0x12, 0x12, IS), | ||||||
// Divide the code by the instruction size to get the number of | ||||||
// instructions | ||||||
op::divi(0x12, 0x12, Instruction::SIZE as u16), | ||||||
// We want to load only on good `ret` opcode. | ||||||
op::movi(0x11, Instruction::SIZE as u32), | ||||||
// Load the code from the memory address `0x10` with the `0x11` size | ||||||
op::ldc(0x10, ZERO, 0x11, 2), | ||||||
// Jump to a new code location | ||||||
op::jmp(0x12), | ||||||
], | ||||||
CORRECT_GAS, | ||||||
Ok(()), | ||||||
), | ||||||
]; | ||||||
|
||||||
assert_inputs_are_validated_for_predicates(inputs, good_blob) | ||||||
|
@@ -399,7 +434,7 @@ mod tests { | |||||
)), | ||||||
), | ||||||
( | ||||||
// PC exceeding predicate bounds | ||||||
// Use `LDC` with mode `1` to load the blob into the predicate. | ||||||
vec![ | ||||||
// Allocate 32 byte on the heap. | ||||||
op::movi(0x10, 32), | ||||||
|
@@ -425,6 +460,43 @@ mod tests { | |||||
PanicReason::PredicateReturnedNonOne, | ||||||
)), | ||||||
), | ||||||
( | ||||||
// Use `LDC` with mode `2` to load the part of the predicate from the | ||||||
// transaction. | ||||||
vec![ | ||||||
// Skip the return opcodes. One of two opcodes is a bad opcode that | ||||||
// returns `0x0`. This opcode is our source for the `LDC` | ||||||
// opcode. We will copy return bad opcode to the end | ||||||
// of the `ssp` via `LDC`. And jump there to | ||||||
// return `false` from the predicate adn fail. | ||||||
op::jmpf(ZERO, 2), | ||||||
// Good return opcode that we want to skip. | ||||||
op::ret(0x1), | ||||||
// Bad return opcode that we want to use for the `LDC`. | ||||||
op::ret(0x0), | ||||||
// This will be our zeroed blob id | ||||||
op::move_(0x10, IS), | ||||||
// We don't need to copy `jmpf` and bad `ret` opcodes via `LDC`. | ||||||
op::addi(0x10, 0x10, 2 * Instruction::SIZE as u16), | ||||||
// Store start of the code | ||||||
op::move_(0x12, SSP), | ||||||
// Subtract the start of the code from the end of the code | ||||||
op::sub(0x12, 0x12, IS), | ||||||
// Divide the code by the instruction size to get the number of | ||||||
// instructions | ||||||
op::divi(0x12, 0x12, Instruction::SIZE as u16), | ||||||
// We want to load only on bad `ret` opcode. | ||||||
op::movi(0x11, Instruction::SIZE as u32), | ||||||
// Load the code from the memory address `0x10` with the `0x11` size | ||||||
op::ldc(0x10, ZERO, 0x11, 2), | ||||||
// Jump to a new code location | ||||||
op::jmp(0x12), | ||||||
], | ||||||
CORRECT_GAS, | ||||||
Err(PredicateVerificationFailed::Panic( | ||||||
PanicReason::PredicateReturnedNonOne, | ||||||
)), | ||||||
), | ||||||
]; | ||||||
|
||||||
assert_inputs_are_validated_for_predicates(inputs, bad_blob) | ||||||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is all the following validation logic new?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the logic from
self.read(src, len)
andself.write_noownerchecks(dst, len)?
here to avoidto_vec
fortmp
slice