-
Notifications
You must be signed in to change notification settings - Fork 6.3k
EIP 4844 - blobhash opcode (part 1) #14757
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
11 changes: 11 additions & 0 deletions
11
test/libsolidity/semanticTests/inlineAssembly/blobhash.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| contract C { | ||
| function f() public view returns (bytes32 ret) { | ||
| assembly { | ||
| ret := blobhash(0) | ||
| } | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // f() -> 0x0100000000000000000000000000000000000000000000000000000000000001 |
14 changes: 14 additions & 0 deletions
14
test/libsolidity/semanticTests/inlineAssembly/blobhash_index_exceeding_blob_count.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| contract C { | ||
| function f() public view returns (bytes32 ret) { | ||
| assembly { | ||
| // EIP-4844 specifies that if `index < len(tx.blob_versioned_hashes)`, `blobhash(index)` should return 0. | ||
| // Thus, as we injected only two blob hashes in the transaction context in EVMHost, | ||
| // the return value of the function below MUST be zero. | ||
| ret := blobhash(2) | ||
| } | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // f() -> 0x00 |
21 changes: 21 additions & 0 deletions
21
test/libsolidity/semanticTests/inlineAssembly/blobhash_pre_cancun.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| contract C { | ||
| function f() public pure returns (uint ret) { | ||
| assembly { | ||
| let blobhash := 1 | ||
| ret := blobhash | ||
| } | ||
| } | ||
| function g() public pure returns (uint ret) { | ||
| assembly { | ||
| function blobhash() -> r { | ||
| r := 1000 | ||
| } | ||
| ret := blobhash() | ||
| } | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: <=shanghai | ||
| // ---- | ||
| // f() -> 1 | ||
| // g() -> 1000 |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| contract C { | ||
| function f() public view returns (bytes32 ret) { | ||
| assembly { | ||
| ret := blobhash(1) | ||
| } | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- |
12 changes: 12 additions & 0 deletions
12
test/libsolidity/syntaxTests/inlineAssembly/blobhash_pre_cancun.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| contract C { | ||
| function f() pure external returns (bytes32 ret) { | ||
| assembly { | ||
| ret := blobhash() | ||
| } | ||
cameel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: <=shanghai | ||
| // ---- | ||
| // DeclarationError 4619: (106-114): Function "blobhash" not found. | ||
| // DeclarationError 8678: (99-116): Variable count for assignment to "ret" does not match number of values (1 vs. 0) | ||
14 changes: 14 additions & 0 deletions
14
test/libsolidity/syntaxTests/inlineAssembly/blobhash_reserved_cancun.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| contract C { | ||
| function f() public pure returns (uint ret) { | ||
| assembly { | ||
| function blobhash() -> r { | ||
| r := 1000 | ||
| } | ||
| ret := blobhash() | ||
| } | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // ParserError 5568: (103-111): Cannot use builtin function name "blobhash" as identifier name. |
9 changes: 9 additions & 0 deletions
9
test/libsolidity/syntaxTests/viewPureChecker/blobhash_not_pure.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| contract C { | ||
| function f() public pure { | ||
| assembly { pop(blobhash(0)) } | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // TypeError 2527: (67-78): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". |
1 change: 1 addition & 0 deletions
1
...solidity/syntaxTests/viewPureChecker/inline_assembly_instructions_allowed_view_cancun.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| contract C { | ||
| function f() public view { | ||
| assembly { | ||
| pop(blobhash(0)) | ||
| pop(blobbasefee()) | ||
| } | ||
| } | ||
|
|
||
4 changes: 3 additions & 1 deletion
4
...idity/syntaxTests/viewPureChecker/inline_assembly_instructions_disallowed_pure_cancun.sol
This file contains hidden or 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 |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| contract C { | ||
| function f() public pure { | ||
| assembly { | ||
| pop(blobhash(0)) | ||
| pop(blobbasefee()) | ||
| } | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // TypeError 2527: (79-92): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". | ||
| // TypeError 2527: (79-90): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". | ||
| // TypeError 2527: (108-121): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| sstore(0, blobhash(0)) | ||
| sstore(1, blobhash(1)) | ||
| sstore(2, blobhash(2)) // should store 0 since EVMHost has only two blob hashes injected in the block the transaction is being executed. | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // Trace: | ||
| // Memory dump: | ||
| // Storage dump: | ||
| // 0000000000000000000000000000000000000000000000000000000000000000: 014916dd28fc4c10d78e287ca5d9cc51ee1ae73cbfde08c6b37324cbfaac8bc5 | ||
| // 0000000000000000000000000000000000000000000000000000000000000001: 0167d3dbed802941483f1afa2a6bc68de5f653128aca9bf1461c5d0a3ad36ed2 |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| { | ||
| let blobhash := 1 | ||
| } | ||
|
|
||
| { | ||
| function blobhash() {} | ||
| blobhash() | ||
| } | ||
| } | ||
|
|
||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // ParserError 5568: (20-28): Cannot use builtin function name "blobhash" as identifier name. |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| { | ||
| let blobhash := 1 | ||
| } | ||
|
|
||
| { | ||
| function blobhash() {} | ||
| blobhash() | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: <=shanghai | ||
| // ---- |
This file contains hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Oh, one more thing, let's finally stop messing with the spacing in the changelog :)
I fixed it earlier in all those PRs but it keeps reappearing again and again for some reason. Don't worry about the wrong spacing of the
Compiler Features:section. We'll fix it when we sort the changelog. In PRs just add an entry for your PR and don't touch other lines.