1use crate::ConfigureEvm;
4use alloy_rpc_types_engine::JwtSecret;
5use reth_beacon_consensus::BeaconConsensusEngineHandle;
6use reth_consensus::FullConsensus;
7use reth_evm::execute::BlockExecutorProvider;
8use reth_network_api::FullNetwork;
9use reth_node_core::node_config::NodeConfig;
10use reth_node_types::{HeaderTy, NodeTypes, NodeTypesWithDB, NodeTypesWithEngine, TxTy};
11use reth_payload_builder_primitives::PayloadBuilder;
12use reth_provider::FullProvider;
13use reth_tasks::TaskExecutor;
14use reth_transaction_pool::{PoolTransaction, TransactionPool};
15use std::{future::Future, marker::PhantomData};
16
17pub trait FullNodeTypes: Send + Sync + Unpin + 'static {
22 type Types: NodeTypesWithDB + NodeTypesWithEngine;
24 type Provider: FullProvider<Self::Types>;
26}
27
28#[derive(Debug)]
30pub struct FullNodeTypesAdapter<Types, Provider> {
31 pub types: PhantomData<Types>,
33 pub provider: PhantomData<Provider>,
35}
36
37impl<Types, Provider> FullNodeTypes for FullNodeTypesAdapter<Types, Provider>
38where
39 Types: NodeTypesWithDB + NodeTypesWithEngine,
40 Provider: FullProvider<Types>,
41{
42 type Types = Types;
43 type Provider = Provider;
44}
45
46pub trait FullNodeComponents: FullNodeTypes + Clone + 'static {
48 type Pool: TransactionPool<Transaction: PoolTransaction<Consensus = TxTy<Self::Types>>> + Unpin;
50
51 type Evm: ConfigureEvm<Header = HeaderTy<Self::Types>, Transaction = TxTy<Self::Types>>;
53
54 type Executor: BlockExecutorProvider<Primitives = <Self::Types as NodeTypes>::Primitives>;
56
57 type Consensus: FullConsensus<<Self::Types as NodeTypes>::Primitives> + Clone + Unpin + 'static;
59
60 type Network: FullNetwork;
62
63 type PayloadBuilder: PayloadBuilder<PayloadType = <Self::Types as NodeTypesWithEngine>::Engine>
65 + Clone;
66
67 fn pool(&self) -> &Self::Pool;
69
70 fn evm_config(&self) -> &Self::Evm;
72
73 fn block_executor(&self) -> &Self::Executor;
75
76 fn consensus(&self) -> &Self::Consensus;
78
79 fn network(&self) -> &Self::Network;
81
82 fn payload_builder(&self) -> &Self::PayloadBuilder;
84
85 fn provider(&self) -> &Self::Provider;
87
88 fn task_executor(&self) -> &TaskExecutor;
90}
91
92#[derive(Debug, Clone)]
94pub struct AddOnsContext<'a, N: FullNodeComponents> {
95 pub node: N,
97 pub config: &'a NodeConfig<<N::Types as NodeTypes>::ChainSpec>,
99 pub beacon_engine_handle:
101 BeaconConsensusEngineHandle<<N::Types as NodeTypesWithEngine>::Engine>,
102 pub jwt_secret: JwtSecret,
104}
105
106pub trait NodeAddOns<N: FullNodeComponents>: Send {
108 type Handle: Send + Sync + Clone;
110
111 fn launch_add_ons(
113 self,
114 ctx: AddOnsContext<'_, N>,
115 ) -> impl Future<Output = eyre::Result<Self::Handle>> + Send;
116}
117
118impl<N: FullNodeComponents> NodeAddOns<N> for () {
119 type Handle = ();
120
121 async fn launch_add_ons(self, _components: AddOnsContext<'_, N>) -> eyre::Result<Self::Handle> {
122 Ok(())
123 }
124}