Skip to main content

BlockBuilder

Trait BlockBuilder 

Source
pub trait BlockBuilder: Sized {
    type Primitives: NodePrimitives;
    type Executor: BlockExecutor<Transaction = TxTy<Self::Primitives>, Receipt = ReceiptTy<Self::Primitives>, Evm: Evm<Transaction: FromTxWithEncoded<TxTy<Self::Primitives>>>>;
    type EvmEnv: EvmEnv;

Show 13 methods // Required methods fn evm_env(&self) -> &Self::EvmEnv; fn apply_pre_execution_changes(&mut self) -> Result<(), BlockExecutionError>; fn execute_transaction_with_commit_condition( &mut self, tx: impl ExecutorTx<Self::Executor>, f: impl FnOnce(&TxResult<<<Self::Executor as BlockExecutor>::Evm as Evm>::EvmTypes>, TxStateChanges<'_>) -> CommitChanges, ) -> Result<Option<GasOutput>, BlockExecutionError>; fn execute_transaction_with_result_closure( &mut self, tx: impl ExecutorTx<Self::Executor>, f: impl FnOnce(&<Self::Executor as BlockExecutor>::TransactionResultWithState), ) -> Result<GasOutput, BlockExecutionError>; fn finish_with_state_root( self, state_provider: impl StateProvider, state_root: impl FnOnce(&BlockExecutionOutput<ReceiptTy<Self::Primitives>>) -> Result<Option<(B256, TrieUpdates)>, BlockExecutionError>, ) -> Result<BlockBuilderOutcome<Self::Primitives>, BlockExecutionError>; fn executor_mut(&mut self) -> &mut Self::Executor; fn executor(&self) -> &Self::Executor; fn into_executor(self) -> Self::Executor; // Provided methods fn execute_transaction( &mut self, tx: impl ExecutorTx<Self::Executor>, ) -> Result<GasOutput, BlockExecutionError> { ... } fn finish( self, state_provider: impl StateProvider, state_root_precomputed: Option<(B256, TrieUpdates)>, ) -> Result<BlockBuilderOutcome<Self::Primitives>, BlockExecutionError> { ... } fn set_state_hook( &mut self, _hook: impl FnMut(StateUpdate) + Send + 'static, ) -> bool { ... } fn evm_mut(&mut self) -> &mut <Self::Executor as BlockExecutor>::Evm { ... } fn evm(&self) -> &<Self::Executor as BlockExecutor>::Evm { ... }
}
Expand description

A type that knows how to execute transactions and assemble a block.

Required Associated Types§

Source

type Primitives: NodePrimitives

The primitive types used by the inner BlockExecutor.

Source

type Executor: BlockExecutor<Transaction = TxTy<Self::Primitives>, Receipt = ReceiptTy<Self::Primitives>, Evm: Evm<Transaction: FromTxWithEncoded<TxTy<Self::Primitives>>>>

Inner block executor.

Source

type EvmEnv: EvmEnv

EVM environment used for block execution.

Required Methods§

Source

fn evm_env(&self) -> &Self::EvmEnv

Returns the EVM environment used for block execution.

Source

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

Applies pre-execution block changes.

Source

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

Executes a transaction, exposes its borrowed execution result and state changes to f, and saves it for block assembly only if committed.

Source

fn execute_transaction_with_result_closure( &mut self, tx: impl ExecutorTx<Self::Executor>, f: impl FnOnce(&<Self::Executor as BlockExecutor>::TransactionResultWithState), ) -> Result<GasOutput, BlockExecutionError>

Executes a transaction, invokes f with the detached result and state changes, and saves it for block assembly.

Source

fn finish_with_state_root( self, state_provider: impl StateProvider, state_root: impl FnOnce(&BlockExecutionOutput<ReceiptTy<Self::Primitives>>) -> Result<Option<(B256, TrieUpdates)>, BlockExecutionError>, ) -> Result<BlockBuilderOutcome<Self::Primitives>, BlockExecutionError>

Completes block building, resolving an optional state root after execution is finalized.

Source

fn executor_mut(&mut self) -> &mut Self::Executor

Provides mutable access to the inner BlockExecutor.

Source

fn executor(&self) -> &Self::Executor

Provides access to the inner BlockExecutor.

Source

fn into_executor(self) -> Self::Executor

Consumes the type and returns the underlying executor.

Provided Methods§

Source

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

Executes a transaction and saves it for block assembly.

Source

fn finish( self, state_provider: impl StateProvider, state_root_precomputed: Option<(B256, TrieUpdates)>, ) -> Result<BlockBuilderOutcome<Self::Primitives>, BlockExecutionError>

Completes block building.

Source

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

Sets a hook for transaction state updates emitted while building a block.

Returns true if the hook was installed.

Source

fn evm_mut(&mut self) -> &mut <Self::Executor as BlockExecutor>::Evm

Provides mutable access to the underlying EVM.

Source

fn evm(&self) -> &<Self::Executor as BlockExecutor>::Evm

Provides access to the underlying EVM.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<'a, F, Executor, Assembler, N> BlockBuilder for BasicBlockBuilder<'a, F, Executor, Assembler, N>
where F: BlockExecutorFactory<Transaction = TxTy<N>, Receipt = ReceiptTy<N>>, Executor: BlockExecutor<Transaction = TxTy<N>, Receipt = ReceiptTy<N>, Evm: Evm<EvmTypes = F::EvmTypes>>, Assembler: BlockAssembler<F, Block = N::Block>, N: NodePrimitives, TxTy<N>: Clone, <<Executor as BlockExecutor>::Evm as Evm>::Transaction: FromTxWithEncoded<TxTy<N>>,