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