diff --git a/Cargo.lock b/Cargo.lock index ce08ce4a7620..7929e1f15cb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8315,6 +8315,7 @@ dependencies = [ name = "reth-rpc-builder" version = "1.0.6" dependencies = [ + "alloy-network", "clap", "http", "jsonrpsee", diff --git a/crates/e2e-test-utils/src/lib.rs b/crates/e2e-test-utils/src/lib.rs index d11e397677c5..61c79968d0be 100644 --- a/crates/e2e-test-utils/src/lib.rs +++ b/crates/e2e-test-utils/src/lib.rs @@ -8,7 +8,10 @@ use reth::{ args::{DiscoveryArgs, NetworkArgs, RpcServerArgs}, builder::{NodeBuilder, NodeConfig, NodeHandle}, network::PeersHandleProvider, - rpc::api::eth::{helpers::AddDevSigners, FullEthApiServer}, + rpc::{ + api::eth::{helpers::AddDevSigners, FullEthApiServer}, + types::AnyTransactionReceipt, + }, tasks::TaskManager, }; use reth_chainspec::ChainSpec; @@ -62,6 +65,7 @@ where EthApi: FullEthApiServer< NetworkTypes: Network< TransactionResponse = reth_rpc_types::WithOtherFields, + ReceiptResponse = AnyTransactionReceipt, >, > + AddDevSigners + EthApiBuilderProvider>, diff --git a/crates/e2e-test-utils/src/node.rs b/crates/e2e-test-utils/src/node.rs index 0eb141bc159e..67995de53fd6 100644 --- a/crates/e2e-test-utils/src/node.rs +++ b/crates/e2e-test-utils/src/node.rs @@ -11,7 +11,7 @@ use reth::{ providers::{BlockReader, BlockReaderIdExt, CanonStateSubscriptions, StageCheckpointReader}, rpc::{ api::eth::helpers::{EthApiSpec, EthTransactions, TraceExt}, - types::engine::PayloadStatusEnum, + types::{engine::PayloadStatusEnum, AnyTransactionReceipt}, }, }; use reth_chainspec::ChainSpec; @@ -90,8 +90,10 @@ where ::ExecutionPayloadV3: From + PayloadEnvelopeExt, AddOns::EthApi: EthApiSpec + EthTransactions + TraceExt, - ::NetworkTypes: - Network>, + ::NetworkTypes: Network< + TransactionResponse = WithOtherFields, + ReceiptResponse = AnyTransactionReceipt, + >, { let mut chain = Vec::with_capacity(length as usize); for i in 0..length { diff --git a/crates/e2e-test-utils/src/rpc.rs b/crates/e2e-test-utils/src/rpc.rs index a7d3030f1286..087b714302ad 100644 --- a/crates/e2e-test-utils/src/rpc.rs +++ b/crates/e2e-test-utils/src/rpc.rs @@ -10,7 +10,7 @@ use reth::{ use reth_chainspec::ChainSpec; use reth_node_builder::{EthApiTypes, NodeTypes}; use reth_primitives::{Bytes, B256}; -use reth_rpc_types::WithOtherFields; +use reth_rpc_types::{AnyTransactionReceipt, WithOtherFields}; #[allow(missing_debug_implementations)] pub struct RpcTestContext { @@ -24,6 +24,7 @@ where + EthTransactions< NetworkTypes: Network< TransactionResponse = WithOtherFields, + ReceiptResponse = AnyTransactionReceipt, >, > + TraceExt, { diff --git a/crates/node/builder/src/builder/mod.rs b/crates/node/builder/src/builder/mod.rs index 3c0bae0252bf..472bc425aaa0 100644 --- a/crates/node/builder/src/builder/mod.rs +++ b/crates/node/builder/src/builder/mod.rs @@ -30,7 +30,10 @@ use reth_node_core::{ dirs::{ChainPath, DataDirPath}, node_config::NodeConfig, primitives::Head, - rpc::eth::{helpers::AddDevSigners, FullEthApiServer}, + rpc::{ + eth::{helpers::AddDevSigners, FullEthApiServer}, + types::AnyTransactionReceipt, + }, }; use reth_primitives::revm_primitives::EnvKzgSettings; use reth_provider::{providers::BlockchainProvider, ChainSpecProvider, FullProvider}; @@ -341,6 +344,7 @@ where + FullEthApiServer< NetworkTypes: alloy_network::Network< TransactionResponse = WithOtherFields, + ReceiptResponse = AnyTransactionReceipt, >, > + AddDevSigners @@ -491,6 +495,7 @@ where + FullEthApiServer< NetworkTypes: alloy_network::Network< TransactionResponse = WithOtherFields, + ReceiptResponse = AnyTransactionReceipt, >, > + AddDevSigners, >, diff --git a/crates/node/builder/src/launch/engine.rs b/crates/node/builder/src/launch/engine.rs index 7ce1c37a6c33..506d3b8f5c96 100644 --- a/crates/node/builder/src/launch/engine.rs +++ b/crates/node/builder/src/launch/engine.rs @@ -24,7 +24,10 @@ use reth_node_core::{ dirs::{ChainPath, DataDirPath}, exit::NodeExitFuture, primitives::Head, - rpc::eth::{helpers::AddDevSigners, FullEthApiServer}, + rpc::{ + eth::{helpers::AddDevSigners, FullEthApiServer}, + types::AnyTransactionReceipt, + }, version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA}, }; use reth_node_events::{cl::ConsensusLayerHealthEvents, node}; @@ -71,6 +74,7 @@ where + FullEthApiServer< NetworkTypes: alloy_network::Network< TransactionResponse = WithOtherFields, + ReceiptResponse = AnyTransactionReceipt, >, > + AddDevSigners, >, diff --git a/crates/node/builder/src/launch/mod.rs b/crates/node/builder/src/launch/mod.rs index 39698f6e68e1..0d03f8f7ebfe 100644 --- a/crates/node/builder/src/launch/mod.rs +++ b/crates/node/builder/src/launch/mod.rs @@ -27,7 +27,10 @@ use reth_node_api::{ use reth_node_core::{ dirs::{ChainPath, DataDirPath}, exit::NodeExitFuture, - rpc::eth::{helpers::AddDevSigners, FullEthApiServer}, + rpc::{ + eth::{helpers::AddDevSigners, FullEthApiServer}, + types::AnyTransactionReceipt, + }, version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA}, }; use reth_node_events::{cl::ConsensusLayerHealthEvents, node}; @@ -113,6 +116,7 @@ where + FullEthApiServer< NetworkTypes: alloy_network::Network< TransactionResponse = WithOtherFields, + ReceiptResponse = AnyTransactionReceipt, >, > + AddDevSigners, >, diff --git a/crates/node/builder/src/rpc.rs b/crates/node/builder/src/rpc.rs index d51eaa5b04bd..64ce0b8ffa89 100644 --- a/crates/node/builder/src/rpc.rs +++ b/crates/node/builder/src/rpc.rs @@ -13,6 +13,7 @@ use reth_node_core::{ rpc::{ api::EngineApiServer, eth::{EthApiTypes, FullEthApiServer}, + types::AnyTransactionReceipt, }, }; use reth_payload_builder::PayloadBuilderHandle; @@ -306,6 +307,7 @@ where + FullEthApiServer< NetworkTypes: alloy_network::Network< TransactionResponse = WithOtherFields, + ReceiptResponse = AnyTransactionReceipt, >, >, { diff --git a/crates/rpc/rpc-builder/Cargo.toml b/crates/rpc/rpc-builder/Cargo.toml index f4b8e4f64b61..6e0d5a48fa45 100644 --- a/crates/rpc/rpc-builder/Cargo.toml +++ b/crates/rpc/rpc-builder/Cargo.toml @@ -30,6 +30,9 @@ reth-evm.workspace = true reth-engine-primitives.workspace = true reth-rpc-types.workspace = true +# ethereum +alloy-network.workspace = true + # rpc/net jsonrpsee = { workspace = true, features = ["server"] } tower-http = { workspace = true, features = ["full"] } diff --git a/crates/rpc/rpc-builder/src/lib.rs b/crates/rpc/rpc-builder/src/lib.rs index f82532432291..53802e5221a6 100644 --- a/crates/rpc/rpc-builder/src/lib.rs +++ b/crates/rpc/rpc-builder/src/lib.rs @@ -165,7 +165,7 @@ use reth_rpc::{ use reth_rpc_api::servers::*; use reth_rpc_eth_api::{ helpers::{Call, EthApiSpec, EthTransactions, LoadPendingBlock, TraceExt}, - EthApiServer, FullEthApiServer, + EthApiServer, EthApiTypes, FullEthApiServer, RpcReceipt, }; use reth_rpc_eth_types::{EthConfig, EthStateCache, EthSubscriptionIdProvider}; use reth_rpc_layer::{AuthLayer, Claims, JwtAuthValidator, JwtSecret}; @@ -207,6 +207,7 @@ pub use eth::EthHandlers; // Rpc server metrics mod metrics; pub use metrics::{MeteredRequestFuture, RpcRequestMetricsService}; +use reth_node_core::rpc::types::AnyTransactionReceipt; /// Convenience function for starting a server in one step. #[allow(clippy::too_many_arguments)] @@ -228,7 +229,9 @@ where Tasks: TaskSpawner + Clone + 'static, Events: CanonStateSubscriptions + Clone + 'static, EvmConfig: ConfigureEvm, - EthApi: FullEthApiServer, + EthApi: FullEthApiServer< + NetworkTypes: alloy_network::Network, + >, { let module_config = module_config.into(); server_config @@ -435,7 +438,9 @@ where where EngineT: EngineTypes, EngineApi: EngineApiServer, - EthApi: FullEthApiServer, + EthApi: FullEthApiServer< + NetworkTypes: alloy_network::Network, + >, { let Self { provider, pool, network, executor, events, evm_config } = self; @@ -501,7 +506,9 @@ where eth: DynEthApiBuilder, ) -> TransportRpcModules<()> where - EthApi: FullEthApiServer, + EthApi: FullEthApiServer< + NetworkTypes: alloy_network::Network, + >, { let mut modules = TransportRpcModules::default(); @@ -792,10 +799,12 @@ where pub fn register_eth(&mut self) -> &mut Self where EthApi: EthApiServer< - reth_rpc_types::Transaction, - reth_rpc_types::Block, - reth_rpc_types::AnyTransactionReceipt, - >, + reth_rpc_types::Transaction, + reth_rpc_types::Block, + RpcReceipt, + > + EthApiTypes< + NetworkTypes: alloy_network::Network, + >, { let eth_api = self.eth_api().clone(); self.modules.insert(RethRpcModule::Eth, eth_api.into_rpc().into()); @@ -812,7 +821,9 @@ where EthApi: EthApiServer< WithOtherFields, reth_rpc_types::Block>, - reth_rpc_types::AnyTransactionReceipt, + RpcReceipt, + > + EthApiTypes< + NetworkTypes: alloy_network::Network, > + TraceExt + EthTransactions, { @@ -917,7 +928,9 @@ where EthApi: EthApiServer< WithOtherFields, reth_rpc_types::Block>, - reth_rpc_types::AnyTransactionReceipt, + RpcReceipt, + > + EthApiTypes< + NetworkTypes: alloy_network::Network, > + TraceExt + EthTransactions, { @@ -965,7 +978,9 @@ where Network: NetworkInfo + Peers + Clone + 'static, Tasks: TaskSpawner + Clone + 'static, Events: CanonStateSubscriptions + Clone + 'static, - EthApi: FullEthApiServer, + EthApi: FullEthApiServer< + NetworkTypes: alloy_network::Network, + >, { /// Configures the auth module that includes the /// * `engine_` namespace diff --git a/crates/rpc/rpc-eth-api/src/core.rs b/crates/rpc/rpc-eth-api/src/core.rs index b9d22a7221e1..b745b0516bae 100644 --- a/crates/rpc/rpc-eth-api/src/core.rs +++ b/crates/rpc/rpc-eth-api/src/core.rs @@ -1,8 +1,8 @@ //! Implementation of the [`jsonrpsee`] generated [`EthApiServer`] trait. Handles RPC requests for //! the `eth_` namespace. - use alloy_dyn_abi::TypedData; use alloy_json_rpc::RpcObject; +use alloy_network::Network; use jsonrpsee::{core::RpcResult, proc_macros::rpc}; use reth_primitives::{ transaction::AccessListResult, Address, BlockId, BlockNumberOrTag, Bytes, B256, B64, U256, U64, @@ -12,8 +12,8 @@ use reth_rpc_types::{ serde_helpers::JsonStorageKey, simulate::{SimBlock, SimulatedBlock}, state::{EvmOverrides, StateOverride}, - BlockOverrides, Bundle, EIP1186AccountProofResponse, EthCallResponse, FeeHistory, Header, - Index, StateContext, SyncStatus, TransactionRequest, Work, + AnyTransactionReceipt, BlockOverrides, Bundle, EIP1186AccountProofResponse, EthCallResponse, + FeeHistory, Header, Index, StateContext, SyncStatus, TransactionRequest, Work, }; use tracing::trace; @@ -369,7 +369,7 @@ impl RpcReceipt, > for T where - T: FullEthApi, + T: FullEthApi>, jsonrpsee_types::error::ErrorObject<'static>: From, { /// Handler for: `eth_protocolVersion` diff --git a/crates/rpc/rpc-eth-api/src/types.rs b/crates/rpc/rpc-eth-api/src/types.rs index e1d83095adaa..91a9ffdc691a 100644 --- a/crates/rpc/rpc-eth-api/src/types.rs +++ b/crates/rpc/rpc-eth-api/src/types.rs @@ -4,7 +4,7 @@ use std::error::Error; use alloy_network::{AnyNetwork, Network}; use reth_rpc_eth_types::EthApiError; -use reth_rpc_types::{AnyTransactionReceipt, Block, Transaction, WithOtherFields}; +use reth_rpc_types::{Block, Transaction, WithOtherFields}; use crate::{AsEthApiError, FromEthApiError, FromEvmError}; @@ -20,11 +20,9 @@ pub trait EthApiTypes: Send + Sync + Clone { + Sync; /// Blockchain primitive types, specific to network, e.g. block and transaction. // todo: remove restriction [`reth_rpc_types::Transaction`] - // todo: remove restriction [`reth_rpc_types::AnyTransactionReceipt`] type NetworkTypes: Network< TransactionResponse = WithOtherFields, HeaderResponse = reth_rpc_types::Header, - ReceiptResponse = AnyTransactionReceipt, >; } diff --git a/crates/rpc/rpc/src/otterscan.rs b/crates/rpc/rpc/src/otterscan.rs index f7295bdb37ce..e213737142fe 100644 --- a/crates/rpc/rpc/src/otterscan.rs +++ b/crates/rpc/rpc/src/otterscan.rs @@ -44,14 +44,17 @@ impl OtterscanApi { impl OtterscanApi where Eth: EthApiTypes< - NetworkTypes: Network>, + NetworkTypes: Network< + TransactionResponse = WithOtherFields, + ReceiptResponse = AnyTransactionReceipt, + >, >, { /// Constructs a `BlockDetails` from a block and its receipts. fn block_details( &self, block: RpcBlock, - receipts: Vec, + receipts: Vec>, ) -> RpcResult { // blob fee is burnt, so we don't need to calculate it let total_fees = receipts @@ -73,6 +76,7 @@ where > + EthApiTypes< NetworkTypes: Network< TransactionResponse = WithOtherFields, + ReceiptResponse = AnyTransactionReceipt, >, > + TraceExt + EthTransactions