-
Couldn't load subscription status.
- Fork 6.2k
EIP 4844 (part 2) #14759
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
EIP 4844 (part 2) #14759
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1035,9 +1035,13 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) | |
| break; | ||
| } | ||
| case FunctionType::Kind::BlockHash: | ||
| case FunctionType::Kind::BlobHash: | ||
| { | ||
| acceptAndConvert(*arguments[0], *function.parameterTypes()[0], true); | ||
| m_context << Instruction::BLOCKHASH; | ||
| if (function.kind() == FunctionType::Kind::BlockHash) | ||
| m_context << Instruction::BLOCKHASH; | ||
| else | ||
| m_context << Instruction::BLOBHASH; | ||
|
Comment on lines
+1038
to
+1044
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. Not sure I really like this approach - these are separate cases for a reason - why would you combine them and then perform another check as to what the function kind is? Of course, it's easy to see what's going on once you read the code, but it's confusing at first glance - initially, I thought they may have the same opcode and use the difficulty/prevrandao mechanism based on the fork, which is obviously not the case. 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. Yeah, this one is short enough that it would have been clearer as a separate handler. Still, when the code is longer this approach makes sense. The handler in 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. I initially implemented them separately, but as pointed out in #14759 (comment) there are instances where multiple built-ins are handled within the same case, both in 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. Which is why I didn't complain about it myself, but @nikola-matic does have a point here :) 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. @r0qs we seem to have wormholed ourselves into a parallel universe where Kamil doesn't complain, and I do. :D |
||
| break; | ||
| } | ||
| case FunctionType::Kind::AddMod: | ||
|
|
||
r0qs marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| contract C { | ||
| function f() public view returns(bytes32) { | ||
| return blobhash(0); | ||
| } | ||
| function g() public view returns(bytes32) { | ||
| return blobhash(1); | ||
| } | ||
| function h() public view returns(bytes32) { | ||
| // NOTE: blobhash(2) should return 0 since EVMHost has only two blob hashes injected in the block the transaction is being executed. | ||
| return blobhash(2); | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // f() -> 0x0100000000000000000000000000000000000000000000000000000000000001 | ||
| // g() -> 0x0100000000000000000000000000000000000000000000000000000000000002 | ||
| // h() -> 0x00 | ||
r0qs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| contract C { | ||
| function blobhash(uint256 index) public pure returns(bytes32) { | ||
| return bytes32(index); | ||
| } | ||
| function f() public pure returns(bytes32) { | ||
| return blobhash(3); | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // f() -> 0x03 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| contract C { | ||
| function f(uint _index) public returns (bytes32) { | ||
| return blobhash(_index); | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // f(uint256): 0 -> 0x0100000000000000000000000000000000000000000000000000000000000001 | ||
| // f(uint256): 1 -> 0x0100000000000000000000000000000000000000000000000000000000000002 | ||
| // f(uint256): 2 -> 0x00 | ||
| // f(uint256): 255 -> 0x00 | ||
| // f(uint256): 256 -> 0x00 | ||
| // f(uint256): 257 -> 0x00 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| contract C { | ||
| function f() public returns (bytes32) { | ||
| // NOTE: The `tx_context.blob_hashes` is injected into EVMHost with the following hashes, indexed accordingly: | ||
| // 0 -> 0x0100000000000000000000000000000000000000000000000000000000000001 | ||
| // 1 -> 0x0100000000000000000000000000000000000000000000000000000000000002 | ||
| return (blobhash)(0); | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // f() -> 0x0100000000000000000000000000000000000000000000000000000000000001 | ||
r0qs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| contract C { | ||
| function blobhash(uint256 index) public pure returns(bytes32) { | ||
| return bytes32(index); | ||
| } | ||
| function f() public pure returns(bytes32) { | ||
| return blobhash(2); | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: <=shanghai | ||
| // ---- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| contract C { | ||
| function blobhash(uint256 index) public pure returns(bytes32) { | ||
| return bytes32(index); | ||
| } | ||
| function f() public pure returns(bytes32) { | ||
| return blobhash(2); | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // Warning 2319: (17-117): This declaration shadows a builtin symbol. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| contract C | ||
| { | ||
| function f() public pure { | ||
| blobhash; | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // Warning 6133: (52-60): Statement has no effect. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| contract C | ||
| { | ||
| function f() public pure { | ||
| blobhash; | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: <=shanghai | ||
| // ---- | ||
| // DeclarationError 7576: (52-60): Undeclared identifier. Did you mean "blockhash"? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| contract C { | ||
| function f() public pure returns (bool) { | ||
| bool blobhash = true; | ||
| return blobhash; | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: <=shanghai | ||
| // ---- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| contract C | ||
| { | ||
| function f() public pure returns (bool) { | ||
| bool blobhash = true; | ||
| return blobhash; | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=cancun | ||
| // ---- | ||
| // Warning 2319: (67-80): This declaration shadows a builtin symbol. | ||
r0qs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| 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 | ||
| // ---- |
Uh oh!
There was an error while loading. Please reload this page.