-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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 block.prevrandao
as alias for block.difficulty
#13759
Conversation
test/libsolidity/syntaxTests/inlineAssembly/prevrandao_reserved_paris.sol
Outdated
Show resolved
Hide resolved
I only had a quick look over this so far, but this looks generally good! I think we can still reduce the number of cases, in which we have to drag along the evm version a bit and switch between passing it along and storing it in some cases, but most of it looks good already! Testing failures seem mostly or entirely SMT related bugs independent of this PR. |
71d2abf
to
553aae5
Compare
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.
Some suggestions and questions. Haven't gone through everything yet.
34c0beb
to
7a2f21d
Compare
9e3c982
to
7b99050
Compare
9c35c73
to
5f349e2
Compare
There was an error when running
Please check that your changes are working as intended. |
484c674
to
392dad8
Compare
Only some very minor comments and a question left. We can probably merge it soon (we should squash the 66+ commits then, though :-)) |
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.
Looks like you missed quite a few of the block.difficulty
tests in terms of adding EVMVersion: <paris
.
test/libsolidity/semanticTests/state/block_difficulty.sol
test/libsolidity/semanticTests/state/block_difficulty_post_paris.sol
test/libsolidity/smtCheckerTests/bmc_coverage/range_check.sol
test/libsolidity/smtCheckerTests/special/block_vars_bmc_internal.sol
test/libsolidity/smtCheckerTests/special/block_vars_chc_internal.sol
test/libsolidity/smtCheckerTests/special/difficulty.sol
test/libsolidity/smtCheckerTests/special/many.sol
test/libsolidity/smtCheckerTests/special/many_internal.sol
test/libsolidity/smtCheckerTests/special/range_check.sol
test/libsolidity/smtCheckerTests/special/tx_data_immutable.sol
test/libsolidity/smtCheckerTests/special/tx_data_immutable_fail.sol
test/libsolidity/syntaxTests/types/magic_block.sol
test/libsolidity/syntaxTests/types/magic_block_istanbul.sol
Unless you wanna fix those up in #13883?
Yes, related with the smtCheckerTests, I'm adding them right now in #13883 because SMT tests only run for the default EVM version. For the For the syntaxTests in questions indeed it is missing the |
test/libsolidity/syntaxTests/viewPureChecker/inline_assembly_instructions_disallowed_paris.sol
Outdated
Show resolved
Hide resolved
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'm approving this - but we should squash the commits before merging. A single commit should suffice :-).
Deprecates `block.difficulty` and disallow `difficulty()` in inline assembly for EVM versions >= paris. The change is due to the renaming introduced by EIP-4399 (see: https://eips.ethereum.org/EIPS/eip-4399). Introduces `block.prevrandao` in Solidity and `prevrandao()` in inline assembly for EVM versions >= paris. Co-authored-by: Alex Beregszaszi <alex@rtfs.hu> Co-authored-by: Daniel <daniel@ekpyron.org> Co-authored-by: matheusaaguiar <95899911+matheusaaguiar@users.noreply.github.com> Co-authored-by: Nikola Matić <nikola.matic@ethereum.org>
@@ -221,7 +221,7 @@ class GasMeter | |||
|
|||
/// @returns gas costs for simple instructions with constant gas costs (that do not |
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 this comment still correct? I mean we have now the EVM version as a parameter here - so something may be different based on that information, right?
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.
Ah ok, maybe not - gas costs seem to be still the same
Supersedes #13531. Fixes #13512.
This PR is an attempt to finish the work started in #13531. It reuses part of the solution proposed there but ignores the renaming of the
Instruction
enum.As both opcodes share the same bytecode for different EVMs, the EVM version determine whether the compiler outputs one or the other in the
instructionInfo
function. The table below illustrate the expected behavior:difficulty
: builtin and reserved identifier (not changed). Not allowed as user-defined identifier.prevrandao
: not reserved. Allowed as user-defined identifier.difficulty
: reserved identifier (warning, behave as prevrandao).prevrandao
: builtin and reserved identifier. Not allowed as user-defined identifier.difficulty
: not reserved. Allowed as user-defined identifier.prevrandao
: builtin and reserved identifier. Not allowed as user-defined identifier.block.difficulty
andblock.prevrandao
are allowed in all versions with their appropriate warnings.