reth_node_builder/components/
mod.rs
1mod 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;
24use reth_payload_builder::PayloadBuilderHandle;
25use std::fmt::Debug;
26
27use crate::{ConfigureEvm, FullNodeTypes};
28use reth_consensus::{ConsensusError, FullConsensus};
29use reth_evm::execute::BlockExecutorProvider;
30use reth_network::{NetworkHandle, NetworkPrimitives};
31use reth_network_api::FullNetwork;
32use reth_node_api::{BlockTy, BodyTy, HeaderTy, NodeTypes, PrimitivesTy, TxTy};
33use reth_transaction_pool::{PoolTransaction, TransactionPool};
34
35pub trait NodeComponents<T: FullNodeTypes>: Clone + Debug + Unpin + Send + Sync + 'static {
41 type Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<T::Types>>> + Unpin;
43
44 type Evm: ConfigureEvm<Primitives = <T::Types as NodeTypes>::Primitives>;
46
47 type Executor: BlockExecutorProvider<Primitives = <T::Types as NodeTypes>::Primitives>;
49
50 type Consensus: FullConsensus<<T::Types as NodeTypes>::Primitives, Error = ConsensusError>
52 + Clone
53 + Unpin
54 + 'static;
55
56 type Network: FullNetwork<Client: BlockClient<Block = BlockTy<T::Types>>>;
58
59 fn pool(&self) -> &Self::Pool;
61
62 fn evm_config(&self) -> &Self::Evm;
64
65 fn block_executor(&self) -> &Self::Executor;
67
68 fn consensus(&self) -> &Self::Consensus;
70
71 fn network(&self) -> &Self::Network;
73
74 fn payload_builder_handle(&self) -> &PayloadBuilderHandle<<T::Types as NodeTypes>::Payload>;
77}
78
79#[derive(Debug)]
83pub struct Components<Node: FullNodeTypes, N: NetworkPrimitives, Pool, EVM, Executor, Consensus> {
84 pub transaction_pool: Pool,
86 pub evm_config: EVM,
88 pub executor: Executor,
90 pub consensus: Consensus,
92 pub network: NetworkHandle<N>,
94 pub payload_builder_handle: PayloadBuilderHandle<<Node::Types as NodeTypes>::Payload>,
96}
97
98impl<Node, Pool, EVM, Executor, Cons, N> NodeComponents<Node>
99 for Components<Node, N, Pool, EVM, Executor, Cons>
100where
101 Node: FullNodeTypes,
102 N: NetworkPrimitives<
103 BlockHeader = HeaderTy<Node::Types>,
104 BlockBody = BodyTy<Node::Types>,
105 Block = BlockTy<Node::Types>,
106 >,
107 Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Node::Types>>>
108 + Unpin
109 + 'static,
110 EVM: ConfigureEvm<Primitives = PrimitivesTy<Node::Types>> + 'static,
111 Executor: BlockExecutorProvider<Primitives = PrimitivesTy<Node::Types>>,
112 Cons:
113 FullConsensus<PrimitivesTy<Node::Types>, Error = ConsensusError> + Clone + Unpin + 'static,
114{
115 type Pool = Pool;
116 type Evm = EVM;
117 type Executor = Executor;
118 type Consensus = Cons;
119 type Network = NetworkHandle<N>;
120
121 fn pool(&self) -> &Self::Pool {
122 &self.transaction_pool
123 }
124
125 fn evm_config(&self) -> &Self::Evm {
126 &self.evm_config
127 }
128
129 fn block_executor(&self) -> &Self::Executor {
130 &self.executor
131 }
132
133 fn consensus(&self) -> &Self::Consensus {
134 &self.consensus
135 }
136
137 fn network(&self) -> &Self::Network {
138 &self.network
139 }
140
141 fn payload_builder_handle(&self) -> &PayloadBuilderHandle<<Node::Types as NodeTypes>::Payload> {
142 &self.payload_builder_handle
143 }
144}
145
146impl<Node, N, Pool, EVM, Executor, Cons> Clone for Components<Node, N, Pool, EVM, Executor, Cons>
147where
148 N: NetworkPrimitives,
149 Node: FullNodeTypes,
150 Pool: TransactionPool,
151 EVM: ConfigureEvm,
152 Executor: BlockExecutorProvider,
153 Cons: Clone,
154{
155 fn clone(&self) -> Self {
156 Self {
157 transaction_pool: self.transaction_pool.clone(),
158 evm_config: self.evm_config.clone(),
159 executor: self.executor.clone(),
160 consensus: self.consensus.clone(),
161 network: self.network.clone(),
162 payload_builder_handle: self.payload_builder_handle.clone(),
163 }
164 }
165}