Skip to content

Conversation

@ScottyPoi
Copy link
Contributor

PR #4133 added support for the new CLZ opcode from EIP-7939.

The CLZ opcode (0x1e) pops one 256-bit word (x) from the stack and pushes the number of leading zero bits in x.

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.

Copilot AI review requested due to automatic review settings November 7, 2025 22:52
@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.79%. Comparing base (f91b729) to head (03b4221).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 87.81% <ø> (ø)
blockchain 89.37% <ø> (ø)
common 96.75% <ø> (ø)
evm 72.39% <ø> (ø)
mpt 89.69% <ø> (-0.06%) ⬇️
statemanager 80.21% <ø> (ø)
static 99.77% <ø> (ø)
tx 88.35% <ø> (ø)
util 89.62% <ø> (ø)
vm 57.42% <ø> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a 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({
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants