Skip to main content

BlockExecutor

Trait BlockExecutor 

Source
pub trait BlockExecutor: Sized {
    type Transaction;
    type Receipt;
    type Evm: Evm;
    type TransactionResultWithState: BlockTransactionResult<<Self::Evm as Evm>::EvmTypes> + Send;
    type BlockAccessList: Send + Sync;

Show 21 methods // Required methods fn evm(&self) -> &Self::Evm; fn evm_mut(&mut self) -> &mut Self::Evm; fn convert_block_access_list( block_access_list: &BlockAccessList, ) -> Result<Self::BlockAccessList, BlockExecutionError>; fn set_block_access_list( &mut self, block_access_list: Arc<Self::BlockAccessList>, ); fn set_block_access_index(&mut self, index: BlockAccessIndex); fn enable_block_access_list_builder(&mut self); fn take_block_access_list(&mut self) -> Option<BlockAccessList>; fn apply_pre_execution_changes(&mut self) -> Result<(), BlockExecutionError>; fn into_state(self) -> BundleState; fn validate_transaction_gas_limit( &mut self, gas_limit: u64, ) -> Result<(), BlockExecutionError>; fn execute_transaction_without_commit( &mut self, transaction: impl ExecutorTx<Self>, ) -> Result<Self::TransactionResultWithState, BlockExecutionError>; fn commit_transaction( &mut self, output: Self::TransactionResultWithState, ) -> Result<GasOutput, BlockExecutionError>; fn receipts(&self) -> &[Self::Receipt]; fn finish_with_block_access_list( self, ) -> Result<(BlockExecutionOutput<Self::Receipt>, Option<BlockAccessList>), BlockExecutionError>; // Provided methods fn set_state_hook( &mut self, _hook: impl FnMut(StateUpdate) + Send + 'static, ) -> bool { ... } fn execute_transaction_with_commit_condition( &mut self, transaction: impl ExecutorTx<Self>, f: impl FnOnce(&TxResult<<Self::Evm as Evm>::EvmTypes>, TxStateChanges<'_>) -> CommitChanges, ) -> Result<Option<GasOutput>, BlockExecutionError> { ... } fn inspect_transaction_without_commit<I>( &mut self, transaction: impl ExecutorTx<Self>, inspector: I, ) -> Result<(I, Self::TransactionResultWithState), BlockExecutionError> where I: Inspector<<Self::Evm as Evm>::EvmTypes> + 'static { ... } fn execute_transaction_with_result_closure( &mut self, transaction: impl ExecutorTx<Self>, f: impl FnOnce(&TxResult<<Self::Evm as Evm>::EvmTypes>), ) -> Result<GasOutput, BlockExecutionError> { ... } fn execute_transaction( &mut self, transaction: impl ExecutorTx<Self>, ) -> Result<GasOutput, BlockExecutionError> { ... } fn finish_with_prepared_block_access_list( self, ) -> Result<(BlockExecutionOutput<Self::Receipt>, Option<Bal>), BlockExecutionError> { ... } fn finish( self, ) -> Result<BlockExecutionOutput<Self::Receipt>, BlockExecutionError> { ... }
}
Expand description

A configured block executor.

Required Associated Types§

Source

type Transaction

Consensus transaction type executed by this executor.

Source

type Receipt

Receipt type produced by this executor.

Source

type Evm: Evm

EVM instance used by this executor.

Source

type TransactionResultWithState: BlockTransactionResult<<Self::Evm as Evm>::EvmTypes> + Send

Owned transaction execution result and detached state changes.

Source

type BlockAccessList: Send + Sync

EVM-native block access list used for indexed reads.

Required Methods§

Source

fn evm(&self) -> &Self::Evm

Returns the underlying EVM.

Source

fn evm_mut(&mut self) -> &mut Self::Evm

Returns the underlying EVM mutably.

Source

fn convert_block_access_list( block_access_list: &BlockAccessList, ) -> Result<Self::BlockAccessList, BlockExecutionError>

Converts a canonical EIP-7928 block access list into the EVM-native representation.

Source

fn set_block_access_list( &mut self, block_access_list: Arc<Self::BlockAccessList>, )

Attaches an EIP-7928 block access list for indexed state reads.

Source

fn set_block_access_index(&mut self, index: BlockAccessIndex)

Sets the EIP-7928 block access index used by state reads and BAL construction.

Source

fn enable_block_access_list_builder(&mut self)

Enables construction of an EIP-7928 block access list from committed state changes.

Source

fn take_block_access_list(&mut self) -> Option<BlockAccessList>

Takes the canonical EIP-7928 block access list built from committed state changes.

Source

fn apply_pre_execution_changes(&mut self) -> Result<(), BlockExecutionError>

Applies pre-execution block changes.

Source

fn into_state(self) -> BundleState

Consumes the executor and returns the state accumulated so far without applying post-execution block changes.

Source

fn validate_transaction_gas_limit( &mut self, gas_limit: u64, ) -> Result<(), BlockExecutionError>

Validates transaction gas admission against the executor’s current block or segment budget. Speculative workers and ordered commits must perform the same check before accepting a transaction’s result or execution error.

Source

fn execute_transaction_without_commit( &mut self, transaction: impl ExecutorTx<Self>, ) -> Result<Self::TransactionResultWithState, BlockExecutionError>

Executes a transaction and detaches its state changes without committing them.

Source

fn commit_transaction( &mut self, output: Self::TransactionResultWithState, ) -> Result<GasOutput, BlockExecutionError>

Commits detached transaction state and records its receipt and gas accounting.

Source

fn receipts(&self) -> &[Self::Receipt]

Returns receipts accumulated so far.

Source

fn finish_with_block_access_list( self, ) -> Result<(BlockExecutionOutput<Self::Receipt>, Option<BlockAccessList>), BlockExecutionError>

Finishes block execution and returns the output.

Provided Methods§

Source

fn set_state_hook( &mut self, _hook: impl FnMut(StateUpdate) + Send + 'static, ) -> bool

Sets a hook for state updates emitted during block execution, including pre-execution block changes and transaction changes.

Returns true if the hook was installed.

Source

fn execute_transaction_with_commit_condition( &mut self, transaction: impl ExecutorTx<Self>, f: impl FnOnce(&TxResult<<Self::Evm as Evm>::EvmTypes>, TxStateChanges<'_>) -> CommitChanges, ) -> Result<Option<GasOutput>, BlockExecutionError>

Executes a transaction, invokes f with the borrowed execution result and state changes, and commits changes when f returns CommitChanges::Yes.

The state changes are borrowed before the transaction is committed or discarded, so f can read what the transaction wrote (balances, storage slots) to decide whether to keep it.

Source

fn inspect_transaction_without_commit<I>( &mut self, transaction: impl ExecutorTx<Self>, inspector: I, ) -> Result<(I, Self::TransactionResultWithState), BlockExecutionError>
where I: Inspector<<Self::Evm as Evm>::EvmTypes> + 'static,

Executes a transaction with inspector and detaches its state changes without committing them.

Returns the inspector together with the output, so a tracer observes the transaction exactly as the executor runs it, including any changes the executor applies on top of the EVM result. Replaces any inspector already set on the executor’s EVM. Returns an error if the executor removed or replaced the inspector while executing the transaction.

Source

fn execute_transaction_with_result_closure( &mut self, transaction: impl ExecutorTx<Self>, f: impl FnOnce(&TxResult<<Self::Evm as Evm>::EvmTypes>), ) -> Result<GasOutput, BlockExecutionError>

Executes a transaction, invokes f with the borrowed execution result, and commits changes.

Source

fn execute_transaction( &mut self, transaction: impl ExecutorTx<Self>, ) -> Result<GasOutput, BlockExecutionError>

Executes a transaction and commits changes.

Source

fn finish_with_prepared_block_access_list( self, ) -> Result<(BlockExecutionOutput<Self::Receipt>, Option<Bal>), BlockExecutionError>

Finishes execution while retaining the prepared evm2 BAL for downstream consumers.

Executors that build a native BAL can override this to avoid converting it back from the canonical representation.

Source

fn finish( self, ) -> Result<BlockExecutionOutput<Self::Receipt>, BlockExecutionError>

Finishes block execution and returns the output.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§