mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
refactor: move ValidationApi setup to EthereumAddOns (#14342)
This commit is contained in:
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -8231,7 +8231,11 @@ dependencies = [
|
|||||||
"reth-provider",
|
"reth-provider",
|
||||||
"reth-revm",
|
"reth-revm",
|
||||||
"reth-rpc",
|
"reth-rpc",
|
||||||
|
"reth-rpc-api",
|
||||||
|
"reth-rpc-builder",
|
||||||
"reth-rpc-eth-api",
|
"reth-rpc-eth-api",
|
||||||
|
"reth-rpc-eth-types",
|
||||||
|
"reth-rpc-server-types",
|
||||||
"reth-tasks",
|
"reth-tasks",
|
||||||
"reth-tracing",
|
"reth-tracing",
|
||||||
"reth-transaction-pool",
|
"reth-transaction-pool",
|
||||||
@ -8929,6 +8933,7 @@ dependencies = [
|
|||||||
"reth-network-api",
|
"reth-network-api",
|
||||||
"reth-network-peers",
|
"reth-network-peers",
|
||||||
"reth-network-types",
|
"reth-network-types",
|
||||||
|
"reth-node-api",
|
||||||
"reth-primitives",
|
"reth-primitives",
|
||||||
"reth-primitives-traits",
|
"reth-primitives-traits",
|
||||||
"reth-provider",
|
"reth-provider",
|
||||||
|
|||||||
@ -25,10 +25,14 @@ reth-evm.workspace = true
|
|||||||
reth-evm-ethereum.workspace = true
|
reth-evm-ethereum.workspace = true
|
||||||
reth-consensus.workspace = true
|
reth-consensus.workspace = true
|
||||||
reth-rpc.workspace = true
|
reth-rpc.workspace = true
|
||||||
|
reth-rpc-builder.workspace = true
|
||||||
|
reth-rpc-api.workspace = true
|
||||||
|
reth-rpc-server-types.workspace = true
|
||||||
reth-node-api.workspace = true
|
reth-node-api.workspace = true
|
||||||
reth-chainspec.workspace = true
|
reth-chainspec.workspace = true
|
||||||
reth-revm = { workspace = true, features = ["std"] }
|
reth-revm = { workspace = true, features = ["std"] }
|
||||||
reth-trie-db.workspace = true
|
reth-trie-db.workspace = true
|
||||||
|
reth-rpc-eth-types.workspace = true
|
||||||
|
|
||||||
# revm with required ethereum features
|
# revm with required ethereum features
|
||||||
revm = { workspace = true, features = ["secp256k1", "blst", "c-kzg"] }
|
revm = { workspace = true, features = ["secp256k1", "blst", "c-kzg"] }
|
||||||
|
|||||||
@ -10,26 +10,31 @@ use reth_ethereum_engine_primitives::{
|
|||||||
EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes,
|
EthBuiltPayload, EthPayloadAttributes, EthPayloadBuilderAttributes,
|
||||||
};
|
};
|
||||||
use reth_ethereum_primitives::{EthPrimitives, PooledTransaction};
|
use reth_ethereum_primitives::{EthPrimitives, PooledTransaction};
|
||||||
use reth_evm::execute::BasicBlockExecutorProvider;
|
use reth_evm::{execute::BasicBlockExecutorProvider, ConfigureEvm};
|
||||||
use reth_evm_ethereum::execute::EthExecutionStrategyFactory;
|
use reth_evm_ethereum::execute::EthExecutionStrategyFactory;
|
||||||
use reth_network::{EthNetworkPrimitives, NetworkHandle, PeersInfo};
|
use reth_network::{EthNetworkPrimitives, NetworkHandle, PeersInfo};
|
||||||
use reth_node_api::{AddOnsContext, FullNodeComponents, TxTy};
|
use reth_node_api::{AddOnsContext, FullNodeComponents, NodeAddOns, TxTy};
|
||||||
use reth_node_builder::{
|
use reth_node_builder::{
|
||||||
components::{
|
components::{
|
||||||
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder, PoolBuilder,
|
ComponentsBuilder, ConsensusBuilder, ExecutorBuilder, NetworkBuilder, PoolBuilder,
|
||||||
},
|
},
|
||||||
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
|
node::{FullNodeTypes, NodeTypes, NodeTypesWithEngine},
|
||||||
rpc::{EngineValidatorBuilder, RpcAddOns},
|
rpc::{EngineValidatorAddOn, EngineValidatorBuilder, RethRpcAddOns, RpcAddOns, RpcHandle},
|
||||||
BuilderContext, Node, NodeAdapter, NodeComponentsBuilder, PayloadTypes,
|
BuilderContext, Node, NodeAdapter, NodeComponentsBuilder, PayloadTypes,
|
||||||
};
|
};
|
||||||
use reth_provider::{providers::ProviderFactoryBuilder, CanonStateSubscriptions, EthStorage};
|
use reth_provider::{providers::ProviderFactoryBuilder, CanonStateSubscriptions, EthStorage};
|
||||||
use reth_rpc::EthApi;
|
use reth_rpc::{eth::core::EthApiFor, ValidationApi};
|
||||||
|
use reth_rpc_api::servers::BlockSubmissionValidationApiServer;
|
||||||
|
use reth_rpc_builder::config::RethRpcServerConfig;
|
||||||
|
use reth_rpc_eth_types::{error::FromEvmError, EthApiError};
|
||||||
|
use reth_rpc_server_types::RethRpcModule;
|
||||||
use reth_tracing::tracing::{debug, info};
|
use reth_tracing::tracing::{debug, info};
|
||||||
use reth_transaction_pool::{
|
use reth_transaction_pool::{
|
||||||
blobstore::DiskFileBlobStore, EthTransactionPool, PoolTransaction, TransactionPool,
|
blobstore::DiskFileBlobStore, EthTransactionPool, PoolTransaction, TransactionPool,
|
||||||
TransactionValidationTaskExecutor,
|
TransactionValidationTaskExecutor,
|
||||||
};
|
};
|
||||||
use reth_trie_db::MerklePatriciaTrie;
|
use reth_trie_db::MerklePatriciaTrie;
|
||||||
|
use revm::primitives::TxEnv;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// Type configuration for a regular Ethereum node.
|
/// Type configuration for a regular Ethereum node.
|
||||||
@ -112,16 +117,92 @@ impl NodeTypesWithEngine for EthereumNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add-ons w.r.t. l1 ethereum.
|
/// Add-ons w.r.t. l1 ethereum.
|
||||||
pub type EthereumAddOns<N> = RpcAddOns<
|
#[derive(Debug)]
|
||||||
N,
|
pub struct EthereumAddOns<N: FullNodeComponents> {
|
||||||
EthApi<
|
inner: RpcAddOns<N, EthApiFor<N>, EthereumEngineValidatorBuilder>,
|
||||||
<N as FullNodeTypes>::Provider,
|
}
|
||||||
<N as FullNodeComponents>::Pool,
|
|
||||||
NetworkHandle,
|
impl<N: FullNodeComponents> Default for EthereumAddOns<N> {
|
||||||
<N as FullNodeComponents>::Evm,
|
fn default() -> Self {
|
||||||
|
Self { inner: Default::default() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N> NodeAddOns<N> for EthereumAddOns<N>
|
||||||
|
where
|
||||||
|
N: FullNodeComponents<
|
||||||
|
Types: NodeTypesWithEngine<
|
||||||
|
ChainSpec = ChainSpec,
|
||||||
|
Primitives = EthPrimitives,
|
||||||
|
Engine = EthEngineTypes,
|
||||||
>,
|
>,
|
||||||
EthereumEngineValidatorBuilder,
|
Evm: ConfigureEvm<TxEnv = TxEnv>,
|
||||||
>;
|
>,
|
||||||
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
|
{
|
||||||
|
type Handle = RpcHandle<N, EthApiFor<N>>;
|
||||||
|
|
||||||
|
async fn launch_add_ons(
|
||||||
|
self,
|
||||||
|
ctx: reth_node_api::AddOnsContext<'_, N>,
|
||||||
|
) -> eyre::Result<Self::Handle> {
|
||||||
|
let validation_api = ValidationApi::new(
|
||||||
|
ctx.node.provider().clone(),
|
||||||
|
Arc::new(ctx.node.consensus().clone()),
|
||||||
|
ctx.node.block_executor().clone(),
|
||||||
|
ctx.config.rpc.flashbots_config(),
|
||||||
|
Box::new(ctx.node.task_executor().clone()),
|
||||||
|
Arc::new(EthereumEngineValidator::new(ctx.config.chain.clone())),
|
||||||
|
);
|
||||||
|
|
||||||
|
self.inner
|
||||||
|
.launch_add_ons_with(ctx, move |modules, _| {
|
||||||
|
modules.merge_if_module_configured(
|
||||||
|
RethRpcModule::Flashbots,
|
||||||
|
validation_api.into_rpc(),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N> RethRpcAddOns<N> for EthereumAddOns<N>
|
||||||
|
where
|
||||||
|
N: FullNodeComponents<
|
||||||
|
Types: NodeTypesWithEngine<
|
||||||
|
ChainSpec = ChainSpec,
|
||||||
|
Primitives = EthPrimitives,
|
||||||
|
Engine = EthEngineTypes,
|
||||||
|
>,
|
||||||
|
Evm: ConfigureEvm<TxEnv = TxEnv>,
|
||||||
|
>,
|
||||||
|
EthApiError: FromEvmError<N::Evm>,
|
||||||
|
{
|
||||||
|
type EthApi = EthApiFor<N>;
|
||||||
|
|
||||||
|
fn hooks_mut(&mut self) -> &mut reth_node_builder::rpc::RpcHooks<N, Self::EthApi> {
|
||||||
|
self.inner.hooks_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N> EngineValidatorAddOn<N> for EthereumAddOns<N>
|
||||||
|
where
|
||||||
|
N: FullNodeComponents<
|
||||||
|
Types: NodeTypesWithEngine<
|
||||||
|
ChainSpec = ChainSpec,
|
||||||
|
Primitives = EthPrimitives,
|
||||||
|
Engine = EthEngineTypes,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
|
{
|
||||||
|
type Validator = EthereumEngineValidator;
|
||||||
|
|
||||||
|
async fn engine_validator(&self, ctx: &AddOnsContext<'_, N>) -> eyre::Result<Self::Validator> {
|
||||||
|
EthereumEngineValidatorBuilder::default().build(ctx).await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<N> Node<N> for EthereumNode
|
impl<N> Node<N> for EthereumNode
|
||||||
where
|
where
|
||||||
|
|||||||
@ -19,7 +19,6 @@ use reth_node_core::{
|
|||||||
version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA},
|
version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA},
|
||||||
};
|
};
|
||||||
use reth_payload_builder::PayloadStore;
|
use reth_payload_builder::PayloadStore;
|
||||||
use reth_primitives::EthPrimitives;
|
|
||||||
use reth_provider::ChainSpecProvider;
|
use reth_provider::ChainSpecProvider;
|
||||||
use reth_rpc::{
|
use reth_rpc::{
|
||||||
eth::{EthApiTypes, FullEthApiServer},
|
eth::{EthApiTypes, FullEthApiServer},
|
||||||
@ -35,7 +34,6 @@ use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi};
|
|||||||
use reth_tasks::TaskExecutor;
|
use reth_tasks::TaskExecutor;
|
||||||
use reth_tokio_util::EventSender;
|
use reth_tokio_util::EventSender;
|
||||||
use reth_tracing::tracing::{debug, info};
|
use reth_tracing::tracing::{debug, info};
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
/// Contains the handles to the spawned RPC servers.
|
/// Contains the handles to the spawned RPC servers.
|
||||||
///
|
///
|
||||||
@ -473,12 +471,7 @@ where
|
|||||||
.with_evm_config(node.evm_config().clone())
|
.with_evm_config(node.evm_config().clone())
|
||||||
.with_block_executor(node.block_executor().clone())
|
.with_block_executor(node.block_executor().clone())
|
||||||
.with_consensus(node.consensus().clone())
|
.with_consensus(node.consensus().clone())
|
||||||
.build_with_auth_server(
|
.build_with_auth_server(module_config, engine_api, eth_api_builder);
|
||||||
module_config,
|
|
||||||
engine_api,
|
|
||||||
eth_api_builder,
|
|
||||||
Arc::new(engine_validator),
|
|
||||||
);
|
|
||||||
|
|
||||||
// in dev mode we generate 20 random dev-signer accounts
|
// in dev mode we generate 20 random dev-signer accounts
|
||||||
if config.dev.dev {
|
if config.dev.dev {
|
||||||
@ -591,12 +584,8 @@ pub trait EthApiBuilder<N: FullNodeComponents>: 'static {
|
|||||||
fn build(ctx: &EthApiBuilderCtx<N>) -> Self;
|
fn build(ctx: &EthApiBuilderCtx<N>) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<N: FullNodeComponents<Provider: ChainSpecProvider>> EthApiBuilder<N>
|
||||||
N: FullNodeComponents<
|
for EthApi<N::Provider, N::Pool, N::Network, N::Evm>
|
||||||
Provider: ChainSpecProvider,
|
|
||||||
Types: NodeTypes<Primitives = EthPrimitives>,
|
|
||||||
>,
|
|
||||||
> EthApiBuilder<N> for EthApi<N::Provider, N::Pool, N::Network, N::Evm>
|
|
||||||
{
|
{
|
||||||
fn build(ctx: &EthApiBuilderCtx<N>) -> Self {
|
fn build(ctx: &EthApiBuilderCtx<N>) -> Self {
|
||||||
Self::with_spawner(ctx)
|
Self::with_spawner(ctx)
|
||||||
|
|||||||
@ -29,7 +29,6 @@ reth-rpc-server-types.workspace = true
|
|||||||
reth-tasks = { workspace = true, features = ["rayon"] }
|
reth-tasks = { workspace = true, features = ["rayon"] }
|
||||||
reth-transaction-pool.workspace = true
|
reth-transaction-pool.workspace = true
|
||||||
reth-evm.workspace = true
|
reth-evm.workspace = true
|
||||||
reth-engine-primitives.workspace = true
|
|
||||||
|
|
||||||
# rpc/net
|
# rpc/net
|
||||||
jsonrpsee = { workspace = true, features = ["server"] }
|
jsonrpsee = { workspace = true, features = ["server"] }
|
||||||
@ -66,6 +65,7 @@ reth-tracing.workspace = true
|
|||||||
reth-transaction-pool = { workspace = true, features = ["test-utils"] }
|
reth-transaction-pool = { workspace = true, features = ["test-utils"] }
|
||||||
reth-rpc-types-compat.workspace = true
|
reth-rpc-types-compat.workspace = true
|
||||||
reth-primitives.workspace = true
|
reth-primitives.workspace = true
|
||||||
|
reth-engine-primitives.workspace = true
|
||||||
|
|
||||||
alloy-primitives.workspace = true
|
alloy-primitives.workspace = true
|
||||||
alloy-rpc-types-eth.workspace = true
|
alloy-rpc-types-eth.workspace = true
|
||||||
|
|||||||
@ -31,14 +31,13 @@
|
|||||||
//! use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
//! use reth_transaction_pool::{PoolTransaction, TransactionPool};
|
||||||
//! use std::sync::Arc;
|
//! use std::sync::Arc;
|
||||||
//!
|
//!
|
||||||
//! pub async fn launch<Provider, Pool, Network, BlockExecutor, Consensus, Validator>(
|
//! pub async fn launch<Provider, Pool, Network, BlockExecutor, Consensus>(
|
||||||
//! provider: Provider,
|
//! provider: Provider,
|
||||||
//! pool: Pool,
|
//! pool: Pool,
|
||||||
//! network: Network,
|
//! network: Network,
|
||||||
//! evm_config: EthEvmConfig,
|
//! evm_config: EthEvmConfig,
|
||||||
//! block_executor: BlockExecutor,
|
//! block_executor: BlockExecutor,
|
||||||
//! consensus: Consensus,
|
//! consensus: Consensus,
|
||||||
//! validator: Validator,
|
|
||||||
//! ) where
|
//! ) where
|
||||||
//! Provider: FullRpcProvider<
|
//! Provider: FullRpcProvider<
|
||||||
//! Transaction = TransactionSigned,
|
//! Transaction = TransactionSigned,
|
||||||
@ -58,7 +57,6 @@
|
|||||||
//! Network: NetworkInfo + Peers + Clone + 'static,
|
//! Network: NetworkInfo + Peers + Clone + 'static,
|
||||||
//! BlockExecutor: BlockExecutorProvider<Primitives = Provider::Primitives>,
|
//! BlockExecutor: BlockExecutorProvider<Primitives = Provider::Primitives>,
|
||||||
//! Consensus: FullConsensus<Provider::Primitives, Error = ConsensusError> + Clone + 'static,
|
//! Consensus: FullConsensus<Provider::Primitives, Error = ConsensusError> + Clone + 'static,
|
||||||
//! Validator: PayloadValidator<Block = reth_primitives::Block, ExecutionData = ExecutionData>,
|
|
||||||
//! {
|
//! {
|
||||||
//! // configure the rpc module per transport
|
//! // configure the rpc module per transport
|
||||||
//! let transports = TransportRpcModuleConfig::default().with_http(vec![
|
//! let transports = TransportRpcModuleConfig::default().with_http(vec![
|
||||||
@ -76,7 +74,7 @@
|
|||||||
//! block_executor,
|
//! block_executor,
|
||||||
//! consensus,
|
//! consensus,
|
||||||
//! )
|
//! )
|
||||||
//! .build(transports, Box::new(EthApi::with_spawner), Arc::new(validator));
|
//! .build(transports, Box::new(EthApi::with_spawner));
|
||||||
//! let handle = RpcServerConfig::default()
|
//! let handle = RpcServerConfig::default()
|
||||||
//! .with_http(ServerBuilder::default())
|
//! .with_http(ServerBuilder::default())
|
||||||
//! .start(&transport_modules)
|
//! .start(&transport_modules)
|
||||||
@ -107,16 +105,7 @@
|
|||||||
//! use std::sync::Arc;
|
//! use std::sync::Arc;
|
||||||
//! use tokio::try_join;
|
//! use tokio::try_join;
|
||||||
//!
|
//!
|
||||||
//! pub async fn launch<
|
//! pub async fn launch<Provider, Pool, Network, EngineApi, EngineT, BlockExecutor, Consensus>(
|
||||||
//! Provider,
|
|
||||||
//! Pool,
|
|
||||||
//! Network,
|
|
||||||
//! EngineApi,
|
|
||||||
//! EngineT,
|
|
||||||
//! BlockExecutor,
|
|
||||||
//! Consensus,
|
|
||||||
//! Validator,
|
|
||||||
//! >(
|
|
||||||
//! provider: Provider,
|
//! provider: Provider,
|
||||||
//! pool: Pool,
|
//! pool: Pool,
|
||||||
//! network: Network,
|
//! network: Network,
|
||||||
@ -124,7 +113,6 @@
|
|||||||
//! evm_config: EthEvmConfig,
|
//! evm_config: EthEvmConfig,
|
||||||
//! block_executor: BlockExecutor,
|
//! block_executor: BlockExecutor,
|
||||||
//! consensus: Consensus,
|
//! consensus: Consensus,
|
||||||
//! validator: Validator,
|
|
||||||
//! ) where
|
//! ) where
|
||||||
//! Provider: FullRpcProvider<
|
//! Provider: FullRpcProvider<
|
||||||
//! Transaction = TransactionSigned,
|
//! Transaction = TransactionSigned,
|
||||||
@ -144,7 +132,6 @@
|
|||||||
//! Network: NetworkInfo + Peers + Clone + 'static,
|
//! Network: NetworkInfo + Peers + Clone + 'static,
|
||||||
//! BlockExecutor: BlockExecutorProvider<Primitives = Provider::Primitives>,
|
//! BlockExecutor: BlockExecutorProvider<Primitives = Provider::Primitives>,
|
||||||
//! Consensus: FullConsensus<Provider::Primitives, Error = ConsensusError> + Clone + 'static,
|
//! Consensus: FullConsensus<Provider::Primitives, Error = ConsensusError> + Clone + 'static,
|
||||||
//! Validator: PayloadValidator<Block = reth_primitives::Block, ExecutionData = ExecutionData>,
|
|
||||||
//! {
|
//! {
|
||||||
//! // configure the rpc module per transport
|
//! // configure the rpc module per transport
|
||||||
//! let transports = TransportRpcModuleConfig::default().with_http(vec![
|
//! let transports = TransportRpcModuleConfig::default().with_http(vec![
|
||||||
@ -164,12 +151,8 @@
|
|||||||
//! );
|
//! );
|
||||||
//!
|
//!
|
||||||
//! // configure the server modules
|
//! // configure the server modules
|
||||||
//! let (modules, auth_module, _registry) = builder.build_with_auth_server(
|
//! let (modules, auth_module, _registry) =
|
||||||
//! transports,
|
//! builder.build_with_auth_server(transports, engine_api, Box::new(EthApi::with_spawner));
|
||||||
//! engine_api,
|
|
||||||
//! Box::new(EthApi::with_spawner),
|
|
||||||
//! Arc::new(validator),
|
|
||||||
//! );
|
|
||||||
//!
|
//!
|
||||||
//! // start the servers
|
//! // start the servers
|
||||||
//! let auth_config = AuthServerConfig::builder(JwtSecret::random()).build();
|
//! let auth_config = AuthServerConfig::builder(JwtSecret::random()).build();
|
||||||
@ -211,7 +194,6 @@ use jsonrpsee::{
|
|||||||
};
|
};
|
||||||
use reth_chainspec::EthereumHardforks;
|
use reth_chainspec::EthereumHardforks;
|
||||||
use reth_consensus::{ConsensusError, FullConsensus};
|
use reth_consensus::{ConsensusError, FullConsensus};
|
||||||
use reth_engine_primitives::{ExecutionData, PayloadValidator};
|
|
||||||
use reth_evm::{execute::BlockExecutorProvider, ConfigureEvm};
|
use reth_evm::{execute::BlockExecutorProvider, ConfigureEvm};
|
||||||
use reth_network_api::{noop::NoopNetwork, NetworkInfo, Peers};
|
use reth_network_api::{noop::NoopNetwork, NetworkInfo, Peers};
|
||||||
use reth_primitives::NodePrimitives;
|
use reth_primitives::NodePrimitives;
|
||||||
@ -221,7 +203,7 @@ use reth_provider::{
|
|||||||
};
|
};
|
||||||
use reth_rpc::{
|
use reth_rpc::{
|
||||||
AdminApi, DebugApi, EngineEthApi, EthBundle, MinerApi, NetApi, OtterscanApi, RPCApi, RethApi,
|
AdminApi, DebugApi, EngineEthApi, EthBundle, MinerApi, NetApi, OtterscanApi, RPCApi, RethApi,
|
||||||
TraceApi, TxPoolApi, ValidationApi, ValidationApiConfig, Web3Api,
|
TraceApi, TxPoolApi, ValidationApiConfig, Web3Api,
|
||||||
};
|
};
|
||||||
use reth_rpc_api::servers::*;
|
use reth_rpc_api::servers::*;
|
||||||
use reth_rpc_eth_api::{
|
use reth_rpc_eth_api::{
|
||||||
@ -282,9 +264,6 @@ pub async fn launch<Provider, Pool, Network, Tasks, EvmConfig, EthApi, BlockExec
|
|||||||
eth: DynEthApiBuilder<Provider, Pool, EvmConfig, Network, Tasks, EthApi>,
|
eth: DynEthApiBuilder<Provider, Pool, EvmConfig, Network, Tasks, EthApi>,
|
||||||
block_executor: BlockExecutor,
|
block_executor: BlockExecutor,
|
||||||
consensus: Arc<dyn FullConsensus<BlockExecutor::Primitives, Error = ConsensusError>>,
|
consensus: Arc<dyn FullConsensus<BlockExecutor::Primitives, Error = ConsensusError>>,
|
||||||
payload_validator: Arc<
|
|
||||||
dyn PayloadValidator<Block = Provider::Block, ExecutionData = ExecutionData>,
|
|
||||||
>,
|
|
||||||
) -> Result<RpcServerHandle, RpcError>
|
) -> Result<RpcServerHandle, RpcError>
|
||||||
where
|
where
|
||||||
Provider: FullRpcProvider<
|
Provider: FullRpcProvider<
|
||||||
@ -323,7 +302,7 @@ where
|
|||||||
block_executor,
|
block_executor,
|
||||||
consensus,
|
consensus,
|
||||||
)
|
)
|
||||||
.build(module_config, eth, payload_validator),
|
.build(module_config, eth),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
@ -614,9 +593,6 @@ where
|
|||||||
module_config: TransportRpcModuleConfig,
|
module_config: TransportRpcModuleConfig,
|
||||||
engine: impl IntoEngineApiRpcModule,
|
engine: impl IntoEngineApiRpcModule,
|
||||||
eth: DynEthApiBuilder<Provider, Pool, EvmConfig, Network, Tasks, EthApi>,
|
eth: DynEthApiBuilder<Provider, Pool, EvmConfig, Network, Tasks, EthApi>,
|
||||||
payload_validator: Arc<
|
|
||||||
dyn PayloadValidator<Block = Provider::Block, ExecutionData = ExecutionData>,
|
|
||||||
>,
|
|
||||||
) -> (
|
) -> (
|
||||||
TransportRpcModules,
|
TransportRpcModules,
|
||||||
AuthRpcModule,
|
AuthRpcModule,
|
||||||
@ -646,7 +622,6 @@ where
|
|||||||
evm_config,
|
evm_config,
|
||||||
eth,
|
eth,
|
||||||
block_executor,
|
block_executor,
|
||||||
payload_validator,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let modules = registry.create_transport_rpc_modules(module_config);
|
let modules = registry.create_transport_rpc_modules(module_config);
|
||||||
@ -677,11 +652,9 @@ where
|
|||||||
/// use reth_transaction_pool::noop::NoopTransactionPool;
|
/// use reth_transaction_pool::noop::NoopTransactionPool;
|
||||||
/// use std::sync::Arc;
|
/// use std::sync::Arc;
|
||||||
///
|
///
|
||||||
/// fn init<Evm, Validator>(evm: Evm, validator: Validator)
|
/// fn init<Evm>(evm: Evm)
|
||||||
/// where
|
/// where
|
||||||
/// Evm: ConfigureEvm<Header = Header, Transaction = TransactionSigned> + 'static,
|
/// Evm: ConfigureEvm<Header = Header, Transaction = TransactionSigned> + 'static,
|
||||||
/// Validator: PayloadValidator<Block = reth_primitives::Block, ExecutionData = ExecutionData>
|
|
||||||
/// + 'static,
|
|
||||||
/// {
|
/// {
|
||||||
/// let mut registry = RpcModuleBuilder::default()
|
/// let mut registry = RpcModuleBuilder::default()
|
||||||
/// .with_provider(NoopProvider::default())
|
/// .with_provider(NoopProvider::default())
|
||||||
@ -691,7 +664,7 @@ where
|
|||||||
/// .with_evm_config(evm)
|
/// .with_evm_config(evm)
|
||||||
/// .with_block_executor(EthExecutorProvider::mainnet())
|
/// .with_block_executor(EthExecutorProvider::mainnet())
|
||||||
/// .with_consensus(NoopConsensus::default())
|
/// .with_consensus(NoopConsensus::default())
|
||||||
/// .into_registry(Default::default(), Box::new(EthApi::with_spawner), Arc::new(validator));
|
/// .into_registry(Default::default(), Box::new(EthApi::with_spawner));
|
||||||
///
|
///
|
||||||
/// let eth_api = registry.eth_api();
|
/// let eth_api = registry.eth_api();
|
||||||
/// }
|
/// }
|
||||||
@ -700,9 +673,6 @@ where
|
|||||||
self,
|
self,
|
||||||
config: RpcModuleConfig,
|
config: RpcModuleConfig,
|
||||||
eth: DynEthApiBuilder<Provider, Pool, EvmConfig, Network, Tasks, EthApi>,
|
eth: DynEthApiBuilder<Provider, Pool, EvmConfig, Network, Tasks, EthApi>,
|
||||||
payload_validator: Arc<
|
|
||||||
dyn PayloadValidator<Block = Provider::Block, ExecutionData = ExecutionData>,
|
|
||||||
>,
|
|
||||||
) -> RpcRegistryInner<Provider, Pool, Network, Tasks, EthApi, BlockExecutor, Consensus>
|
) -> RpcRegistryInner<Provider, Pool, Network, Tasks, EthApi, BlockExecutor, Consensus>
|
||||||
where
|
where
|
||||||
EthApi: EthApiTypes + 'static,
|
EthApi: EthApiTypes + 'static,
|
||||||
@ -719,7 +689,6 @@ where
|
|||||||
evm_config,
|
evm_config,
|
||||||
eth,
|
eth,
|
||||||
block_executor,
|
block_executor,
|
||||||
payload_validator,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,9 +698,6 @@ where
|
|||||||
self,
|
self,
|
||||||
module_config: TransportRpcModuleConfig,
|
module_config: TransportRpcModuleConfig,
|
||||||
eth: DynEthApiBuilder<Provider, Pool, EvmConfig, Network, Tasks, EthApi>,
|
eth: DynEthApiBuilder<Provider, Pool, EvmConfig, Network, Tasks, EthApi>,
|
||||||
payload_validator: Arc<
|
|
||||||
dyn PayloadValidator<Block = Provider::Block, ExecutionData = ExecutionData>,
|
|
||||||
>,
|
|
||||||
) -> TransportRpcModules<()>
|
) -> TransportRpcModules<()>
|
||||||
where
|
where
|
||||||
EthApi: FullEthApiServer<
|
EthApi: FullEthApiServer<
|
||||||
@ -761,7 +727,6 @@ where
|
|||||||
evm_config,
|
evm_config,
|
||||||
eth,
|
eth,
|
||||||
block_executor,
|
block_executor,
|
||||||
payload_validator,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
modules.config = module_config;
|
modules.config = module_config;
|
||||||
@ -859,6 +824,7 @@ impl RpcModuleConfigBuilder {
|
|||||||
|
|
||||||
/// A Helper type the holds instances of the configured modules.
|
/// A Helper type the holds instances of the configured modules.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[expect(dead_code)] // Consensus generic, might be useful in the future
|
||||||
pub struct RpcRegistryInner<
|
pub struct RpcRegistryInner<
|
||||||
Provider: BlockReader,
|
Provider: BlockReader,
|
||||||
Pool,
|
Pool,
|
||||||
@ -874,10 +840,6 @@ pub struct RpcRegistryInner<
|
|||||||
executor: Tasks,
|
executor: Tasks,
|
||||||
block_executor: BlockExecutor,
|
block_executor: BlockExecutor,
|
||||||
consensus: Consensus,
|
consensus: Consensus,
|
||||||
payload_validator:
|
|
||||||
Arc<dyn PayloadValidator<Block = Provider::Block, ExecutionData = ExecutionData>>,
|
|
||||||
/// Holds the configuration for the RPC modules
|
|
||||||
config: RpcModuleConfig,
|
|
||||||
/// Holds a all `eth_` namespace handlers
|
/// Holds a all `eth_` namespace handlers
|
||||||
eth: EthHandlers<Provider, EthApi>,
|
eth: EthHandlers<Provider, EthApi>,
|
||||||
/// to put trace calls behind semaphore
|
/// to put trace calls behind semaphore
|
||||||
@ -916,9 +878,6 @@ where
|
|||||||
evm_config: EvmConfig,
|
evm_config: EvmConfig,
|
||||||
eth_api_builder: DynEthApiBuilder<Provider, Pool, EvmConfig, Network, Tasks, EthApi>,
|
eth_api_builder: DynEthApiBuilder<Provider, Pool, EvmConfig, Network, Tasks, EthApi>,
|
||||||
block_executor: BlockExecutor,
|
block_executor: BlockExecutor,
|
||||||
payload_validator: Arc<
|
|
||||||
dyn PayloadValidator<Block = Provider::Block, ExecutionData = ExecutionData>,
|
|
||||||
>,
|
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
EvmConfig: ConfigureEvm<Header = Provider::Header>,
|
EvmConfig: ConfigureEvm<Header = Provider::Header>,
|
||||||
@ -942,11 +901,9 @@ where
|
|||||||
eth,
|
eth,
|
||||||
executor,
|
executor,
|
||||||
consensus,
|
consensus,
|
||||||
config,
|
|
||||||
modules: Default::default(),
|
modules: Default::default(),
|
||||||
blocking_pool_guard,
|
blocking_pool_guard,
|
||||||
block_executor,
|
block_executor,
|
||||||
payload_validator,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1220,23 +1177,6 @@ where
|
|||||||
pub fn reth_api(&self) -> RethApi<Provider> {
|
pub fn reth_api(&self) -> RethApi<Provider> {
|
||||||
RethApi::new(self.provider.clone(), Box::new(self.executor.clone()))
|
RethApi::new(self.provider.clone(), Box::new(self.executor.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Instantiates `ValidationApi`
|
|
||||||
pub fn validation_api(&self) -> ValidationApi<Provider, BlockExecutor>
|
|
||||||
where
|
|
||||||
Consensus:
|
|
||||||
FullConsensus<BlockExecutor::Primitives, Error = ConsensusError> + Clone + 'static,
|
|
||||||
Provider: BlockReader<Block = <BlockExecutor::Primitives as NodePrimitives>::Block>,
|
|
||||||
{
|
|
||||||
ValidationApi::new(
|
|
||||||
self.provider.clone(),
|
|
||||||
Arc::new(self.consensus.clone()),
|
|
||||||
self.block_executor.clone(),
|
|
||||||
self.config.flashbots.clone(),
|
|
||||||
Box::new(self.executor.clone()),
|
|
||||||
self.payload_validator.clone(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Provider, Pool, Network, Tasks, EthApi, BlockExecutor, Consensus>
|
impl<Provider, Pool, Network, Tasks, EthApi, BlockExecutor, Consensus>
|
||||||
@ -1393,16 +1333,10 @@ where
|
|||||||
.into_rpc()
|
.into_rpc()
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
RethRpcModule::Flashbots => ValidationApi::new(
|
// only relevant for Ethereum and configured in `EthereumAddOns`
|
||||||
eth_api.provider().clone(),
|
// implementation
|
||||||
Arc::new(self.consensus.clone()),
|
// TODO: can we get rid of this here?
|
||||||
self.block_executor.clone(),
|
RethRpcModule::Flashbots => Default::default(),
|
||||||
self.config.flashbots.clone(),
|
|
||||||
Box::new(self.executor.clone()),
|
|
||||||
self.payload_validator.clone(),
|
|
||||||
)
|
|
||||||
.into_rpc()
|
|
||||||
.into(),
|
|
||||||
RethRpcModule::Miner => MinerApi::default().into_rpc().into(),
|
RethRpcModule::Miner => MinerApi::default().into_rpc().into(),
|
||||||
})
|
})
|
||||||
.clone()
|
.clone()
|
||||||
|
|||||||
@ -5,8 +5,6 @@ use jsonrpsee::{
|
|||||||
types::Request,
|
types::Request,
|
||||||
MethodResponse,
|
MethodResponse,
|
||||||
};
|
};
|
||||||
use reth_chainspec::MAINNET;
|
|
||||||
use reth_ethereum_engine_primitives::EthereumEngineValidator;
|
|
||||||
use reth_rpc::EthApi;
|
use reth_rpc::EthApi;
|
||||||
use reth_rpc_builder::{RpcServerConfig, TransportRpcModuleConfig};
|
use reth_rpc_builder::{RpcServerConfig, TransportRpcModuleConfig};
|
||||||
use reth_rpc_eth_api::EthApiClient;
|
use reth_rpc_eth_api::EthApiClient;
|
||||||
@ -65,7 +63,6 @@ async fn test_rpc_middleware() {
|
|||||||
let modules = builder.build(
|
let modules = builder.build(
|
||||||
TransportRpcModuleConfig::set_http(RpcModuleSelection::All),
|
TransportRpcModuleConfig::set_http(RpcModuleSelection::All),
|
||||||
Box::new(EthApi::with_spawner),
|
Box::new(EthApi::with_spawner),
|
||||||
Arc::new(EthereumEngineValidator::new(MAINNET.clone())),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let mylayer = MyMiddlewareLayer::default();
|
let mylayer = MyMiddlewareLayer::default();
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
//! Startup tests
|
//! Startup tests
|
||||||
|
|
||||||
use std::{io, sync::Arc};
|
use std::io;
|
||||||
|
|
||||||
use reth_chainspec::MAINNET;
|
|
||||||
use reth_ethereum_engine_primitives::EthereumEngineValidator;
|
|
||||||
use reth_rpc::EthApi;
|
use reth_rpc::EthApi;
|
||||||
use reth_rpc_builder::{
|
use reth_rpc_builder::{
|
||||||
error::{RpcError, ServerKind, WsHttpSamePortError},
|
error::{RpcError, ServerKind, WsHttpSamePortError},
|
||||||
@ -32,7 +30,6 @@ async fn test_http_addr_in_use() {
|
|||||||
let server = builder.build(
|
let server = builder.build(
|
||||||
TransportRpcModuleConfig::set_http(vec![RethRpcModule::Admin]),
|
TransportRpcModuleConfig::set_http(vec![RethRpcModule::Admin]),
|
||||||
Box::new(EthApi::with_spawner),
|
Box::new(EthApi::with_spawner),
|
||||||
Arc::new(EthereumEngineValidator::new(MAINNET.clone())),
|
|
||||||
);
|
);
|
||||||
let result =
|
let result =
|
||||||
RpcServerConfig::http(Default::default()).with_http_address(addr).start(&server).await;
|
RpcServerConfig::http(Default::default()).with_http_address(addr).start(&server).await;
|
||||||
@ -48,7 +45,6 @@ async fn test_ws_addr_in_use() {
|
|||||||
let server = builder.build(
|
let server = builder.build(
|
||||||
TransportRpcModuleConfig::set_ws(vec![RethRpcModule::Admin]),
|
TransportRpcModuleConfig::set_ws(vec![RethRpcModule::Admin]),
|
||||||
Box::new(EthApi::with_spawner),
|
Box::new(EthApi::with_spawner),
|
||||||
Arc::new(EthereumEngineValidator::new(MAINNET.clone())),
|
|
||||||
);
|
);
|
||||||
let result = RpcServerConfig::ws(Default::default()).with_ws_address(addr).start(&server).await;
|
let result = RpcServerConfig::ws(Default::default()).with_ws_address(addr).start(&server).await;
|
||||||
let err = result.unwrap_err();
|
let err = result.unwrap_err();
|
||||||
@ -70,7 +66,6 @@ async fn test_launch_same_port_different_modules() {
|
|||||||
TransportRpcModuleConfig::set_ws(vec![RethRpcModule::Admin])
|
TransportRpcModuleConfig::set_ws(vec![RethRpcModule::Admin])
|
||||||
.with_http(vec![RethRpcModule::Eth]),
|
.with_http(vec![RethRpcModule::Eth]),
|
||||||
Box::new(EthApi::with_spawner),
|
Box::new(EthApi::with_spawner),
|
||||||
Arc::new(EthereumEngineValidator::new(MAINNET.clone())),
|
|
||||||
);
|
);
|
||||||
let addr = test_address();
|
let addr = test_address();
|
||||||
let res = RpcServerConfig::ws(Default::default())
|
let res = RpcServerConfig::ws(Default::default())
|
||||||
@ -93,7 +88,6 @@ async fn test_launch_same_port_same_cors() {
|
|||||||
TransportRpcModuleConfig::set_ws(vec![RethRpcModule::Eth])
|
TransportRpcModuleConfig::set_ws(vec![RethRpcModule::Eth])
|
||||||
.with_http(vec![RethRpcModule::Eth]),
|
.with_http(vec![RethRpcModule::Eth]),
|
||||||
Box::new(EthApi::with_spawner),
|
Box::new(EthApi::with_spawner),
|
||||||
Arc::new(EthereumEngineValidator::new(MAINNET.clone())),
|
|
||||||
);
|
);
|
||||||
let addr = test_address();
|
let addr = test_address();
|
||||||
let res = RpcServerConfig::ws(Default::default())
|
let res = RpcServerConfig::ws(Default::default())
|
||||||
@ -114,7 +108,6 @@ async fn test_launch_same_port_different_cors() {
|
|||||||
TransportRpcModuleConfig::set_ws(vec![RethRpcModule::Eth])
|
TransportRpcModuleConfig::set_ws(vec![RethRpcModule::Eth])
|
||||||
.with_http(vec![RethRpcModule::Eth]),
|
.with_http(vec![RethRpcModule::Eth]),
|
||||||
Box::new(EthApi::with_spawner),
|
Box::new(EthApi::with_spawner),
|
||||||
Arc::new(EthereumEngineValidator::new(MAINNET.clone())),
|
|
||||||
);
|
);
|
||||||
let addr = test_address();
|
let addr = test_address();
|
||||||
let res = RpcServerConfig::ws(Default::default())
|
let res = RpcServerConfig::ws(Default::default())
|
||||||
|
|||||||
@ -1,7 +1,4 @@
|
|||||||
use std::{
|
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
|
||||||
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
|
|
||||||
sync::Arc,
|
|
||||||
};
|
|
||||||
|
|
||||||
use alloy_rpc_types_engine::{ClientCode, ClientVersionV1};
|
use alloy_rpc_types_engine::{ClientCode, ClientVersionV1};
|
||||||
use reth_chainspec::MAINNET;
|
use reth_chainspec::MAINNET;
|
||||||
@ -63,11 +60,8 @@ pub async fn launch_auth(secret: JwtSecret) -> AuthServerHandle {
|
|||||||
/// Launches a new server with http only with the given modules
|
/// Launches a new server with http only with the given modules
|
||||||
pub async fn launch_http(modules: impl Into<RpcModuleSelection>) -> RpcServerHandle {
|
pub async fn launch_http(modules: impl Into<RpcModuleSelection>) -> RpcServerHandle {
|
||||||
let builder = test_rpc_builder();
|
let builder = test_rpc_builder();
|
||||||
let server = builder.build(
|
let server =
|
||||||
TransportRpcModuleConfig::set_http(modules),
|
builder.build(TransportRpcModuleConfig::set_http(modules), Box::new(EthApi::with_spawner));
|
||||||
Box::new(EthApi::with_spawner),
|
|
||||||
Arc::new(EthereumEngineValidator::new(MAINNET.clone())),
|
|
||||||
);
|
|
||||||
RpcServerConfig::http(Default::default())
|
RpcServerConfig::http(Default::default())
|
||||||
.with_http_address(test_address())
|
.with_http_address(test_address())
|
||||||
.start(&server)
|
.start(&server)
|
||||||
@ -78,11 +72,8 @@ pub async fn launch_http(modules: impl Into<RpcModuleSelection>) -> RpcServerHan
|
|||||||
/// Launches a new server with ws only with the given modules
|
/// Launches a new server with ws only with the given modules
|
||||||
pub async fn launch_ws(modules: impl Into<RpcModuleSelection>) -> RpcServerHandle {
|
pub async fn launch_ws(modules: impl Into<RpcModuleSelection>) -> RpcServerHandle {
|
||||||
let builder = test_rpc_builder();
|
let builder = test_rpc_builder();
|
||||||
let server = builder.build(
|
let server =
|
||||||
TransportRpcModuleConfig::set_ws(modules),
|
builder.build(TransportRpcModuleConfig::set_ws(modules), Box::new(EthApi::with_spawner));
|
||||||
Box::new(EthApi::with_spawner),
|
|
||||||
Arc::new(EthereumEngineValidator::new(MAINNET.clone())),
|
|
||||||
);
|
|
||||||
RpcServerConfig::ws(Default::default())
|
RpcServerConfig::ws(Default::default())
|
||||||
.with_ws_address(test_address())
|
.with_ws_address(test_address())
|
||||||
.start(&server)
|
.start(&server)
|
||||||
@ -97,7 +88,6 @@ pub async fn launch_http_ws(modules: impl Into<RpcModuleSelection>) -> RpcServer
|
|||||||
let server = builder.build(
|
let server = builder.build(
|
||||||
TransportRpcModuleConfig::set_ws(modules.clone()).with_http(modules),
|
TransportRpcModuleConfig::set_ws(modules.clone()).with_http(modules),
|
||||||
Box::new(EthApi::with_spawner),
|
Box::new(EthApi::with_spawner),
|
||||||
Arc::new(EthereumEngineValidator::new(MAINNET.clone())),
|
|
||||||
);
|
);
|
||||||
RpcServerConfig::ws(Default::default())
|
RpcServerConfig::ws(Default::default())
|
||||||
.with_ws_address(test_address())
|
.with_ws_address(test_address())
|
||||||
@ -116,7 +106,6 @@ pub async fn launch_http_ws_same_port(modules: impl Into<RpcModuleSelection>) ->
|
|||||||
let server = builder.build(
|
let server = builder.build(
|
||||||
TransportRpcModuleConfig::set_ws(modules.clone()).with_http(modules),
|
TransportRpcModuleConfig::set_ws(modules.clone()).with_http(modules),
|
||||||
Box::new(EthApi::with_spawner),
|
Box::new(EthApi::with_spawner),
|
||||||
Arc::new(EthereumEngineValidator::new(MAINNET.clone())),
|
|
||||||
);
|
);
|
||||||
let addr = test_address();
|
let addr = test_address();
|
||||||
RpcServerConfig::ws(Default::default())
|
RpcServerConfig::ws(Default::default())
|
||||||
|
|||||||
@ -36,6 +36,7 @@ reth-rpc-eth-types.workspace = true
|
|||||||
reth-rpc-server-types.workspace = true
|
reth-rpc-server-types.workspace = true
|
||||||
reth-network-types.workspace = true
|
reth-network-types.workspace = true
|
||||||
reth-consensus.workspace = true
|
reth-consensus.workspace = true
|
||||||
|
reth-node-api.workspace = true
|
||||||
|
|
||||||
# ethereum
|
# ethereum
|
||||||
alloy-consensus.workspace = true
|
alloy-consensus.workspace = true
|
||||||
|
|||||||
@ -9,6 +9,7 @@ use alloy_eips::BlockNumberOrTag;
|
|||||||
use alloy_network::Ethereum;
|
use alloy_network::Ethereum;
|
||||||
use alloy_primitives::{Bytes, U256};
|
use alloy_primitives::{Bytes, U256};
|
||||||
use derive_more::Deref;
|
use derive_more::Deref;
|
||||||
|
use reth_node_api::{FullNodeComponents, FullNodeTypes};
|
||||||
use reth_primitives::NodePrimitives;
|
use reth_primitives::NodePrimitives;
|
||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
BlockReader, BlockReaderIdExt, CanonStateSubscriptions, ChainSpecProvider, ProviderBlock,
|
BlockReader, BlockReaderIdExt, CanonStateSubscriptions, ChainSpecProvider, ProviderBlock,
|
||||||
@ -31,6 +32,14 @@ use tokio::sync::{broadcast, Mutex};
|
|||||||
|
|
||||||
const DEFAULT_BROADCAST_CAPACITY: usize = 2000;
|
const DEFAULT_BROADCAST_CAPACITY: usize = 2000;
|
||||||
|
|
||||||
|
/// Helper type alias for [`EthApi`] with components from the given [`FullNodeComponents`].
|
||||||
|
pub type EthApiFor<N> = EthApi<
|
||||||
|
<N as FullNodeTypes>::Provider,
|
||||||
|
<N as FullNodeComponents>::Pool,
|
||||||
|
<N as FullNodeComponents>::Network,
|
||||||
|
<N as FullNodeComponents>::Evm,
|
||||||
|
>;
|
||||||
|
|
||||||
/// `Eth` API implementation.
|
/// `Eth` API implementation.
|
||||||
///
|
///
|
||||||
/// This type provides the functionality for handling `eth_` related requests.
|
/// This type provides the functionality for handling `eth_` related requests.
|
||||||
|
|||||||
@ -34,9 +34,7 @@ use reth::rpc::builder::{
|
|||||||
// Configuring the network parts, ideally also wouldn't need to think about this.
|
// Configuring the network parts, ideally also wouldn't need to think about this.
|
||||||
use myrpc_ext::{MyRpcExt, MyRpcExtApiServer};
|
use myrpc_ext::{MyRpcExt, MyRpcExtApiServer};
|
||||||
use reth::tasks::TokioTaskExecutor;
|
use reth::tasks::TokioTaskExecutor;
|
||||||
use reth_node_ethereum::{
|
use reth_node_ethereum::{EthEvmConfig, EthExecutorProvider, EthereumNode};
|
||||||
node::EthereumEngineValidator, EthEvmConfig, EthExecutorProvider, EthereumNode,
|
|
||||||
};
|
|
||||||
use reth_provider::ChainSpecProvider;
|
use reth_provider::ChainSpecProvider;
|
||||||
|
|
||||||
// Custom rpc extension
|
// Custom rpc extension
|
||||||
@ -75,11 +73,7 @@ async fn main() -> eyre::Result<()> {
|
|||||||
|
|
||||||
// Pick which namespaces to expose.
|
// Pick which namespaces to expose.
|
||||||
let config = TransportRpcModuleConfig::default().with_http([RethRpcModule::Eth]);
|
let config = TransportRpcModuleConfig::default().with_http([RethRpcModule::Eth]);
|
||||||
let mut server = rpc_builder.build(
|
let mut server = rpc_builder.build(config, Box::new(EthApi::with_spawner));
|
||||||
config,
|
|
||||||
Box::new(EthApi::with_spawner),
|
|
||||||
Arc::new(EthereumEngineValidator::new(spec)),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add a custom rpc namespace
|
// Add a custom rpc namespace
|
||||||
let custom_rpc = MyRpcExt { provider };
|
let custom_rpc = MyRpcExt { provider };
|
||||||
|
|||||||
Reference in New Issue
Block a user