mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: remove constraint of concrete type AnyTransactionReceipt for EthApiTypes::NetworkType (#10693)
Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -8315,6 +8315,7 @@ dependencies = [
|
||||
name = "reth-rpc-builder"
|
||||
version = "1.0.6"
|
||||
dependencies = [
|
||||
"alloy-network",
|
||||
"clap",
|
||||
"http",
|
||||
"jsonrpsee",
|
||||
|
||||
@ -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<reth_rpc_types::Transaction>,
|
||||
ReceiptResponse = AnyTransactionReceipt,
|
||||
>,
|
||||
> + AddDevSigners
|
||||
+ EthApiBuilderProvider<Adapter<N>>,
|
||||
|
||||
@ -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
|
||||
<Engine as EngineTypes>::ExecutionPayloadV3:
|
||||
From<Engine::BuiltPayload> + PayloadEnvelopeExt,
|
||||
AddOns::EthApi: EthApiSpec + EthTransactions + TraceExt,
|
||||
<AddOns::EthApi as EthApiTypes>::NetworkTypes:
|
||||
Network<TransactionResponse = WithOtherFields<alloy_rpc_types::Transaction>>,
|
||||
<AddOns::EthApi as EthApiTypes>::NetworkTypes: Network<
|
||||
TransactionResponse = WithOtherFields<alloy_rpc_types::Transaction>,
|
||||
ReceiptResponse = AnyTransactionReceipt,
|
||||
>,
|
||||
{
|
||||
let mut chain = Vec::with_capacity(length as usize);
|
||||
for i in 0..length {
|
||||
|
||||
@ -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<Node: FullNodeComponents, EthApi: EthApiTypes> {
|
||||
@ -24,6 +24,7 @@ where
|
||||
+ EthTransactions<
|
||||
NetworkTypes: Network<
|
||||
TransactionResponse = WithOtherFields<alloy_rpc_types::Transaction>,
|
||||
ReceiptResponse = AnyTransactionReceipt,
|
||||
>,
|
||||
> + TraceExt,
|
||||
{
|
||||
|
||||
@ -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<reth_rpc_types::Transaction>,
|
||||
ReceiptResponse = AnyTransactionReceipt,
|
||||
>,
|
||||
>
|
||||
+ AddDevSigners
|
||||
@ -491,6 +495,7 @@ where
|
||||
+ FullEthApiServer<
|
||||
NetworkTypes: alloy_network::Network<
|
||||
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
|
||||
ReceiptResponse = AnyTransactionReceipt,
|
||||
>,
|
||||
> + AddDevSigners,
|
||||
>,
|
||||
|
||||
@ -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<reth_rpc_types::Transaction>,
|
||||
ReceiptResponse = AnyTransactionReceipt,
|
||||
>,
|
||||
> + AddDevSigners,
|
||||
>,
|
||||
|
||||
@ -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<reth_rpc_types::Transaction>,
|
||||
ReceiptResponse = AnyTransactionReceipt,
|
||||
>,
|
||||
> + AddDevSigners,
|
||||
>,
|
||||
|
||||
@ -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<reth_rpc_types::Transaction>,
|
||||
ReceiptResponse = AnyTransactionReceipt,
|
||||
>,
|
||||
>,
|
||||
{
|
||||
|
||||
@ -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"] }
|
||||
|
||||
@ -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<ReceiptResponse = AnyTransactionReceipt>,
|
||||
>,
|
||||
{
|
||||
let module_config = module_config.into();
|
||||
server_config
|
||||
@ -435,7 +438,9 @@ where
|
||||
where
|
||||
EngineT: EngineTypes,
|
||||
EngineApi: EngineApiServer<EngineT>,
|
||||
EthApi: FullEthApiServer,
|
||||
EthApi: FullEthApiServer<
|
||||
NetworkTypes: alloy_network::Network<ReceiptResponse = AnyTransactionReceipt>,
|
||||
>,
|
||||
{
|
||||
let Self { provider, pool, network, executor, events, evm_config } = self;
|
||||
|
||||
@ -501,7 +506,9 @@ where
|
||||
eth: DynEthApiBuilder<Provider, Pool, EvmConfig, Network, Tasks, Events, EthApi>,
|
||||
) -> TransportRpcModules<()>
|
||||
where
|
||||
EthApi: FullEthApiServer,
|
||||
EthApi: FullEthApiServer<
|
||||
NetworkTypes: alloy_network::Network<ReceiptResponse = AnyTransactionReceipt>,
|
||||
>,
|
||||
{
|
||||
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<EthApi::NetworkTypes>,
|
||||
> + EthApiTypes<
|
||||
NetworkTypes: alloy_network::Network<ReceiptResponse = AnyTransactionReceipt>,
|
||||
>,
|
||||
{
|
||||
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::Transaction>,
|
||||
reth_rpc_types::Block<WithOtherFields<reth_rpc_types::Transaction>>,
|
||||
reth_rpc_types::AnyTransactionReceipt,
|
||||
RpcReceipt<EthApi::NetworkTypes>,
|
||||
> + EthApiTypes<
|
||||
NetworkTypes: alloy_network::Network<ReceiptResponse = AnyTransactionReceipt>,
|
||||
> + TraceExt
|
||||
+ EthTransactions,
|
||||
{
|
||||
@ -917,7 +928,9 @@ where
|
||||
EthApi: EthApiServer<
|
||||
WithOtherFields<reth_rpc_types::Transaction>,
|
||||
reth_rpc_types::Block<WithOtherFields<reth_rpc_types::Transaction>>,
|
||||
reth_rpc_types::AnyTransactionReceipt,
|
||||
RpcReceipt<EthApi::NetworkTypes>,
|
||||
> + EthApiTypes<
|
||||
NetworkTypes: alloy_network::Network<ReceiptResponse = AnyTransactionReceipt>,
|
||||
> + 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<ReceiptResponse = AnyTransactionReceipt>,
|
||||
>,
|
||||
{
|
||||
/// Configures the auth module that includes the
|
||||
/// * `engine_` namespace
|
||||
|
||||
@ -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<T>
|
||||
RpcReceipt<T::NetworkTypes>,
|
||||
> for T
|
||||
where
|
||||
T: FullEthApi,
|
||||
T: FullEthApi<NetworkTypes: Network<ReceiptResponse = AnyTransactionReceipt>>,
|
||||
jsonrpsee_types::error::ErrorObject<'static>: From<T::Error>,
|
||||
{
|
||||
/// Handler for: `eth_protocolVersion`
|
||||
|
||||
@ -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<Transaction>,
|
||||
HeaderResponse = reth_rpc_types::Header,
|
||||
ReceiptResponse = AnyTransactionReceipt,
|
||||
>;
|
||||
}
|
||||
|
||||
|
||||
@ -44,14 +44,17 @@ impl<Eth> OtterscanApi<Eth> {
|
||||
impl<Eth> OtterscanApi<Eth>
|
||||
where
|
||||
Eth: EthApiTypes<
|
||||
NetworkTypes: Network<TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>>,
|
||||
NetworkTypes: Network<
|
||||
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
|
||||
ReceiptResponse = AnyTransactionReceipt,
|
||||
>,
|
||||
>,
|
||||
{
|
||||
/// Constructs a `BlockDetails` from a block and its receipts.
|
||||
fn block_details(
|
||||
&self,
|
||||
block: RpcBlock<Eth::NetworkTypes>,
|
||||
receipts: Vec<AnyTransactionReceipt>,
|
||||
receipts: Vec<RpcReceipt<Eth::NetworkTypes>>,
|
||||
) -> RpcResult<BlockDetails> {
|
||||
// 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<reth_rpc_types::Transaction>,
|
||||
ReceiptResponse = AnyTransactionReceipt,
|
||||
>,
|
||||
> + TraceExt
|
||||
+ EthTransactions
|
||||
|
||||
Reference in New Issue
Block a user