reth_evm::execute

Trait BatchExecutor

Source
pub trait BatchExecutor<DB> {
    type Input<'a>;
    type Output;
    type Error;

    // Required methods
    fn execute_and_verify_one(
        &mut self,
        input: Self::Input<'_>,
    ) -> Result<(), Self::Error>;
    fn finalize(self) -> Self::Output;
    fn set_tip(&mut self, tip: BlockNumber);
    fn set_prune_modes(&mut self, prune_modes: PruneModes);
    fn size_hint(&self) -> Option<usize>;

    // Provided methods
    fn execute_and_verify_many<'a, I>(
        &mut self,
        inputs: I,
    ) -> Result<(), Self::Error>
       where I: IntoIterator<Item = Self::Input<'a>> { ... }
    fn execute_and_verify_batch<'a, I>(
        self,
        batch: I,
    ) -> Result<Self::Output, Self::Error>
       where I: IntoIterator<Item = Self::Input<'a>>,
             Self: Sized { ... }
}
Expand description

A general purpose executor that can execute multiple inputs in sequence, validate the outputs, and keep track of the state over the entire batch.

Required Associated Types§

Source

type Input<'a>

The input type for the executor.

Source

type Output

The output type for the executor.

Source

type Error

The error type returned by the executor.

Required Methods§

Source

fn execute_and_verify_one( &mut self, input: Self::Input<'_>, ) -> Result<(), Self::Error>

Executes the next block in the batch, verifies the output and updates the state internally.

Source

fn finalize(self) -> Self::Output

Finishes the batch and return the final state.

Source

fn set_tip(&mut self, tip: BlockNumber)

Set the expected tip of the batch.

This can be used to optimize state pruning during execution.

Source

fn set_prune_modes(&mut self, prune_modes: PruneModes)

Set the prune modes.

They are used to determine which parts of the state should be kept during execution.

Source

fn size_hint(&self) -> Option<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§

Source

fn execute_and_verify_many<'a, I>( &mut self, inputs: I, ) -> Result<(), Self::Error>
where I: IntoIterator<Item = Self::Input<'a>>,

Executes multiple inputs in the batch, verifies the output, and updates the state internally.

This method is a convenience function for calling BatchExecutor::execute_and_verify_one for each input.

Source

fn execute_and_verify_batch<'a, I>( self, batch: I, ) -> Result<Self::Output, Self::Error>
where I: IntoIterator<Item = Self::Input<'a>>, Self: Sized,

Executes the entire batch, verifies the output, and returns the final state.

This method is a convenience function for calling BatchExecutor::execute_and_verify_many and BatchExecutor::finalize.

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§

Source§

impl<A, B, DB> BatchExecutor<DB> for Either<A, B>
where A: BatchExecutor<DB>, B: for<'a> BatchExecutor<DB, Input<'a> = A::Input<'a>, Output = A::Output, Error = A::Error>, DB: Database<Error: Into<ProviderError> + Display>,

Source§

type Input<'a> = <A as BatchExecutor<DB>>::Input<'a>

Source§

type Output = <A as BatchExecutor<DB>>::Output

Source§

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

Source§

impl<DB> BatchExecutor<DB> for MockExecutorProvider

Available on crate feature test-utils only.
Source§

impl<DB, P: NodePrimitives> BatchExecutor<DB> for NoopBlockExecutorProvider<P>

Source§

type Input<'a> = &'a BlockWithSenders<<P as NodePrimitives>::Block>

Source§

type Output = ExecutionOutcome<<P as NodePrimitives>::Receipt>

Source§

type Error = BlockExecutionError

Source§

impl<S, DB> BatchExecutor<DB> for BasicBatchExecutor<S>
where S: BlockExecutionStrategy<DB = DB, Error = BlockExecutionError>, DB: Database<Error: Into<ProviderError> + Display>,

Source§

type Input<'a> = &'a BlockWithSenders<<<S as BlockExecutionStrategy>::Primitives as NodePrimitives>::Block>

Source§

type Output = ExecutionOutcome<<<S as BlockExecutionStrategy>::Primitives as NodePrimitives>::Receipt>

Source§

type Error = BlockExecutionError