Skip to content

rpc: add Reth-compatible format for debug_executionWitness#21509

Draft
lupin012 wants to merge 1 commit into
mainfrom
lupin012/debug_executionWitness_reth_format
Draft

rpc: add Reth-compatible format for debug_executionWitness#21509
lupin012 wants to merge 1 commit into
mainfrom
lupin012/debug_executionWitness_reth_format

Conversation

@lupin012
Copy link
Copy Markdown
Contributor

@lupin012 lupin012 commented May 29, 2026

This PR permit to return debug_executionWitness () in two format Get and Reth canonical.

In debug_execution_witness.go:

  • ExecutionWitnessResult.Headers changed from []map[string]any to any (holds either JSON objects or RLP-encoded bytes depending on the flag)

  • Added internal allCodes field for stateless verification (unfiltered: accessed + newly deployed code)

  • New witnessHeadersToJSON and witnessHeadersToRLP serialisation helpers

  • New filterEIP7702Codes — removes EIP-7702 delegation designator codes and their targets from codes in Reth-compat mode

  • collectAccessedState accepts gethCompat bool and integrates the EIP-7702 filter internally, avoiding a second GetAccessedCode() call

  • collectAccessedHeaders now returns []*types.Header; serialisation to wire format happens at the call site

  • Storage keys: emit key.Bytes() only (previously addr || key composite)

  • Local sortedCodesSlice helper eliminates the duplicated sort-and-collect pattern used for both SortedCodes and AllCodes

  • Stateless verifier uses allCodes instead of Codes so contracts deployed within the block are available during re-execution

  • default: Reth-compatible:

    • headers RLP-encoded,
    • keys populated (EIP-7702 delegation codes filtered out)
    • code see Reth canonical
    • state
  • --rpc.witness.gethcompat: Geth-compatible:

    • headers json object
    • keys null
    • code
    • state

I've run some tests on Hive, and Erigon returns the exact same responses as Geth and Reth (canonical) for all fields except for state. For a few tests, Erigon provides fewer MPT nodes than Geth, and even fewer than Reth canonical.
It's possible that these extra missing nodes aren't actually essential for the witness

@lupin012 lupin012 requested a review from awskii May 29, 2026 12:00
Add --rpc.witness.gethcompat flag to select the output format:
- default (off): Reth-compatible — headers RLP-encoded, keys populated,
  EIP-7702 delegation codes filtered out
- --rpc.witness.gethcompat: Geth-compatible — headers as JSON objects,
  keys null (previous behaviour)

Also remove the unused mode *string parameter from the ExecutionWitness
interface, extract a sortedCodesSlice helper to eliminate duplicated
sort-and-collect logic, and avoid a second GetAccessedCode() call by
integrating the EIP-7702 filter into collectAccessedState.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lupin012 lupin012 force-pushed the lupin012/debug_executionWitness_reth_format branch from 1a352c3 to 5927fa4 Compare May 29, 2026 13:49
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