Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements EIP-7939 (Count Leading Zeros) for the FEVM EVM interpreter by adding the CLZ opcode at byte position 0x1e. The opcode counts the number of leading zero bits in a 256-bit word, returning 256 when the input is zero.
Changes:
- Added CLZ opcode (0x1e) to the opcode dispatch table
- Implemented CLZ semantics using U256's
leading_zeros()method - Added comprehensive test coverage including unit tests, bytecode-level tests, and end-to-end actor tests
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| actors/evm/src/interpreter/execution.rs | Adds CLZ opcode at 0x1e to the opcode table and includes it in underflow testing |
| actors/evm/src/interpreter/instructions/mod.rs | Defines CLZ instruction using the def_primop! macro with single operand |
| actors/evm/src/interpreter/instructions/bitwise.rs | Implements clz function and includes unit tests and bytecode-level integration tests |
| actors/evm/tests/eip7939_clz.rs | Adds end-to-end test with EIP-7939 test vectors using a deployed EVM actor |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@LesnyRumcajs : are you or someone on Forest able to take a look at this one? |
There was a problem hiding this comment.
nit: this PR doesn't need to change the lockfile (fine to do it in a separate PR); especially the syn major version downgrade is suspicious.
| #[inline] | ||
| pub fn clz(value: U256) -> U256 { | ||
| U256::from(value.leading_zeros()) | ||
| } |
There was a problem hiding this comment.
nit: it might be obvious to some, but my brain doesn't immediately click that clz is count leading zeroes. One line of docs would reduce mental overhead.
| mod tests { | ||
| use crate::evm_unit_test; | ||
|
|
||
| #[test] |
There was a problem hiding this comment.
I don't think it's a valuable test. If we want to check the def_opcodes macro works, lets write a test to for it entirely.
Summary
Implements Ethereum EIP-7939 (Count Leading Zeros) for the FEVM EVM interpreter by adding the
CLZopcode at byte0x1e.Changes
CLZ(0x1e) to the opcode table and instruction dispatch.CLZsemantics over 256-bit words (CLZ(0) = 256).CLZin a deployed EVM actorNotes
cargo testmay require a wasm32-capable clang; on macOS this can be run withCC=/opt/homebrew/opt/llvm/bin/clang cargo test.Related