Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions crates/cli/commands/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use clap::Parser;
use reth_chainspec::EthChainSpec;
use reth_cli::chainspec::ChainSpecParser;
use reth_config::{config::EtlConfig, Config};
use reth_consensus::{noop::NoopConsensus, ConsensusError, FullConsensus};
use reth_consensus::noop::NoopConsensus;
use reth_db::{init_db, open_db_read_only, DatabaseEnv};
use reth_db_common::init::init_genesis;
use reth_downloaders::{bodies::noop::NoopBodiesDownloader, headers::noop::NoopHeaderDownloader};
Expand Down Expand Up @@ -229,7 +229,7 @@ impl CliHeader for alloy_consensus::Header {

/// Helper trait with a common set of requirements for the
/// [`NodeTypes`] in CLI.
pub trait CliNodeTypes: NodeTypesForProvider {
pub trait CliNodeTypes: Node<FullTypesAdapter<Self>> + NodeTypesForProvider {
type Evm: ConfigureEvm<Primitives = Self::Primitives>;
type NetworkPrimitives: NetPrimitivesFor<Self::Primitives>;
}
Expand All @@ -242,32 +242,29 @@ where
type NetworkPrimitives = <<<N::ComponentsBuilder as NodeComponentsBuilder<FullTypesAdapter<Self>>>::Components as NodeComponents<FullTypesAdapter<Self>>>::Network as NetworkEventListenerProvider>::Primitives;
}

type EvmFor<N> = <<<N as Node<FullTypesAdapter<N>>>::ComponentsBuilder as NodeComponentsBuilder<
FullTypesAdapter<N>,
>>::Components as NodeComponents<FullTypesAdapter<N>>>::Evm;

type ConsensusFor<N> =
<<<N as Node<FullTypesAdapter<N>>>::ComponentsBuilder as NodeComponentsBuilder<
FullTypesAdapter<N>,
>>::Components as NodeComponents<FullTypesAdapter<N>>>::Consensus;

/// Helper trait aggregating components required for the CLI.
pub trait CliNodeComponents<N: CliNodeTypes>: Send + Sync + 'static {
/// Evm to use.
type Evm: ConfigureEvm<Primitives = N::Primitives> + 'static;
/// Consensus implementation.
type Consensus: FullConsensus<N::Primitives, Error = ConsensusError> + Clone + 'static;

/// Returns the configured EVM.
fn evm_config(&self) -> &Self::Evm;
fn evm_config(&self) -> &EvmFor<N>;
/// Returns the consensus implementation.
fn consensus(&self) -> &Self::Consensus;
fn consensus(&self) -> &ConsensusFor<N>;
}

impl<N: CliNodeTypes, E, C> CliNodeComponents<N> for (E, C)
where
E: ConfigureEvm<Primitives = N::Primitives> + 'static,
C: FullConsensus<N::Primitives, Error = ConsensusError> + Clone + 'static,
{
type Evm = E;
type Consensus = C;

fn evm_config(&self) -> &Self::Evm {
impl<N: CliNodeTypes> CliNodeComponents<N> for (EvmFor<N>, ConsensusFor<N>) {
fn evm_config(&self) -> &EvmFor<N> {
&self.0
}

fn consensus(&self) -> &Self::Consensus {
fn consensus(&self) -> &ConsensusFor<N> {
&self.1
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ethereum/cli/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl<C: ChainSpecParser, Ext: clap::Args + fmt::Debug, Rpc: RpcModuleValidator>
C: ChainSpecParser<ChainSpec = ChainSpec>,
{
let components = |spec: Arc<C::ChainSpec>| {
(EthEvmConfig::ethereum(spec.clone()), EthBeaconConsensus::new(spec))
(EthEvmConfig::ethereum(spec.clone()), Arc::new(EthBeaconConsensus::new(spec)))
};

self.with_runner_and_components::<EthereumNode>(
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/cli/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ where
let _ = install_prometheus_recorder();

let components = |spec: Arc<OpChainSpec>| {
(OpExecutorProvider::optimism(spec.clone()), OpBeaconConsensus::new(spec))
(OpExecutorProvider::optimism(spec.clone()), Arc::new(OpBeaconConsensus::new(spec)))
};

match self.cli.command {
Expand Down