reth_node_builder/components/
mod.rs1mod builder;
11mod consensus;
12mod execute;
13mod network;
14mod payload;
15mod pool;
16
17pub use builder::*;
18pub use consensus::*;
19pub use execute::*;
20pub use network::*;
21pub use payload::*;
22pub use pool::*;
23use reth_network_p2p::BlockClient;
24
25use crate::{ConfigureEvm, FullNodeTypes};
26use reth_consensus::FullConsensus;
27use reth_evm::execute::BlockExecutorProvider;
28use reth_network::{NetworkHandle, NetworkPrimitives};
29use reth_network_api::FullNetwork;
30use reth_node_api::{BodyTy, HeaderTy, NodeTypes, NodeTypesWithEngine, PayloadBuilder, TxTy};
31use reth_payload_builder::PayloadBuilderHandle;
32use reth_transaction_pool::{PoolTransaction, TransactionPool};
33
34pub trait NodeComponents<T: FullNodeTypes>: Clone + Unpin + Send + Sync + 'static {
40 type Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<T::Types>>> + Unpin;
42
43 type Evm: ConfigureEvm<Header = HeaderTy<T::Types>, Transaction = TxTy<T::Types>>;
45
46 type Executor: BlockExecutorProvider<Primitives = <T::Types as NodeTypes>::Primitives>;
48
49 type Consensus: FullConsensus<<T::Types as NodeTypes>::Primitives> + Clone + Unpin + 'static;
51
52 type Network: FullNetwork<
54 Client: BlockClient<Header = HeaderTy<T::Types>, Body = BodyTy<T::Types>>,
55 >;
56
57 type PayloadBuilder: PayloadBuilder<PayloadType = <T::Types as NodeTypesWithEngine>::Engine>
59 + Clone;
60
61 fn pool(&self) -> &Self::Pool;
63
64 fn evm_config(&self) -> &Self::Evm;
66
67 fn block_executor(&self) -> &Self::Executor;
69
70 fn consensus(&self) -> &Self::Consensus;
72
73 fn network(&self) -> &Self::Network;
75
76 fn payload_builder(&self) -> &Self::PayloadBuilder;
78}
79
80#[derive(Debug)]
84pub struct Components<Node: FullNodeTypes, N: NetworkPrimitives, Pool, EVM, Executor, Consensus> {
85 pub transaction_pool: Pool,
87 pub evm_config: EVM,
89 pub executor: Executor,
91 pub consensus: Consensus,
93 pub network: NetworkHandle<N>,
95 pub payload_builder: PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>,
97}
98
99impl<Node, Pool, EVM, Executor, Cons, N> NodeComponents<Node>
100 for Components<Node, N, Pool, EVM, Executor, Cons>
101where
102 N: NetworkPrimitives<BlockHeader = HeaderTy<Node::Types>, BlockBody = BodyTy<Node::Types>>,
103 Node: FullNodeTypes,
104 Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
105 + Unpin
106 + 'static,
107 EVM: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>,
108 Executor: BlockExecutorProvider<Primitives = <Node::Types as NodeTypes>::Primitives>,
109 Cons: FullConsensus<<Node::Types as NodeTypes>::Primitives> + Clone + Unpin + 'static,
110{
111 type Pool = Pool;
112 type Evm = EVM;
113 type Executor = Executor;
114 type Consensus = Cons;
115 type Network = NetworkHandle<N>;
116 type PayloadBuilder = PayloadBuilderHandle<<Node::Types as NodeTypesWithEngine>::Engine>;
117
118 fn pool(&self) -> &Self::Pool {
119 &self.transaction_pool
120 }
121
122 fn evm_config(&self) -> &Self::Evm {
123 &self.evm_config
124 }
125
126 fn block_executor(&self) -> &Self::Executor {
127 &self.executor
128 }
129
130 fn consensus(&self) -> &Self::Consensus {
131 &self.consensus
132 }
133
134 fn network(&self) -> &Self::Network {
135 &self.network
136 }
137
138 fn payload_builder(&self) -> &Self::PayloadBuilder {
139 &self.payload_builder
140 }
141}
142
143impl<Node, N, Pool, EVM, Executor, Cons> Clone for Components<Node, N, Pool, EVM, Executor, Cons>
144where
145 N: NetworkPrimitives,
146 Node: FullNodeTypes,
147 Pool: TransactionPool,
148 EVM: ConfigureEvm<Header = HeaderTy<Node::Types>, Transaction = TxTy<Node::Types>>,
149 Executor: BlockExecutorProvider,
150 Cons: Clone,
151{
152 fn clone(&self) -> Self {
153 Self {
154 transaction_pool: self.transaction_pool.clone(),
155 evm_config: self.evm_config.clone(),
156 executor: self.executor.clone(),
157 consensus: self.consensus.clone(),
158 network: self.network.clone(),
159 payload_builder: self.payload_builder.clone(),
160 }
161 }
162}