Crate reth_stateless

Source
Expand description

Provides types and functions for stateless execution and validation of Ethereum blocks.

This crate enables the verification of block execution without requiring access to a full node’s persistent database. Instead, it relies on pre-generated “witness” data that proves the specific state accessed during the block’s execution.

§Key Components

  • WitnessDatabase: An implementation of [reth_revm::Database] that uses a [reth_trie_sparse::SparseStateTrie] populated from witness data, along with provided bytecode and ancestor block hashes, to serve state reads during execution.
  • stateless_validation: The core function that orchestrates the stateless validation process. It takes a block, its execution witness, ancestor headers, and chain specification, then performs:
    1. Witness verification against the parent block’s state root.
    2. Block execution using the WitnessDatabase.
    3. Post-execution consensus checks.
    4. Post-state root calculation and comparison against the block header.

§Usage

The primary entry point is typically the validation::stateless_validation function. Callers need to provide the block to be validated along with accurately generated ExecutionWitness data corresponding to that block’s execution trace and the necessary Headers of ancestor blocks.

Modules§

validation
Implementation of stateless validation

Structs§

ExecutionWitness
Represents the execution witness of a block. Contains an optional map of state preimages.
StatelessInput
StatelessInput is a convenience structure for serializing the input needed for the stateless validation function.