From 9188e658d8a66b0bd1662b19a3c16f014d8b85bb Mon Sep 17 00:00:00 2001 From: Sreekesh V Date: Wed, 25 Aug 2021 11:58:02 +0530 Subject: [PATCH 1/3] Revert "Allow basefee as Yul identifier for EVMVersion < london" This reverts commit 7f1a2be0fee99531b5e9c0eca7dc1c70b9ffcaa0. Added changes to changelog to include Make basfee as a reserved identifier added changes under the breaking changes rst file Update Changelog.md Co-authored-by: Harikrishnan Mulackal Update 090-breaking-changes.rst moved the changes under "New restrictions" section Update Changelog.md avoided removing line no 6 Update docs/090-breaking-changes.rst Co-authored-by: Alex Beregszaszi --- docs/090-breaking-changes.rst | 2 +- libyul/backends/evm/EVMDialect.cpp | 14 +++----------- scripts/error_codes.py | 3 +-- .../types/magic_block_basefee_error.sol | 9 ++++++++- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/docs/090-breaking-changes.rst b/docs/090-breaking-changes.rst index 3df7f21da..ea655732b 100644 --- a/docs/090-breaking-changes.rst +++ b/docs/090-breaking-changes.rst @@ -15,7 +15,7 @@ Silent Changes of the Semantics New Restrictions ================ -... +- Make ``basefee`` a reserved identifier in assembly. Interface Changes ================= diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index 0fefb24d0..c45268fba 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -109,22 +109,14 @@ pair createFunction( return {name, f}; } -set createReservedIdentifiers(langutil::EVMVersion _evmVersion) +set createReservedIdentifiers() { - // TODO remove this in 0.9.0. We allow creating functions or identifiers in Yul with the name - // basefee for VMs before london. - auto baseFeeException = [&](evmasm::Instruction _instr) -> bool - { - return _instr == evmasm::Instruction::BASEFEE && _evmVersion < langutil::EVMVersion::london(); - }; - set reserved; for (auto const& instr: evmasm::c_instructions) { string name = instr.first; transform(name.begin(), name.end(), name.begin(), [](unsigned char _c) { return tolower(_c); }); - if (!baseFeeException(instr.second)) - reserved.emplace(name); + reserved.emplace(name); } reserved += vector{ "linkersymbol"_yulstring, @@ -292,7 +284,7 @@ EVMDialect::EVMDialect(langutil::EVMVersion _evmVersion, bool _objectAccess): m_objectAccess(_objectAccess), m_evmVersion(_evmVersion), m_functions(createBuiltins(_evmVersion, _objectAccess)), - m_reserved(createReservedIdentifiers(_evmVersion)) + m_reserved(createReservedIdentifiers()) { } diff --git a/scripts/error_codes.py b/scripts/error_codes.py index f3d35cae4..9b6fd0677 100755 --- a/scripts/error_codes.py +++ b/scripts/error_codes.py @@ -201,8 +201,7 @@ def examine_id_coverage(top_dir, source_id_to_file_names, new_ids_only=False): # The warning may or may not exist in a compiler build. "4591", # "There are more than 256 warnings. Ignoring the rest." # Due to 3805, the warning lists look different for different compiler builds. - "1834", # Unimplemented feature error, as we do not test it anymore via cmdLineTests - "5430" # basefee being used in inline assembly for EVMVersion < london + "1834" # Unimplemented feature error, as we do not test it anymore via cmdLineTests } assert len(test_ids & white_ids) == 0, "The sets are not supposed to intersect" test_ids |= white_ids diff --git a/test/libsolidity/syntaxTests/types/magic_block_basefee_error.sol b/test/libsolidity/syntaxTests/types/magic_block_basefee_error.sol index b723d0aee..3e1650ad8 100644 --- a/test/libsolidity/syntaxTests/types/magic_block_basefee_error.sol +++ b/test/libsolidity/syntaxTests/types/magic_block_basefee_error.sol @@ -2,8 +2,15 @@ contract C { function f() public view returns (uint) { return block.basefee; } + function g() public view returns (uint ret) { + assembly { + ret := basefee() + } + } } // ==== -// EVMVersion: <=berlin +// EVMVersion: =berlin // ---- // 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"). +// DeclarationError 8678: (176-192): Variable count for assignment to "ret" does not match number of values (1 vs. 0) From 5941f029ad96547dffc228ade02c8e49d997b103 Mon Sep 17 00:00:00 2001 From: Sreekesh V <61742339+v-sreekesh@users.noreply.github.com> Date: Tue, 31 Aug 2021 10:05:40 +0530 Subject: [PATCH 2/3] Added changes in changelog.md --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index ec8724502..073abe410 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ Breaking changes: * Inline Assembly: Consider functions, function parameters and return variables for shadowing checks. * Commandline Interface: Remapping targets are not automatically added to allowed paths. * Commandline Interface: Assembler mode no longer enables all outputs by default. + * General: The identifier ``basefee`` is a reserved identifier in Yul for all EVM versions. ### 0.8.13 (unreleased) From 8e2f9296480dcb4f8e3ee4dfaf529d4494567749 Mon Sep 17 00:00:00 2001 From: wechman Date: Wed, 2 Mar 2022 07:49:56 +0100 Subject: [PATCH 3/3] Move basefee_berlin_function test to syntax tests. --- .../inlineAssembly/basefee_berlin_function.sol | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) rename test/libsolidity/{semanticTests => syntaxTests}/inlineAssembly/basefee_berlin_function.sol (63%) diff --git a/test/libsolidity/semanticTests/inlineAssembly/basefee_berlin_function.sol b/test/libsolidity/syntaxTests/inlineAssembly/basefee_berlin_function.sol similarity index 63% rename from test/libsolidity/semanticTests/inlineAssembly/basefee_berlin_function.sol rename to test/libsolidity/syntaxTests/inlineAssembly/basefee_berlin_function.sol index 81c1ee431..89ae0f445 100644 --- a/test/libsolidity/semanticTests/inlineAssembly/basefee_berlin_function.sol +++ b/test/libsolidity/syntaxTests/inlineAssembly/basefee_berlin_function.sol @@ -15,8 +15,7 @@ contract C { } } // ==== -// compileViaYul: also -// EVMVersion: <=berlin +// EVMVersion: =berlin // ---- -// f() -> 0 -// g() -> 1000 +// DeclarationError 5017: (98-105): The identifier "basefee" is reserved and can not be used. +// DeclarationError 5017: (242-307): The identifier "basefee" is reserved and can not be used.