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 = [
"eyre",
"reth",
"reth-chainspec",
"reth-node-ethereum",
"reth-tracing",
"reth-transaction-pool",
@ -7690,6 +7691,7 @@ dependencies = [
name = "reth-node-api"
version = "1.0.5"
dependencies = [
"reth-chainspec",
"reth-db-api",
"reth-engine-primitives",
"reth-evm",
@ -8031,6 +8033,7 @@ dependencies = [
"jsonrpsee",
"jsonrpsee-types",
"parking_lot 0.12.3",
"reth-chainspec",
"reth-evm",
"reth-evm-optimism",
"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.
mod spec;
mod api;
pub use api::EthChainSpec;
/// Chain specific 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"))]
use alloc::{boxed::Box, sync::Arc, vec::Vec};
use alloy_chains::{Chain, ChainKind, NamedChain};
@ -813,8 +813,11 @@ impl From<Genesis> for ChainSpec {
/// A trait for reading the current [`ChainSpec`].
#[auto_impl::auto_impl(&, Arc)]
pub trait ChainSpecProvider: Send + Sync {
/// The chain spec type.
type ChainSpec: EthChainSpec;
/// 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

View File

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

View File

@ -14,7 +14,7 @@ use reth_chainspec::ChainSpec;
use reth_db::{test_utils::TempDatabase, DatabaseEnv};
use reth_node_builder::{
components::NodeComponentsBuilder, rpc::EthApiBuilderProvider, FullNodeTypesAdapter, Node,
NodeAdapter, NodeAddOns, NodeComponents, RethFullAdapter,
NodeAdapter, NodeAddOns, NodeComponents, NodeTypes, RethFullAdapter,
};
use reth_provider::providers::BlockchainProvider;
use tracing::{span, Level};
@ -50,7 +50,7 @@ pub async fn setup<N>(
is_dev: bool,
) -> eyre::Result<(Vec<NodeHelperType<N, N::AddOns>>, TaskManager, Wallet)>
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::AddOns as NodeAddOns<Adapter<N>>>::EthApi:
FullEthApiServer + AddDevSigners + EthApiBuilderProvider<Adapter<N>>,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -206,7 +206,7 @@ where
/// Configures the types of the node.
pub fn with_types<T>(self) -> NodeBuilderWithTypes<RethFullAdapter<DB, T>>
where
T: NodeTypes,
T: NodeTypes<ChainSpec = ChainSpec>,
{
self.with_types_and_provider()
}
@ -216,8 +216,8 @@ where
self,
) -> NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>>
where
T: NodeTypes,
P: FullProvider<DB>,
T: NodeTypes<ChainSpec = ChainSpec>,
P: FullProvider<DB, T::ChainSpec>,
{
NodeBuilderWithTypes::new(self.config, self.database)
}
@ -230,7 +230,7 @@ where
node: N,
) -> NodeBuilderWithComponents<RethFullAdapter<DB, N>, N::ComponentsBuilder, N::AddOns>
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>()
}
@ -264,7 +264,7 @@ where
/// Configures the types of the node.
pub fn with_types<T>(self) -> WithLaunchContext<NodeBuilderWithTypes<RethFullAdapter<DB, T>>>
where
T: NodeTypes,
T: NodeTypes<ChainSpec = ChainSpec>,
{
WithLaunchContext { builder: self.builder.with_types(), task_executor: self.task_executor }
}
@ -274,8 +274,8 @@ where
self,
) -> WithLaunchContext<NodeBuilderWithTypes<FullNodeTypesAdapter<T, DB, P>>>
where
T: NodeTypes,
P: FullProvider<DB>,
T: NodeTypes<ChainSpec = ChainSpec>,
P: FullProvider<DB, T::ChainSpec>,
{
WithLaunchContext {
builder: self.builder.with_types_and_provider(),
@ -293,7 +293,7 @@ where
NodeBuilderWithComponents<RethFullAdapter<DB, N>, N::ComponentsBuilder, N::AddOns>,
>
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>()
}
@ -316,7 +316,7 @@ where
>,
>
where
N: Node<RethFullAdapter<DB, N>>,
N: Node<RethFullAdapter<DB, N>, ChainSpec = ChainSpec>,
N::AddOns: NodeAddOns<
NodeAdapter<
RethFullAdapter<DB, N>,
@ -469,7 +469,7 @@ where
impl<T, DB, CB, AO> WithLaunchContext<NodeBuilderWithComponents<RethFullAdapter<DB, T>, CB, AO>>
where
DB: Database + DatabaseMetrics + DatabaseMetadata + Clone + Unpin + 'static,
T: NodeTypes,
T: NodeTypes<ChainSpec = ChainSpec>,
CB: NodeComponentsBuilder<RethFullAdapter<DB, T>>,
AO: NodeAddOns<
NodeAdapter<RethFullAdapter<DB, T>, CB::Components>,
@ -540,7 +540,7 @@ impl<Node: FullNodeTypes> BuilderContext<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()
}

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -151,6 +151,7 @@ use jsonrpsee::{
},
Methods, RpcModule,
};
use reth_chainspec::ChainSpec;
use reth_engine_primitives::EngineTypes;
use reth_evm::ConfigureEvm;
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>
where
Network: NetworkInfo + Clone + 'static,
Provider: ChainSpecProvider<ChainSpec = ChainSpec>,
{
/// Instantiates `AdminApi`
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.
use futures::Future;
use reth_chainspec::ChainSpec;
use reth_primitives::U256;
use reth_provider::{BlockIdReader, BlockReaderIdExt, ChainSpecProvider, HeaderProvider};
use reth_rpc_eth_types::{
@ -239,7 +240,9 @@ pub trait LoadFee: LoadBlock {
// Returns a handle for reading data from disk.
///
/// 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.
///

View File

@ -4,7 +4,7 @@
use std::time::{Duration, Instant};
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_execution_types::ExecutionOutcome;
use reth_primitives::{
@ -47,7 +47,10 @@ pub trait LoadPendingBlock: EthApiTypes {
/// Data access in default (L1) trait method implementations.
fn provider(
&self,
) -> impl BlockReaderIdExt + EvmEnvProvider + ChainSpecProvider + StateProviderFactory;
) -> impl BlockReaderIdExt
+ EvmEnvProvider
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ StateProviderFactory;
/// Returns a handle for reading data from transaction pool.
///

View File

@ -18,7 +18,9 @@ use super::EthSigner;
#[auto_impl::auto_impl(&, Arc)]
pub trait EthApiSpec: Send + Sync {
/// 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.
fn network(&self) -> impl NetworkInfo;

View File

@ -2,6 +2,7 @@
//! RPC methods.
use futures::Future;
use reth_chainspec::ChainSpec;
use reth_errors::RethError;
use reth_evm::ConfigureEvmEnv;
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.
///
/// 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.
///

View File

@ -1,7 +1,7 @@
use alloy_rlp::{Decodable, Encodable};
use async_trait::async_trait;
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_primitives::{
Address, Block, BlockId, BlockNumberOrTag, Bytes, TransactionSignedEcRecovered, B256, U256,
@ -68,7 +68,7 @@ impl<Provider, Eth> DebugApi<Provider, Eth>
where
Provider: BlockReaderIdExt
+ HeaderProvider
+ ChainSpecProvider
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ StateProviderFactory
+ EvmEnvProvider
+ 'static,
@ -789,7 +789,7 @@ impl<Provider, Eth> DebugApiServer for DebugApi<Provider, Eth>
where
Provider: BlockReaderIdExt
+ HeaderProvider
+ ChainSpecProvider
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ StateProviderFactory
+ EvmEnvProvider
+ 'static,

View File

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

View File

@ -1,5 +1,6 @@
//! Contains RPC handler implementations for fee history.
use reth_chainspec::ChainSpec;
use reth_provider::{BlockIdReader, BlockReaderIdExt, ChainSpecProvider, HeaderProvider};
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>
where
Self: LoadBlock,
Provider: BlockReaderIdExt + HeaderProvider + ChainSpecProvider,
Provider: BlockReaderIdExt + HeaderProvider + ChainSpecProvider<ChainSpec = ChainSpec>,
{
#[inline]
fn provider(&self) -> impl BlockIdReader + HeaderProvider + ChainSpecProvider {
fn provider(
&self,
) -> impl BlockIdReader + HeaderProvider + ChainSpecProvider<ChainSpec = ChainSpec> {
self.inner.provider()
}

View File

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

View File

@ -1,3 +1,4 @@
use reth_chainspec::ChainSpec;
use reth_network_api::NetworkInfo;
use reth_primitives::U256;
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>
where
Pool: TransactionPool + 'static,
Provider: ChainSpecProvider + BlockNumReader + StageCheckpointReader + 'static,
Provider:
ChainSpecProvider<ChainSpec = ChainSpec> + BlockNumReader + StageCheckpointReader + 'static,
Network: NetworkInfo + 'static,
EvmConfig: Send + Sync,
{
fn provider(&self) -> impl ChainSpecProvider + BlockNumReader + StageCheckpointReader {
fn provider(
&self,
) -> impl ChainSpecProvider<ChainSpec = ChainSpec> + BlockNumReader + StageCheckpointReader
{
self.inner.provider()
}

View File

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

View File

@ -2,7 +2,7 @@ use std::{collections::HashSet, sync::Arc};
use async_trait::async_trait;
use jsonrpsee::core::RpcResult;
use reth_chainspec::EthereumHardforks;
use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_consensus_common::calc::{
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>
where
Provider: BlockReader + StateProviderFactory + EvmEnvProvider + ChainSpecProvider + 'static,
Provider: BlockReader
+ StateProviderFactory
+ EvmEnvProvider
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ 'static,
Eth: TraceExt + 'static,
{
/// Executes the given call and returns a number of possible traces for it.
@ -547,7 +551,11 @@ where
#[async_trait]
impl<Provider, Eth> TraceApiServer for TraceApi<Provider, Eth>
where
Provider: BlockReader + StateProviderFactory + EvmEnvProvider + ChainSpecProvider + 'static,
Provider: BlockReader
+ StateProviderFactory
+ EvmEnvProvider
+ ChainSpecProvider<ChainSpec = ChainSpec>
+ 'static,
Eth: TraceExt + 'static,
{
/// 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
/// type that holds an instance of the database and the blockchain tree.
#[derive(Debug)]
pub struct BlockchainProvider2<DB> {
pub struct BlockchainProvider2<DB, Spec = ChainSpec> {
/// 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
/// state.
pub(super) canonical_in_memory_state: CanonicalInMemoryState,
@ -1173,6 +1173,8 @@ impl<DB> ChainSpecProvider for BlockchainProvider2<DB>
where
DB: Send + Sync,
{
type ChainSpec = ChainSpec;
fn chain_spec(&self) -> Arc<ChainSpec> {
self.database.chain_spec()
}

View File

@ -7,7 +7,7 @@ use crate::{
PruneCheckpointReader, RequestsProvider, StageCheckpointReader, StateProviderBox,
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_api::{database::Database, models::StoredBlockBodyIndices};
use reth_errors::{RethError, RethResult};
@ -39,11 +39,11 @@ mod metrics;
///
/// This provider implements most provider or provider factory traits.
#[derive(Debug)]
pub struct ProviderFactory<DB> {
pub struct ProviderFactory<DB, Spec = ChainSpec> {
/// Database
db: Arc<DB>,
/// Chain spec
chain_spec: Arc<ChainSpec>,
chain_spec: Arc<Spec>,
/// Static File Provider
static_file_provider: StaticFileProvider,
/// 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
DB: Send + Sync,
ChainSpec: EthChainSpec,
{
type ChainSpec = ChainSpec;
fn chain_spec(&self) -> Arc<ChainSpec> {
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 {
Self {
db: Arc::clone(&self.db),

View File

@ -13,7 +13,7 @@ use reth_blockchain_tree_api::{
InsertPayloadOk,
};
use reth_chain_state::{ChainInfoTracker, ForkChoiceNotifications, ForkChoiceSubscriptions};
use reth_chainspec::{ChainInfo, ChainSpec};
use reth_chainspec::{ChainInfo, ChainSpec, EthChainSpec};
use reth_db_api::{
database::Database,
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
/// type that holds an instance of the database and the blockchain tree.
#[allow(missing_debug_implementations)]
pub struct BlockchainProvider<DB> {
pub struct BlockchainProvider<DB, Spec = ChainSpec> {
/// Provider type used to access the database.
database: ProviderFactory<DB>,
database: ProviderFactory<DB, Spec>,
/// The blockchain tree instance.
tree: Arc<dyn TreeViewer>,
/// Tracks the chain info wrt forkchoice updates
chain_info: ChainInfoTracker,
}
impl<DB> Clone for BlockchainProvider<DB> {
impl<DB, Spec> Clone for BlockchainProvider<DB, Spec> {
fn clone(&self) -> Self {
Self {
database: self.database.clone(),
@ -613,11 +613,14 @@ where
}
}
impl<DB> ChainSpecProvider for BlockchainProvider<DB>
impl<DB, ChainSpec> ChainSpecProvider for BlockchainProvider<DB, ChainSpec>
where
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()
}
}

View File

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

View File

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

View File

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

View File

@ -108,7 +108,7 @@
//! ```
//! use futures_util::Stream;
//! use reth_chain_state::CanonStateNotification;
//! use reth_chainspec::{MAINNET, ChainSpecProvider};
//! use reth_chainspec::{MAINNET, ChainSpecProvider, ChainSpec};
//! use reth_storage_api::{BlockReaderIdExt, StateProviderFactory};
//! use reth_tasks::TokioTaskExecutor;
//! use reth_tasks::TaskSpawner;
@ -118,7 +118,7 @@
//! use reth_transaction_pool::maintain::{maintain_transaction_pool_future};
//!
//! 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,
//! {
//! let blob_store = InMemoryBlobStore::default();

View File

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

View File

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

View File

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

View File

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

View File

@ -10,6 +10,7 @@ use reth::{
blobstore::InMemoryBlobStore, EthTransactionPool, TransactionValidationTaskExecutor,
},
};
use reth_chainspec::ChainSpec;
use reth_node_ethereum::{node::EthereumAddOns, EthereumNode};
use reth_tracing::tracing::{debug, info};
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.
impl<Node> PoolBuilder<Node> for CustomPoolBuilder
where
Node: FullNodeTypes,
Node: FullNodeTypes<ChainSpec = ChainSpec>,
{
type Pool = EthTransactionPool<Node::Provider, InMemoryBlobStore>;

View File

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

View File

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