-
Notifications
You must be signed in to change notification settings - Fork 838
evm: add clz example #4176
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
base: master
Are you sure you want to change the base?
evm: add clz example #4176
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR adds a new example demonstrating the CLZ (Count Leading Zeros) opcode introduced in EIP-7939 for the Osaka hardfork. The example shows how to use the new opcode with various test cases.
- Adds a comprehensive example file showcasing the CLZ opcode functionality
- Demonstrates four test cases covering edge cases: all zeros, minimal value, and different bit positions
- Uses manual bytecode assembly to construct and execute CLZ operations
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { type EVM, createEVM } from '@ethereumjs/evm' | ||
| import { type PrefixedHexString, hexToBytes } from '@ethereumjs/util' | ||
|
|
||
| const common = new Common({ |
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.
Could we add a little bit more description/context as to what this does and what the purpose of this example is? We could also link to the EIP https://eips.ethereum.org/EIPS/eip-7939 etc.
PR #4133 added support for the new CLZ opcode from EIP-7939.
The
CLZopcode (0x1e) pops one 256-bit word (x) from the stack and pushes the number of leading zero bits inx.This PR adds a small example script to demonstrate the opcode in action. It creates an Osaka hardfork EVM with EIP-7939 enabled and executes the CLZ opcode on a few different 32-byte inputs.