Function verify_execution_witness

Source
pub fn verify_execution_witness(
    witness: &ExecutionWitness,
    pre_state_root: B256,
) -> Result<(SparseStateTrie, B256Map<Bytecode>), StatelessValidationError>
Expand description

Verifies execution witness ExecutionWitness against an expected pre-state root.

This function takes the RLP-encoded values provided in ExecutionWitness (which includes state trie nodes, storage trie nodes, and contract bytecode) and uses it to populate a new [SparseStateTrie].

If the computed root hash matches the pre_state_root, it signifies that the provided execution witness is consistent with that pre-state root. In this case, the function returns the populated [SparseStateTrie] and a [B256Map] containing the contract bytecode (mapping code hash to [Bytecode]).

The bytecode has a separate mapping because the [SparseStateTrie] does not store the contract bytecode, only the hash of it (code hash).

If the roots do not match, it returns None, indicating the witness is invalid for the given pre_state_root.