-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Implement London EVMVersion and the BASEFEE opcode #11647
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
Changes from all commits
d92b211
95091f6
543ccf5
af1dabb
cb9b52c
43605d9
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 |
|---|---|---|
|
|
@@ -51,10 +51,11 @@ class EVMVersion: | |
| static EVMVersion petersburg() { return {Version::Petersburg}; } | ||
| static EVMVersion istanbul() { return {Version::Istanbul}; } | ||
| static EVMVersion berlin() { return {Version::Berlin}; } | ||
| static EVMVersion london() { return {Version::London}; } | ||
|
|
||
| static std::optional<EVMVersion> fromString(std::string const& _version) | ||
| { | ||
| for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin()}) | ||
| for (auto const& v: {homestead(), tangerineWhistle(), spuriousDragon(), byzantium(), constantinople(), petersburg(), istanbul(), berlin(), london()}) | ||
| if (_version == v.name()) | ||
| return v; | ||
| return std::nullopt; | ||
|
|
@@ -75,6 +76,7 @@ class EVMVersion: | |
| case Version::Petersburg: return "petersburg"; | ||
| case Version::Istanbul: return "istanbul"; | ||
| case Version::Berlin: return "berlin"; | ||
| case Version::London: return "london"; | ||
| } | ||
| return "INVALID"; | ||
| } | ||
|
|
@@ -87,6 +89,7 @@ class EVMVersion: | |
| bool hasExtCodeHash() const { return *this >= constantinople(); } | ||
| bool hasChainID() const { return *this >= istanbul(); } | ||
| bool hasSelfBalance() const { return *this >= istanbul(); } | ||
| bool hasBaseFee() const { return *this >= london(); } | ||
|
|
||
| bool hasOpcode(evmasm::Instruction _opcode) const; | ||
|
Contributor
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. Needs change
Contributor
Author
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. It's done in 0c8b612
Contributor
Author
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. Or second commit in #11763 |
||
|
|
||
|
|
@@ -95,7 +98,7 @@ class EVMVersion: | |
| bool canOverchargeGasForCall() const { return *this >= tangerineWhistle(); } | ||
|
|
||
| private: | ||
| enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin }; | ||
| enum class Version { Homestead, TangerineWhistle, SpuriousDragon, Byzantium, Constantinople, Petersburg, Istanbul, Berlin, London }; | ||
|
|
||
| EVMVersion(Version _version): m_version(_version) {} | ||
|
|
||
|
Contributor
Author
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'll make a separate PR changing the default to London. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| contract C { | ||
| function f() public view returns (uint) { | ||
| return block.basefee; | ||
| } | ||
| function g() public view returns (uint ret) { | ||
| assembly { | ||
| ret := basefee() | ||
| } | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=london | ||
| // compileViaYul: also | ||
| // ---- | ||
| // f() -> 7 | ||
| // g() -> 7 | ||
| // f() -> 7 | ||
| // g() -> 7 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| contract C { | ||
| function f() public view returns (uint) { | ||
| return block.basefee; | ||
| } | ||
| function g() public view returns (uint ret) { | ||
| assembly { | ||
| ret := basefee() | ||
| } | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: =berlin | ||
ekpyron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // ---- | ||
| // TypeError 5921: (74-87): "basefee" is not supported by the VM version. | ||
| // TypeError 5430: (183-190): The "basefee" instruction is only available for London-compatible VMs (you are currently compiling for "berlin"). | ||
ekpyron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| contract C { | ||
| function f() public view returns (uint) { | ||
| return block.basefee; | ||
| } | ||
| function g() public view returns (uint ret) { | ||
| assembly { | ||
| ret := basefee() | ||
| } | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=london | ||
| // ---- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| contract C { | ||
| function f() public pure { | ||
| assembly { pop(basefee()) } | ||
| } | ||
| function g() public pure returns (uint) { | ||
| return block.basefee; | ||
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: >=london | ||
| // ---- | ||
| // TypeError 2527: (67-76): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". | ||
| // TypeError 2527: (147-160): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,5 +13,5 @@ object "a" { | |
| // stop | ||
| // data_acaf3289d7b601cbd114fb36c4d29c85bbfd5e133f14cb355c3fd8d99367964f 48656c6c6f2c20576f726c6421 | ||
| // Bytecode: 6006600055fe48656c6c6f2c20576f726c6421 | ||
| // Opcodes: PUSH1 0x6 PUSH1 0x0 SSTORE INVALID 0x48 PUSH6 0x6C6C6F2C2057 PUSH16 0x726C6421000000000000000000000000 | ||
| // Opcodes: PUSH1 0x6 PUSH1 0x0 SSTORE INVALID BASEFEE PUSH6 0x6C6C6F2C2057 PUSH16 0x726C6421000000000000000000000000 | ||
|
Contributor
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. :) |
||
| // SourceMappings: 32:19:0:-:0;29:1;22:30 | ||
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.
The doc on the top also explains what these letters stand for,
Lis missing.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.
Thanks. Fixed.