feat: ChainSpec associated type (#10292)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Arsenii Kulikov
2024-08-22 20:30:09 +08:00
committed by GitHub
parent a4c30ead7e
commit f2e0bc073a
52 changed files with 254 additions and 116 deletions

3
Cargo.lock generated
View File

@ -2862,6 +2862,7 @@ version = "0.0.0"
dependencies = [ dependencies = [
"eyre", "eyre",
"reth", "reth",
"reth-chainspec",
"reth-node-ethereum", "reth-node-ethereum",
"reth-tracing", "reth-tracing",
"reth-transaction-pool", "reth-transaction-pool",
@ -7690,6 +7691,7 @@ dependencies = [
name = "reth-node-api" name = "reth-node-api"
version = "1.0.5" version = "1.0.5"
dependencies = [ dependencies = [
"reth-chainspec",
"reth-db-api", "reth-db-api",
"reth-engine-primitives", "reth-engine-primitives",
"reth-evm", "reth-evm",
@ -8031,6 +8033,7 @@ dependencies = [
"jsonrpsee", "jsonrpsee",
"jsonrpsee-types", "jsonrpsee-types",
"parking_lot 0.12.3", "parking_lot 0.12.3",
"reth-chainspec",
"reth-evm", "reth-evm",
"reth-evm-optimism", "reth-evm-optimism",
"reth-network-api", "reth-network-api",

View File

@ -0,0 +1,27 @@
use crate::ChainSpec;
use alloy_chains::Chain;
use reth_ethereum_forks::{EthereumHardfork, ForkCondition};
/// Trait representing type configuring a chain spec.
pub trait EthChainSpec: Send + Sync + Unpin + 'static {
/// Enumw with chain hardforks.
type Hardfork: Clone + Copy + 'static;
/// Chain id.
fn chain(&self) -> Chain;
/// Activation condition for a given hardfork.
fn activation_condition(&self, hardfork: Self::Hardfork) -> ForkCondition;
}
impl EthChainSpec for ChainSpec {
type Hardfork = EthereumHardfork;
fn chain(&self) -> Chain {
self.chain
}
fn activation_condition(&self, hardfork: Self::Hardfork) -> ForkCondition {
self.hardforks.fork(hardfork)
}
}

View File

@ -29,6 +29,9 @@ mod info;
/// The chain spec module. /// The chain spec module.
mod spec; mod spec;
mod api;
pub use api::EthChainSpec;
/// Chain specific constants /// Chain specific constants
pub(crate) mod constants; pub(crate) mod constants;

View File

@ -1,4 +1,4 @@
use crate::constants::MAINNET_DEPOSIT_CONTRACT; use crate::{constants::MAINNET_DEPOSIT_CONTRACT, EthChainSpec};
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
use alloc::{boxed::Box, sync::Arc, vec::Vec}; use alloc::{boxed::Box, sync::Arc, vec::Vec};
use alloy_chains::{Chain, ChainKind, NamedChain}; use alloy_chains::{Chain, ChainKind, NamedChain};
@ -813,8 +813,11 @@ impl From<Genesis> for ChainSpec {
/// A trait for reading the current [`ChainSpec`]. /// A trait for reading the current [`ChainSpec`].
#[auto_impl::auto_impl(&, Arc)] #[auto_impl::auto_impl(&, Arc)]
pub trait ChainSpecProvider: Send + Sync { pub trait ChainSpecProvider: Send + Sync {
/// The chain spec type.
type ChainSpec: EthChainSpec;
/// Get an [`Arc`] to the [`ChainSpec`]. /// Get an [`Arc`] to the [`ChainSpec`].
fn chain_spec(&self) -> Arc<ChainSpec>; fn chain_spec(&self) -> Arc<Self::ChainSpec>;
} }
/// A helper to build custom chain specs /// A helper to build custom chain specs

View File

@ -4,6 +4,7 @@ use reth_blockchain_tree_api::{
error::{BlockchainTreeError, CanonicalError, InsertBlockError, InsertBlockErrorKind}, error::{BlockchainTreeError, CanonicalError, InsertBlockError, InsertBlockErrorKind},
BlockStatus, BlockValidationKind, BlockchainTreeEngine, CanonicalOutcome, InsertPayloadOk, BlockStatus, BlockValidationKind, BlockchainTreeEngine, CanonicalOutcome, InsertPayloadOk,
}; };
use reth_chainspec::ChainSpec;
use reth_db_api::database::Database; use reth_db_api::database::Database;
use reth_engine_primitives::EngineTypes; use reth_engine_primitives::EngineTypes;
use reth_errors::{BlockValidationError, ProviderResult, RethError, RethResult}; use reth_errors::{BlockValidationError, ProviderResult, RethError, RethResult};
@ -231,7 +232,7 @@ where
+ BlockIdReader + BlockIdReader
+ CanonChainTracker + CanonChainTracker
+ StageCheckpointReader + StageCheckpointReader
+ ChainSpecProvider + ChainSpecProvider<ChainSpec = ChainSpec>
+ 'static, + 'static,
Client: BlockClient + 'static, Client: BlockClient + 'static,
EngineT: EngineTypes + Unpin, EngineT: EngineTypes + Unpin,
@ -1797,7 +1798,7 @@ where
+ BlockIdReader + BlockIdReader
+ CanonChainTracker + CanonChainTracker
+ StageCheckpointReader + StageCheckpointReader
+ ChainSpecProvider + ChainSpecProvider<ChainSpec = ChainSpec>
+ Unpin + Unpin
+ 'static, + 'static,
EngineT: EngineTypes + Unpin, EngineT: EngineTypes + Unpin,

View File

@ -14,7 +14,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, RethFullAdapter, NodeAdapter, NodeAddOns, NodeComponents, NodeTypes, RethFullAdapter,
}; };
use reth_provider::providers::BlockchainProvider; use reth_provider::providers::BlockchainProvider;
use tracing::{span, Level}; use tracing::{span, Level};
@ -50,7 +50,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>>, N: Default + Node<TmpNodeAdapter<N>> + NodeTypes<ChainSpec = ChainSpec>,
<<N::ComponentsBuilder as NodeComponentsBuilder<TmpNodeAdapter<N>>>::Components as NodeComponents<TmpNodeAdapter<N>>>::Network: PeersHandleProvider, <<N::ComponentsBuilder as NodeComponentsBuilder<TmpNodeAdapter<N>>>::Components as NodeComponents<TmpNodeAdapter<N>>>::Network: PeersHandleProvider,
<N::AddOns as NodeAddOns<Adapter<N>>>::EthApi: <N::AddOns as NodeAddOns<Adapter<N>>>::EthApi:
FullEthApiServer + AddDevSigners + EthApiBuilderProvider<Adapter<N>>, FullEthApiServer + AddDevSigners + EthApiBuilderProvider<Adapter<N>>,

View File

@ -14,6 +14,7 @@ use reth::{
types::engine::PayloadStatusEnum, types::engine::PayloadStatusEnum,
}, },
}; };
use reth_chainspec::ChainSpec;
use reth_node_builder::{NodeAddOns, NodeTypes}; use reth_node_builder::{NodeAddOns, NodeTypes};
use reth_primitives::{BlockHash, BlockNumber, Bytes, B256}; use reth_primitives::{BlockHash, BlockNumber, Bytes, B256};
use reth_stages_types::StageId; use reth_stages_types::StageId;
@ -45,7 +46,7 @@ where
impl<Node, AddOns> NodeTestContext<Node, AddOns> impl<Node, AddOns> NodeTestContext<Node, AddOns>
where where
Node: FullNodeComponents, Node: FullNodeComponents<ChainSpec = ChainSpec>,
Node::Network: PeersHandleProvider, Node::Network: PeersHandleProvider,
AddOns: NodeAddOns<Node>, AddOns: NodeAddOns<Node>,
{ {

View File

@ -7,6 +7,7 @@ use reth::{
DebugApiServer, DebugApiServer,
}, },
}; };
use reth_chainspec::ChainSpec;
use reth_primitives::{Bytes, B256}; use reth_primitives::{Bytes, B256};
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
@ -14,7 +15,7 @@ pub struct RpcTestContext<Node: FullNodeComponents, EthApi> {
pub inner: RpcRegistry<Node, EthApi>, pub inner: RpcRegistry<Node, EthApi>,
} }
impl<Node: FullNodeComponents, EthApi> RpcTestContext<Node, EthApi> impl<Node: FullNodeComponents<ChainSpec = ChainSpec>, EthApi> RpcTestContext<Node, EthApi>
where where
EthApi: EthApiSpec + EthTransactions + TraceExt, EthApi: EthApiSpec + EthTransactions + TraceExt,
{ {

View File

@ -27,6 +27,7 @@ reth-auto-seal-consensus.workspace = true
reth-beacon-consensus.workspace = true reth-beacon-consensus.workspace = true
reth-rpc.workspace = true reth-rpc.workspace = true
reth-node-api.workspace = true reth-node-api.workspace = true
reth-chainspec.workspace = true
# misc # misc
eyre.workspace = true eyre.workspace = true

View File

@ -5,6 +5,7 @@ use std::sync::Arc;
use reth_auto_seal_consensus::AutoSealConsensus; use reth_auto_seal_consensus::AutoSealConsensus;
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig}; use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
use reth_beacon_consensus::EthBeaconConsensus; use reth_beacon_consensus::EthBeaconConsensus;
use reth_chainspec::ChainSpec;
use reth_ethereum_engine_primitives::{ use reth_ethereum_engine_primitives::{
EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes, EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes,
}; };
@ -46,7 +47,7 @@ impl EthereumNode {
EthereumConsensusBuilder, EthereumConsensusBuilder,
> >
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
<Node as NodeTypes>::Engine: PayloadTypes< <Node as NodeTypes>::Engine: PayloadTypes<
BuiltPayload = EthBuiltPayload, BuiltPayload = EthBuiltPayload,
PayloadAttributes = EthPayloadAttributes, PayloadAttributes = EthPayloadAttributes,
@ -66,6 +67,7 @@ impl EthereumNode {
impl NodeTypes for EthereumNode { impl NodeTypes for EthereumNode {
type Primitives = (); type Primitives = ();
type Engine = EthEngineTypes; type Engine = EthEngineTypes;
type ChainSpec = ChainSpec;
} }
/// Add-ons w.r.t. l1 ethereum. /// Add-ons w.r.t. l1 ethereum.
@ -78,7 +80,7 @@ impl<N: FullNodeComponents> NodeAddOns<N> for EthereumAddOns {
impl<N> Node<N> for EthereumNode impl<N> Node<N> for EthereumNode
where where
N: FullNodeTypes<Engine = EthEngineTypes>, N: FullNodeTypes<Engine = EthEngineTypes, ChainSpec = ChainSpec>,
{ {
type ComponentsBuilder = ComponentsBuilder< type ComponentsBuilder = ComponentsBuilder<
N, N,
@ -103,7 +105,7 @@ pub struct EthereumExecutorBuilder;
impl<Node> ExecutorBuilder<Node> for EthereumExecutorBuilder impl<Node> ExecutorBuilder<Node> for EthereumExecutorBuilder
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
{ {
type EVM = EthEvmConfig; type EVM = EthEvmConfig;
type Executor = EthExecutorProvider<Self::EVM>; type Executor = EthExecutorProvider<Self::EVM>;
@ -132,7 +134,7 @@ pub struct EthereumPoolBuilder {
impl<Node> PoolBuilder<Node> for EthereumPoolBuilder impl<Node> PoolBuilder<Node> for EthereumPoolBuilder
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
{ {
type Pool = EthTransactionPool<Node::Provider, DiskFileBlobStore>; type Pool = EthTransactionPool<Node::Provider, DiskFileBlobStore>;
@ -210,7 +212,7 @@ impl<EVM> EthereumPayloadBuilder<EVM> {
impl<Node, Evm, Pool> PayloadServiceBuilder<Node, Pool> for EthereumPayloadBuilder<Evm> impl<Node, Evm, Pool> PayloadServiceBuilder<Node, Pool> for EthereumPayloadBuilder<Evm>
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
Evm: ConfigureEvm, Evm: ConfigureEvm,
Pool: TransactionPool + Unpin + 'static, Pool: TransactionPool + Unpin + 'static,
<Node as NodeTypes>::Engine: PayloadTypes< <Node as NodeTypes>::Engine: PayloadTypes<
@ -282,7 +284,7 @@ pub struct EthereumConsensusBuilder {
impl<Node> ConsensusBuilder<Node> for EthereumConsensusBuilder impl<Node> ConsensusBuilder<Node> for EthereumConsensusBuilder
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
{ {
type Consensus = Arc<dyn reth_consensus::Consensus>; type Consensus = Arc<dyn reth_consensus::Consensus>;

View File

@ -111,11 +111,12 @@ pub struct TestNode;
impl NodeTypes for TestNode { impl NodeTypes for TestNode {
type Primitives = (); type Primitives = ();
type Engine = EthEngineTypes; type Engine = EthEngineTypes;
type ChainSpec = ChainSpec;
} }
impl<N> Node<N> for TestNode impl<N> Node<N> for TestNode
where where
N: FullNodeTypes<Engine = EthEngineTypes>, N: FullNodeTypes<Engine = EthEngineTypes, ChainSpec = ChainSpec>,
{ {
type ComponentsBuilder = ComponentsBuilder< type ComponentsBuilder = ComponentsBuilder<
N, N,

View File

@ -14,6 +14,7 @@ workspace = true
# reth # reth
reth-evm.workspace = true reth-evm.workspace = true
reth-provider.workspace = true reth-provider.workspace = true
reth-chainspec.workspace = true
reth-db-api.workspace = true reth-db-api.workspace = true
reth-engine-primitives.workspace = true reth-engine-primitives.workspace = true
reth-transaction-pool.workspace = true reth-transaction-pool.workspace = true

View File

@ -2,6 +2,7 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use reth_chainspec::EthChainSpec;
use reth_db_api::{ use reth_db_api::{
database::Database, database::Database,
database_metrics::{DatabaseMetadata, DatabaseMetrics}, database_metrics::{DatabaseMetadata, DatabaseMetrics},
@ -26,32 +27,37 @@ pub trait NodeTypes: Send + Sync + Unpin + 'static {
type Primitives: NodePrimitives; type Primitives: NodePrimitives;
/// The node's engine types, defining the interaction with the consensus engine. /// The node's engine types, defining the interaction with the consensus engine.
type Engine: EngineTypes; type Engine: EngineTypes;
/// The type used for configuration of the EVM.
type ChainSpec: EthChainSpec;
} }
/// A [`NodeTypes`] type builder /// A [`NodeTypes`] type builder
#[derive(Default, Debug)] #[derive(Default, Debug)]
pub struct AnyNodeTypes<P = (), E = ()>(PhantomData<P>, PhantomData<E>); pub struct AnyNodeTypes<P = (), E = (), C = ()>(PhantomData<P>, PhantomData<E>, PhantomData<C>);
impl<P, E> AnyNodeTypes<P, E> { impl<P, E, C> AnyNodeTypes<P, E, C> {
/// Sets the `Primitives` associated type. /// Sets the `Primitives` associated type.
pub const fn primitives<T>(self) -> AnyNodeTypes<T, E> { pub const fn primitives<T>(self) -> AnyNodeTypes<T, E, C> {
AnyNodeTypes::<T, E>(PhantomData::<T>, PhantomData::<E>) AnyNodeTypes::<T, E, C>(PhantomData::<T>, PhantomData::<E>, PhantomData::<C>)
} }
/// Sets the `Engine` associated type. /// Sets the `Engine` associated type.
pub const fn engine<T>(self) -> AnyNodeTypes<P, T> { pub const fn engine<T>(self) -> AnyNodeTypes<P, T, C> {
AnyNodeTypes::<P, T>(PhantomData::<P>, PhantomData::<T>) AnyNodeTypes::<P, T, C>(PhantomData::<P>, PhantomData::<T>, PhantomData::<C>)
} }
} }
impl<P, E> NodeTypes for AnyNodeTypes<P, E> impl<P, E, C> NodeTypes for AnyNodeTypes<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,
{ {
type Primitives = P; type Primitives = P;
type Engine = E; type Engine = E;
type ChainSpec = C;
} }
/// A helper trait that is downstream of the [`NodeTypes`] trait and adds stateful components to the /// A helper trait that is downstream of the [`NodeTypes`] trait and adds stateful components to the
@ -62,7 +68,7 @@ pub trait FullNodeTypes: NodeTypes + '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.
type Provider: FullProvider<Self::DB>; type Provider: FullProvider<Self::DB, Self::ChainSpec>;
} }
/// An adapter type that adds the builtin provider type to the user configured node types. /// An adapter type that adds the builtin provider type to the user configured node types.
@ -103,12 +109,13 @@ where
{ {
type Primitives = Types::Primitives; type Primitives = Types::Primitives;
type Engine = Types::Engine; type Engine = Types::Engine;
type ChainSpec = Types::ChainSpec;
} }
impl<Types, DB, Provider> FullNodeTypes for FullNodeTypesAdapter<Types, DB, Provider> impl<Types, DB, Provider> FullNodeTypes for FullNodeTypesAdapter<Types, DB, Provider>
where where
Types: NodeTypes, Types: NodeTypes,
Provider: FullProvider<DB>, Provider: FullProvider<DB, Types::ChainSpec>,
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static, DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
{ {
type DB = DB; type DB = DB;

View File

@ -206,7 +206,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, T: NodeTypes<ChainSpec = ChainSpec>,
{ {
self.with_types_and_provider() self.with_types_and_provider()
} }
@ -216,8 +216,8 @@ where
self, self,
) -> NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>> ) -> NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>>
where where
T: NodeTypes, T: NodeTypes<ChainSpec = ChainSpec>,
P: FullProvider<DB>, P: FullProvider<DB, T::ChainSpec>,
{ {
NodeBuilderWithTypes::new(self.config, self.database) NodeBuilderWithTypes::new(self.config, self.database)
} }
@ -230,7 +230,7 @@ where
node: N, node: N,
) -> NodeBuilderWithComponents<RethFullAdapter<DB, N>, N::ComponentsBuilder, N::AddOns> ) -> NodeBuilderWithComponents<RethFullAdapter<DB, N>, N::ComponentsBuilder, N::AddOns>
where where
N: Node<RethFullAdapter<DB, N>>, N: Node<RethFullAdapter<DB, N>, ChainSpec = ChainSpec>,
{ {
self.with_types().with_components(node.components_builder()).with_add_ons::<N::AddOns>() self.with_types().with_components(node.components_builder()).with_add_ons::<N::AddOns>()
} }
@ -264,7 +264,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, T: NodeTypes<ChainSpec = ChainSpec>,
{ {
WithLaunchContext { builder: self.builder.with_types(), task_executor: self.task_executor } WithLaunchContext { builder: self.builder.with_types(), task_executor: self.task_executor }
} }
@ -274,8 +274,8 @@ where
self, self,
) -> WithLaunchContext<NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>>> ) -> WithLaunchContext<NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>>>
where where
T: NodeTypes, T: NodeTypes<ChainSpec = ChainSpec>,
P: FullProvider<DB>, P: FullProvider<DB, T::ChainSpec>,
{ {
WithLaunchContext { WithLaunchContext {
builder: self.builder.with_types_and_provider(), builder: self.builder.with_types_and_provider(),
@ -293,7 +293,7 @@ where
NodeBuilderWithComponents<RethFullAdapter<DB, N>, N::ComponentsBuilder, N::AddOns>, NodeBuilderWithComponents<RethFullAdapter<DB, N>, N::ComponentsBuilder, N::AddOns>,
> >
where where
N: Node<RethFullAdapter<DB, N>>, N: Node<RethFullAdapter<DB, N>, ChainSpec = ChainSpec>,
{ {
self.with_types().with_components(node.components_builder()).with_add_ons::<N::AddOns>() self.with_types().with_components(node.components_builder()).with_add_ons::<N::AddOns>()
} }
@ -316,7 +316,7 @@ where
>, >,
> >
where where
N: Node<RethFullAdapter<DB, N>>, N: Node<RethFullAdapter<DB, N>, ChainSpec = ChainSpec>,
N::AddOns: NodeAddOns< N::AddOns: NodeAddOns<
NodeAdapter< NodeAdapter<
RethFullAdapter<DB, N>, RethFullAdapter<DB, N>,
@ -469,7 +469,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, T: NodeTypes<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>,
@ -540,7 +540,7 @@ impl<Node: FullNodeTypes> BuilderContext<Node> {
} }
/// Returns the chain spec of the node. /// Returns the chain spec of the node.
pub fn chain_spec(&self) -> Arc<ChainSpec> { pub fn chain_spec(&self) -> Arc<Node::ChainSpec> {
self.provider().chain_spec() self.provider().chain_spec()
} }

View File

@ -91,6 +91,7 @@ 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 Engine = T::Engine;
type ChainSpec = T::ChainSpec;
} }
impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeTypes for NodeAdapter<T, C> { impl<T: FullNodeTypes, C: NodeComponents<T>> FullNodeTypes for NodeAdapter<T, C> {

View File

@ -569,7 +569,7 @@ where
) -> eyre::Result<LaunchContextWith<Attached<WithConfigs, WithMeteredProviders<DB, T>>>> ) -> eyre::Result<LaunchContextWith<Attached<WithConfigs, WithMeteredProviders<DB, T>>>>
where where
T: FullNodeTypes, T: FullNodeTypes,
T::Provider: FullProvider<DB>, T::Provider: FullProvider<DB, T::ChainSpec>,
F: FnOnce(ProviderFactory<DB>) -> eyre::Result<T::Provider>, F: FnOnce(ProviderFactory<DB>) -> eyre::Result<T::Provider>,
{ {
let blockchain_db = create_blockchain_provider(self.provider_factory().clone())?; let blockchain_db = create_blockchain_provider(self.provider_factory().clone())?;
@ -598,7 +598,7 @@ where
impl<DB, T> LaunchContextWith<Attached<WithConfigs, WithMeteredProviders<DB, T>>> impl<DB, T> LaunchContextWith<Attached<WithConfigs, WithMeteredProviders<DB, T>>>
where where
DB: Database + DatabaseMetrics + Send + Sync + Clone + 'static, DB: Database + DatabaseMetrics + Send + Sync + Clone + 'static,
T: FullNodeTypes<Provider: FullProvider<DB> + WithTree>, T: FullNodeTypes<Provider: FullProvider<DB, T::ChainSpec> + WithTree>,
{ {
/// Returns access to the underlying database. /// Returns access to the underlying database.
pub fn database(&self) -> &DB { pub fn database(&self) -> &DB {
@ -717,7 +717,7 @@ where
impl<DB, T, CB> LaunchContextWith<Attached<WithConfigs, WithComponents<DB, T, CB>>> impl<DB, T, CB> LaunchContextWith<Attached<WithConfigs, WithComponents<DB, T, CB>>>
where where
DB: Database + DatabaseMetrics + Send + Sync + Clone + 'static, DB: Database + DatabaseMetrics + Send + Sync + Clone + 'static,
T: FullNodeTypes<Provider: FullProvider<DB> + WithTree>, T: FullNodeTypes<Provider: FullProvider<DB, T::ChainSpec> + WithTree>,
CB: NodeComponentsBuilder<T>, CB: NodeComponentsBuilder<T>,
{ {
/// Returns the configured `ProviderFactory`. /// Returns the configured `ProviderFactory`.
@ -915,7 +915,7 @@ pub struct WithMeteredProvider<DB> {
pub struct WithMeteredProviders<DB, T> pub struct WithMeteredProviders<DB, T>
where where
DB: Database, DB: Database,
T: FullNodeTypes<Provider: FullProvider<DB>>, T: FullNodeTypes<Provider: FullProvider<DB, T::ChainSpec>>,
{ {
db_provider_container: WithMeteredProvider<DB>, db_provider_container: WithMeteredProvider<DB>,
blockchain_db: T::Provider, blockchain_db: T::Provider,
@ -931,7 +931,7 @@ where
pub struct WithComponents<DB, T, CB> pub struct WithComponents<DB, T, CB>
where where
DB: Database, DB: Database,
T: FullNodeTypes<Provider: FullProvider<DB>>, T: FullNodeTypes<Provider: FullProvider<DB, T::ChainSpec>>,
CB: NodeComponentsBuilder<T>, CB: NodeComponentsBuilder<T>,
{ {
db_provider_container: WithMeteredProvider<DB>, db_provider_container: WithMeteredProvider<DB>,

View File

@ -6,6 +6,7 @@ use reth_beacon_consensus::{
BeaconConsensusEngineHandle, BeaconConsensusEngineHandle,
}; };
use reth_blockchain_tree::BlockchainTreeConfig; use reth_blockchain_tree::BlockchainTreeConfig;
use reth_chainspec::ChainSpec;
use reth_engine_service::service::{ChainEvent, EngineService}; use reth_engine_service::service::{ChainEvent, EngineService};
use reth_engine_tree::{ use reth_engine_tree::{
engine::{EngineApiRequest, EngineRequestHandler}, engine::{EngineApiRequest, EngineRequestHandler},
@ -59,7 +60,10 @@ impl EngineNodeLauncher {
impl<T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for EngineNodeLauncher impl<T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for EngineNodeLauncher
where where
T: FullNodeTypes<Provider = BlockchainProvider2<<T as FullNodeTypes>::DB>>, T: FullNodeTypes<
Provider = BlockchainProvider2<<T as FullNodeTypes>::DB>,
ChainSpec = ChainSpec,
>,
CB: NodeComponentsBuilder<T>, CB: NodeComponentsBuilder<T>,
AO: NodeAddOns< AO: NodeAddOns<
NodeAdapter<T, CB::Components>, NodeAdapter<T, CB::Components>,

View File

@ -16,6 +16,7 @@ use reth_beacon_consensus::{
BeaconConsensusEngine, BeaconConsensusEngine,
}; };
use reth_blockchain_tree::{noop::NoopBlockchainTree, BlockchainTreeConfig}; use reth_blockchain_tree::{noop::NoopBlockchainTree, BlockchainTreeConfig};
use reth_chainspec::ChainSpec;
use reth_consensus_debug_client::{DebugConsensusClient, EtherscanBlockProvider, RpcBlockProvider}; use reth_consensus_debug_client::{DebugConsensusClient, EtherscanBlockProvider, RpcBlockProvider};
use reth_engine_util::EngineMessageStreamExt; use reth_engine_util::EngineMessageStreamExt;
use reth_exex::ExExManagerHandle; use reth_exex::ExExManagerHandle;
@ -101,7 +102,10 @@ impl DefaultNodeLauncher {
impl<T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for DefaultNodeLauncher impl<T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for DefaultNodeLauncher
where where
T: FullNodeTypes<Provider = BlockchainProvider<<T as FullNodeTypes>::DB>>, T: FullNodeTypes<
Provider = BlockchainProvider<<T as FullNodeTypes>::DB>,
ChainSpec = ChainSpec,
>,
CB: NodeComponentsBuilder<T>, CB: NodeComponentsBuilder<T>,
AO: NodeAddOns< AO: NodeAddOns<
NodeAdapter<T, CB::Components>, NodeAdapter<T, CB::Components>,

View File

@ -3,7 +3,6 @@ pub use reth_node_api::{FullNodeTypes, NodeTypes};
use std::{marker::PhantomData, sync::Arc}; use std::{marker::PhantomData, sync::Arc};
use reth_chainspec::ChainSpec;
use reth_node_api::FullNodeComponents; use reth_node_api::FullNodeComponents;
use reth_node_core::{ use reth_node_core::{
dirs::{ChainPath, DataDirPath}, dirs::{ChainPath, DataDirPath},
@ -62,6 +61,8 @@ where
type Primitives = N::Primitives; type Primitives = N::Primitives;
type Engine = N::Engine; type Engine = N::Engine;
type ChainSpec = N::ChainSpec;
} }
impl<N, C, AO> Node<N> for AnyNode<N, C, AO> impl<N, C, AO> Node<N> for AnyNode<N, C, AO>
@ -112,8 +113,8 @@ where
Node: FullNodeComponents, Node: FullNodeComponents,
AddOns: NodeAddOns<Node>, AddOns: NodeAddOns<Node>,
{ {
/// Returns the [`ChainSpec`] of the node. /// Returns the chain spec of the node.
pub fn chain_spec(&self) -> Arc<ChainSpec> { pub fn chain_spec(&self) -> Arc<Node::ChainSpec> {
self.provider.chain_spec() self.provider.chain_spec()
} }

View File

@ -6,6 +6,7 @@ use std::{
}; };
use futures::TryFutureExt; use futures::TryFutureExt;
use reth_chainspec::ChainSpec;
use reth_node_api::{BuilderProvider, FullNodeComponents}; use reth_node_api::{BuilderProvider, FullNodeComponents};
use reth_node_core::{ use reth_node_core::{
node_config::NodeConfig, node_config::NodeConfig,
@ -260,7 +261,7 @@ pub async fn launch_rpc_servers<Node, Engine, EthApi>(
) -> eyre::Result<(RethRpcServerHandles, RpcRegistry<Node, EthApi>)> ) -> eyre::Result<(RethRpcServerHandles, RpcRegistry<Node, EthApi>)>
where where
EthApi: EthApiBuilderProvider<Node> + FullEthApiServer, EthApi: EthApiBuilderProvider<Node> + FullEthApiServer,
Node: FullNodeComponents + Clone, Node: FullNodeComponents<ChainSpec = ChainSpec> + Clone,
Engine: EngineApiServer<Node::Engine>, Engine: EngineApiServer<Node::Engine>,
{ {
let auth_config = config.rpc.auth_server_config(jwt_secret)?; let auth_config = config.rpc.auth_server_config(jwt_secret)?;

View File

@ -3,6 +3,7 @@
use std::sync::Arc; use std::sync::Arc;
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig}; use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
use reth_chainspec::ChainSpec;
use reth_evm::ConfigureEvm; use reth_evm::ConfigureEvm;
use reth_evm_optimism::{OpExecutorProvider, OptimismEvmConfig}; use reth_evm_optimism::{OpExecutorProvider, OptimismEvmConfig};
use reth_network::{NetworkHandle, NetworkManager}; use reth_network::{NetworkHandle, NetworkManager};
@ -57,7 +58,7 @@ impl OptimismNode {
OptimismConsensusBuilder, OptimismConsensusBuilder,
> >
where where
Node: FullNodeTypes<Engine = OptimismEngineTypes>, Node: FullNodeTypes<Engine = OptimismEngineTypes, ChainSpec = ChainSpec>,
{ {
let RollupArgs { disable_txpool_gossip, compute_pending_block, discovery_v4, .. } = args; let RollupArgs { disable_txpool_gossip, compute_pending_block, discovery_v4, .. } = args;
ComponentsBuilder::default() ComponentsBuilder::default()
@ -78,7 +79,7 @@ impl OptimismNode {
impl<N> Node<N> for OptimismNode impl<N> Node<N> for OptimismNode
where where
N: FullNodeTypes<Engine = OptimismEngineTypes>, N: FullNodeTypes<Engine = OptimismEngineTypes, ChainSpec = ChainSpec>,
{ {
type ComponentsBuilder = ComponentsBuilder< type ComponentsBuilder = ComponentsBuilder<
N, N,
@ -100,6 +101,7 @@ where
impl NodeTypes for OptimismNode { impl NodeTypes for OptimismNode {
type Primitives = (); type Primitives = ();
type Engine = OptimismEngineTypes; type Engine = OptimismEngineTypes;
type ChainSpec = ChainSpec;
} }
/// Add-ons w.r.t. optimism. /// Add-ons w.r.t. optimism.
@ -117,7 +119,7 @@ pub struct OptimismExecutorBuilder;
impl<Node> ExecutorBuilder<Node> for OptimismExecutorBuilder impl<Node> ExecutorBuilder<Node> for OptimismExecutorBuilder
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
{ {
type EVM = OptimismEvmConfig; type EVM = OptimismEvmConfig;
type Executor = OpExecutorProvider<Self::EVM>; type Executor = OpExecutorProvider<Self::EVM>;
@ -144,7 +146,7 @@ pub struct OptimismPoolBuilder;
impl<Node> PoolBuilder<Node> for OptimismPoolBuilder impl<Node> PoolBuilder<Node> for OptimismPoolBuilder
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
{ {
type Pool = OpTransactionPool<Node::Provider, DiskFileBlobStore>; type Pool = OpTransactionPool<Node::Provider, DiskFileBlobStore>;
@ -239,7 +241,7 @@ impl<EVM> OptimismPayloadBuilder<EVM> {
impl<Node, EVM, Pool> PayloadServiceBuilder<Node, Pool> for OptimismPayloadBuilder<EVM> impl<Node, EVM, Pool> PayloadServiceBuilder<Node, Pool> for OptimismPayloadBuilder<EVM>
where where
Node: FullNodeTypes<Engine = OptimismEngineTypes>, Node: FullNodeTypes<Engine = OptimismEngineTypes, ChainSpec = ChainSpec>,
Pool: TransactionPool + Unpin + 'static, Pool: TransactionPool + Unpin + 'static,
EVM: ConfigureEvm, EVM: ConfigureEvm,
{ {
@ -288,7 +290,7 @@ pub struct OptimismNetworkBuilder {
impl<Node, Pool> NetworkBuilder<Node, Pool> for OptimismNetworkBuilder impl<Node, Pool> NetworkBuilder<Node, Pool> for OptimismNetworkBuilder
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
Pool: TransactionPool + Unpin + 'static, Pool: TransactionPool + Unpin + 'static,
{ {
async fn build_network( async fn build_network(
@ -345,7 +347,7 @@ pub struct OptimismConsensusBuilder;
impl<Node> ConsensusBuilder<Node> for OptimismConsensusBuilder impl<Node> ConsensusBuilder<Node> for OptimismConsensusBuilder
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
{ {
type Consensus = Arc<dyn reth_consensus::Consensus>; type Consensus = Arc<dyn reth_consensus::Consensus>;

View File

@ -26,6 +26,7 @@ reth-transaction-pool.workspace = true
reth-rpc.workspace = true reth-rpc.workspace = true
reth-node-api.workspace = true reth-node-api.workspace = true
reth-network-api.workspace = true reth-network-api.workspace = true
reth-chainspec.workspace = true
# ethereum # ethereum
alloy-primitives.workspace = true alloy-primitives.workspace = true

View File

@ -1,3 +1,4 @@
use reth_chainspec::ChainSpec;
use reth_evm::ConfigureEvm; use reth_evm::ConfigureEvm;
use reth_node_api::FullNodeComponents; use reth_node_api::FullNodeComponents;
use reth_primitives::{ use reth_primitives::{
@ -16,7 +17,7 @@ use crate::{OpEthApi, OpEthApiError};
impl<N> EthCall for OpEthApi<N> impl<N> EthCall for OpEthApi<N>
where where
Self: Call, Self: Call,
N: FullNodeComponents, N: FullNodeComponents<ChainSpec = ChainSpec>,
{ {
} }

View File

@ -11,6 +11,7 @@ use std::{fmt, sync::Arc};
use alloy_primitives::U256; use alloy_primitives::U256;
use derive_more::Deref; use derive_more::Deref;
use reth_chainspec::ChainSpec;
use reth_evm::ConfigureEvm; use reth_evm::ConfigureEvm;
use reth_network_api::NetworkInfo; use reth_network_api::NetworkInfo;
use reth_node_api::{BuilderProvider, FullNodeComponents, FullNodeTypes}; use reth_node_api::{BuilderProvider, FullNodeComponents, FullNodeTypes};
@ -98,17 +99,20 @@ impl<N: FullNodeComponents> OpEthApi<N> {
impl<N> EthApiTypes for OpEthApi<N> impl<N> EthApiTypes for OpEthApi<N>
where where
Self: Send + Sync, Self: Send + Sync,
N: FullNodeComponents, N: FullNodeComponents<ChainSpec = ChainSpec>,
{ {
type Error = OpEthApiError; type Error = OpEthApiError;
} }
impl<N> EthApiSpec for OpEthApi<N> impl<N> EthApiSpec for OpEthApi<N>
where where
N: FullNodeComponents, N: FullNodeComponents<ChainSpec = ChainSpec>,
{ {
#[inline] #[inline]
fn provider(&self) -> impl ChainSpecProvider + BlockNumReader + StageCheckpointReader { fn provider(
&self,
) -> impl ChainSpecProvider<ChainSpec = ChainSpec> + BlockNumReader + StageCheckpointReader
{
self.inner.provider() self.inner.provider()
} }
@ -131,7 +135,7 @@ where
impl<N> SpawnBlocking for OpEthApi<N> impl<N> SpawnBlocking for OpEthApi<N>
where where
Self: Send + Sync + Clone + 'static, Self: Send + Sync + Clone + 'static,
N: FullNodeComponents, N: FullNodeComponents<ChainSpec = ChainSpec>,
{ {
#[inline] #[inline]
fn io_task_spawner(&self) -> impl TaskSpawner { fn io_task_spawner(&self) -> impl TaskSpawner {
@ -152,10 +156,12 @@ where
impl<N> LoadFee for OpEthApi<N> impl<N> LoadFee for OpEthApi<N>
where where
Self: LoadBlock, Self: LoadBlock,
N: FullNodeComponents, N: FullNodeComponents<ChainSpec = ChainSpec>,
{ {
#[inline] #[inline]
fn provider(&self) -> impl BlockIdReader + HeaderProvider + ChainSpecProvider { fn provider(
&self,
) -> impl BlockIdReader + HeaderProvider + ChainSpecProvider<ChainSpec = ChainSpec> {
self.inner.provider() self.inner.provider()
} }
@ -178,10 +184,10 @@ where
impl<N> LoadState for OpEthApi<N> impl<N> LoadState for OpEthApi<N>
where where
Self: Send + Sync, Self: Send + Sync,
N: FullNodeComponents, N: FullNodeComponents<ChainSpec = ChainSpec>,
{ {
#[inline] #[inline]
fn provider(&self) -> impl StateProviderFactory + ChainSpecProvider { fn provider(&self) -> impl StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec> {
self.inner.provider() self.inner.provider()
} }

View File

@ -1,6 +1,7 @@
//! Loads OP pending block for a RPC response. //! Loads OP pending block for a RPC response.
use crate::OpEthApi; use crate::OpEthApi;
use reth_chainspec::ChainSpec;
use reth_evm::ConfigureEvm; use reth_evm::ConfigureEvm;
use reth_node_api::FullNodeComponents; use reth_node_api::FullNodeComponents;
use reth_primitives::{ use reth_primitives::{
@ -20,12 +21,15 @@ use reth_transaction_pool::TransactionPool;
impl<N> LoadPendingBlock for OpEthApi<N> impl<N> LoadPendingBlock for OpEthApi<N>
where where
Self: SpawnBlocking, Self: SpawnBlocking,
N: FullNodeComponents, N: FullNodeComponents<ChainSpec = ChainSpec>,
{ {
#[inline] #[inline]
fn provider( fn provider(
&self, &self,
) -> impl BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory { ) -> impl BlockReaderIdExt
+ EvmEnvProvider
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ StateProviderFactory {
self.inner.provider() self.inner.provider()
} }

View File

@ -14,6 +14,7 @@ workspace = true
[dependencies] [dependencies]
# reth # reth
reth-ipc.workspace = true reth-ipc.workspace = true
reth-chainspec.workspace = true
reth-network-api.workspace = true reth-network-api.workspace = true
reth-node-core.workspace = true reth-node-core.workspace = true
reth-provider.workspace = true reth-provider.workspace = true

View File

@ -151,6 +151,7 @@ use jsonrpsee::{
}, },
Methods, RpcModule, Methods, RpcModule,
}; };
use reth_chainspec::ChainSpec;
use reth_engine_primitives::EngineTypes; use reth_engine_primitives::EngineTypes;
use reth_evm::ConfigureEvm; use reth_evm::ConfigureEvm;
use reth_network_api::{noop::NoopNetwork, NetworkInfo, Peers}; use reth_network_api::{noop::NoopNetwork, NetworkInfo, Peers};
@ -754,10 +755,11 @@ where
} }
} }
impl<Provider: ChainSpecProvider, Pool, Network, Tasks, Events, EthApi> impl<Provider, Pool, Network, Tasks, Events, EthApi>
RpcRegistryInner<Provider, Pool, Network, Tasks, Events, EthApi> RpcRegistryInner<Provider, Pool, Network, Tasks, Events, EthApi>
where where
Network: NetworkInfo + Clone + 'static, Network: NetworkInfo + Clone + 'static,
Provider: ChainSpecProvider<ChainSpec = ChainSpec>,
{ {
/// Instantiates `AdminApi` /// Instantiates `AdminApi`
pub fn admin_api(&self) -> AdminApi<Network> pub fn admin_api(&self) -> AdminApi<Network>

View File

@ -1,6 +1,7 @@
//! Loads fee history from database. Helper trait for `eth_` fee and transaction RPC methods. //! Loads fee history from database. Helper trait for `eth_` fee and transaction RPC methods.
use futures::Future; use futures::Future;
use reth_chainspec::ChainSpec;
use reth_primitives::U256; use reth_primitives::U256;
use reth_provider::{BlockIdReader, BlockReaderIdExt, ChainSpecProvider, HeaderProvider}; use reth_provider::{BlockIdReader, BlockReaderIdExt, ChainSpecProvider, HeaderProvider};
use reth_rpc_eth_types::{ use reth_rpc_eth_types::{
@ -239,7 +240,9 @@ pub trait LoadFee: LoadBlock {
// Returns a handle for reading data from disk. // Returns a handle for reading data from disk.
/// ///
/// Data access in default (L1) trait method implementations. /// Data access in default (L1) trait method implementations.
fn provider(&self) -> impl BlockIdReader + HeaderProvider + ChainSpecProvider; fn provider(
&self,
) -> impl BlockIdReader + HeaderProvider + ChainSpecProvider<ChainSpec = ChainSpec>;
/// Returns a handle for reading data from memory. /// Returns a handle for reading data from memory.
/// ///

View File

@ -4,7 +4,7 @@
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
use futures::Future; use futures::Future;
use reth_chainspec::EthereumHardforks; use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_evm::{system_calls::pre_block_beacon_root_contract_call, ConfigureEvm, ConfigureEvmEnv}; use reth_evm::{system_calls::pre_block_beacon_root_contract_call, ConfigureEvm, ConfigureEvmEnv};
use reth_execution_types::ExecutionOutcome; use reth_execution_types::ExecutionOutcome;
use reth_primitives::{ use reth_primitives::{
@ -47,7 +47,10 @@ pub trait LoadPendingBlock: EthApiTypes {
/// Data access in default (L1) trait method implementations. /// Data access in default (L1) trait method implementations.
fn provider( fn provider(
&self, &self,
) -> impl BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory; ) -> impl BlockReaderIdExt
+ EvmEnvProvider
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ StateProviderFactory;
/// Returns a handle for reading data from transaction pool. /// Returns a handle for reading data from transaction pool.
/// ///

View File

@ -18,7 +18,9 @@ use super::EthSigner;
#[auto_impl::auto_impl(&, Arc)] #[auto_impl::auto_impl(&, Arc)]
pub trait EthApiSpec: Send + Sync { pub trait EthApiSpec: Send + Sync {
/// Returns a handle for reading data from disk. /// Returns a handle for reading data from disk.
fn provider(&self) -> impl ChainSpecProvider + BlockNumReader + StageCheckpointReader; fn provider(
&self,
) -> impl ChainSpecProvider<ChainSpec = ChainSpec> + BlockNumReader + StageCheckpointReader;
/// Returns a handle for reading network data summary. /// Returns a handle for reading network data summary.
fn network(&self) -> impl NetworkInfo; fn network(&self) -> impl NetworkInfo;

View File

@ -2,6 +2,7 @@
//! RPC methods. //! RPC methods.
use futures::Future; use futures::Future;
use reth_chainspec::ChainSpec;
use reth_errors::RethError; use reth_errors::RethError;
use reth_evm::ConfigureEvmEnv; use reth_evm::ConfigureEvmEnv;
use reth_primitives::{Address, BlockId, Bytes, Header, B256, KECCAK_EMPTY, U256}; use reth_primitives::{Address, BlockId, Bytes, Header, B256, KECCAK_EMPTY, U256};
@ -163,7 +164,7 @@ pub trait LoadState: EthApiTypes {
/// Returns a handle for reading state from database. /// Returns a handle for reading state from database.
/// ///
/// Data access in default trait method implementations. /// Data access in default trait method implementations.
fn provider(&self) -> impl StateProviderFactory + ChainSpecProvider; fn provider(&self) -> impl StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec>;
/// Returns a handle for reading data from memory. /// Returns a handle for reading data from memory.
/// ///

View File

@ -1,7 +1,7 @@
use alloy_rlp::{Decodable, Encodable}; use alloy_rlp::{Decodable, Encodable};
use async_trait::async_trait; use async_trait::async_trait;
use jsonrpsee::core::RpcResult; use jsonrpsee::core::RpcResult;
use reth_chainspec::EthereumHardforks; use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_evm::{system_calls::pre_block_beacon_root_contract_call, ConfigureEvmEnv}; use reth_evm::{system_calls::pre_block_beacon_root_contract_call, ConfigureEvmEnv};
use reth_primitives::{ use reth_primitives::{
Address, Block, BlockId, BlockNumberOrTag, Bytes, TransactionSignedEcRecovered, B256, U256, Address, Block, BlockId, BlockNumberOrTag, Bytes, TransactionSignedEcRecovered, B256, U256,
@ -68,7 +68,7 @@ impl<Provider, Eth> DebugApi<Provider, Eth>
where where
Provider: BlockReaderIdExt Provider: BlockReaderIdExt
+ HeaderProvider + HeaderProvider
+ ChainSpecProvider + ChainSpecProvider<ChainSpec = ChainSpec>
+ StateProviderFactory + StateProviderFactory
+ EvmEnvProvider + EvmEnvProvider
+ 'static, + 'static,
@ -789,7 +789,7 @@ impl<Provider, Eth> DebugApiServer for DebugApi<Provider, Eth>
where where
Provider: BlockReaderIdExt Provider: BlockReaderIdExt
+ HeaderProvider + HeaderProvider
+ ChainSpecProvider + ChainSpecProvider<ChainSpec = ChainSpec>
+ StateProviderFactory + StateProviderFactory
+ EvmEnvProvider + EvmEnvProvider
+ 'static, + 'static,

View File

@ -368,7 +368,7 @@ impl<Provider, Pool, Network, EvmConfig> UpdateRawTxForwarder
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use jsonrpsee_types::error::INVALID_PARAMS_CODE; use jsonrpsee_types::error::INVALID_PARAMS_CODE;
use reth_chainspec::BaseFeeParams; use reth_chainspec::{BaseFeeParams, ChainSpec};
use reth_evm_ethereum::EthEvmConfig; use reth_evm_ethereum::EthEvmConfig;
use reth_network_api::noop::NoopNetwork; use reth_network_api::noop::NoopNetwork;
use reth_primitives::{Block, BlockNumberOrTag, Header, TransactionSigned, B256, U64}; use reth_primitives::{Block, BlockNumberOrTag, Header, TransactionSigned, B256, U64};
@ -391,7 +391,7 @@ mod tests {
fn build_test_eth_api< fn build_test_eth_api<
P: BlockReaderIdExt P: BlockReaderIdExt
+ BlockReader + BlockReader
+ ChainSpecProvider + ChainSpecProvider<ChainSpec = ChainSpec>
+ EvmEnvProvider + EvmEnvProvider
+ StateProviderFactory + StateProviderFactory
+ Unpin + Unpin

View File

@ -1,5 +1,6 @@
//! Contains RPC handler implementations for fee history. //! Contains RPC handler implementations for fee history.
use reth_chainspec::ChainSpec;
use reth_provider::{BlockIdReader, BlockReaderIdExt, ChainSpecProvider, HeaderProvider}; use reth_provider::{BlockIdReader, BlockReaderIdExt, ChainSpecProvider, HeaderProvider};
use reth_rpc_eth_api::helpers::{EthFees, LoadBlock, LoadFee}; use reth_rpc_eth_api::helpers::{EthFees, LoadBlock, LoadFee};
@ -15,10 +16,12 @@ impl<Provider, Pool, Network, EvmConfig> EthFees for EthApi<Provider, Pool, Netw
impl<Provider, Pool, Network, EvmConfig> LoadFee for EthApi<Provider, Pool, Network, EvmConfig> impl<Provider, Pool, Network, EvmConfig> LoadFee for EthApi<Provider, Pool, Network, EvmConfig>
where where
Self: LoadBlock, Self: LoadBlock,
Provider: BlockReaderIdExt + HeaderProvider + ChainSpecProvider, Provider: BlockReaderIdExt + HeaderProvider + ChainSpecProvider<ChainSpec = ChainSpec>,
{ {
#[inline] #[inline]
fn provider(&self) -> impl BlockIdReader + HeaderProvider + ChainSpecProvider { fn provider(
&self,
) -> impl BlockIdReader + HeaderProvider + ChainSpecProvider<ChainSpec = ChainSpec> {
self.inner.provider() self.inner.provider()
} }

View File

@ -1,5 +1,6 @@
//! Support for building a pending block with transactions from local view of mempool. //! Support for building a pending block with transactions from local view of mempool.
use reth_chainspec::ChainSpec;
use reth_evm::ConfigureEvm; use reth_evm::ConfigureEvm;
use reth_provider::{BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProviderFactory}; use reth_provider::{BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProviderFactory};
use reth_rpc_eth_api::helpers::{LoadPendingBlock, SpawnBlocking}; use reth_rpc_eth_api::helpers::{LoadPendingBlock, SpawnBlocking};
@ -12,14 +13,20 @@ impl<Provider, Pool, Network, EvmConfig> LoadPendingBlock
for EthApi<Provider, Pool, Network, EvmConfig> for EthApi<Provider, Pool, Network, EvmConfig>
where where
Self: SpawnBlocking, Self: SpawnBlocking,
Provider: BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory, Provider: BlockReaderIdExt
+ EvmEnvProvider
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ StateProviderFactory,
Pool: TransactionPool, Pool: TransactionPool,
EvmConfig: ConfigureEvm, EvmConfig: ConfigureEvm,
{ {
#[inline] #[inline]
fn provider( fn provider(
&self, &self,
) -> impl BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory { ) -> impl BlockReaderIdExt
+ EvmEnvProvider
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ StateProviderFactory {
self.inner.provider() self.inner.provider()
} }

View File

@ -1,3 +1,4 @@
use reth_chainspec::ChainSpec;
use reth_network_api::NetworkInfo; use reth_network_api::NetworkInfo;
use reth_primitives::U256; use reth_primitives::U256;
use reth_provider::{BlockNumReader, ChainSpecProvider, StageCheckpointReader}; use reth_provider::{BlockNumReader, ChainSpecProvider, StageCheckpointReader};
@ -9,11 +10,15 @@ use crate::EthApi;
impl<Provider, Pool, Network, EvmConfig> EthApiSpec for EthApi<Provider, Pool, Network, EvmConfig> impl<Provider, Pool, Network, EvmConfig> EthApiSpec for EthApi<Provider, Pool, Network, EvmConfig>
where where
Pool: TransactionPool + 'static, Pool: TransactionPool + 'static,
Provider: ChainSpecProvider + BlockNumReader + StageCheckpointReader + 'static, Provider:
ChainSpecProvider<ChainSpec = ChainSpec> + BlockNumReader + StageCheckpointReader + 'static,
Network: NetworkInfo + 'static, Network: NetworkInfo + 'static,
EvmConfig: Send + Sync, EvmConfig: Send + Sync,
{ {
fn provider(&self) -> impl ChainSpecProvider + BlockNumReader + StageCheckpointReader { fn provider(
&self,
) -> impl ChainSpecProvider<ChainSpec = ChainSpec> + BlockNumReader + StageCheckpointReader
{
self.inner.provider() self.inner.provider()
} }

View File

@ -1,5 +1,6 @@
//! Contains RPC handler implementations specific to state. //! Contains RPC handler implementations specific to state.
use reth_chainspec::ChainSpec;
use reth_provider::{ChainSpecProvider, StateProviderFactory}; use reth_provider::{ChainSpecProvider, StateProviderFactory};
use reth_transaction_pool::TransactionPool; use reth_transaction_pool::TransactionPool;
@ -20,11 +21,11 @@ where
impl<Provider, Pool, Network, EvmConfig> LoadState for EthApi<Provider, Pool, Network, EvmConfig> impl<Provider, Pool, Network, EvmConfig> LoadState for EthApi<Provider, Pool, Network, EvmConfig>
where where
Self: Send + Sync, Self: Send + Sync,
Provider: StateProviderFactory + ChainSpecProvider, Provider: StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec>,
Pool: TransactionPool, Pool: TransactionPool,
{ {
#[inline] #[inline]
fn provider(&self) -> impl StateProviderFactory + ChainSpecProvider { fn provider(&self) -> impl StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec> {
self.inner.provider() self.inner.provider()
} }

View File

@ -2,7 +2,7 @@ use std::{collections::HashSet, sync::Arc};
use async_trait::async_trait; use async_trait::async_trait;
use jsonrpsee::core::RpcResult; use jsonrpsee::core::RpcResult;
use reth_chainspec::EthereumHardforks; use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_consensus_common::calc::{ use reth_consensus_common::calc::{
base_block_reward, base_block_reward_pre_merge, block_reward, ommer_reward, base_block_reward, base_block_reward_pre_merge, block_reward, ommer_reward,
}; };
@ -75,7 +75,11 @@ impl<Provider, Eth> TraceApi<Provider, Eth> {
impl<Provider, Eth> TraceApi<Provider, Eth> impl<Provider, Eth> TraceApi<Provider, Eth>
where where
Provider: BlockReader + StateProviderFactory + EvmEnvProvider + ChainSpecProvider + 'static, Provider: BlockReader
+ StateProviderFactory
+ EvmEnvProvider
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ 'static,
Eth: TraceExt + 'static, Eth: TraceExt + 'static,
{ {
/// Executes the given call and returns a number of possible traces for it. /// Executes the given call and returns a number of possible traces for it.
@ -547,7 +551,11 @@ where
#[async_trait] #[async_trait]
impl<Provider, Eth> TraceApiServer for TraceApi<Provider, Eth> impl<Provider, Eth> TraceApiServer for TraceApi<Provider, Eth>
where where
Provider: BlockReader + StateProviderFactory + EvmEnvProvider + ChainSpecProvider + 'static, Provider: BlockReader
+ StateProviderFactory
+ EvmEnvProvider
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ 'static,
Eth: TraceExt + 'static, Eth: TraceExt + 'static,
{ {
/// Executes the given call and returns a number of possible traces for it. /// Executes the given call and returns a number of possible traces for it.

View File

@ -41,9 +41,9 @@ use tracing::trace;
/// from database storage and from the blockchain tree (pending state etc.) It is a simple wrapper /// from database storage and from the blockchain tree (pending state etc.) It is a simple wrapper
/// type that holds an instance of the database and the blockchain tree. /// type that holds an instance of the database and the blockchain tree.
#[derive(Debug)] #[derive(Debug)]
pub struct BlockchainProvider2<DB> { pub struct BlockchainProvider2<DB, Spec = ChainSpec> {
/// Provider type used to access the database. /// Provider type used to access the database.
database: ProviderFactory<DB>, database: ProviderFactory<DB, Spec>,
/// Tracks the chain info wrt forkchoice updates and in memory canonical /// Tracks the chain info wrt forkchoice updates and in memory canonical
/// state. /// state.
pub(super) canonical_in_memory_state: CanonicalInMemoryState, pub(super) canonical_in_memory_state: CanonicalInMemoryState,
@ -1173,6 +1173,8 @@ impl<DB> ChainSpecProvider for BlockchainProvider2<DB>
where where
DB: Send + Sync, DB: Send + Sync,
{ {
type ChainSpec = ChainSpec;
fn chain_spec(&self) -> Arc<ChainSpec> { fn chain_spec(&self) -> Arc<ChainSpec> {
self.database.chain_spec() self.database.chain_spec()
} }

View File

@ -7,7 +7,7 @@ use crate::{
PruneCheckpointReader, RequestsProvider, StageCheckpointReader, StateProviderBox, PruneCheckpointReader, RequestsProvider, StageCheckpointReader, StateProviderBox,
StaticFileProviderFactory, TransactionVariant, TransactionsProvider, WithdrawalsProvider, StaticFileProviderFactory, TransactionVariant, TransactionsProvider, WithdrawalsProvider,
}; };
use reth_chainspec::{ChainInfo, ChainSpec}; use reth_chainspec::{ChainInfo, ChainSpec, EthChainSpec};
use reth_db::{init_db, mdbx::DatabaseArguments, DatabaseEnv}; use reth_db::{init_db, mdbx::DatabaseArguments, DatabaseEnv};
use reth_db_api::{database::Database, models::StoredBlockBodyIndices}; use reth_db_api::{database::Database, models::StoredBlockBodyIndices};
use reth_errors::{RethError, RethResult}; use reth_errors::{RethError, RethResult};
@ -39,11 +39,11 @@ mod metrics;
/// ///
/// This provider implements most provider or provider factory traits. /// This provider implements most provider or provider factory traits.
#[derive(Debug)] #[derive(Debug)]
pub struct ProviderFactory<DB> { pub struct ProviderFactory<DB, Spec = ChainSpec> {
/// Database /// Database
db: Arc<DB>, db: Arc<DB>,
/// Chain spec /// Chain spec
chain_spec: Arc<ChainSpec>, chain_spec: Arc<Spec>,
/// Static File Provider /// Static File Provider
static_file_provider: StaticFileProvider, static_file_provider: StaticFileProvider,
/// Optional pruning configuration /// Optional pruning configuration
@ -569,10 +569,12 @@ impl<DB: Database> EvmEnvProvider for ProviderFactory<DB> {
} }
} }
impl<DB> ChainSpecProvider for ProviderFactory<DB> impl<DB, ChainSpec> ChainSpecProvider for ProviderFactory<DB, ChainSpec>
where where
DB: Send + Sync, DB: Send + Sync,
ChainSpec: EthChainSpec,
{ {
type ChainSpec = ChainSpec;
fn chain_spec(&self) -> Arc<ChainSpec> { fn chain_spec(&self) -> Arc<ChainSpec> {
self.chain_spec.clone() self.chain_spec.clone()
} }
@ -591,7 +593,7 @@ impl<DB: Database> PruneCheckpointReader for ProviderFactory<DB> {
} }
} }
impl<DB> Clone for ProviderFactory<DB> { impl<DB, Spec> Clone for ProviderFactory<DB, Spec> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { Self {
db: Arc::clone(&self.db), db: Arc::clone(&self.db),

View File

@ -13,7 +13,7 @@ use reth_blockchain_tree_api::{
InsertPayloadOk, InsertPayloadOk,
}; };
use reth_chain_state::{ChainInfoTracker, ForkChoiceNotifications, ForkChoiceSubscriptions}; use reth_chain_state::{ChainInfoTracker, ForkChoiceNotifications, ForkChoiceSubscriptions};
use reth_chainspec::{ChainInfo, ChainSpec}; use reth_chainspec::{ChainInfo, ChainSpec, EthChainSpec};
use reth_db_api::{ use reth_db_api::{
database::Database, database::Database,
models::{AccountBeforeTx, StoredBlockBodyIndices}, models::{AccountBeforeTx, StoredBlockBodyIndices},
@ -68,16 +68,16 @@ pub use blockchain_provider::BlockchainProvider2;
/// from database storage and from the blockchain tree (pending state etc.) It is a simple wrapper /// from database storage and from the blockchain tree (pending state etc.) It is a simple wrapper
/// type that holds an instance of the database and the blockchain tree. /// type that holds an instance of the database and the blockchain tree.
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct BlockchainProvider<DB> { pub struct BlockchainProvider<DB, Spec = ChainSpec> {
/// Provider type used to access the database. /// Provider type used to access the database.
database: ProviderFactory<DB>, database: ProviderFactory<DB, Spec>,
/// The blockchain tree instance. /// The blockchain tree instance.
tree: Arc<dyn TreeViewer>, tree: Arc<dyn TreeViewer>,
/// Tracks the chain info wrt forkchoice updates /// Tracks the chain info wrt forkchoice updates
chain_info: ChainInfoTracker, chain_info: ChainInfoTracker,
} }
impl<DB> Clone for BlockchainProvider<DB> { impl<DB, Spec> Clone for BlockchainProvider<DB, Spec> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { Self {
database: self.database.clone(), database: self.database.clone(),
@ -613,11 +613,14 @@ where
} }
} }
impl<DB> ChainSpecProvider for BlockchainProvider<DB> impl<DB, ChainSpec> ChainSpecProvider for BlockchainProvider<DB, ChainSpec>
where where
DB: Send + Sync, DB: Send + Sync,
ChainSpec: EthChainSpec,
{ {
fn chain_spec(&self) -> Arc<ChainSpec> { type ChainSpec = ChainSpec;
fn chain_spec(&self) -> Arc<Self::ChainSpec> {
self.database.chain_spec() self.database.chain_spec()
} }
} }

View File

@ -197,6 +197,8 @@ impl HeaderProvider for MockEthProvider {
} }
impl ChainSpecProvider for MockEthProvider { impl ChainSpecProvider for MockEthProvider {
type ChainSpec = ChainSpec;
fn chain_spec(&self) -> Arc<ChainSpec> { fn chain_spec(&self) -> Arc<ChainSpec> {
self.chain_spec.clone() self.chain_spec.clone()
} }

View File

@ -44,6 +44,8 @@ use crate::{
pub struct NoopProvider; pub struct NoopProvider;
impl ChainSpecProvider for NoopProvider { impl ChainSpecProvider for NoopProvider {
type ChainSpec = ChainSpec;
fn chain_spec(&self) -> Arc<ChainSpec> { fn chain_spec(&self) -> Arc<ChainSpec> {
MAINNET.clone() MAINNET.clone()
} }

View File

@ -6,17 +6,18 @@ use crate::{
StaticFileProviderFactory, TransactionsProvider, StaticFileProviderFactory, TransactionsProvider,
}; };
use reth_chain_state::{CanonStateSubscriptions, ForkChoiceSubscriptions}; use reth_chain_state::{CanonStateSubscriptions, ForkChoiceSubscriptions};
use reth_chainspec::{ChainSpec, EthChainSpec};
use reth_db_api::database::Database; use reth_db_api::database::Database;
/// Helper trait to unify all provider traits for simplicity. /// Helper trait to unify all provider traits for simplicity.
pub trait FullProvider<DB: Database>: pub trait FullProvider<DB: Database, ChainSpec: EthChainSpec>:
DatabaseProviderFactory<DB> DatabaseProviderFactory<DB>
+ StaticFileProviderFactory + StaticFileProviderFactory
+ BlockReaderIdExt + BlockReaderIdExt
+ AccountReader + AccountReader
+ StateProviderFactory + StateProviderFactory
+ EvmEnvProvider + EvmEnvProvider
+ ChainSpecProvider + ChainSpecProvider<ChainSpec = ChainSpec>
+ ChangeSetReader + ChangeSetReader
+ CanonStateSubscriptions + CanonStateSubscriptions
+ ForkChoiceSubscriptions + ForkChoiceSubscriptions
@ -27,14 +28,14 @@ pub trait FullProvider<DB: Database>:
{ {
} }
impl<T, DB: Database> FullProvider<DB> for T where impl<T, DB: Database, ChainSpec: EthChainSpec> FullProvider<DB, ChainSpec> for T where
T: DatabaseProviderFactory<DB> T: DatabaseProviderFactory<DB>
+ StaticFileProviderFactory + StaticFileProviderFactory
+ BlockReaderIdExt + BlockReaderIdExt
+ AccountReader + AccountReader
+ StateProviderFactory + StateProviderFactory
+ EvmEnvProvider + EvmEnvProvider
+ ChainSpecProvider + ChainSpecProvider<ChainSpec = ChainSpec>
+ ChangeSetReader + ChangeSetReader
+ CanonStateSubscriptions + CanonStateSubscriptions
+ ForkChoiceSubscriptions + ForkChoiceSubscriptions
@ -50,7 +51,7 @@ impl<T, DB: Database> FullProvider<DB> for T where
pub trait FullRpcProvider: pub trait FullRpcProvider:
StateProviderFactory StateProviderFactory
+ EvmEnvProvider + EvmEnvProvider
+ ChainSpecProvider + ChainSpecProvider<ChainSpec = ChainSpec>
+ BlockReaderIdExt + BlockReaderIdExt
+ HeaderProvider + HeaderProvider
+ TransactionsProvider + TransactionsProvider
@ -64,7 +65,7 @@ pub trait FullRpcProvider:
impl<T> FullRpcProvider for T where impl<T> FullRpcProvider for T where
T: StateProviderFactory T: StateProviderFactory
+ EvmEnvProvider + EvmEnvProvider
+ ChainSpecProvider + ChainSpecProvider<ChainSpec = ChainSpec>
+ BlockReaderIdExt + BlockReaderIdExt
+ HeaderProvider + HeaderProvider
+ TransactionsProvider + TransactionsProvider

View File

@ -108,7 +108,7 @@
//! ``` //! ```
//! use futures_util::Stream; //! use futures_util::Stream;
//! use reth_chain_state::CanonStateNotification; //! use reth_chain_state::CanonStateNotification;
//! use reth_chainspec::{MAINNET, ChainSpecProvider}; //! use reth_chainspec::{MAINNET, ChainSpecProvider, ChainSpec};
//! use reth_storage_api::{BlockReaderIdExt, StateProviderFactory}; //! use reth_storage_api::{BlockReaderIdExt, StateProviderFactory};
//! use reth_tasks::TokioTaskExecutor; //! use reth_tasks::TokioTaskExecutor;
//! use reth_tasks::TaskSpawner; //! use reth_tasks::TaskSpawner;
@ -118,7 +118,7 @@
//! use reth_transaction_pool::maintain::{maintain_transaction_pool_future}; //! use reth_transaction_pool::maintain::{maintain_transaction_pool_future};
//! //!
//! async fn t<C, St>(client: C, stream: St) //! async fn t<C, St>(client: C, stream: St)
//! where C: StateProviderFactory + BlockReaderIdExt + ChainSpecProvider + Clone + 'static, //! where C: StateProviderFactory + BlockReaderIdExt + ChainSpecProvider<ChainSpec = ChainSpec> + Clone + 'static,
//! St: Stream<Item = CanonStateNotification> + Send + Unpin + 'static, //! St: Stream<Item = CanonStateNotification> + Send + Unpin + 'static,
//! { //! {
//! let blob_store = InMemoryBlobStore::default(); //! let blob_store = InMemoryBlobStore::default();

View File

@ -12,7 +12,7 @@ use futures_util::{
FutureExt, Stream, StreamExt, FutureExt, Stream, StreamExt,
}; };
use reth_chain_state::CanonStateNotification; use reth_chain_state::CanonStateNotification;
use reth_chainspec::ChainSpecProvider; use reth_chainspec::{ChainSpec, ChainSpecProvider};
use reth_execution_types::ExecutionOutcome; use reth_execution_types::ExecutionOutcome;
use reth_fs_util::FsPathError; use reth_fs_util::FsPathError;
use reth_primitives::{ use reth_primitives::{
@ -73,7 +73,12 @@ pub fn maintain_transaction_pool_future<Client, P, St, Tasks>(
config: MaintainPoolConfig, config: MaintainPoolConfig,
) -> BoxFuture<'static, ()> ) -> BoxFuture<'static, ()>
where where
Client: StateProviderFactory + BlockReaderIdExt + ChainSpecProvider + Clone + Send + 'static, Client: StateProviderFactory
+ BlockReaderIdExt
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ Clone
+ Send
+ 'static,
P: TransactionPoolExt + 'static, P: TransactionPoolExt + 'static,
St: Stream<Item = CanonStateNotification> + Send + Unpin + 'static, St: Stream<Item = CanonStateNotification> + Send + Unpin + 'static,
Tasks: TaskSpawner + 'static, Tasks: TaskSpawner + 'static,
@ -94,7 +99,12 @@ pub async fn maintain_transaction_pool<Client, P, St, Tasks>(
task_spawner: Tasks, task_spawner: Tasks,
config: MaintainPoolConfig, config: MaintainPoolConfig,
) where ) where
Client: StateProviderFactory + BlockReaderIdExt + ChainSpecProvider + Clone + Send + 'static, Client: StateProviderFactory
+ BlockReaderIdExt
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ Clone
+ Send
+ 'static,
P: TransactionPoolExt + 'static, P: TransactionPoolExt + 'static,
St: Stream<Item = CanonStateNotification> + Send + Unpin + 'static, St: Stream<Item = CanonStateNotification> + Send + Unpin + 'static,
Tasks: TaskSpawner + 'static, Tasks: TaskSpawner + 'static,

View File

@ -196,6 +196,7 @@ impl NodeTypes for MyCustomNode {
type Primitives = (); type Primitives = ();
// use the custom engine types // use the custom engine types
type Engine = CustomEngineTypes; type Engine = CustomEngineTypes;
type ChainSpec = ChainSpec;
} }
/// Implement the Node trait for the custom node /// Implement the Node trait for the custom node
@ -203,7 +204,7 @@ impl NodeTypes for MyCustomNode {
/// This provides a preset configuration for the node /// This provides a preset configuration for the node
impl<N> Node<N> for MyCustomNode impl<N> Node<N> for MyCustomNode
where where
N: FullNodeTypes<Engine = CustomEngineTypes>, N: FullNodeTypes<Engine = CustomEngineTypes, ChainSpec = ChainSpec>,
{ {
type ComponentsBuilder = ComponentsBuilder< type ComponentsBuilder = ComponentsBuilder<
N, N,
@ -233,7 +234,7 @@ pub struct CustomPayloadServiceBuilder;
impl<Node, Pool> PayloadServiceBuilder<Node, Pool> for CustomPayloadServiceBuilder impl<Node, Pool> PayloadServiceBuilder<Node, Pool> for CustomPayloadServiceBuilder
where where
Node: FullNodeTypes<Engine = CustomEngineTypes>, Node: FullNodeTypes<Engine = CustomEngineTypes, ChainSpec = ChainSpec>,
Pool: TransactionPool + Unpin + 'static, Pool: TransactionPool + Unpin + 'static,
{ {
async fn spawn_payload_service( async fn spawn_payload_service(

View File

@ -144,7 +144,7 @@ pub struct MyExecutorBuilder;
impl<Node> ExecutorBuilder<Node> for MyExecutorBuilder impl<Node> ExecutorBuilder<Node> for MyExecutorBuilder
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
{ {
type EVM = MyEvmConfig; type EVM = MyEvmConfig;
type Executor = EthExecutorProvider<Self::EVM>; type Executor = EthExecutorProvider<Self::EVM>;

View File

@ -11,6 +11,7 @@ reth.workspace = true
reth-node-ethereum.workspace = true reth-node-ethereum.workspace = true
reth-transaction-pool.workspace = true reth-transaction-pool.workspace = true
reth-tracing.workspace = true reth-tracing.workspace = true
reth-chainspec.workspace = true
eyre.workspace = true eyre.workspace = true

View File

@ -10,6 +10,7 @@ use reth::{
blobstore::InMemoryBlobStore, EthTransactionPool, TransactionValidationTaskExecutor, blobstore::InMemoryBlobStore, EthTransactionPool, TransactionValidationTaskExecutor,
}, },
}; };
use reth_chainspec::ChainSpec;
use reth_node_ethereum::{node::EthereumAddOns, EthereumNode}; use reth_node_ethereum::{node::EthereumAddOns, EthereumNode};
use reth_tracing::tracing::{debug, info}; use reth_tracing::tracing::{debug, info};
use reth_transaction_pool::PoolConfig; use reth_transaction_pool::PoolConfig;
@ -45,7 +46,7 @@ pub struct CustomPoolBuilder {
/// This will be used to build the transaction pool and its maintenance tasks during launch. /// This will be used to build the transaction pool and its maintenance tasks during launch.
impl<Node> PoolBuilder<Node> for CustomPoolBuilder impl<Node> PoolBuilder<Node> for CustomPoolBuilder
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
{ {
type Pool = EthTransactionPool<Node::Provider, InMemoryBlobStore>; type Pool = EthTransactionPool<Node::Provider, InMemoryBlobStore>;

View File

@ -20,6 +20,7 @@ use reth::{
transaction_pool::TransactionPool, transaction_pool::TransactionPool,
}; };
use reth_basic_payload_builder::BasicPayloadJobGeneratorConfig; use reth_basic_payload_builder::BasicPayloadJobGeneratorConfig;
use reth_chainspec::ChainSpec;
use reth_node_ethereum::{node::EthereumAddOns, EthEngineTypes, EthereumNode}; use reth_node_ethereum::{node::EthereumAddOns, EthEngineTypes, EthereumNode};
use reth_payload_builder::PayloadBuilderService; use reth_payload_builder::PayloadBuilderService;
@ -32,7 +33,7 @@ pub struct CustomPayloadBuilder;
impl<Node, Pool> PayloadServiceBuilder<Node, Pool> for CustomPayloadBuilder impl<Node, Pool> PayloadServiceBuilder<Node, Pool> for CustomPayloadBuilder
where where
Node: FullNodeTypes<Engine = EthEngineTypes>, Node: FullNodeTypes<Engine = EthEngineTypes, ChainSpec = ChainSpec>,
Pool: TransactionPool + Unpin + 'static, Pool: TransactionPool + Unpin + 'static,
{ {
async fn spawn_payload_service( async fn spawn_payload_service(

View File

@ -207,7 +207,7 @@ pub struct MyExecutorBuilder {
impl<Node> ExecutorBuilder<Node> for MyExecutorBuilder impl<Node> ExecutorBuilder<Node> for MyExecutorBuilder
where where
Node: FullNodeTypes, Node: FullNodeTypes<ChainSpec = ChainSpec>,
{ {
type EVM = MyEvmConfig; type EVM = MyEvmConfig;
type Executor = EthExecutorProvider<Self::EVM>; type Executor = EthExecutorProvider<Self::EVM>;