reth_node_builder/components/
mod.rsmod builder;
mod consensus;
mod execute;
mod network;
mod payload;
mod pool;
pub use builder::*;
pub use consensus::*;
pub use execute::*;
pub use network::*;
pub use payload::*;
pub use pool::*;
use reth_network_p2p::BlockClient;
use crate::{ConfigureEvm, FullNodeTypes};
use reth_consensus::FullConsensus;
use reth_evm::execute::BlockExecutorProvider;
use reth_network::{NetworkHandle, NetworkPrimitives};
use reth_network_api::FullNetwork;
use reth_node_api::{BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, PayloadBuilder, TxTy};
use reth_payload_builder::PayloadBuilderHandle;
use reth_transaction_pool::{PoolTransaction, TransactionPool};
pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'static {
type Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<T::Types>>> + Unpin;
type Evm: ConfigureEvm<Header = HeaderTy<T::Types>, Transaction = TxTy<T::Types>>;
type Executor: BlockExecutorProvider<Primitives = <T::Types as NodeTypes>::Primitives>;
type Consensus: FullConsensus<<T::Types as NodeTypes>::Primitives> + Clone + Unpin + 'static;
type Network: FullNetwork<
Client: BlockClient<Header = HeaderTy<T::Types>, Body = BodyTy<T::Types>>,
>;
type PayloadBuilder: PayloadBuilder<PayloadType = <T::Types as NodeTypesWithEngine>::Engine>
+ Clone;
fn pool(&self) -> &Self::Pool;
fn evm_config(&self) -> &Self::Evm;
fn block_executor(&self) -> &Self::Executor;
fn consensus(&self) -> &Self::Consensus;
fn network(&self) -> &Self::Network;
fn payload_builder(&self) -> &Self::PayloadBuilder;
}
#[derive(Debug)]
pub struct Components<Node: FullNodeTypes, N: NetworkPrimitives, Pool, EVM, Executor, Consensus> {
pub transaction_pool: Pool,
pub evm_config: EVM,
pub executor: Executor,
pub consensus: Consensus,
pub network: NetworkHandle<N>,
pub payload_builder: PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
}
impl<Node, Pool, EVM, Executor, Cons, N> NodeComponents<Node>
for Components<Node, N, Pool, EVM, Executor, Cons>
where
N: NetworkPrimitives<BlockHeader = HeaderTy<Node::Types>, BlockBody = BodyTy<Node::Types>>,
Node: FullNodeTypes,
Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
+ Unpin
+ 'static,
EVM: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>,
Executor: BlockExecutorProvider<Primitives = <Node::Types as NodeTypes>::Primitives>,
Cons: FullConsensus<<Node::Types as NodeTypes>::Primitives> + Clone + Unpin + 'static,
{
type Pool = Pool;
type Evm = EVM;
type Executor = Executor;
type Consensus = Cons;
type Network = NetworkHandle<N>;
type PayloadBuilder = PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>;
fn pool(&self) -> &Self::Pool {
&self.transaction_pool
}
fn evm_config(&self) -> &Self::Evm {
&self.evm_config
}
fn block_executor(&self) -> &Self::Executor {
&self.executor
}
fn consensus(&self) -> &Self::Consensus {
&self.consensus
}
fn network(&self) -> &Self::Network {
&self.network
}
fn payload_builder(&self) -> &Self::PayloadBuilder {
&self.payload_builder
}
}
impl<Node, N, Pool, EVM, Executor, Cons> Clone for Components<Node, N, Pool, EVM, Executor, Cons>
where
N: NetworkPrimitives,
Node: FullNodeTypes,
Pool: TransactionPool,
EVM: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>,
Executor: BlockExecutorProvider,
Cons: Clone,
{
fn clone(&self) -> Self {
Self {
transaction_pool: self.transaction_pool.clone(),
evm_config: self.evm_config.clone(),
executor: self.executor.clone(),
consensus: self.consensus.clone(),
network: self.network.clone(),
payload_builder: self.payload_builder.clone(),
}
}
}