chore: relax ProviderFactory setup (#13254)

This commit is contained in:
Arsenii Kulikov
2024-12-10 04:17:34 +04:00
committed by GitHub
parent 386e4b3ebd
commit 980e62a5b8
13 changed files with 61 additions and 85 deletions

View File

@ -4,7 +4,7 @@ use alloy_primitives::BlockNumber;
use core::fmt::Display;
use reth_execution_errors::BlockExecutionError;
use reth_execution_types::{BlockExecutionInput, BlockExecutionOutput, ExecutionOutcome};
use reth_primitives::{BlockWithSenders, EthPrimitives, Receipt};
use reth_primitives::{BlockWithSenders, NodePrimitives};
use reth_prune_types::PruneModes;
use reth_storage_errors::provider::ProviderError;
use revm::State;
@ -20,10 +20,10 @@ const UNAVAILABLE_FOR_NOOP: &str = "execution unavailable for noop";
/// A [`BlockExecutorProvider`] implementation that does nothing.
#[derive(Debug, Default, Clone)]
#[non_exhaustive]
pub struct NoopBlockExecutorProvider;
pub struct NoopBlockExecutorProvider<P>(core::marker::PhantomData<P>);
impl BlockExecutorProvider for NoopBlockExecutorProvider {
type Primitives = EthPrimitives;
impl<P: NodePrimitives> BlockExecutorProvider for NoopBlockExecutorProvider<P> {
type Primitives = P;
type Executor<DB: Database<Error: Into<ProviderError> + Display>> = Self;
@ -33,20 +33,20 @@ impl BlockExecutorProvider for NoopBlockExecutorProvider {
where
DB: Database<Error: Into<ProviderError> + Display>,
{
Self
Self::default()
}
fn batch_executor<DB>(&self, _: DB) -> Self::BatchExecutor<DB>
where
DB: Database<Error: Into<ProviderError> + Display>,
{
Self
Self::default()
}
}
impl<DB> Executor<DB> for NoopBlockExecutorProvider {
type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>;
type Output = BlockExecutionOutput<Receipt>;
impl<DB, P: NodePrimitives> Executor<DB> for NoopBlockExecutorProvider<P> {
type Input<'a> = BlockExecutionInput<'a, BlockWithSenders<P::Block>>;
type Output = BlockExecutionOutput<P::Receipt>;
type Error = BlockExecutionError;
fn execute(self, _: Self::Input<'_>) -> Result<Self::Output, Self::Error> {
@ -76,9 +76,9 @@ impl<DB> Executor<DB> for NoopBlockExecutorProvider {
}
}
impl<DB> BatchExecutor<DB> for NoopBlockExecutorProvider {
type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>;
type Output = ExecutionOutcome;
impl<DB, P: NodePrimitives> BatchExecutor<DB> for NoopBlockExecutorProvider<P> {
type Input<'a> = BlockExecutionInput<'a, BlockWithSenders<P::Block>>;
type Output = ExecutionOutcome<P::Receipt>;
type Error = BlockExecutionError;
fn execute_and_verify_one(&mut self, _: Self::Input<'_>) -> Result<(), Self::Error> {