Lower-level block engine with an injectable transaction executor: system calls, then transactions in order, then beacon-chain withdrawals, then EIP-7685 requests, then the commitments a consensus-level verifier will check.
Most callers want EEVM.Block.execute/4, which validates the block, runs
each transaction through EEVM.Handler, and checks the commitments against
the header. Use this module directly to plug in a custom executor.
If any transaction fails (the injected executor returns an {:error, _})
the processor halts and reports the failing index. The post-state database
is left at whatever the last successful transaction produced — this
processor does not attempt optimistic rollback.
Options
Callers inject the executor and any per-block hooks:
:tx_executor—(tx, %EEVM.BlockEnv{}, %Database{}) -> {:ok, tx_result} | {:error, reason}. Each call receives the current database after all prior transactions and system calls have been applied. The returnedtx_resultis a map with keys:status,:gas_used,:logs, and:db, plus an optional:tx_type(default:legacy) that selects the EIP-2718 receipt encoding, an optional:state_rootthat the receipt carries in place of its status (before Byzantium, EIP-658), an optional:contract_addressthat the receipt carries for a contract creation, and an optional:trace(anEEVM.Tracer); when any transaction returns one,result.tracelists them in order.:system_calls— list of hooks, each(%Database{}, %EEVM.BlockEnv{}) -> %Database{}. Executed in order, strictly before any transaction. The default is[].:tx_encoder—(tx) -> binaryused to compute thetransactions_root. Defaults toEEVM.Transaction.Envelope.encode/1, which handles every typed envelope this codebase knows about. Tests using plain maps supply their own.:rewards— list of{address, wei}balance credits for the block's proof-of-work miner and ommer rewards, applied after the transactions. Defaults to[].:withdrawals— list ofEEVM.Block.Withdrawalstructs (EIP-4895). Applied as flat balance credits after the transaction fold and before the state root is computed, so the returnedstate_rootalready reflects them. Defaults to[].:block_context— theEEVM.BlockEnvhanded to system calls and the executor. Defaults to one derived from the header's fields.:requests—(%Database{}, %EEVM.BlockEnv{}, [%Receipt{}]) -> {:ok, requests, %Database{}} | {:error, reason}, run after the withdrawals to collect the block's EIP-7685 requests (seeEEVM.Block.Requests.collect/5). Its database is the one thestate_rootis computed from. Without it,result.requestsisnil.
Summary
Functions
Execute every phase of the block and produce a %EEVM.Block.Result{}.
Types
@type process_error() :: {:tx_failed, non_neg_integer(), term()} | atom()
@type process_opts() :: [ tx_executor: tx_executor(), system_calls: [system_call()], tx_encoder: tx_encoder(), rewards: [{non_neg_integer(), non_neg_integer()}], withdrawals: [EEVM.Block.Withdrawal.t()], block_context: EEVM.BlockEnv.t(), requests: requests_hook() ]
@type requests_hook() :: (EEVM.Database.t(), EEVM.BlockEnv.t(), [EEVM.Block.Receipt.t()] -> {:ok, [binary()], EEVM.Database.t()} | {:error, atom()})
@type system_call() :: (EEVM.Database.t(), EEVM.BlockEnv.t() -> EEVM.Database.t())
@type tx_executor() :: (term(), EEVM.BlockEnv.t(), EEVM.Database.t() -> {:ok, tx_result()} | {:error, term()})
@type tx_result() :: %{ :status => 0 | 1, :gas_used => non_neg_integer(), :logs => [EEVM.Block.Bloom.log_entry()], :db => EEVM.Database.t(), optional(:tx_type) => EEVM.Block.Receipt.tx_type(), optional(:state_root) => binary(), optional(:contract_address) => non_neg_integer() | nil, optional(:trace) => EEVM.Tracer.t() | nil }
Functions
@spec process_block( EEVM.Block.Header.t(), [term()], EEVM.Database.t(), process_opts() ) :: {:ok, EEVM.Block.Result.t()} | {:error, process_error()}
Execute every phase of the block and produce a %EEVM.Block.Result{}.
The caller owns pre_state_db and must pass an injected :tx_executor.
See the module doc for the full option list.
Returns:
{:ok, %Result{}}on success.{:error, {:tx_failed, index, :gas_allowance_exceeded}}when a transaction'sgas_limitexceeds the gas left in the block (header.gas_limitminus the gas used so far).{:error, {:tx_failed, index, reason}}when the injected executor rejects a transaction.indexis 0-based intransactionsorder.{:error, reason}when the:requestshook fails.