Conversation
There was a problem hiding this comment.
Looks good, but I guess we have to fix/circunvent some tests (at least for now)
test_antl_grammar.sh needs to skip slotnum_osaka_function.sol for chk_antlr_grammar to pass.
We can also add a test case in test/libsolidity/ViewPureChecker.cpp and syntaxTests/constants/initialization/block_tx_msg_property.sol (although I guess they depend on restricting the evm version).
| - ``block.gaslimit`` (``uint``): current block gaslimit | ||
| - ``block.number`` (``uint``): current block number | ||
| - ``block.prevrandao`` (``uint``): random number provided by the beacon chain (``EVM >= Paris``) (see `EIP-4399 <https://eips.ethereum.org/EIPS/eip-4399>`_ ) | ||
| - ``block.slotnum`` (``uint``): current beacon chain slot number (``EVM >= Amsterdam``) (see `EIP-7843 <https://eips.ethereum.org/EIPS/eip-7843>`_ ) |
There was a problem hiding this comment.
The EIP guarantees that the returned value fits in uint64 (because that's how it's stored in the state), so I think we can give the builtin that type.
| {"basefee", TypeProvider::uint256()}, | ||
| {"blobbasefee", TypeProvider::uint256()} | ||
| {"blobbasefee", TypeProvider::uint256()}, | ||
| {"slotnum", TypeProvider::uint256()} |
There was a problem hiding this comment.
| {"slotnum", TypeProvider::uint256()} | |
| {"slotnum", TypeProvider::uint256()}, |
| // TODO remove this in 0.9.0. We allow creating functions or identifiers in Yul with the name | ||
| // slotnum for VMs before amsterdam. | ||
| auto slotNumException = [&](evmasm::Instruction _instr) -> bool | ||
| { | ||
| return _instr == evmasm::Instruction::SLOTNUM && !_evmVersion.hasSlotNum(); | ||
| }; |
| } | ||
| } | ||
| // ==== | ||
| // EVMVersion: <=osaka |
There was a problem hiding this comment.
IMO it would be slightly better do do this when possible:
| // EVMVersion: <=osaka | |
| // EVMVersion: <amsterdam |
because it will make the test show up when you search for "Amsterdam". And it makes it unnecessary to know what the exact order of versions where - what's important is pre/post Amsterdam.
Same for test names.
|
I updated our guide to cover new opcodes with a high-level builtin based on our past PRs. I did not find anything missing, but please double check: https://notes.argot.org/@solidity-new-opcode-guide#Special-case-Opcodes-with-a-high-level-Solidity-builtin. Especially the Yul part and test coverage. |
Description
This PR implements support for
SLOTNUMopcode in the EVM.Introduces:
slotnumin theblockglobal variable on solidity language levelslotnum()function in yul and inline assemblyslotnumidentifier in the yul and inline assembly starting fromamsterdamfork.AI Disclosure
Claude Code, Anthropic's CLI for Claude (running on the Sonnet 5 model).