-
Notifications
You must be signed in to change notification settings - Fork 2
Add ASSERT_UNREACHABLE and environment opcode semantics #24
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
Conversation
Implement semantics for many Venom IR opcodes that compile to EVM: Assertions: - ASSERT: revert if condition is zero - ASSERT_UNREACHABLE: halt if condition is non-zero Environment context (new state fields): - call_context: caller, address, callvalue, calldata, gas - tx_context: origin, gasprice, chainid - block_context: coinbase, timestamp, number, prevrandao, gaslimit, basefee, blobbasefee, blockhash Environment opcodes: - CALLER, ADDRESS, CALLVALUE, GAS - ORIGIN, GASPRICE, CHAINID - COINBASE, TIMESTAMP, NUMBER, PREVRANDAO, GASLIMIT, BASEFEE, BLOBBASEFEE, BLOCKHASH - BALANCE, SELFBALANCE Calldata/returndata: - CALLDATASIZE, CALLDATALOAD, CALLDATACOPY - RETURNDATASIZE, RETURNDATACOPY - MSIZE Hashing (using Keccak from HOL4): - SHA3: Keccak256 on memory region - SHA3_64: Keccak256 on two words (Vyper optimization) External calls (CALL, STATICCALL, DELEGATECALL) are left unimplemented for now - they error out. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
venom/venomSemScript.sml
Outdated
| let dest = w2n destOffset in | ||
| let mem = s.vs_memory in | ||
| let needed = (dest + size) - LENGTH mem in | ||
| let expanded = if needed > 0 then mem ++ REPLICATE needed 0w else mem in |
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.
we do have expand_memory helpers in verifereum that could possibly be used here
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 think we should probably just add comments everywhere that verifereum functionality could be used and then do a pass over verifereum to extract helper functions for each opcode, then revisit this code after that pass
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 don't think there are that many other opportunities. Maybe if verifereum were refactored too, but I don't want this to bleed into that for now...
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.
Extract the common pattern of expanding memory then writing bytes into a reusable helper function write_memory_with_expansion. Refactor CALLDATACOPY and RETURNDATACOPY to use this helper, reducing code duplication. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Summary
Opcodes Implemented
Assertions:
Environment:
Calldata/Returndata:
Hashing:
Not Implemented
External calls (CALL, STATICCALL, DELEGATECALL) are left as "unimplemented opcode" errors for now.
Test plan
Holmakebuilds successfully🤖 Generated with Claude Code