Expand description
Types and traits for validating blocks and payloads.
§Payload validation flow
BasicEngineValidator::validate_block_with_state is the engine-side entry point for an
inserted block or an engine_newPayload payload. It overlaps payload conversion, transaction
preparation, cache prewarming, receipt-root computation, state-root computation, and deferred
trie input construction wherever those tasks do not depend on each other.
§Validation phases
- Fetch the parent header and spawn
payload-convert, which converts payloads into sealed blocks and runs header, parent-header, and pre-execution consensus validation. - Build the parent state provider, EVM environment, transaction iterator, lazy ancestor overlay, and optional decoded EIP-7928 block access list (BAL).
- Prepare the per-block state-root job. The default strategy picks a skipped, synchronous, or
sparse-trie job from
TreeConfig. - Spawn the payload processor. This always prepares transaction conversion and prewarming; a streaming state-root job can provide a sink for prewarm and execution updates.
- Execute the block. BAL payloads use the parallel BAL execute path only when state caching and BAL parallel execution are enabled. Otherwise the regular executor still builds and validates the BAL before post-execution consensus uses the decoded BAL hash.
- Stop prewarming, terminate execution caching, spawn
hash-post-state, awaitpayload-convertandreceipt-root, then run post-execution consensus validation. - Resolve the state root by finishing the prepared job. The sparse-trie job falls back to serial computation when the state-root task fails to produce a usable root.
- Verify the header state root, spawn deferred trie input computation, and return the executed block without waiting for that deferred trie task on the hot path.
§Spawned background work
| Work | Spawned when | Role | Completion point |
|---|---|---|---|
payload-convert | parent is known | convert payloads, validate header and body roots | after execution, unless the gas sanity check awaits it earlier |
tx-iterator | payload processor setup | convert transactions, using rayon for larger blocks | consumed by regular and BAL execution |
prewarm | payload processor setup | warm execution caches; in BAL mode, stream BAL-derived trie targets | stopped after execution, then caching is terminated |
| proof workers | sparse-trie task setup | fetch trie proofs for sparse trie updates | consumed by the sparse trie task |
sparse-trie | sparse-trie task setup | apply execution or BAL updates and compute the state root | awaited by the state-root job |
receipt-root | execution start | compute receipt root and logs bloom incrementally | awaited before post-execution consensus |
hash-post-state | after execution | hash changed accounts and storage from BundleState | awaited by post-execution validation and root computation |
serial-root | sparse trie timeout fallback | race serial state-root computation against the sparse trie task | polled by the sparse-trie job |
| deferred trie task | after root verification | sort trie data | not awaited by the validation hot path |
sequenceDiagram
autonumber
participant Main as validate_block_with_state
participant Convert as payload-convert
participant Tx as tx-iterator
participant Prewarm as prewarm
participant Exec as EVM execution
participant Receipt as receipt-root
participant Trie as sparse trie and proofs
participant Hash as hash-post-state
participant Deferred as deferred trie task
Main->>Convert: spawn convert and pre-execution validation
Main->>Main: parent provider, EVM env, optional BAL decode
Main->>Tx: spawn transaction conversion
alt sparse-trie job
Main->>Trie: spawn proof workers and sparse trie
end
Main->>Prewarm: spawn transaction, BAL, or skipped prewarm
Main->>Receipt: spawn receipt root task
alt BAL path eligible
Main->>Exec: execute_block_bal
Prewarm->>Trie: BAL-derived sparse trie updates
else regular execution
Tx-->>Exec: recovered transactions in block order
Main->>Exec: execute_block
Exec->>Receipt: stream receipts
Exec->>Trie: stream state hook updates
Exec->>Exec: rebuild and validate BAL when present
end
Main->>Prewarm: stop prewarming and terminate cache
Main->>Hash: spawn changed-state hashing
Convert-->>Main: sealed block
Receipt-->>Main: receipt root and logs bloom
Main->>Main: post-execution consensus and BAL hash check
Hash-->>Main: hashed post state
alt sparse-trie job
Trie-->>Main: state root and trie updates
else synchronous or fallback
Main->>Main: compute serial StateRoot
end
Main->>Main: verify header state root
Main->>Deferred: spawn trie input sorting
Main-->>Main: return ValidationOutput§Payload attributes validation
During engine_forkchoiceUpdated,
PayloadValidator::validate_payload_attributes_against_header checks payload attributes
before a payload build job starts. On failure, the engine returns
INVALID_PAYLOAD_ATTRIBUTES without rolling back the forkchoice update.
Re-exports§
pub use crate::tree::types::ValidationOutcome;
Structs§
- Basic
Engine Validator - A helper type that provides reusable payload validation logic for network-specific validators.
- TreeCtx
- Context providing access to tree state during validation.
Enums§
- Block
OrPayload - Enum representing either block or payload being validated.
Traits§
- Engine
Validator - Type that validates the payloads processed by the engine.