Skip to main content

BlockBuilder

Trait BlockBuilder 

Source
pub trait BlockBuilder: Sized {
    type Primitives: NodePrimitives;
    type Executor: BlockExecutor<Transaction = <Self::Primitives as NodePrimitives>::SignedTx, Receipt = <Self::Primitives as NodePrimitives>::Receipt>
       where <Self::Executor as BlockExecutor>::Evm: Evm,
             <<Self::Executor as BlockExecutor>::Evm as Evm>::Transaction: FromTxWithEncoded<<Self::Primitives as NodePrimitives>::SignedTx>;
    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(&TxResultExt<<<<Self::Executor as BlockExecutor>::Evm as Evm>::EvmTypes as EvmTypesHost>::TxResultExt>, 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<<Self::Primitives as NodePrimitives>::Receipt>) -> Result<Option<(FixedBytes<32>, 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<(FixedBytes<32>, 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 { ... }
}
Available on crate feature evm only.
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 = <Self::Primitives as NodePrimitives>::SignedTx, Receipt = <Self::Primitives as NodePrimitives>::Receipt> where <Self::Executor as BlockExecutor>::Evm: Evm, <<Self::Executor as BlockExecutor>::Evm as Evm>::Transaction: FromTxWithEncoded<<Self::Primitives as NodePrimitives>::SignedTx>

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(&TxResultExt<<<<Self::Executor as BlockExecutor>::Evm as Evm>::EvmTypes as EvmTypesHost>::TxResultExt>, 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<<Self::Primitives as NodePrimitives>::Receipt>) -> Result<Option<(FixedBytes<32>, 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<(FixedBytes<32>, 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 Executor: BlockExecutor<Transaction = <N as NodePrimitives>::SignedTx, Receipt = <N as NodePrimitives>::Receipt>, <Executor as BlockExecutor>::Evm: Evm<EvmTypes = <F as BlockExecutorFactory>::EvmTypes>, F: BlockExecutorFactory<Transaction = <N as NodePrimitives>::SignedTx, Receipt = <N as NodePrimitives>::Receipt>, Assembler: BlockAssembler<F, Block = <N as NodePrimitives>::Block>, N: NodePrimitives, <N as NodePrimitives>::SignedTx: Clone, <<Executor as BlockExecutor>::Evm as Evm>::Transaction: FromTxWithEncoded<<N as NodePrimitives>::SignedTx>,