mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-09 07:17:56 -05:00
experiment with different designs
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::{
|
||||
};
|
||||
use reth_node_api::ConfigureEvmEnv;
|
||||
use reth_primitives::ChainSpec;
|
||||
use reth_provider::{ExecutorFactory, PrunableBlockExecutor, StateProvider};
|
||||
use reth_provider::{ExecutorFactory, PrunableBlockExecutor, StateProvider, ExecutorFactoryLifetime, ExecutorFactoryGat};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Factory for creating [EVMProcessor].
|
||||
@@ -36,6 +36,46 @@ impl<EvmConfig> EvmProcessorFactory<EvmConfig> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, EvmConfig> ExecutorFactoryLifetime<'a> for EvmProcessorFactory<EvmConfig>
|
||||
where
|
||||
EvmConfig: ConfigureEvmEnv + Send + Sync + Clone + 'static,
|
||||
{
|
||||
type Executor = EVMProcessor<'a, EvmConfig>;
|
||||
|
||||
fn with_state<SP: StateProvider + 'a>(&self, sp: SP) -> Self::Executor {
|
||||
let database_state = StateProviderDatabase::new(sp);
|
||||
let mut evm = EVMProcessor::new_with_db(
|
||||
self.chain_spec.clone(),
|
||||
database_state,
|
||||
self.evm_config.clone(),
|
||||
);
|
||||
if let Some(ref stack) = self.stack {
|
||||
evm.set_stack(stack.clone());
|
||||
}
|
||||
evm
|
||||
}
|
||||
}
|
||||
|
||||
impl<EvmConfig> ExecutorFactoryGat for EvmProcessorFactory<EvmConfig>
|
||||
where
|
||||
EvmConfig: ConfigureEvmEnv + Send + Sync + Clone + 'static,
|
||||
{
|
||||
type Executor<'a> = EVMProcessor<'a, EvmConfig>;
|
||||
|
||||
fn with_state<'a, SP: StateProvider + 'a>(&self, sp: SP) -> Self::Executor<'a> {
|
||||
let database_state = StateProviderDatabase::new(sp);
|
||||
let mut evm = EVMProcessor::new_with_db(
|
||||
self.chain_spec.clone(),
|
||||
database_state,
|
||||
self.evm_config.clone(),
|
||||
);
|
||||
if let Some(ref stack) = self.stack {
|
||||
evm.set_stack(stack.clone());
|
||||
}
|
||||
evm
|
||||
}
|
||||
}
|
||||
|
||||
impl<EvmConfig> ExecutorFactory for EvmProcessorFactory<EvmConfig>
|
||||
where
|
||||
EvmConfig: ConfigureEvmEnv + Send + Sync + Clone + 'static,
|
||||
|
||||
@@ -17,6 +17,22 @@ pub trait ExecutorFactory: Send + Sync + 'static {
|
||||
) -> Box<dyn PrunableBlockExecutor + 'a>;
|
||||
}
|
||||
|
||||
/// ExecutorFactory that is generic over a lifetime.
|
||||
pub trait ExecutorFactoryLifetime<'a>: Send + Sync + 'static {
|
||||
type Executor: PrunableBlockExecutor;
|
||||
|
||||
/// Executor with [`StateProvider`]
|
||||
fn with_state<SP: StateProvider + 'a>(&self, sp: SP) -> Self::Executor;
|
||||
}
|
||||
|
||||
/// ExecutorFactoryGat uses a GAT
|
||||
pub trait ExecutorFactoryGat: Send + Sync + 'static {
|
||||
type Executor<'a>: PrunableBlockExecutor;
|
||||
|
||||
/// Executor with [`StateProvider`]
|
||||
fn with_state<'a, SP: StateProvider + 'a>(&self, sp: SP) -> Self::Executor<'a>;
|
||||
}
|
||||
|
||||
/// An executor capable of executing a block.
|
||||
pub trait BlockExecutor {
|
||||
/// Execute a block.
|
||||
|
||||
@@ -46,7 +46,10 @@ mod withdrawals;
|
||||
pub use withdrawals::WithdrawalsProvider;
|
||||
|
||||
mod executor;
|
||||
pub use executor::{BlockExecutor, BlockExecutorStats, ExecutorFactory, PrunableBlockExecutor};
|
||||
pub use executor::{
|
||||
BlockExecutor, BlockExecutorStats, ExecutorFactory, ExecutorFactoryLifetime, ExecutorFactoryGat,
|
||||
PrunableBlockExecutor,
|
||||
};
|
||||
|
||||
mod chain;
|
||||
pub use chain::{
|
||||
|
||||
Reference in New Issue
Block a user