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§
Sourcetype Primitives: NodePrimitives
type Primitives: NodePrimitives
The primitive types used by the inner BlockExecutor.
Sourcetype Executor: BlockExecutor<Transaction = TxTy<Self::Primitives>, Receipt = ReceiptTy<Self::Primitives>, Evm: Evm<Transaction: FromTxWithEncoded<TxTy<Self::Primitives>>>>
type Executor: BlockExecutor<Transaction = TxTy<Self::Primitives>, Receipt = ReceiptTy<Self::Primitives>, Evm: Evm<Transaction: FromTxWithEncoded<TxTy<Self::Primitives>>>>
Inner block executor.
Required Methods§
Sourcefn apply_pre_execution_changes(&mut self) -> Result<(), BlockExecutionError>
fn apply_pre_execution_changes(&mut self) -> Result<(), BlockExecutionError>
Applies pre-execution block changes.
Sourcefn 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_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.
Sourcefn execute_transaction_with_result_closure(
&mut self,
tx: impl ExecutorTx<Self::Executor>,
f: impl FnOnce(&<Self::Executor as BlockExecutor>::TransactionResultWithState),
) -> Result<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>
Executes a transaction, invokes f with the detached result and state changes, and saves
it for block assembly.
Sourcefn 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 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.
Sourcefn executor_mut(&mut self) -> &mut Self::Executor
fn executor_mut(&mut self) -> &mut Self::Executor
Provides mutable access to the inner BlockExecutor.
Sourcefn executor(&self) -> &Self::Executor
fn executor(&self) -> &Self::Executor
Provides access to the inner BlockExecutor.
Sourcefn into_executor(self) -> Self::Executor
fn into_executor(self) -> Self::Executor
Consumes the type and returns the underlying executor.
Provided Methods§
Sourcefn execute_transaction(
&mut self,
tx: impl ExecutorTx<Self::Executor>,
) -> Result<GasOutput, BlockExecutionError>
fn execute_transaction( &mut self, tx: impl ExecutorTx<Self::Executor>, ) -> Result<GasOutput, BlockExecutionError>
Executes a transaction and saves it for block assembly.
Sourcefn finish(
self,
state_provider: impl StateProvider,
state_root_precomputed: Option<(B256, TrieUpdates)>,
) -> Result<BlockBuilderOutcome<Self::Primitives>, BlockExecutionError>
fn finish( self, state_provider: impl StateProvider, state_root_precomputed: Option<(B256, TrieUpdates)>, ) -> Result<BlockBuilderOutcome<Self::Primitives>, BlockExecutionError>
Completes block building.
Sourcefn set_state_hook(
&mut self,
_hook: impl FnMut(StateUpdate) + Send + 'static,
) -> bool
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.
Sourcefn evm_mut(&mut self) -> &mut <Self::Executor as BlockExecutor>::Evm
fn evm_mut(&mut self) -> &mut <Self::Executor as BlockExecutor>::Evm
Provides mutable access to the underlying EVM.
Sourcefn evm(&self) -> &<Self::Executor as BlockExecutor>::Evm
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".