Trait Executor

pub trait Executor<DB>: Sized
where DB: Database,
{ type Primitives: NodePrimitives; type Error; // Required methods fn execute_one( &mut self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, ) -> Result<BlockExecutionResult<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>; fn execute_one_with_state_hook<F>( &mut self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, state_hook: F, ) -> Result<BlockExecutionResult<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error> where F: OnStateHook + 'static; fn into_state(self) -> State<DB>; fn size_hint(&self) -> usize; // Provided methods fn execute( self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error> { ... } fn execute_batch<'a, I>( self, blocks: I, ) -> Result<ExecutionOutcome<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error> where I: IntoIterator<Item = &'a RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>> { ... } fn execute_with_state_closure<F>( self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, f: F, ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error> where F: FnMut(&State<DB>) { ... } fn execute_with_state_hook<F>( self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, state_hook: F, ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error> where F: OnStateHook + 'static { ... } }
Available on crate feature evm only.
Expand description

A type that knows how to execute a block. It is assumed to operate on a crate::Evm internally and use [State] as database.

Required Associated Types§

type Primitives: NodePrimitives

The primitive types used by the executor.

type Error

The error type returned by the executor.

Required Methods§

fn execute_one( &mut self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, ) -> Result<BlockExecutionResult<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>

Executes a single block and returns BlockExecutionResult, without the state changes.

fn execute_one_with_state_hook<F>( &mut self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, state_hook: F, ) -> Result<BlockExecutionResult<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
where F: OnStateHook + 'static,

Executes the EVM with the given input and accepts a state hook closure that is invoked with the EVM state after execution.

fn into_state(self) -> State<DB>

Consumes the executor and returns the [State] containing all state changes.

fn size_hint(&self) -> usize

The size hint of the batch’s tracked state size.

This is used to optimize DB commits depending on the size of the state.

Provided Methods§

fn execute( self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>

Consumes the type and executes the block.

§Note

Execution happens without any validation of the output.

§Returns

The output of the block execution.

fn execute_batch<'a, I>( self, blocks: I, ) -> Result<ExecutionOutcome<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
where I: IntoIterator<Item = &'a RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>>,

Executes multiple inputs in the batch, and returns an aggregated ExecutionOutcome.

fn execute_with_state_closure<F>( self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, f: F, ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
where F: FnMut(&State<DB>),

Executes the EVM with the given input and accepts a state closure that is invoked with the EVM state after execution.

fn execute_with_state_hook<F>( self, block: &RecoveredBlock<<Self::Primitives as NodePrimitives>::Block>, state_hook: F, ) -> Result<BlockExecutionOutput<<Self::Primitives as NodePrimitives>::Receipt>, Self::Error>
where F: OnStateHook + 'static,

Executes the EVM with the given input and accepts a state hook closure that is invoked with the EVM state after execution.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl<A, B, DB> Executor<DB> for Either<A, B>
where A: Executor<DB>, B: Executor<DB, Primitives = <A as Executor<DB>>::Primitives, Error = <A as Executor<DB>>::Error>, DB: Database,

§

type Primitives = <A as Executor<DB>>::Primitives

§

type Error = <A as Executor<DB>>::Error

§

impl<DB> Executor<DB> for MockExecutorProvider
where DB: Database,

§

type Primitives = EthPrimitives

§

type Error = BlockExecutionError

§

impl<DB, P> Executor<DB> for NoopBlockExecutorProvider<P>
where DB: Database, P: NodePrimitives,

§

impl<F, DB> Executor<DB> for BasicBlockExecutor<F, DB>
where F: ConfigureEvm, DB: Database,