Skip to content

Conversation

@manuelmauro
Copy link
Contributor

@manuelmauro manuelmauro commented Jan 9, 2026

Description

Implements the Count Leading Zeros (CLZ) opcode as specified in https://eips.ethereum.org/EIPS/eip-7939.

Changes

  • Add CLZ opcode (0x1e) to evm-core
  • Add clz() function returning leading zero count (256 for zero input)
  • Add has_eip_7939 config flag, enabled starting from Osaka fork
  • Gas cost is set to 5 (G_LOW), matching MUL and consistent with both the EIP-7939 specification and go-ethereum's implementation.
  • Add Config::osaka() fork configuration

Copy link
Member

@sorpaas sorpaas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks straightforward. Let me know if it's ready.

@manuelmauro
Copy link
Contributor Author

Thank you @sorpaas ! I consider it ready 👍

@manuelmauro manuelmauro marked this pull request as ready for review January 12, 2026 08:28
Copy link

@librelois librelois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
@sorpaas can you merge it?

@sorpaas sorpaas merged commit a656db9 into rust-ethereum:v0.x Jan 12, 2026
2 checks passed
manuelmauro added a commit to moonbeam-foundation/evm that referenced this pull request Jan 13, 2026
* feat: ✨ add support for count leading zeros (CLZ) opcode

* style: 🎨 fmt

* refactor: ♻️ remove redundant check

* refactor: 🚨 clippy

* refactor: 🚨 more clippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants