rpc: add Reth-compatible format for debug_executionWitness#21509
Draft
lupin012 wants to merge 1 commit into
Draft
rpc: add Reth-compatible format for debug_executionWitness#21509lupin012 wants to merge 1 commit into
lupin012 wants to merge 1 commit into
Conversation
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>
1a352c3 to
5927fa4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
--rpc.witness.gethcompat: Geth-compatible:
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