diff --git a/.github/assets/check_wasm.sh b/.github/assets/check_wasm.sh index ea6c82611..1f441bf3e 100755 --- a/.github/assets/check_wasm.sh +++ b/.github/assets/check_wasm.sh @@ -43,6 +43,7 @@ exclude_crates=( reth-net-nat reth-network reth-node-api + reth-node-types reth-node-builder reth-node-core reth-node-ethereum diff --git a/Cargo.lock b/Cargo.lock index 4b8391935..bfba114e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7493,6 +7493,7 @@ dependencies = [ "reth-engine-primitives", "reth-evm", "reth-network-api", + "reth-node-types", "reth-payload-builder", "reth-payload-primitives", "reth-provider", @@ -7747,6 +7748,15 @@ dependencies = [ "tracing", ] +[[package]] +name = "reth-node-types" +version = "1.0.6" +dependencies = [ + "reth-chainspec", + "reth-db-api", + "reth-engine-primitives", +] + [[package]] name = "reth-optimism-chainspec" version = "1.0.6" @@ -8021,6 +8031,7 @@ dependencies = [ "reth-metrics", "reth-network-p2p", "reth-nippy-jar", + "reth-node-types", "reth-primitives", "reth-prune-types", "reth-stages-types", diff --git a/Cargo.toml b/Cargo.toml index 1d833f973..4d366ec19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,6 +68,7 @@ members = [ "crates/node/core/", "crates/node/events/", "crates/node/metrics", + "crates/node/types", "crates/optimism/bin", "crates/optimism/chainspec", "crates/optimism/cli", @@ -352,6 +353,7 @@ reth-node-ethereum = { path = "crates/ethereum/node" } reth-node-events = { path = "crates/node/events" } reth-node-metrics = { path = "crates/node/metrics" } reth-node-optimism = { path = "crates/optimism/node" } +reth-node-types = { path = "crates/node/types" } op-reth = { path = "crates/optimism/bin" } reth-optimism-chainspec = { path = "crates/optimism/chainspec" } reth-optimism-cli = { path = "crates/optimism/cli" } diff --git a/crates/e2e-test-utils/src/lib.rs b/crates/e2e-test-utils/src/lib.rs index 942f9e869..287114397 100644 --- a/crates/e2e-test-utils/src/lib.rs +++ b/crates/e2e-test-utils/src/lib.rs @@ -15,7 +15,8 @@ use reth_chainspec::ChainSpec; use reth_db::{test_utils::TempDatabase, DatabaseEnv}; use reth_node_builder::{ components::NodeComponentsBuilder, rpc::EthApiBuilderProvider, FullNodeTypesAdapter, Node, - NodeAdapter, NodeAddOns, NodeComponents, NodeTypesWithEngine, RethFullAdapter, + NodeAdapter, NodeAddOns, NodeComponents, NodeTypesWithDBAdapter, NodeTypesWithEngine, + RethFullAdapter, }; use reth_provider::providers::BlockchainProvider; use tracing::{span, Level}; @@ -116,7 +117,8 @@ where // Type aliases type TmpDB = Arc>; -type TmpNodeAdapter = FullNodeTypesAdapter>; +type TmpNodeAdapter = + FullNodeTypesAdapter, BlockchainProvider>; type Adapter = NodeAdapter< RethFullAdapter, diff --git a/crates/e2e-test-utils/src/node.rs b/crates/e2e-test-utils/src/node.rs index f54521983..0eb141bc1 100644 --- a/crates/e2e-test-utils/src/node.rs +++ b/crates/e2e-test-utils/src/node.rs @@ -8,13 +8,13 @@ use reth::{ api::{BuiltPayload, EngineTypes, FullNodeComponents, PayloadBuilderAttributes}, builder::FullNode, network::PeersHandleProvider, - payload::PayloadTypes, providers::{BlockReader, BlockReaderIdExt, CanonStateSubscriptions, StageCheckpointReader}, rpc::{ api::eth::helpers::{EthApiSpec, EthTransactions, TraceExt}, types::engine::PayloadStatusEnum, }, }; +use reth_chainspec::ChainSpec; use reth_node_builder::{EthApiTypes, NodeAddOns, NodeTypesWithEngine}; use reth_primitives::{BlockHash, BlockNumber, Bytes, B256}; use reth_rpc_types::WithOtherFields; @@ -36,18 +36,20 @@ where /// The core structure representing the full node. pub inner: FullNode, /// Context for testing payload-related features. - pub payload: PayloadTestContext, + pub payload: PayloadTestContext<::Engine>, /// Context for testing network functionalities. pub network: NetworkTestContext, /// Context for testing the Engine API. - pub engine_api: EngineApiTestContext, + pub engine_api: EngineApiTestContext<::Engine>, /// Context for testing RPC features. pub rpc: RpcTestContext, } -impl NodeTestContext +impl NodeTestContext where + Engine: EngineTypes, Node: FullNodeComponents, + Node::Types: NodeTypesWithEngine, Node::Network: PeersHandleProvider, AddOns: NodeAddOns, { @@ -62,7 +64,7 @@ where engine_api: EngineApiTestContext { engine_api_client: node.auth_server_handle().http_client(), canonical_stream: node.provider.canonical_state_stream(), - _marker: PhantomData::, + _marker: PhantomData::, }, rpc: RpcTestContext { inner: node.rpc_registry }, }) @@ -82,17 +84,11 @@ where &mut self, length: u64, tx_generator: impl Fn(u64) -> Pin>>, - attributes_generator: impl Fn(u64) -> ::PayloadBuilderAttributes - + Copy, - ) -> eyre::Result< - Vec<( - ::BuiltPayload, - ::PayloadBuilderAttributes, - )>, - > + attributes_generator: impl Fn(u64) -> Engine::PayloadBuilderAttributes + Copy, + ) -> eyre::Result> where - ::ExecutionPayloadV3: - From<::BuiltPayload> + PayloadEnvelopeExt, + ::ExecutionPayloadV3: + From + PayloadEnvelopeExt, AddOns::EthApi: EthApiSpec + EthTransactions + TraceExt, ::NetworkTypes: Network>, @@ -116,14 +112,11 @@ where /// It triggers the resolve payload via engine api and expects the built payload event. pub async fn new_payload( &mut self, - attributes_generator: impl Fn(u64) -> ::PayloadBuilderAttributes, - ) -> eyre::Result<( - <::Engine as PayloadTypes>::BuiltPayload, - <::Engine as PayloadTypes>::PayloadBuilderAttributes, - )> + attributes_generator: impl Fn(u64) -> Engine::PayloadBuilderAttributes, + ) -> eyre::Result<(Engine::BuiltPayload, Engine::PayloadBuilderAttributes)> where - ::ExecutionPayloadV3: - From<::BuiltPayload> + PayloadEnvelopeExt, + ::ExecutionPayloadV3: + From + PayloadEnvelopeExt, { // trigger new payload building draining the pool let eth_attr = self.payload.new_payload(attributes_generator).await.unwrap(); @@ -141,14 +134,11 @@ where pub async fn advance_block( &mut self, versioned_hashes: Vec, - attributes_generator: impl Fn(u64) -> ::PayloadBuilderAttributes, - ) -> eyre::Result<( - ::BuiltPayload, - <::Engine as PayloadTypes>::PayloadBuilderAttributes, - )> + attributes_generator: impl Fn(u64) -> Engine::PayloadBuilderAttributes, + ) -> eyre::Result<(Engine::BuiltPayload, Engine::PayloadBuilderAttributes)> where - ::ExecutionPayloadV3: - From<::BuiltPayload> + PayloadEnvelopeExt, + ::ExecutionPayloadV3: + From + PayloadEnvelopeExt, { let (payload, eth_attr) = self.new_payload(attributes_generator).await?; diff --git a/crates/e2e-test-utils/src/rpc.rs b/crates/e2e-test-utils/src/rpc.rs index a7d548a93..a7d3030f1 100644 --- a/crates/e2e-test-utils/src/rpc.rs +++ b/crates/e2e-test-utils/src/rpc.rs @@ -7,7 +7,8 @@ use reth::{ DebugApiServer, }, }; -use reth_node_builder::EthApiTypes; +use reth_chainspec::ChainSpec; +use reth_node_builder::{EthApiTypes, NodeTypes}; use reth_primitives::{Bytes, B256}; use reth_rpc_types::WithOtherFields; @@ -18,7 +19,7 @@ pub struct RpcTestContext { impl RpcTestContext where - Node: FullNodeComponents, + Node: FullNodeComponents>, EthApi: EthApiSpec + EthTransactions< NetworkTypes: Network< diff --git a/crates/ethereum/node/src/node.rs b/crates/ethereum/node/src/node.rs index 24628019b..5e902a93a 100644 --- a/crates/ethereum/node/src/node.rs +++ b/crates/ethereum/node/src/node.rs @@ -47,8 +47,8 @@ impl EthereumNode { EthereumConsensusBuilder, > where - Node: FullNodeTypes, - ::Engine: PayloadTypes< + Node: FullNodeTypes>, + ::Engine: PayloadTypes< BuiltPayload = EthBuiltPayload, PayloadAttributes = EthPayloadAttributes, PayloadBuilderAttributes = EthPayloadBuilderAttributes, @@ -81,9 +81,10 @@ impl NodeAddOns for EthereumAddOns { type EthApi = EthApi; } -impl Node for EthereumNode +impl Node for EthereumNode where - N: FullNodeTypes, + Types: NodeTypesWithEngine, + N: FullNodeTypes, { type ComponentsBuilder = ComponentsBuilder< N, @@ -106,9 +107,10 @@ where #[non_exhaustive] pub struct EthereumExecutorBuilder; -impl ExecutorBuilder for EthereumExecutorBuilder +impl ExecutorBuilder for EthereumExecutorBuilder where - Node: FullNodeTypes, + Types: NodeTypesWithEngine, + Node: FullNodeTypes, { type EVM = EthEvmConfig; type Executor = EthExecutorProvider; @@ -135,9 +137,10 @@ pub struct EthereumPoolBuilder { // TODO add options for txpool args } -impl PoolBuilder for EthereumPoolBuilder +impl PoolBuilder for EthereumPoolBuilder where - Node: FullNodeTypes, + Types: NodeTypesWithEngine, + Node: FullNodeTypes, { type Pool = EthTransactionPool; @@ -213,12 +216,13 @@ impl EthereumPayloadBuilder { } } -impl PayloadServiceBuilder for EthereumPayloadBuilder +impl PayloadServiceBuilder for EthereumPayloadBuilder where - Node: FullNodeTypes, + Types: NodeTypesWithEngine, + Node: FullNodeTypes, Evm: ConfigureEvm, Pool: TransactionPool + Unpin + 'static, - ::Engine: PayloadTypes< + Types::Engine: PayloadTypes< BuiltPayload = EthBuiltPayload, PayloadAttributes = EthPayloadAttributes, PayloadBuilderAttributes = EthPayloadBuilderAttributes, @@ -228,7 +232,7 @@ where self, ctx: &BuilderContext, pool: Pool, - ) -> eyre::Result> { + ) -> eyre::Result> { let payload_builder = reth_ethereum_payload_builder::EthereumPayloadBuilder::new(self.evm_config); let conf = ctx.payload_builder_config(); @@ -287,7 +291,7 @@ pub struct EthereumConsensusBuilder { impl ConsensusBuilder for EthereumConsensusBuilder where - Node: FullNodeTypes, + Node: FullNodeTypes>, { type Consensus = Arc; diff --git a/crates/exex/exex/src/context.rs b/crates/exex/exex/src/context.rs index c159b90bd..90fbe0d56 100644 --- a/crates/exex/exex/src/context.rs +++ b/crates/exex/exex/src/context.rs @@ -1,6 +1,6 @@ use std::fmt::Debug; -use reth_node_api::FullNodeComponents; +use reth_node_api::{FullNodeComponents, NodeTypesWithEngine}; use reth_node_core::node_config::NodeConfig; use reth_primitives::Head; use reth_tasks::TaskExecutor; @@ -76,7 +76,10 @@ impl ExExContext { } /// Returns the handle to the payload builder service. - pub fn payload_builder(&self) -> &reth_payload_builder::PayloadBuilderHandle { + pub fn payload_builder( + &self, + ) -> &reth_payload_builder::PayloadBuilderHandle<::Engine> + { self.components.payload_builder() } diff --git a/crates/exex/test-utils/src/lib.rs b/crates/exex/test-utils/src/lib.rs index c470cd1d9..47e2f9be2 100644 --- a/crates/exex/test-utils/src/lib.rs +++ b/crates/exex/test-utils/src/lib.rs @@ -18,7 +18,9 @@ use reth_evm::test_utils::MockExecutorProvider; use reth_execution_types::Chain; use reth_exex::{ExExContext, ExExEvent, ExExNotification}; use reth_network::{config::SecretKey, NetworkConfigBuilder, NetworkManager}; -use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeTypes, NodeTypesWithEngine}; +use reth_node_api::{ + FullNodeTypes, FullNodeTypesAdapter, NodeTypes, NodeTypesWithDBAdapter, NodeTypesWithEngine, +}; use reth_node_builder::{ components::{ Components, ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NodeComponentsBuilder, @@ -119,7 +121,7 @@ impl NodeTypesWithEngine for TestNode { impl Node for TestNode where - N: FullNodeTypes, + N: FullNodeTypes>, { type ComponentsBuilder = ComponentsBuilder< N, @@ -148,9 +150,9 @@ pub type TmpDB = Arc>; /// boot the testing environment pub type Adapter = NodeAdapter< RethFullAdapter, - <>>>::ComponentsBuilder as NodeComponentsBuilder< - RethFullAdapter, - >>::Components, + <, BlockchainProvider>, + >>::ComponentsBuilder as NodeComponentsBuilder>>::Components, >; /// An [`ExExContext`] using the [`Adapter`] type. pub type TestExExContext = ExExContext; @@ -251,7 +253,7 @@ pub async fn test_exex_context_with_chain_spec( let tasks = TaskManager::current(); let task_executor = tasks.executor(); - let components = NodeAdapter::, _> { + let components = NodeAdapter::, _>, _> { components: Components { transaction_pool, evm_config, diff --git a/crates/node/api/Cargo.toml b/crates/node/api/Cargo.toml index e9f297fc4..eaba88fee 100644 --- a/crates/node/api/Cargo.toml +++ b/crates/node/api/Cargo.toml @@ -23,3 +23,4 @@ reth-payload-primitives.workspace = true reth-tasks.workspace = true reth-rpc-eth-api.workspace = true reth-network-api.workspace = true +reth-node-types.workspace = true diff --git a/crates/node/api/src/lib.rs b/crates/node/api/src/lib.rs index 8748fc79d..fc925e1fa 100644 --- a/crates/node/api/src/lib.rs +++ b/crates/node/api/src/lib.rs @@ -19,12 +19,11 @@ pub use reth_payload_primitives::*; /// Traits and helper types used to abstract over EVM methods and types. pub use reth_evm::{ConfigureEvm, ConfigureEvmEnv}; -pub mod primitives; - pub mod node; pub use node::*; // re-export for convenience +pub use reth_node_types::*; pub use reth_provider::FullProvider; pub use reth_rpc_eth_api::EthApiTypes; diff --git a/crates/node/api/src/node.rs b/crates/node/api/src/node.rs index 275cdc5a1..227a170d3 100644 --- a/crates/node/api/src/node.rs +++ b/crates/node/api/src/node.rs @@ -2,38 +2,21 @@ use std::marker::PhantomData; -use reth_chainspec::{ChainSpec, EthChainSpec}; +use reth_chainspec::EthChainSpec; use reth_db_api::{ database::Database, database_metrics::{DatabaseMetadata, DatabaseMetrics}, }; use reth_evm::execute::BlockExecutorProvider; use reth_network_api::FullNetwork; +use reth_node_types::{NodePrimitives, NodeTypes, NodeTypesWithDB, NodeTypesWithEngine}; use reth_payload_builder::PayloadBuilderHandle; use reth_provider::FullProvider; use reth_rpc_eth_api::EthApiTypes; use reth_tasks::TaskExecutor; use reth_transaction_pool::TransactionPool; -use crate::{primitives::NodePrimitives, ConfigureEvm, EngineTypes}; - -/// The type that configures the essential types of an Ethereum-like node. -/// -/// This includes the primitive types of a node. -/// -/// This trait is intended to be stateless and only define the types of the node. -pub trait NodeTypes: Send + Sync + Unpin + 'static { - /// The node's primitive types, defining basic operations and structures. - type Primitives: NodePrimitives; - /// The type used for configuration of the EVM. - type ChainSpec: EthChainSpec; -} - -/// The type that configures an Ethereum-like node with an engine for consensus. -pub trait NodeTypesWithEngine: NodeTypes { - /// The node's engine types, defining the interaction with the consensus engine. - type Engine: EngineTypes; -} +use crate::{ConfigureEvm, EngineTypes}; /// A [`NodeTypes`] type builder. #[derive(Default, Debug)] @@ -109,69 +92,79 @@ where /// components to the node. /// /// Its types are configured by node internally and are not intended to be user configurable. -pub trait FullNodeTypes: NodeTypesWithEngine + 'static { - /// Underlying database type used by the node to store and retrieve data. - type DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static; +pub trait FullNodeTypes: Send + Sync + Unpin + 'static { + /// Node's types with the database. + type Types: NodeTypesWithDB; /// The provider type used to interact with the node. - type Provider: FullProvider; + type Provider: FullProvider; } -/// An adapter type that adds the builtin provider type to the user configured node types. +/// An adapter type combining [`NodeTypes`] and db into [`NodeTypesWithDB`]. #[derive(Debug)] -pub struct FullNodeTypesAdapter { - /// An instance of the user configured node types. - pub types: PhantomData, - /// The database type used by the node. - pub db: PhantomData, - /// The provider type used by the node. - pub provider: PhantomData, +pub struct NodeTypesWithDBAdapter { + types: PhantomData, + db: PhantomData, } -impl FullNodeTypesAdapter { +impl NodeTypesWithDBAdapter { /// Create a new adapter with the configured types. pub fn new() -> Self { - Self { types: Default::default(), db: Default::default(), provider: Default::default() } + Self { types: Default::default(), db: Default::default() } } } -impl Default for FullNodeTypesAdapter { +impl Default for NodeTypesWithDBAdapter { fn default() -> Self { Self::new() } } -impl Clone for FullNodeTypesAdapter { +impl Clone for NodeTypesWithDBAdapter { fn clone(&self) -> Self { - Self { types: self.types, db: self.db, provider: self.provider } + Self { types: self.types, db: self.db } } } -impl NodeTypes for FullNodeTypesAdapter +impl NodeTypes for NodeTypesWithDBAdapter where - Types: NodeTypesWithEngine, + Types: NodeTypes, DB: Send + Sync + Unpin + 'static, - Provider: Send + Sync + Unpin + 'static, { type Primitives = Types::Primitives; type ChainSpec = Types::ChainSpec; } -impl NodeTypesWithEngine for FullNodeTypesAdapter +impl NodeTypesWithEngine for NodeTypesWithDBAdapter where Types: NodeTypesWithEngine, DB: Send + Sync + Unpin + 'static, - Provider: Send + Sync + Unpin + 'static, { type Engine = Types::Engine; } -impl FullNodeTypes for FullNodeTypesAdapter +impl NodeTypesWithDB for NodeTypesWithDBAdapter where - Types: NodeTypesWithEngine, - Provider: FullProvider, + Types: NodeTypesWithEngine, DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static, { type DB = DB; +} + +/// An adapter type that adds the builtin provider type to the user configured node types. +#[derive(Debug)] +pub struct FullNodeTypesAdapter { + /// An instance of the user configured node types. + pub types: PhantomData, + /// The provider type used by the node. + pub provider: PhantomData, +} + +impl FullNodeTypes for FullNodeTypesAdapter +where + Types: NodeTypesWithDB, + Provider: FullProvider, +{ + type Types = Types; type Provider = Provider; } @@ -205,7 +198,9 @@ pub trait FullNodeComponents: FullNodeTypes + Clone + 'static { fn network(&self) -> &Self::Network; /// Returns the handle to the payload builder service. - fn payload_builder(&self) -> &PayloadBuilderHandle; + fn payload_builder( + &self, + ) -> &PayloadBuilderHandle<::Engine>; /// Returns handle to runtime. fn task_executor(&self) -> &TaskExecutor; diff --git a/crates/node/api/src/primitives.rs b/crates/node/api/src/primitives.rs deleted file mode 100644 index 235be5ff7..000000000 --- a/crates/node/api/src/primitives.rs +++ /dev/null @@ -1,8 +0,0 @@ -//! Type abstraction for node primitive types. - -/// Configures all the primitive types of the node. -// TODO(mattsse): this is currently a placeholder -pub trait NodePrimitives {} - -// TODO(mattsse): Placeholder -impl NodePrimitives for () {} diff --git a/crates/node/builder/src/builder/mod.rs b/crates/node/builder/src/builder/mod.rs index 7f6338ead..f799d2b68 100644 --- a/crates/node/builder/src/builder/mod.rs +++ b/crates/node/builder/src/builder/mod.rs @@ -21,7 +21,10 @@ use reth_exex::ExExContext; use reth_network::{ NetworkBuilder, NetworkConfig, NetworkConfigBuilder, NetworkHandle, NetworkManager, }; -use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeAddOns, NodeTypesWithEngine}; +use reth_node_api::{ + FullNodeTypes, FullNodeTypesAdapter, NodeAddOns, NodeTypes, NodeTypesWithDBAdapter, + NodeTypesWithEngine, +}; use reth_node_core::{ cli::config::{PayloadBuilderConfig, RethTransactionPoolConfig}, dirs::{ChainPath, DataDirPath}, @@ -46,7 +49,8 @@ use crate::{ /// The adapter type for a reth node with the builtin provider type // Note: we need to hardcode this because custom components might depend on it in associated types. -pub type RethFullAdapter = FullNodeTypesAdapter>; +pub type RethFullAdapter = + FullNodeTypesAdapter, BlockchainProvider>; #[allow(clippy::doc_markdown)] #[cfg_attr(doc, aquamarine::aquamarine)] @@ -216,10 +220,10 @@ where /// Configures the types of the node and the provider type that will be used by the node. pub fn with_types_and_provider( self, - ) -> NodeBuilderWithTypes> + ) -> NodeBuilderWithTypes, P>> where T: NodeTypesWithEngine, - P: FullProvider, + P: FullProvider>, { NodeBuilderWithTypes::new(self.config, self.database) } @@ -274,10 +278,12 @@ where /// Configures the types of the node and the provider type that will be used by the node. pub fn with_types_and_provider( self, - ) -> WithLaunchContext>> + ) -> WithLaunchContext< + NodeBuilderWithTypes, P>>, + > where T: NodeTypesWithEngine, - P: FullProvider, + P: FullProvider>, { WithLaunchContext { builder: self.builder.with_types_and_provider(), @@ -549,7 +555,7 @@ impl BuilderContext { } /// Returns the chain spec of the node. - pub fn chain_spec(&self) -> Arc { + pub fn chain_spec(&self) -> Arc<::ChainSpec> { self.provider().chain_spec() } diff --git a/crates/node/builder/src/builder/states.rs b/crates/node/builder/src/builder/states.rs index e31ea363f..b5c99d082 100644 --- a/crates/node/builder/src/builder/states.rs +++ b/crates/node/builder/src/builder/states.rs @@ -9,7 +9,7 @@ use std::{fmt, future::Future, marker::PhantomData}; use reth_exex::ExExContext; use reth_node_api::{ - FullNodeComponents, FullNodeTypes, NodeAddOns, NodeTypes, NodeTypesWithEngine, + FullNodeComponents, FullNodeTypes, NodeAddOns, NodeTypesWithDB, NodeTypesWithEngine, }; use reth_node_core::{ node_config::NodeConfig, @@ -36,7 +36,7 @@ pub struct NodeBuilderWithTypes { impl NodeBuilderWithTypes { /// Creates a new instance of the node builder with the given configuration and types. - pub const fn new(config: NodeConfig, database: T::DB) -> Self { + pub const fn new(config: NodeConfig, database: ::DB) -> Self { Self { config, adapter: NodeTypesAdapter::new(database) } } @@ -63,12 +63,12 @@ impl NodeBuilderWithTypes { /// Container for the node's types and the database the node uses. pub struct NodeTypesAdapter { /// The database type used by the node. - pub database: T::DB, + pub database: ::DB, } impl NodeTypesAdapter { /// Create a new adapter from the given node types. - pub(crate) const fn new(database: T::DB) -> Self { + pub(crate) const fn new(database: ::DB) -> Self { Self { database } } } @@ -90,17 +90,8 @@ pub struct NodeAdapter> { pub provider: T::Provider, } -impl> NodeTypes for NodeAdapter { - type Primitives = T::Primitives; - type ChainSpec = T::ChainSpec; -} - -impl> NodeTypesWithEngine for NodeAdapter { - type Engine = T::Engine; -} - impl> FullNodeTypes for NodeAdapter { - type DB = T::DB; + type Types = T::Types; type Provider = T::Provider; } @@ -130,7 +121,7 @@ impl> FullNodeComponents for NodeAdapter< self.components.network() } - fn payload_builder(&self) -> &PayloadBuilderHandle { + fn payload_builder(&self) -> &PayloadBuilderHandle<::Engine> { self.components.payload_builder() } diff --git a/crates/node/builder/src/components/mod.rs b/crates/node/builder/src/components/mod.rs index 0d2af5b97..b268b43a1 100644 --- a/crates/node/builder/src/components/mod.rs +++ b/crates/node/builder/src/components/mod.rs @@ -25,6 +25,7 @@ use reth_consensus::Consensus; use reth_evm::execute::BlockExecutorProvider; use reth_network::NetworkHandle; use reth_network_api::FullNetwork; +use reth_node_api::NodeTypesWithEngine; use reth_payload_builder::PayloadBuilderHandle; use reth_transaction_pool::TransactionPool; @@ -35,9 +36,7 @@ use crate::{ConfigureEvm, FullNodeTypes}; /// - transaction pool /// - network /// - payload builder. -pub trait NodeComponents: - Clone + Unpin + Send + Sync + 'static -{ +pub trait NodeComponents: Clone + Unpin + Send + Sync + 'static { /// The transaction pool of the node. type Pool: TransactionPool + Unpin; @@ -69,7 +68,7 @@ pub trait NodeComponents: fn network(&self) -> &Self::Network; /// Returns the handle to the payload builder service. - fn payload_builder(&self) -> &PayloadBuilderHandle; + fn payload_builder(&self) -> &PayloadBuilderHandle<::Engine>; } /// All the components of the node. @@ -88,7 +87,7 @@ pub struct Components { /// The network implementation of the node. pub network: NetworkHandle, /// The handle to the payload builder service. - pub payload_builder: PayloadBuilderHandle, + pub payload_builder: PayloadBuilderHandle<::Engine>, } impl NodeComponents @@ -126,7 +125,9 @@ where &self.network } - fn payload_builder(&self) -> &PayloadBuilderHandle { + fn payload_builder( + &self, + ) -> &PayloadBuilderHandle<::Engine> { &self.payload_builder } } diff --git a/crates/node/builder/src/components/payload.rs b/crates/node/builder/src/components/payload.rs index 55c7669ef..0efad9ba5 100644 --- a/crates/node/builder/src/components/payload.rs +++ b/crates/node/builder/src/components/payload.rs @@ -2,6 +2,7 @@ use std::future::Future; +use reth_node_api::NodeTypesWithEngine; use reth_payload_builder::PayloadBuilderHandle; use reth_transaction_pool::TransactionPool; @@ -16,7 +17,9 @@ pub trait PayloadServiceBuilder: Sen self, ctx: &BuilderContext, pool: Pool, - ) -> impl Future>> + Send; + ) -> impl Future< + Output = eyre::Result::Engine>>, + > + Send; } impl PayloadServiceBuilder for F @@ -24,13 +27,19 @@ where Node: FullNodeTypes, Pool: TransactionPool, F: Fn(&BuilderContext, Pool) -> Fut + Send, - Fut: Future>> + Send, + Fut: Future< + Output = eyre::Result< + PayloadBuilderHandle<::Engine>, + >, + > + Send, { fn spawn_payload_service( self, ctx: &BuilderContext, pool: Pool, - ) -> impl Future>> + Send { + ) -> impl Future< + Output = eyre::Result::Engine>>, + > + Send { self(ctx, pool) } } diff --git a/crates/node/builder/src/launch/common.rs b/crates/node/builder/src/launch/common.rs index d0ab6929f..eeb6fc4a4 100644 --- a/crates/node/builder/src/launch/common.rs +++ b/crates/node/builder/src/launch/common.rs @@ -35,7 +35,7 @@ use reth_node_metrics::{ use reth_primitives::{BlockNumber, Head, B256}; use reth_provider::{ providers::{BlockchainProvider, BlockchainProvider2, StaticFileProvider}, - BlockHashReader, CanonStateNotificationSender, FullProvider, ProviderFactory, ProviderResult, + BlockHashReader, CanonStateNotificationSender, ProviderFactory, ProviderResult, StageCheckpointReader, StaticFileProviderFactory, TreeViewer, }; use reth_prune::{PruneModes, PrunerBuilder}; @@ -570,7 +570,6 @@ where ) -> eyre::Result>>> where T: FullNodeTypes, - T::Provider: FullProvider, F: FnOnce(ProviderFactory) -> eyre::Result, { let blockchain_db = create_blockchain_provider(self.provider_factory().clone())?; @@ -599,7 +598,7 @@ where impl LaunchContextWith>> where DB: Database + DatabaseMetrics + Send + Sync + Clone + 'static, - T: FullNodeTypes + WithTree>, + T: FullNodeTypes, { /// Returns access to the underlying database. pub fn database(&self) -> &DB { @@ -718,7 +717,7 @@ where impl LaunchContextWith>> where DB: Database + DatabaseMetrics + Send + Sync + Clone + 'static, - T: FullNodeTypes + WithTree>, + T: FullNodeTypes, CB: NodeComponentsBuilder, { /// Returns the configured `ProviderFactory`. @@ -941,7 +940,7 @@ pub struct WithMeteredProvider { pub struct WithMeteredProviders where DB: Database, - T: FullNodeTypes>, + T: FullNodeTypes, { db_provider_container: WithMeteredProvider, blockchain_db: T::Provider, @@ -957,7 +956,7 @@ where pub struct WithComponents where DB: Database, - T: FullNodeTypes>, + T: FullNodeTypes, CB: NodeComponentsBuilder, { db_provider_container: WithMeteredProvider, diff --git a/crates/node/builder/src/launch/engine.rs b/crates/node/builder/src/launch/engine.rs index e4ed58d2c..f56c31cff 100644 --- a/crates/node/builder/src/launch/engine.rs +++ b/crates/node/builder/src/launch/engine.rs @@ -16,7 +16,7 @@ use reth_engine_util::EngineMessageStreamExt; use reth_exex::ExExManagerHandle; use reth_network::{NetworkSyncUpdater, SyncState}; use reth_network_api::{BlockDownloaderProvider, NetworkEventListenerProvider}; -use reth_node_api::{BuiltPayload, FullNodeTypes, NodeAddOns}; +use reth_node_api::{BuiltPayload, FullNodeTypes, NodeAddOns, NodeTypesWithDB}; use reth_node_core::{ dirs::{ChainPath, DataDirPath}, exit::NodeExitFuture, @@ -56,12 +56,10 @@ impl EngineNodeLauncher { } } -impl LaunchNode> for EngineNodeLauncher +impl LaunchNode> for EngineNodeLauncher where - T: FullNodeTypes< - Provider = BlockchainProvider2<::DB>, - ChainSpec = ChainSpec, - >, + Types: NodeTypesWithDB, + T: FullNodeTypes>, CB: NodeComponentsBuilder, AO: NodeAddOns< NodeAdapter, diff --git a/crates/node/builder/src/launch/mod.rs b/crates/node/builder/src/launch/mod.rs index 89a40a1a5..b74e6debd 100644 --- a/crates/node/builder/src/launch/mod.rs +++ b/crates/node/builder/src/launch/mod.rs @@ -21,7 +21,7 @@ use reth_consensus_debug_client::{DebugConsensusClient, EtherscanBlockProvider, use reth_engine_util::EngineMessageStreamExt; use reth_exex::ExExManagerHandle; use reth_network::{BlockDownloaderProvider, NetworkEventListenerProvider}; -use reth_node_api::{FullNodeComponents, FullNodeTypes, NodeAddOns}; +use reth_node_api::{FullNodeComponents, FullNodeTypes, NodeAddOns, NodeTypesWithDB}; use reth_node_core::{ dirs::{ChainPath, DataDirPath}, exit::NodeExitFuture, @@ -100,12 +100,10 @@ impl DefaultNodeLauncher { } } -impl LaunchNode> for DefaultNodeLauncher +impl LaunchNode> for DefaultNodeLauncher where - T: FullNodeTypes< - Provider = BlockchainProvider<::DB>, - ChainSpec = ChainSpec, - >, + Types: NodeTypesWithDB, + T: FullNodeTypes, Types = Types>, CB: NodeComponentsBuilder, AO: NodeAddOns< NodeAdapter, @@ -409,7 +407,7 @@ where Arc::new(block_provider), ); ctx.task_executor().spawn_critical("etherscan consensus client", async move { - rpc_consensus_client.run::().await + rpc_consensus_client.run::().await }); } @@ -422,7 +420,7 @@ where Arc::new(block_provider), ); ctx.task_executor().spawn_critical("rpc consensus client", async move { - rpc_consensus_client.run::().await + rpc_consensus_client.run::().await }); } diff --git a/crates/node/builder/src/node.rs b/crates/node/builder/src/node.rs index c27b85d41..912046643 100644 --- a/crates/node/builder/src/node.rs +++ b/crates/node/builder/src/node.rs @@ -3,7 +3,7 @@ pub use reth_node_api::{FullNodeTypes, NodeTypes, NodeTypesWithEngine}; use std::{marker::PhantomData, sync::Arc}; -use reth_node_api::FullNodeComponents; +use reth_node_api::{EngineTypes, FullNodeComponents}; use reth_node_core::{ dirs::{ChainPath, DataDirPath}, node_config::NodeConfig, @@ -58,9 +58,9 @@ where C: Send + Sync + Unpin + 'static, AO: Send + Sync + Unpin + Clone + 'static, { - type Primitives = N::Primitives; + type Primitives = ::Primitives; - type ChainSpec = N::ChainSpec; + type ChainSpec = ::ChainSpec; } impl NodeTypesWithEngine for AnyNode @@ -69,7 +69,7 @@ where C: Send + Sync + Unpin + 'static, AO: Send + Sync + Unpin + Clone + 'static, { - type Engine = N::Engine; + type Engine = ::Engine; } impl Node for AnyNode @@ -89,7 +89,7 @@ where /// The launched node with all components including RPC handlers. /// /// This can be used to interact with the launched node. -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct FullNode> { /// The evm configuration. pub evm_config: Node::Evm, @@ -102,7 +102,7 @@ pub struct FullNode> { /// Provider to interact with the node's database pub provider: Node::Provider, /// Handle to the node's payload builder service. - pub payload_builder: PayloadBuilderHandle, + pub payload_builder: PayloadBuilderHandle<::Engine>, /// Task executor for the node. pub task_executor: TaskExecutor, /// Handles to the node's rpc servers @@ -115,13 +115,32 @@ pub struct FullNode> { pub data_dir: ChainPath, } -impl FullNode +impl> Clone for FullNode { + fn clone(&self) -> Self { + Self { + evm_config: self.evm_config.clone(), + block_executor: self.block_executor.clone(), + pool: self.pool.clone(), + network: self.network.clone(), + provider: self.provider.clone(), + payload_builder: self.payload_builder.clone(), + task_executor: self.task_executor.clone(), + rpc_server_handles: self.rpc_server_handles.clone(), + rpc_registry: self.rpc_registry.clone(), + config: self.config.clone(), + data_dir: self.data_dir.clone(), + } + } +} + +impl FullNode where - Node: FullNodeComponents, + Engine: EngineTypes, + Node: FullNodeComponents>, AddOns: NodeAddOns, { /// Returns the chain spec of the node. - pub fn chain_spec(&self) -> Arc { + pub fn chain_spec(&self) -> Arc<::ChainSpec> { self.provider.chain_spec() } @@ -138,14 +157,14 @@ where /// Returns the [`EngineApiClient`] interface for the authenticated engine API. /// /// This will send authenticated http requests to the node's auth server. - pub fn engine_http_client(&self) -> impl EngineApiClient { + pub fn engine_http_client(&self) -> impl EngineApiClient { self.auth_server_handle().http_client() } /// Returns the [`EngineApiClient`] interface for the authenticated engine API. /// /// This will send authenticated ws requests to the node's auth server. - pub async fn engine_ws_client(&self) -> impl EngineApiClient { + pub async fn engine_ws_client(&self) -> impl EngineApiClient { self.auth_server_handle().ws_client().await } @@ -153,7 +172,7 @@ where /// /// This will send not authenticated IPC requests to the node's auth server. #[cfg(unix)] - pub async fn engine_ipc_client(&self) -> Option> { + pub async fn engine_ipc_client(&self) -> Option> { self.auth_server_handle().ipc_client().await } } diff --git a/crates/node/builder/src/rpc.rs b/crates/node/builder/src/rpc.rs index 141bca1f9..d51eaa5b0 100644 --- a/crates/node/builder/src/rpc.rs +++ b/crates/node/builder/src/rpc.rs @@ -6,7 +6,8 @@ use std::{ }; use futures::TryFutureExt; -use reth_node_api::{BuilderProvider, FullNodeComponents}; +use reth_chainspec::ChainSpec; +use reth_node_api::{BuilderProvider, FullNodeComponents, NodeTypesWithDB, NodeTypesWithEngine}; use reth_node_core::{ node_config::NodeConfig, rpc::{ @@ -283,7 +284,9 @@ where } /// Returns the handle to the payload builder service - pub fn payload_builder(&self) -> &PayloadBuilderHandle { + pub fn payload_builder( + &self, + ) -> &PayloadBuilderHandle<::Engine> { self.node.payload_builder() } } @@ -297,8 +300,8 @@ pub async fn launch_rpc_servers( add_ons: RpcAddOns, ) -> eyre::Result<(RethRpcServerHandles, RpcRegistry)> where - Node: FullNodeComponents + Clone, - Engine: EngineApiServer, + Node: FullNodeComponents> + Clone, + Engine: EngineApiServer<::Engine>, EthApi: EthApiBuilderProvider + FullEthApiServer< NetworkTypes: alloy_network::Network< diff --git a/crates/node/types/Cargo.toml b/crates/node/types/Cargo.toml new file mode 100644 index 000000000..f04925d9c --- /dev/null +++ b/crates/node/types/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "reth-node-types" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[lints] +workspace = true + +[dependencies] +# reth +reth-chainspec.workspace = true +reth-db-api.workspace = true +reth-engine-primitives.workspace = true \ No newline at end of file diff --git a/crates/node/types/src/lib.rs b/crates/node/types/src/lib.rs new file mode 100644 index 000000000..a53a240a8 --- /dev/null +++ b/crates/node/types/src/lib.rs @@ -0,0 +1,50 @@ +//! Standalone crate for Reth configuration traits and builder types. + +#![doc( + html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png", + html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256", + issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/" +)] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] + +use reth_chainspec::EthChainSpec; +use reth_db_api::{ + database_metrics::{DatabaseMetadata, DatabaseMetrics}, + Database, +}; +use reth_engine_primitives::EngineTypes; + +/// Configures all the primitive types of the node. +// TODO(mattsse): this is currently a placeholder +pub trait NodePrimitives {} + +// TODO(mattsse): Placeholder +impl NodePrimitives for () {} + +/// The type that configures the essential types of an Ethereum-like node. +/// +/// This includes the primitive types of a node and chain specification. +/// +/// This trait is intended to be stateless and only define the types of the node. +pub trait NodeTypes: Send + Sync + Unpin + 'static { + /// The node's primitive types, defining basic operations and structures. + type Primitives: NodePrimitives; + /// The type used for configuration of the EVM. + type ChainSpec: EthChainSpec; +} + +/// The type that configures an Ethereum-like node with an engine for consensus. +pub trait NodeTypesWithEngine: NodeTypes { + /// The node's engine types, defining the interaction with the consensus engine. + type Engine: EngineTypes; +} + +/// A helper trait that is downstream of the [`NodeTypesWithEngine`] trait and adds database to the +/// node. +/// +/// Its types are configured by node internally and are not intended to be user configurable. +pub trait NodeTypesWithDB: NodeTypesWithEngine { + /// Underlying database type used by the node to store and retrieve data. + type DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static; +} diff --git a/crates/optimism/node/src/node.rs b/crates/optimism/node/src/node.rs index 377038472..74549b315 100644 --- a/crates/optimism/node/src/node.rs +++ b/crates/optimism/node/src/node.rs @@ -58,7 +58,9 @@ impl OptimismNode { OptimismConsensusBuilder, > where - Node: FullNodeTypes, + Node: FullNodeTypes< + Types: NodeTypesWithEngine, + >, { let RollupArgs { disable_txpool_gossip, compute_pending_block, discovery_v4, .. } = args; ComponentsBuilder::default() @@ -79,7 +81,9 @@ impl OptimismNode { impl Node for OptimismNode where - N: FullNodeTypes, + N: FullNodeTypes< + Types: NodeTypesWithEngine, + >, { type ComponentsBuilder = ComponentsBuilder< N, @@ -122,7 +126,7 @@ pub struct OptimismExecutorBuilder; impl ExecutorBuilder for OptimismExecutorBuilder where - Node: FullNodeTypes, + Node: FullNodeTypes>, { type EVM = OptimismEvmConfig; type Executor = OpExecutorProvider; @@ -149,7 +153,7 @@ pub struct OptimismPoolBuilder; impl PoolBuilder for OptimismPoolBuilder where - Node: FullNodeTypes, + Node: FullNodeTypes>, { type Pool = OpTransactionPool; @@ -244,7 +248,9 @@ impl OptimismPayloadBuilder { impl PayloadServiceBuilder for OptimismPayloadBuilder where - Node: FullNodeTypes, + Node: FullNodeTypes< + Types: NodeTypesWithEngine, + >, Pool: TransactionPool + Unpin + 'static, EVM: ConfigureEvm, { @@ -252,7 +258,7 @@ where self, ctx: &BuilderContext, pool: Pool, - ) -> eyre::Result> { + ) -> eyre::Result> { let payload_builder = reth_optimism_payload_builder::OptimismPayloadBuilder::new(self.evm_config) .set_compute_pending_block(self.compute_pending_block); @@ -293,7 +299,7 @@ pub struct OptimismNetworkBuilder { impl NetworkBuilder for OptimismNetworkBuilder where - Node: FullNodeTypes, + Node: FullNodeTypes>, Pool: TransactionPool + Unpin + 'static, { async fn build_network( @@ -350,7 +356,7 @@ pub struct OptimismConsensusBuilder; impl ConsensusBuilder for OptimismConsensusBuilder where - Node: FullNodeTypes, + Node: FullNodeTypes>, { type Consensus = Arc; diff --git a/crates/optimism/rpc/src/eth/call.rs b/crates/optimism/rpc/src/eth/call.rs index fbcb403ac..f910ef990 100644 --- a/crates/optimism/rpc/src/eth/call.rs +++ b/crates/optimism/rpc/src/eth/call.rs @@ -1,5 +1,6 @@ +use reth_chainspec::ChainSpec; use reth_evm::ConfigureEvm; -use reth_node_api::FullNodeComponents; +use reth_node_api::{FullNodeComponents, NodeTypes}; use reth_primitives::{ revm_primitives::{BlockEnv, OptimismFields, TxEnv}, Bytes, TxKind, U256, @@ -16,7 +17,7 @@ use crate::{OpEthApi, OpEthApiError}; impl EthCall for OpEthApi where Self: Call, - N: FullNodeComponents, + N: FullNodeComponents>, { } diff --git a/crates/optimism/rpc/src/eth/mod.rs b/crates/optimism/rpc/src/eth/mod.rs index 12f83e0ed..56056c747 100644 --- a/crates/optimism/rpc/src/eth/mod.rs +++ b/crates/optimism/rpc/src/eth/mod.rs @@ -16,7 +16,7 @@ use op_alloy_network::AnyNetwork; use reth_chainspec::ChainSpec; use reth_evm::ConfigureEvm; use reth_network_api::NetworkInfo; -use reth_node_api::{BuilderProvider, FullNodeComponents, FullNodeTypes}; +use reth_node_api::{BuilderProvider, FullNodeComponents, FullNodeTypes, NodeTypes}; use reth_node_builder::EthApiBuilderCtx; use reth_provider::{ BlockIdReader, BlockNumReader, BlockReaderIdExt, ChainSpecProvider, HeaderProvider, @@ -101,7 +101,7 @@ where impl EthApiSpec for OpEthApi where Self: Send + Sync, - N: FullNodeComponents, + N: FullNodeComponents>, { #[inline] fn provider( @@ -151,7 +151,7 @@ where impl LoadFee for OpEthApi where Self: LoadBlock, - N: FullNodeComponents, + N: FullNodeComponents>, { #[inline] fn provider( @@ -179,7 +179,7 @@ where impl LoadState for OpEthApi where Self: Send + Sync, - N: FullNodeComponents, + N: FullNodeComponents>, { #[inline] fn provider(&self) -> impl StateProviderFactory + ChainSpecProvider { @@ -226,7 +226,7 @@ where } } -impl AddDevSigners for OpEthApi { +impl>> AddDevSigners for OpEthApi { fn with_dev_accounts(&self) { *self.signers().write() = DevSigner::random_signers(20) } diff --git a/crates/optimism/rpc/src/eth/pending_block.rs b/crates/optimism/rpc/src/eth/pending_block.rs index 513e04da9..54f29059d 100644 --- a/crates/optimism/rpc/src/eth/pending_block.rs +++ b/crates/optimism/rpc/src/eth/pending_block.rs @@ -2,7 +2,7 @@ use reth_chainspec::ChainSpec; use reth_evm::ConfigureEvm; -use reth_node_api::FullNodeComponents; +use reth_node_api::{FullNodeComponents, NodeTypes}; use reth_primitives::{ revm_primitives::BlockEnv, BlockNumber, Receipt, SealedBlockWithSenders, B256, }; @@ -22,7 +22,7 @@ use crate::OpEthApi; impl LoadPendingBlock for OpEthApi where Self: SpawnBlocking, - N: FullNodeComponents, + N: FullNodeComponents>, { #[inline] fn provider( diff --git a/crates/storage/provider/Cargo.toml b/crates/storage/provider/Cargo.toml index 1393df536..2d8208141 100644 --- a/crates/storage/provider/Cargo.toml +++ b/crates/storage/provider/Cargo.toml @@ -32,6 +32,7 @@ reth-nippy-jar.workspace = true reth-codecs.workspace = true reth-evm.workspace = true reth-chain-state.workspace = true +reth-node-types.workspace = true # ethereum alloy-rpc-types-engine.workspace = true diff --git a/crates/storage/provider/src/traits/full.rs b/crates/storage/provider/src/traits/full.rs index d2a8f1cc7..52346257a 100644 --- a/crates/storage/provider/src/traits/full.rs +++ b/crates/storage/provider/src/traits/full.rs @@ -6,18 +6,18 @@ use crate::{ StaticFileProviderFactory, TransactionsProvider, }; use reth_chain_state::{CanonStateSubscriptions, ForkChoiceSubscriptions}; -use reth_chainspec::{ChainSpec, EthChainSpec}; -use reth_db_api::database::Database; +use reth_chainspec::ChainSpec; +use reth_node_types::NodeTypesWithDB; /// Helper trait to unify all provider traits for simplicity. -pub trait FullProvider: - DatabaseProviderFactory +pub trait FullProvider: + DatabaseProviderFactory + StaticFileProviderFactory + BlockReaderIdExt + AccountReader + StateProviderFactory + EvmEnvProvider - + ChainSpecProvider + + ChainSpecProvider + ChangeSetReader + CanonStateSubscriptions + ForkChoiceSubscriptions @@ -28,14 +28,14 @@ pub trait FullProvider: { } -impl FullProvider for T where - T: DatabaseProviderFactory +impl FullProvider for T where + T: DatabaseProviderFactory + StaticFileProviderFactory + BlockReaderIdExt + AccountReader + StateProviderFactory + EvmEnvProvider - + ChainSpecProvider + + ChainSpecProvider + ChangeSetReader + CanonStateSubscriptions + ForkChoiceSubscriptions diff --git a/examples/custom-engine-types/src/main.rs b/examples/custom-engine-types/src/main.rs index c58111f86..a8f9496f0 100644 --- a/examples/custom-engine-types/src/main.rs +++ b/examples/custom-engine-types/src/main.rs @@ -207,7 +207,7 @@ impl NodeTypesWithEngine for MyCustomNode { /// This provides a preset configuration for the node impl Node for MyCustomNode where - N: FullNodeTypes, + N: FullNodeTypes>, { type ComponentsBuilder = ComponentsBuilder< N, @@ -237,14 +237,16 @@ pub struct CustomPayloadServiceBuilder; impl PayloadServiceBuilder for CustomPayloadServiceBuilder where - Node: FullNodeTypes, + Node: FullNodeTypes< + Types: NodeTypesWithEngine, + >, Pool: TransactionPool + Unpin + 'static, { async fn spawn_payload_service( self, ctx: &BuilderContext, pool: Pool, - ) -> eyre::Result> { + ) -> eyre::Result::Engine>> { let payload_builder = CustomPayloadBuilder::default(); let conf = ctx.payload_builder_config(); diff --git a/examples/custom-evm/src/main.rs b/examples/custom-evm/src/main.rs index c8b8a20f7..5986aaac3 100644 --- a/examples/custom-evm/src/main.rs +++ b/examples/custom-evm/src/main.rs @@ -20,7 +20,7 @@ use reth::{ }; use reth_chainspec::{Chain, ChainSpec, Head}; use reth_evm_ethereum::EthEvmConfig; -use reth_node_api::{ConfigureEvm, ConfigureEvmEnv, FullNodeTypes}; +use reth_node_api::{ConfigureEvm, ConfigureEvmEnv, FullNodeTypes, NodeTypes}; use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig}; use reth_node_ethereum::{ node::{EthereumAddOns, EthereumPayloadBuilder}, @@ -144,7 +144,7 @@ pub struct MyExecutorBuilder; impl ExecutorBuilder for MyExecutorBuilder where - Node: FullNodeTypes, + Node: FullNodeTypes>, { type EVM = MyEvmConfig; type Executor = EthExecutorProvider; diff --git a/examples/custom-node-components/src/main.rs b/examples/custom-node-components/src/main.rs index 2c44e18d8..1faca73d2 100644 --- a/examples/custom-node-components/src/main.rs +++ b/examples/custom-node-components/src/main.rs @@ -3,7 +3,9 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] use reth::{ + api::NodeTypes, builder::{components::PoolBuilder, BuilderContext, FullNodeTypes}, + chainspec::ChainSpec, cli::Cli, providers::CanonStateSubscriptions, transaction_pool::{ @@ -45,7 +47,7 @@ pub struct CustomPoolBuilder { /// This will be used to build the transaction pool and its maintenance tasks during launch. impl PoolBuilder for CustomPoolBuilder where - Node: FullNodeTypes, + Node: FullNodeTypes>, { type Pool = EthTransactionPool; diff --git a/examples/custom-payload-builder/src/main.rs b/examples/custom-payload-builder/src/main.rs index e0bf4e57a..1b612252b 100644 --- a/examples/custom-payload-builder/src/main.rs +++ b/examples/custom-payload-builder/src/main.rs @@ -21,6 +21,7 @@ use reth::{ }; use reth_basic_payload_builder::BasicPayloadJobGeneratorConfig; use reth_chainspec::ChainSpec; +use reth_node_api::NodeTypesWithEngine; use reth_node_ethereum::{node::EthereumAddOns, EthEngineTypes, EthereumNode}; use reth_payload_builder::PayloadBuilderService; @@ -33,14 +34,14 @@ pub struct CustomPayloadBuilder; impl PayloadServiceBuilder for CustomPayloadBuilder where - Node: FullNodeTypes, + Node: FullNodeTypes>, Pool: TransactionPool + Unpin + 'static, { async fn spawn_payload_service( self, ctx: &BuilderContext, pool: Pool, - ) -> eyre::Result> { + ) -> eyre::Result::Engine>> { tracing::info!("Spawning a custom payload builder"); let conf = ctx.payload_builder_config(); diff --git a/examples/stateful-precompile/src/main.rs b/examples/stateful-precompile/src/main.rs index 5505f6d16..e6d83acf0 100644 --- a/examples/stateful-precompile/src/main.rs +++ b/examples/stateful-precompile/src/main.rs @@ -19,7 +19,7 @@ use reth::{ tasks::TaskManager, }; use reth_chainspec::{Chain, ChainSpec}; -use reth_node_api::{ConfigureEvm, ConfigureEvmEnv, FullNodeTypes}; +use reth_node_api::{ConfigureEvm, ConfigureEvmEnv, FullNodeTypes, NodeTypes}; use reth_node_core::{args::RpcServerArgs, node_config::NodeConfig}; use reth_node_ethereum::{node::EthereumAddOns, EthEvmConfig, EthExecutorProvider, EthereumNode}; use reth_primitives::{ @@ -207,7 +207,7 @@ pub struct MyExecutorBuilder { impl ExecutorBuilder for MyExecutorBuilder where - Node: FullNodeTypes, + Node: FullNodeTypes>, { type EVM = MyEvmConfig; type Executor = EthExecutorProvider;