Stateless: Create ExecutionWitness type and implement encoding/decoding #3440
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 ExecutionWitness type follows the structure used by Ress and also Geth, see here:
https://github.com/ethereum/go-ethereum/blob/bc67e7dd487189b828d63927b453f4af2e67f2ff/core/stateless/witness.go#L38
https://docs.rs/alloy-rpc-types-debug/latest/alloy_rpc_types_debug/struct.ExecutionWitness.html
Here is write up on the topic from the Geth team: https://gist.github.com/karalabe/47c906f0ab4fdc5b8b791b74f084e5f9
This structure is different to the prior block witness structure used and this version is actually much simpler to understand and implement. The state is simply a list of MPT nodes (both account and storage tries together). The codes field is the list of bytecodes used/executed by the block. The keys is the ordered list of addresses or storage slot keys accessed while executing the block and the headers contains the list of headers required to prove that the witness is correct. Before the recent Prague hardfork this would have contained all the headers required to support the BLOCKHASH opcode but now since this opcode is implemented using a system contract this field should only need to contain the parent header which is required to validate the witness against the parent state root before starting stateless execution.
This ExecutionWitness type will also be used to implement the
debug_executionWitness
anddebug_executionWitnessByBlockHash
RPC endpoints.