mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
node: revise NodeTypes trait (#10665)
This commit is contained in:
@ -15,7 +15,7 @@ use reth_chainspec::ChainSpec;
|
|||||||
use reth_db::{test_utils::TempDatabase, DatabaseEnv};
|
use reth_db::{test_utils::TempDatabase, DatabaseEnv};
|
||||||
use reth_node_builder::{
|
use reth_node_builder::{
|
||||||
components::NodeComponentsBuilder, rpc::EthApiBuilderProvider, FullNodeTypesAdapter, Node,
|
components::NodeComponentsBuilder, rpc::EthApiBuilderProvider, FullNodeTypesAdapter, Node,
|
||||||
NodeAdapter, NodeAddOns, NodeComponents, NodeTypes, RethFullAdapter,
|
NodeAdapter, NodeAddOns, NodeComponents, NodeTypesWithEngine, RethFullAdapter,
|
||||||
};
|
};
|
||||||
use reth_provider::providers::BlockchainProvider;
|
use reth_provider::providers::BlockchainProvider;
|
||||||
use tracing::{span, Level};
|
use tracing::{span, Level};
|
||||||
@ -51,7 +51,7 @@ pub async fn setup<N>(
|
|||||||
is_dev: bool,
|
is_dev: bool,
|
||||||
) -> eyre::Result<(Vec<NodeHelperType<N, N::AddOns>>, TaskManager, Wallet)>
|
) -> eyre::Result<(Vec<NodeHelperType<N, N::AddOns>>, TaskManager, Wallet)>
|
||||||
where
|
where
|
||||||
N: Default + Node<TmpNodeAdapter<N>> + NodeTypes<ChainSpec = ChainSpec>,
|
N: Default + Node<TmpNodeAdapter<N>> + NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||||
N::ComponentsBuilder: NodeComponentsBuilder<
|
N::ComponentsBuilder: NodeComponentsBuilder<
|
||||||
TmpNodeAdapter<N>,
|
TmpNodeAdapter<N>,
|
||||||
Components: NodeComponents<TmpNodeAdapter<N>, Network: PeersHandleProvider>,
|
Components: NodeComponents<TmpNodeAdapter<N>, Network: PeersHandleProvider>,
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use reth::{
|
|||||||
types::engine::PayloadStatusEnum,
|
types::engine::PayloadStatusEnum,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use reth_node_builder::{EthApiTypes, NodeAddOns, NodeTypes};
|
use reth_node_builder::{EthApiTypes, NodeAddOns, NodeTypesWithEngine};
|
||||||
use reth_primitives::{BlockHash, BlockNumber, Bytes, B256};
|
use reth_primitives::{BlockHash, BlockNumber, Bytes, B256};
|
||||||
use reth_rpc_types::WithOtherFields;
|
use reth_rpc_types::WithOtherFields;
|
||||||
use reth_stages_types::StageId;
|
use reth_stages_types::StageId;
|
||||||
@ -118,8 +118,8 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
attributes_generator: impl Fn(u64) -> <Node::Engine as PayloadTypes>::PayloadBuilderAttributes,
|
attributes_generator: impl Fn(u64) -> <Node::Engine as PayloadTypes>::PayloadBuilderAttributes,
|
||||||
) -> eyre::Result<(
|
) -> eyre::Result<(
|
||||||
<<Node as NodeTypes>::Engine as PayloadTypes>::BuiltPayload,
|
<<Node as NodeTypesWithEngine>::Engine as PayloadTypes>::BuiltPayload,
|
||||||
<<Node as NodeTypes>::Engine as PayloadTypes>::PayloadBuilderAttributes,
|
<<Node as NodeTypesWithEngine>::Engine as PayloadTypes>::PayloadBuilderAttributes,
|
||||||
)>
|
)>
|
||||||
where
|
where
|
||||||
<Node::Engine as EngineTypes>::ExecutionPayloadV3:
|
<Node::Engine as EngineTypes>::ExecutionPayloadV3:
|
||||||
@ -144,7 +144,7 @@ where
|
|||||||
attributes_generator: impl Fn(u64) -> <Node::Engine as PayloadTypes>::PayloadBuilderAttributes,
|
attributes_generator: impl Fn(u64) -> <Node::Engine as PayloadTypes>::PayloadBuilderAttributes,
|
||||||
) -> eyre::Result<(
|
) -> eyre::Result<(
|
||||||
<Node::Engine as PayloadTypes>::BuiltPayload,
|
<Node::Engine as PayloadTypes>::BuiltPayload,
|
||||||
<<Node as NodeTypes>::Engine as PayloadTypes>::PayloadBuilderAttributes,
|
<<Node as NodeTypesWithEngine>::Engine as PayloadTypes>::PayloadBuilderAttributes,
|
||||||
)>
|
)>
|
||||||
where
|
where
|
||||||
<Node::Engine as EngineTypes>::ExecutionPayloadV3:
|
<Node::Engine as EngineTypes>::ExecutionPayloadV3:
|
||||||
|
|||||||
@ -17,7 +17,7 @@ use reth_node_builder::{
|
|||||||
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder,
|
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder,
|
||||||
PayloadServiceBuilder, PoolBuilder,
|
PayloadServiceBuilder, PoolBuilder,
|
||||||
},
|
},
|
||||||
node::{FullNodeTypes, NodeTypes},
|
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
|
||||||
BuilderContext, ConfigureEvm, Node, PayloadBuilderConfig, PayloadTypes,
|
BuilderContext, ConfigureEvm, Node, PayloadBuilderConfig, PayloadTypes,
|
||||||
};
|
};
|
||||||
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
|
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
|
||||||
@ -48,7 +48,7 @@ impl EthereumNode {
|
|||||||
>
|
>
|
||||||
where
|
where
|
||||||
Node: FullNodeTypes,
|
Node: FullNodeTypes,
|
||||||
<Node as NodeTypes>::Engine: PayloadTypes<
|
<Node as NodeTypesWithEngine>::Engine: PayloadTypes<
|
||||||
BuiltPayload = EthBuiltPayload,
|
BuiltPayload = EthBuiltPayload,
|
||||||
PayloadAttributes = EthPayloadAttributes,
|
PayloadAttributes = EthPayloadAttributes,
|
||||||
PayloadBuilderAttributes = EthPayloadBuilderAttributes,
|
PayloadBuilderAttributes = EthPayloadBuilderAttributes,
|
||||||
@ -66,10 +66,13 @@ impl EthereumNode {
|
|||||||
|
|
||||||
impl NodeTypes for EthereumNode {
|
impl NodeTypes for EthereumNode {
|
||||||
type Primitives = ();
|
type Primitives = ();
|
||||||
type Engine = EthEngineTypes;
|
|
||||||
type ChainSpec = ChainSpec;
|
type ChainSpec = ChainSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl NodeTypesWithEngine for EthereumNode {
|
||||||
|
type Engine = EthEngineTypes;
|
||||||
|
}
|
||||||
|
|
||||||
/// Add-ons w.r.t. l1 ethereum.
|
/// Add-ons w.r.t. l1 ethereum.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct EthereumAddOns;
|
pub struct EthereumAddOns;
|
||||||
@ -215,7 +218,7 @@ where
|
|||||||
Node: FullNodeTypes,
|
Node: FullNodeTypes,
|
||||||
Evm: ConfigureEvm,
|
Evm: ConfigureEvm,
|
||||||
Pool: TransactionPool + Unpin + 'static,
|
Pool: TransactionPool + Unpin + 'static,
|
||||||
<Node as NodeTypes>::Engine: PayloadTypes<
|
<Node as NodeTypesWithEngine>::Engine: PayloadTypes<
|
||||||
BuiltPayload = EthBuiltPayload,
|
BuiltPayload = EthBuiltPayload,
|
||||||
PayloadAttributes = EthPayloadAttributes,
|
PayloadAttributes = EthPayloadAttributes,
|
||||||
PayloadBuilderAttributes = EthPayloadBuilderAttributes,
|
PayloadBuilderAttributes = EthPayloadBuilderAttributes,
|
||||||
|
|||||||
@ -18,7 +18,7 @@ use reth_evm::test_utils::MockExecutorProvider;
|
|||||||
use reth_execution_types::Chain;
|
use reth_execution_types::Chain;
|
||||||
use reth_exex::{ExExContext, ExExEvent, ExExNotification};
|
use reth_exex::{ExExContext, ExExEvent, ExExNotification};
|
||||||
use reth_network::{config::SecretKey, NetworkConfigBuilder, NetworkManager};
|
use reth_network::{config::SecretKey, NetworkConfigBuilder, NetworkManager};
|
||||||
use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeTypes};
|
use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeTypes, NodeTypesWithEngine};
|
||||||
use reth_node_builder::{
|
use reth_node_builder::{
|
||||||
components::{
|
components::{
|
||||||
Components, ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NodeComponentsBuilder,
|
Components, ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NodeComponentsBuilder,
|
||||||
@ -110,10 +110,13 @@ pub struct TestNode;
|
|||||||
|
|
||||||
impl NodeTypes for TestNode {
|
impl NodeTypes for TestNode {
|
||||||
type Primitives = ();
|
type Primitives = ();
|
||||||
type Engine = EthEngineTypes;
|
|
||||||
type ChainSpec = ChainSpec;
|
type ChainSpec = ChainSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl NodeTypesWithEngine for TestNode {
|
||||||
|
type Engine = EthEngineTypes;
|
||||||
|
}
|
||||||
|
|
||||||
impl<N> Node<N> for TestNode
|
impl<N> Node<N> for TestNode
|
||||||
where
|
where
|
||||||
N: FullNodeTypes<Engine = EthEngineTypes, ChainSpec = ChainSpec>,
|
N: FullNodeTypes<Engine = EthEngineTypes, ChainSpec = ChainSpec>,
|
||||||
|
|||||||
@ -17,55 +17,99 @@ use reth_transaction_pool::TransactionPool;
|
|||||||
|
|
||||||
use crate::{primitives::NodePrimitives, ConfigureEvm, EngineTypes};
|
use crate::{primitives::NodePrimitives, ConfigureEvm, EngineTypes};
|
||||||
|
|
||||||
/// The type that configures the essential types of an ethereum like node.
|
/// The type that configures the essential types of an Ethereum-like node.
|
||||||
///
|
///
|
||||||
/// This includes the primitive types of a node, the engine API types for communication with the
|
/// This includes the primitive types of a node.
|
||||||
/// consensus layer.
|
|
||||||
///
|
///
|
||||||
/// This trait is intended to be stateless and only define the types of the node.
|
/// This trait is intended to be stateless and only define the types of the node.
|
||||||
pub trait NodeTypes: Send + Sync + Unpin + 'static {
|
pub trait NodeTypes: Send + Sync + Unpin + 'static {
|
||||||
/// The node's primitive types, defining basic operations and structures.
|
/// The node's primitive types, defining basic operations and structures.
|
||||||
type Primitives: NodePrimitives;
|
type Primitives: NodePrimitives;
|
||||||
/// The node's engine types, defining the interaction with the consensus engine.
|
|
||||||
type Engine: EngineTypes;
|
|
||||||
/// The type used for configuration of the EVM.
|
/// The type used for configuration of the EVM.
|
||||||
type ChainSpec: EthChainSpec;
|
type ChainSpec: EthChainSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A [`NodeTypes`] type builder
|
/// The type that configures an Ethereum-like node with an engine for consensus.
|
||||||
#[derive(Default, Debug)]
|
pub trait NodeTypesWithEngine: NodeTypes {
|
||||||
pub struct AnyNodeTypes<P = (), E = (), C = ()>(PhantomData<P>, PhantomData<E>, PhantomData<C>);
|
/// The node's engine types, defining the interaction with the consensus engine.
|
||||||
|
type Engine: EngineTypes;
|
||||||
|
}
|
||||||
|
|
||||||
impl<P, E, C> AnyNodeTypes<P, E, C> {
|
/// A [`NodeTypes`] type builder.
|
||||||
|
#[derive(Default, Debug)]
|
||||||
|
pub struct AnyNodeTypes<P = (), C = ()>(PhantomData<P>, PhantomData<C>);
|
||||||
|
|
||||||
|
impl<P, C> AnyNodeTypes<P, C> {
|
||||||
/// Sets the `Primitives` associated type.
|
/// Sets the `Primitives` associated type.
|
||||||
pub const fn primitives<T>(self) -> AnyNodeTypes<T, E, C> {
|
pub const fn primitives<T>(self) -> AnyNodeTypes<T, C> {
|
||||||
AnyNodeTypes::<T, E, C>(PhantomData::<T>, PhantomData::<E>, PhantomData::<C>)
|
AnyNodeTypes::<T, C>(PhantomData::<T>, PhantomData::<C>)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the `ChainSpec` associated type.
|
||||||
|
pub const fn chain_spec<T>(self) -> AnyNodeTypes<P, T> {
|
||||||
|
AnyNodeTypes::<P, T>(PhantomData::<P>, PhantomData::<T>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P, C> NodeTypes for AnyNodeTypes<P, C>
|
||||||
|
where
|
||||||
|
P: NodePrimitives + Send + Sync + Unpin + 'static,
|
||||||
|
C: EthChainSpec,
|
||||||
|
{
|
||||||
|
type Primitives = P;
|
||||||
|
type ChainSpec = C;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A [`NodeTypesWithEngine`] type builder.
|
||||||
|
#[derive(Default, Debug)]
|
||||||
|
pub struct AnyNodeTypesWithEngine<P = (), E = (), C = ()> {
|
||||||
|
/// Embedding the basic node types.
|
||||||
|
base: AnyNodeTypes<P, C>,
|
||||||
|
/// Phantom data for the engine.
|
||||||
|
_engine: PhantomData<E>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P, E, C> AnyNodeTypesWithEngine<P, E, C> {
|
||||||
|
/// Sets the `Primitives` associated type.
|
||||||
|
pub const fn primitives<T>(self) -> AnyNodeTypesWithEngine<T, E, C> {
|
||||||
|
AnyNodeTypesWithEngine { base: self.base.primitives::<T>(), _engine: PhantomData }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the `Engine` associated type.
|
/// Sets the `Engine` associated type.
|
||||||
pub const fn engine<T>(self) -> AnyNodeTypes<P, T, C> {
|
pub const fn engine<T>(self) -> AnyNodeTypesWithEngine<P, T, C> {
|
||||||
AnyNodeTypes::<P, T, C>(PhantomData::<P>, PhantomData::<T>, PhantomData::<C>)
|
AnyNodeTypesWithEngine { base: self.base, _engine: PhantomData::<T> }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the `ChainSpec` associated type.
|
||||||
|
pub const fn chain_spec<T>(self) -> AnyNodeTypesWithEngine<P, E, T> {
|
||||||
|
AnyNodeTypesWithEngine { base: self.base.chain_spec::<T>(), _engine: PhantomData }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<P, E, C> NodeTypes for AnyNodeTypes<P, E, C>
|
impl<P, E, C> NodeTypes for AnyNodeTypesWithEngine<P, E, C>
|
||||||
where
|
where
|
||||||
P: NodePrimitives + Send + Sync + Unpin + 'static,
|
P: NodePrimitives + Send + Sync + Unpin + 'static,
|
||||||
E: EngineTypes + Send + Sync + Unpin,
|
E: EngineTypes + Send + Sync + Unpin,
|
||||||
C: EthChainSpec,
|
C: EthChainSpec,
|
||||||
{
|
{
|
||||||
type Primitives = P;
|
type Primitives = P;
|
||||||
|
|
||||||
type Engine = E;
|
|
||||||
|
|
||||||
type ChainSpec = C;
|
type ChainSpec = C;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A helper trait that is downstream of the [`NodeTypes`] trait and adds stateful components to the
|
impl<P, E, C> NodeTypesWithEngine for AnyNodeTypesWithEngine<P, E, C>
|
||||||
/// node.
|
where
|
||||||
|
P: NodePrimitives + Send + Sync + Unpin + 'static,
|
||||||
|
E: EngineTypes + Send + Sync + Unpin,
|
||||||
|
C: EthChainSpec,
|
||||||
|
{
|
||||||
|
type Engine = E;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A helper trait that is downstream of the [`NodeTypesWithEngine`] trait and adds stateful
|
||||||
|
/// components to the node.
|
||||||
///
|
///
|
||||||
/// Its types are configured by node internally and are not intended to be user configurable.
|
/// Its types are configured by node internally and are not intended to be user configurable.
|
||||||
pub trait FullNodeTypes: NodeTypes<ChainSpec = ChainSpec> + 'static {
|
pub trait FullNodeTypes: NodeTypesWithEngine<ChainSpec = ChainSpec> + 'static {
|
||||||
/// Underlying database type used by the node to store and retrieve data.
|
/// Underlying database type used by the node to store and retrieve data.
|
||||||
type DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static;
|
type DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static;
|
||||||
/// The provider type used to interact with the node.
|
/// The provider type used to interact with the node.
|
||||||
@ -104,18 +148,26 @@ impl<Types, DB, Provider> Clone for FullNodeTypesAdapter<Types, DB, Provider> {
|
|||||||
|
|
||||||
impl<Types, DB, Provider> NodeTypes for FullNodeTypesAdapter<Types, DB, Provider>
|
impl<Types, DB, Provider> NodeTypes for FullNodeTypesAdapter<Types, DB, Provider>
|
||||||
where
|
where
|
||||||
Types: NodeTypes,
|
Types: NodeTypesWithEngine,
|
||||||
DB: Send + Sync + Unpin + 'static,
|
DB: Send + Sync + Unpin + 'static,
|
||||||
Provider: Send + Sync + Unpin + 'static,
|
Provider: Send + Sync + Unpin + 'static,
|
||||||
{
|
{
|
||||||
type Primitives = Types::Primitives;
|
type Primitives = Types::Primitives;
|
||||||
type Engine = Types::Engine;
|
|
||||||
type ChainSpec = Types::ChainSpec;
|
type ChainSpec = Types::ChainSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<Types, DB, Provider> NodeTypesWithEngine for FullNodeTypesAdapter<Types, DB, Provider>
|
||||||
|
where
|
||||||
|
Types: NodeTypesWithEngine,
|
||||||
|
DB: Send + Sync + Unpin + 'static,
|
||||||
|
Provider: Send + Sync + Unpin + 'static,
|
||||||
|
{
|
||||||
|
type Engine = Types::Engine;
|
||||||
|
}
|
||||||
|
|
||||||
impl<Types, DB, Provider> FullNodeTypes for FullNodeTypesAdapter<Types, DB, Provider>
|
impl<Types, DB, Provider> FullNodeTypes for FullNodeTypesAdapter<Types, DB, Provider>
|
||||||
where
|
where
|
||||||
Types: NodeTypes<ChainSpec = ChainSpec>,
|
Types: NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||||
Provider: FullProvider<DB, Types::ChainSpec>,
|
Provider: FullProvider<DB, Types::ChainSpec>,
|
||||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
||||||
{
|
{
|
||||||
|
|||||||
@ -21,7 +21,7 @@ use reth_exex::ExExContext;
|
|||||||
use reth_network::{
|
use reth_network::{
|
||||||
NetworkBuilder, NetworkConfig, NetworkConfigBuilder, NetworkHandle, NetworkManager,
|
NetworkBuilder, NetworkConfig, NetworkConfigBuilder, NetworkHandle, NetworkManager,
|
||||||
};
|
};
|
||||||
use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeAddOns, NodeTypes};
|
use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeAddOns, NodeTypesWithEngine};
|
||||||
use reth_node_core::{
|
use reth_node_core::{
|
||||||
cli::config::{PayloadBuilderConfig, RethTransactionPoolConfig},
|
cli::config::{PayloadBuilderConfig, RethTransactionPoolConfig},
|
||||||
dirs::{ChainPath, DataDirPath},
|
dirs::{ChainPath, DataDirPath},
|
||||||
@ -58,8 +58,8 @@ pub type RethFullAdapter<DB, Types> = FullNodeTypesAdapter<Types, DB, Blockchain
|
|||||||
/// ## Order
|
/// ## Order
|
||||||
///
|
///
|
||||||
/// Configuring a node starts out with a [`NodeConfig`] (this can be obtained from cli arguments for
|
/// Configuring a node starts out with a [`NodeConfig`] (this can be obtained from cli arguments for
|
||||||
/// example) and then proceeds to configure the core static types of the node: [`NodeTypes`], these
|
/// example) and then proceeds to configure the core static types of the node:
|
||||||
/// include the node's primitive types and the node's engine types.
|
/// [`NodeTypesWithEngine`], these include the node's primitive types and the node's engine types.
|
||||||
///
|
///
|
||||||
/// Next all stateful components of the node are configured, these include all the
|
/// Next all stateful components of the node are configured, these include all the
|
||||||
/// components of the node that are downstream of those types, these include:
|
/// components of the node that are downstream of those types, these include:
|
||||||
@ -125,10 +125,10 @@ pub type RethFullAdapter<DB, Types> = FullNodeTypesAdapter<Types, DB, Blockchain
|
|||||||
///
|
///
|
||||||
/// ## Internals
|
/// ## Internals
|
||||||
///
|
///
|
||||||
/// The node builder is fully type safe, it uses the [`NodeTypes`] trait to enforce that all
|
/// The node builder is fully type safe, it uses the [`NodeTypesWithEngine`] trait to enforce that
|
||||||
/// components are configured with the correct types. However the database types and with that the
|
/// all components are configured with the correct types. However the database types and with that
|
||||||
/// provider trait implementations are currently created by the builder itself during the launch
|
/// the provider trait implementations are currently created by the builder itself during the launch
|
||||||
/// process, hence the database type is not part of the [`NodeTypes`] trait and the node's
|
/// process, hence the database type is not part of the [`NodeTypesWithEngine`] trait and the node's
|
||||||
/// components, that depend on the database, are configured separately. In order to have a nice
|
/// components, that depend on the database, are configured separately. In order to have a nice
|
||||||
/// trait that encapsulates the entire node the
|
/// trait that encapsulates the entire node the
|
||||||
/// [`FullNodeComponents`](reth_node_api::FullNodeComponents) trait was introduced. This
|
/// [`FullNodeComponents`](reth_node_api::FullNodeComponents) trait was introduced. This
|
||||||
@ -208,7 +208,7 @@ where
|
|||||||
/// Configures the types of the node.
|
/// Configures the types of the node.
|
||||||
pub fn with_types<T>(self) -> NodeBuilderWithTypes<RethFullAdapter<DB, T>>
|
pub fn with_types<T>(self) -> NodeBuilderWithTypes<RethFullAdapter<DB, T>>
|
||||||
where
|
where
|
||||||
T: NodeTypes<ChainSpec = ChainSpec>,
|
T: NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||||
{
|
{
|
||||||
self.with_types_and_provider()
|
self.with_types_and_provider()
|
||||||
}
|
}
|
||||||
@ -218,7 +218,7 @@ where
|
|||||||
self,
|
self,
|
||||||
) -> NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>>
|
) -> NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>>
|
||||||
where
|
where
|
||||||
T: NodeTypes<ChainSpec = ChainSpec>,
|
T: NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||||
P: FullProvider<DB, T::ChainSpec>,
|
P: FullProvider<DB, T::ChainSpec>,
|
||||||
{
|
{
|
||||||
NodeBuilderWithTypes::new(self.config, self.database)
|
NodeBuilderWithTypes::new(self.config, self.database)
|
||||||
@ -266,7 +266,7 @@ where
|
|||||||
/// Configures the types of the node.
|
/// Configures the types of the node.
|
||||||
pub fn with_types<T>(self) -> WithLaunchContext<NodeBuilderWithTypes<RethFullAdapter<DB, T>>>
|
pub fn with_types<T>(self) -> WithLaunchContext<NodeBuilderWithTypes<RethFullAdapter<DB, T>>>
|
||||||
where
|
where
|
||||||
T: NodeTypes<ChainSpec = ChainSpec>,
|
T: NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||||
{
|
{
|
||||||
WithLaunchContext { builder: self.builder.with_types(), task_executor: self.task_executor }
|
WithLaunchContext { builder: self.builder.with_types(), task_executor: self.task_executor }
|
||||||
}
|
}
|
||||||
@ -276,7 +276,7 @@ where
|
|||||||
self,
|
self,
|
||||||
) -> WithLaunchContext<NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>>>
|
) -> WithLaunchContext<NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>>>
|
||||||
where
|
where
|
||||||
T: NodeTypes<ChainSpec = ChainSpec>,
|
T: NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||||
P: FullProvider<DB, T::ChainSpec>,
|
P: FullProvider<DB, T::ChainSpec>,
|
||||||
{
|
{
|
||||||
WithLaunchContext {
|
WithLaunchContext {
|
||||||
@ -475,7 +475,7 @@ where
|
|||||||
impl<T, DB, CB, AO> WithLaunchContext<NodeBuilderWithComponents<RethFullAdapter<DB, T>, CB, AO>>
|
impl<T, DB, CB, AO> WithLaunchContext<NodeBuilderWithComponents<RethFullAdapter<DB, T>, CB, AO>>
|
||||||
where
|
where
|
||||||
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
|
||||||
T: NodeTypes<ChainSpec = ChainSpec>,
|
T: NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||||
CB: NodeComponentsBuilder<RethFullAdapter<DB, T>>,
|
CB: NodeComponentsBuilder<RethFullAdapter<DB, T>>,
|
||||||
AO: NodeAddOns<
|
AO: NodeAddOns<
|
||||||
NodeAdapter<RethFullAdapter<DB, T>, CB::Components>,
|
NodeAdapter<RethFullAdapter<DB, T>, CB::Components>,
|
||||||
|
|||||||
@ -8,7 +8,9 @@
|
|||||||
use std::{fmt, future::Future, marker::PhantomData};
|
use std::{fmt, future::Future, marker::PhantomData};
|
||||||
|
|
||||||
use reth_exex::ExExContext;
|
use reth_exex::ExExContext;
|
||||||
use reth_node_api::{FullNodeComponents, FullNodeTypes, NodeAddOns, NodeTypes};
|
use reth_node_api::{
|
||||||
|
FullNodeComponents, FullNodeTypes, NodeAddOns, NodeTypes, NodeTypesWithEngine,
|
||||||
|
};
|
||||||
use reth_node_core::{
|
use reth_node_core::{
|
||||||
node_config::NodeConfig,
|
node_config::NodeConfig,
|
||||||
rpc::eth::{helpers::AddDevSigners, FullEthApiServer},
|
rpc::eth::{helpers::AddDevSigners, FullEthApiServer},
|
||||||
@ -90,10 +92,13 @@ pub struct NodeAdapter<T: FullNodeTypes, C: NodeComponents<T>> {
|
|||||||
|
|
||||||
impl<T: FullNodeTypes, C: NodeComponents<T>> NodeTypes for NodeAdapter<T, C> {
|
impl<T: FullNodeTypes, C: NodeComponents<T>> NodeTypes for NodeAdapter<T, C> {
|
||||||
type Primitives = T::Primitives;
|
type Primitives = T::Primitives;
|
||||||
type Engine = T::Engine;
|
|
||||||
type ChainSpec = T::ChainSpec;
|
type ChainSpec = T::ChainSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: FullNodeTypes, C: NodeComponents<T>> NodeTypesWithEngine for NodeAdapter<T, C> {
|
||||||
|
type Engine = T::Engine;
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeTypes for NodeAdapter<T, C> {
|
impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeTypes for NodeAdapter<T, C> {
|
||||||
type DB = T::DB;
|
type DB = T::DB;
|
||||||
type Provider = T::Provider;
|
type Provider = T::Provider;
|
||||||
|
|||||||
@ -35,7 +35,9 @@ use crate::{ConfigureEvm, FullNodeTypes};
|
|||||||
/// - transaction pool
|
/// - transaction pool
|
||||||
/// - network
|
/// - network
|
||||||
/// - payload builder.
|
/// - payload builder.
|
||||||
pub trait NodeComponents<NodeTypes: FullNodeTypes>: Clone + Unpin + Send + Sync + 'static {
|
pub trait NodeComponents<NodeTypesWithEngine: FullNodeTypes>:
|
||||||
|
Clone + Unpin + Send + Sync + 'static
|
||||||
|
{
|
||||||
/// The transaction pool of the node.
|
/// The transaction pool of the node.
|
||||||
type Pool: TransactionPool + Unpin;
|
type Pool: TransactionPool + Unpin;
|
||||||
|
|
||||||
@ -67,7 +69,7 @@ pub trait NodeComponents<NodeTypes: FullNodeTypes>: Clone + Unpin + Send + Sync
|
|||||||
fn network(&self) -> &Self::Network;
|
fn network(&self) -> &Self::Network;
|
||||||
|
|
||||||
/// Returns the handle to the payload builder service.
|
/// Returns the handle to the payload builder service.
|
||||||
fn payload_builder(&self) -> &PayloadBuilderHandle<NodeTypes::Engine>;
|
fn payload_builder(&self) -> &PayloadBuilderHandle<NodeTypesWithEngine::Engine>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All the components of the node.
|
/// All the components of the node.
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
// re-export the node api types
|
// re-export the node api types
|
||||||
pub use reth_node_api::{FullNodeTypes, NodeTypes};
|
pub use reth_node_api::{FullNodeTypes, NodeTypes, NodeTypesWithEngine};
|
||||||
|
|
||||||
use std::{marker::PhantomData, sync::Arc};
|
use std::{marker::PhantomData, sync::Arc};
|
||||||
|
|
||||||
@ -20,10 +20,10 @@ use crate::{
|
|||||||
NodeAdapter, NodeAddOns,
|
NodeAdapter, NodeAddOns,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A [`crate::Node`] is a [`NodeTypes`] that comes with preconfigured components.
|
/// A [`crate::Node`] is a [`NodeTypesWithEngine`] that comes with preconfigured components.
|
||||||
///
|
///
|
||||||
/// This can be used to configure the builder with a preset of components.
|
/// This can be used to configure the builder with a preset of components.
|
||||||
pub trait Node<N: FullNodeTypes>: NodeTypes + Clone {
|
pub trait Node<N: FullNodeTypes>: NodeTypesWithEngine + Clone {
|
||||||
/// The type that builds the node's components.
|
/// The type that builds the node's components.
|
||||||
type ComponentsBuilder: NodeComponentsBuilder<N>;
|
type ComponentsBuilder: NodeComponentsBuilder<N>;
|
||||||
|
|
||||||
@ -60,11 +60,18 @@ where
|
|||||||
{
|
{
|
||||||
type Primitives = N::Primitives;
|
type Primitives = N::Primitives;
|
||||||
|
|
||||||
type Engine = N::Engine;
|
|
||||||
|
|
||||||
type ChainSpec = N::ChainSpec;
|
type ChainSpec = N::ChainSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<N, C, AO> NodeTypesWithEngine for AnyNode<N, C, AO>
|
||||||
|
where
|
||||||
|
N: FullNodeTypes,
|
||||||
|
C: Send + Sync + Unpin + 'static,
|
||||||
|
AO: Send + Sync + Unpin + Clone + 'static,
|
||||||
|
{
|
||||||
|
type Engine = N::Engine;
|
||||||
|
}
|
||||||
|
|
||||||
impl<N, C, AO> Node<N> for AnyNode<N, C, AO>
|
impl<N, C, AO> Node<N> for AnyNode<N, C, AO>
|
||||||
where
|
where
|
||||||
N: FullNodeTypes + Clone,
|
N: FullNodeTypes + Clone,
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use reth_node_builder::{
|
|||||||
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder,
|
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder,
|
||||||
PayloadServiceBuilder, PoolBuilder,
|
PayloadServiceBuilder, PoolBuilder,
|
||||||
},
|
},
|
||||||
node::{FullNodeTypes, NodeTypes},
|
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
|
||||||
BuilderContext, Node, PayloadBuilderConfig,
|
BuilderContext, Node, PayloadBuilderConfig,
|
||||||
};
|
};
|
||||||
use reth_optimism_consensus::OptimismBeaconConsensus;
|
use reth_optimism_consensus::OptimismBeaconConsensus;
|
||||||
@ -100,10 +100,13 @@ where
|
|||||||
|
|
||||||
impl NodeTypes for OptimismNode {
|
impl NodeTypes for OptimismNode {
|
||||||
type Primitives = ();
|
type Primitives = ();
|
||||||
type Engine = OptimismEngineTypes;
|
|
||||||
type ChainSpec = ChainSpec;
|
type ChainSpec = ChainSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl NodeTypesWithEngine for OptimismNode {
|
||||||
|
type Engine = OptimismEngineTypes;
|
||||||
|
}
|
||||||
|
|
||||||
/// Add-ons w.r.t. optimism.
|
/// Add-ons w.r.t. optimism.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct OptimismAddOns;
|
pub struct OptimismAddOns;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ use reth::{
|
|||||||
api::PayloadTypes,
|
api::PayloadTypes,
|
||||||
builder::{
|
builder::{
|
||||||
components::{ComponentsBuilder, PayloadServiceBuilder},
|
components::{ComponentsBuilder, PayloadServiceBuilder},
|
||||||
node::NodeTypes,
|
node::{NodeTypes, NodeTypesWithEngine},
|
||||||
BuilderContext, FullNodeTypes, Node, NodeBuilder, PayloadBuilderConfig,
|
BuilderContext, FullNodeTypes, Node, NodeBuilder, PayloadBuilderConfig,
|
||||||
},
|
},
|
||||||
primitives::revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg},
|
primitives::revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg},
|
||||||
@ -194,11 +194,14 @@ struct MyCustomNode;
|
|||||||
/// Configure the node types
|
/// Configure the node types
|
||||||
impl NodeTypes for MyCustomNode {
|
impl NodeTypes for MyCustomNode {
|
||||||
type Primitives = ();
|
type Primitives = ();
|
||||||
// use the custom engine types
|
|
||||||
type Engine = CustomEngineTypes;
|
|
||||||
type ChainSpec = ChainSpec;
|
type ChainSpec = ChainSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Configure the node types with the custom engine types
|
||||||
|
impl NodeTypesWithEngine for MyCustomNode {
|
||||||
|
type Engine = CustomEngineTypes;
|
||||||
|
}
|
||||||
|
|
||||||
/// Implement the Node trait for the custom node
|
/// Implement the Node trait for the custom node
|
||||||
///
|
///
|
||||||
/// This provides a preset configuration for the node
|
/// This provides a preset configuration for the node
|
||||||
|
|||||||
Reference in New Issue
Block a user