pub fn stateless_validation<ChainSpec, E>(
current_block: Block,
witness: ExecutionWitness,
chain_spec: Arc<ChainSpec>,
evm_config: E,
) -> Result<B256, StatelessValidationError>
Expand description
Performs stateless validation of a block using the provided witness data.
This function attempts to fully validate a given current_block
statelessly, ie without access
to a persistent database.
It relies entirely on the witness
data and ancestor_headers
provided alongside the block.
The witness data is validated in the following way:
-
Ancestor Header Verification: Checks if the
ancestor_headers
are present, form a contiguous chain back fromcurrent_block
’s parent, and do not exceed theBLOCKHASH
opcode limit usingcompute_ancestor_hashes
. We must have at least one ancestor header, even if theBLOCKHASH
opcode is not used because we need the state root of the previous block to verify the pre state reads. -
Pre-State Verification: Retrieves the expected
pre_state_root
from the parent header fromancestor_headers
. Verifies the providedExecutionWitness
against this root usingverify_execution_witness
. -
Chain Verification: The code currently does not verify the [
EthChainSpec
] and expects a higher level function to assert that this is correct by, for example, asserting that it is equal to the Ethereum MainnetChainSpec
or asserting against the genesis hash that thisChainSpec
defines.
High Level Overview of functionality:
- Verify all state accesses against a trusted pre-state root
- Put all state accesses into an in-memory database
- Use the in-memory database to execute the block
- Validate the output of block execution (e.g. receipts, logs, requests)
- Compute the post-state root using the state-diff from block execution
- Check that the post-state root is the state root in the block.
If all steps succeed the function returns Some
containing the hash of the validated
current_block
.