Skip to content

Add EVM v2 tracing compatibility for getStackItem() and stackSize()#10188

Open
parthdagia05 wants to merge 1 commit intobesu-eth:mainfrom
parthdagia05:feat/evm-v2-tracing-compat
Open

Add EVM v2 tracing compatibility for getStackItem() and stackSize()#10188
parthdagia05 wants to merge 1 commit intobesu-eth:mainfrom
parthdagia05:feat/evm-v2-tracing-compat

Conversation

@parthdagia05
Copy link
Copy Markdown

PR description

Continues the EVM v2 implementation tracked in #10131 .

Existing OperationTracer implementations (StreamingOperationTracer, EthTransferLogOperationTracer, etc.) call frame.getStackItem() and frame.stackSize(), which only read from the v1 Bytes stack. When running with --Xevm-go-fast=true (v2), the stack is a long[] array, so these methods return incorrect results.

Changes

  • Modify MessageFrame.getStackItem(offset) to detect v2 mode and convert 4 longs from the long[] stack into Bytes32 on the fly
  • Modify MessageFrame.stackSize() to return stackTopV2 when running in v2 mode
  • Add MessageFrameV2TracingTest with 8 unit tests covering: empty stack, stack size tracking, simple values, large values, zero, max uint256, offset access, and v1 backward compatibility

Why this approach

All existing tracers work transparently without any changes they keep calling getStackItem() and receive Bytes regardless of whether v1 or v2 is running underneath. No new interfaces or tracer refactoring needed.

Fixed Issue(s)

Partial fix for #10131

Have you done the following

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • spotless: ./gradlew spotlessApply
  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests
  • hive tests: Engine or other RPCs modified?

Enables existing OperationTracer implementations to work transparently
with the v2 long[] stack by converting stack entries to Bytes on the fly
when tracing requests stack data. Includes unit tests for v2 stack
read-back via getStackItem() and stackSize().

Signed-off-by: Parth Dagia <parth.24bcs10414@sst.scaler.com>
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.

1 participant