Expand description
State-root strategies for engine-tree block validation.
A StateRootStrategy is installed once per node, via
BasicEngineValidator::with_state_root_strategy, and consulted for every block that engine
validation executes. For each block the strategy prepares a StateRootJob before execution
starts, and validation finishes the job after execution to obtain the state root that is
checked against the block header. On every FCU that carries payload attributes, the strategy
is also asked through StateRootStrategy::prepare_payload_builder for an optional
PayloadStateRootHandle that the payload builder uses while building a block.
§Job lifecycle
StateRootStrategy::prepareruns before block execution. The job can spawn background work here and can expose hooks that observe execution.- Execution runs. Jobs that observe execution receive updates through their hooks.
StateRootJob::finishruns after execution and returns theStateRootJobOutcome. It must produce a result even if no execution updates were observed, since the fullBlockExecutionOutputis passed to it.
Dropping a prepared job without calling finish aborts it. Implementations must treat
channel disconnects from dropped hooks as cancellation and must not leak background work.
§Stream delivery contract
A prepared job exposes update-stream capabilities over its sink. prepare installs exactly
one authoritative capability per block, matching the execution mode:
- On the parallel BAL execution path, prewarm converts the block access list and delivers
pre-hashed updates through the hashed update stream, terminated by
StateRootUpdateStream::finish. - On the serial execution path, per-transaction
EvmStateupdates arrive through the execution hook, terminated when the hook is dropped after execution.
Which path runs depends on runtime conditions (BAL present, caching and prewarming enabled), so a sink must handle both. Access hints from prewarming are best-effort: they may be missing, duplicated, or stale, and must not be treated as state updates.
§Custom strategies
Custom implementations can hold a DefaultStateRootStrategy and forward calls to it for
blocks where the default behavior is wanted, for example before a fork activates. See
examples/custom-state-root for the wiring.
Returning empty trie updates in the outcome means the trie tables are no longer maintained:
eth_getProof and anything else that reads the stored trie will not work for new blocks.
Returning no changed paths opts the block out of sparse-trie cache pruning.
Structs§
- Default
State Root Strategy - Default state-root strategy used by engine-tree validation.
- Payload
State Root Handle - Opaque state-root task handle passed to payload builders.
- Payload
State Root JobContext - Data available while preparing one payload-builder state-root handle.
- Prepared
State Root Job - Prepared per-block state-root work and its update-stream capabilities.
- State
Access Hint - Hashed account and storage keys that a state-root task may want to prefetch.
- State
Root Compute Outcome - Outcome of the state root computation, including the state root itself with the trie updates.
- State
Root Handle - Handle to a background sparse trie state root computation.
- State
Root Hint Stream - Hint-only view of a state-root stream.
- State
Root JobContext - Data available while preparing one state-root job.
- State
Root JobOutcome - Outcome of a per-block state-root job.
- State
Root Task Cancel Guard - Guard that cancels a state-root task when dropped.
- State
Root Update Hook - EVM hook that forwards state updates into a
StateRootSink. - State
Root Update Stream - Authoritative update capability of a state-root stream.
Enums§
- State
Root Message - Messages used internally by the multi proof task.
- State
Root Task Error - Error returned by the state-root task and the parallel proof workers.
Traits§
- State
Root Job - Per-block state-root job prepared before execution and finished after execution.
- State
Root Sink - Semantic update stream consumed by state-root tasks.
- State
Root Strategy - Strategy used by engine-tree validation to prepare per-block state-root work.
Functions§
- evm_
state_ to_ hashed_ post_ state - Converts [
EvmState] toHashedPostStateby keccak256-hashing addresses and storage slots.
Type Aliases§
- Lazy
Hashed Post State - Handle to a
HashedPostStatecomputed on a background thread.