Skip to content

evm: add pushData to step trace for PUSH0–PUSH32#4283

Open
alirazzaq-dev wants to merge 1 commit into
ethereumjs:masterfrom
alirazzaq-dev:feat/evm-step-pushdata-2418
Open

evm: add pushData to step trace for PUSH0–PUSH32#4283
alirazzaq-dev wants to merge 1 commit into
ethereumjs:masterfrom
alirazzaq-dev:feat/evm-step-pushdata-2418

Conversation

@alirazzaq-dev
Copy link
Copy Markdown

Summary

Implements Issue #2418: when tracing via the EVM step event, expose the bytes that PUSH0PUSH32 place on the stack in an optional InterpreterStep field so callers do not have to re-slice bytecode. PUSH0 has no immediate in the existing stackDelta path; this change sets pushData to a single 0x00 byte for that opcode. For PUSH1PUSH32, pushData matches the existing immediate slice (intentional overlap for clarity). Non-PUSH opcodes (including EOF RJUMP immediates, which use immediate but are outside 0x5f0x7f) leave pushData unset.

Changes

evm:

  • Add optional InterpreterStep.pushData?: Uint8Array and populate it in _runStepHook when the opcode byte is 0x5f0x7f (PUSH0: new Uint8Array([0]); PUSH1PUSH32: same slice as immediate).
  • Document the field on the interface, in the step event JSDoc, in README.md (Events), and in CHANGELOG.md under ## Unreleased.
  • Add test/stepPushData.spec.ts (PUSH0, PUSH1, PUSH32 length, non-PUSH has no pushData).

Testing

  • cd packages/evm && npx vitest run — all EVM package tests pass.
  • npx @biomejs/biome check src/interpreter.ts test/stepPushData.spec.ts — clean.
  • npx tsc --noEmit -p tsconfig.json (in packages/evm) — clean.

Closes #2418.

Expose optional InterpreterStep.pushData so tracers can read the bytes
placed on the stack without re-parsing bytecode. PUSH0 sets a single
0x00 byte; PUSH1–PUSH32 reuse the existing immediate slice.

Closes ethereumjs#2418.

Co-authored-by: Cursor <cursoragent@cursor.com>
@holgerd77
Copy link
Copy Markdown
Member

@alirazzaq-dev Hi hi, thanks for the contribution and sorry that this went on the side line a bit. Are you still interested in bringing this over the finish line?

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.19%. Comparing base (a404e7b) to head (775a2cf).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 87.33% <ø> (ø)
blockchain 88.82% <ø> (ø)
common 93.44% <ø> (ø)
evm 61.27% <100.00%> (+0.04%) ⬆️
mpt 89.64% <ø> (ø)
statemanager 78.04% <ø> (ø)
static 91.35% <ø> (ø)
tx 87.95% <ø> (ø)
util 80.83% <ø> (ø)
vm 55.38% <ø> (ø)

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.

@holgerd77
Copy link
Copy Markdown
Member

(P.S. you can ignore the upper two failures (bundle + vm dev tests))

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.

Add PUSHd value to step event

2 participants