Skip to content

Commit

Permalink
chore(rpc): remove use of extensible transaction + receipt types (par…
Browse files Browse the repository at this point in the history
  • Loading branch information
emhane authored Sep 20, 2024
1 parent 05f862a commit b5adf24
Show file tree
Hide file tree
Showing 52 changed files with 821 additions and 652 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 2 additions & 12 deletions crates/e2e-test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
use std::sync::Arc;

use alloy_network::Network;
use node::NodeTestContext;
use reth::{
args::{DiscoveryArgs, NetworkArgs, RpcServerArgs},
builder::{NodeBuilder, NodeConfig, NodeHandle},
network::PeersHandleProvider,
rpc::{
api::eth::{helpers::AddDevSigners, FullEthApiServer},
types::AnyTransactionReceipt,
},
rpc::api::eth::{helpers::AddDevSigners, FullEthApiServer},
tasks::TaskManager,
};
use reth_chainspec::ChainSpec;
Expand Down Expand Up @@ -62,13 +58,7 @@ where
>,
N::AddOns: NodeAddOns<
Adapter<N>,
EthApi: FullEthApiServer<
NetworkTypes: Network<
TransactionResponse = reth_rpc_types::WithOtherFields<reth_rpc_types::Transaction>,
ReceiptResponse = AnyTransactionReceipt,
>,
> + AddDevSigners
+ EthApiBuilderProvider<Adapter<N>>,
EthApi: FullEthApiServer + AddDevSigners + EthApiBuilderProvider<Adapter<N>>,
>,
{
let tasks = TaskManager::current();
Expand Down
20 changes: 8 additions & 12 deletions crates/e2e-test-utils/src/node.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{marker::PhantomData, pin::Pin};

use alloy_network::Network;
use alloy_primitives::{BlockHash, BlockNumber, Bytes, B256};
use alloy_rpc_types::BlockNumberOrTag;
use eyre::Ok;
Expand All @@ -11,13 +10,15 @@ use reth::{
network::PeersHandleProvider,
providers::{BlockReader, BlockReaderIdExt, CanonStateSubscriptions, StageCheckpointReader},
rpc::{
api::eth::helpers::{EthApiSpec, EthTransactions, TraceExt},
types::{engine::PayloadStatusEnum, AnyTransactionReceipt},
api::eth::{
helpers::{EthApiSpec, EthTransactions, TraceExt},
FullEthApiTypes,
},
types::engine::PayloadStatusEnum,
},
};
use reth_chainspec::ChainSpec;
use reth_node_builder::{EthApiTypes, NodeAddOns, NodeTypesWithEngine};
use reth_rpc_types::WithOtherFields;
use reth_node_builder::{NodeAddOns, NodeTypesWithEngine};
use reth_stages_types::StageId;
use tokio_stream::StreamExt;

Expand Down Expand Up @@ -87,13 +88,8 @@ where
attributes_generator: impl Fn(u64) -> Engine::PayloadBuilderAttributes + Copy,
) -> eyre::Result<Vec<(Engine::BuiltPayload, Engine::PayloadBuilderAttributes)>>
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>,
ReceiptResponse = AnyTransactionReceipt,
>,
Engine::ExecutionPayloadV3: From<Engine::BuiltPayload> + PayloadEnvelopeExt,
AddOns::EthApi: EthApiSpec + EthTransactions + TraceExt + FullEthApiTypes,
{
let mut chain = Vec::with_capacity(length as usize);
for i in 0..length {
Expand Down
11 changes: 2 additions & 9 deletions crates/e2e-test-utils/src/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_consensus::TxEnvelope;
use alloy_network::{eip2718::Decodable2718, Network};
use alloy_network::eip2718::Decodable2718;
use alloy_primitives::{Bytes, B256};
use reth::{
builder::{rpc::RpcRegistry, FullNodeComponents},
Expand All @@ -10,7 +10,6 @@ use reth::{
};
use reth_chainspec::ChainSpec;
use reth_node_builder::{EthApiTypes, NodeTypes};
use reth_rpc_types::{AnyTransactionReceipt, WithOtherFields};

#[allow(missing_debug_implementations)]
pub struct RpcTestContext<Node: FullNodeComponents, EthApi: EthApiTypes> {
Expand All @@ -20,13 +19,7 @@ pub struct RpcTestContext<Node: FullNodeComponents, EthApi: EthApiTypes> {
impl<Node, EthApi> RpcTestContext<Node, EthApi>
where
Node: FullNodeComponents<Types: NodeTypes<ChainSpec = ChainSpec>>,
EthApi: EthApiSpec
+ EthTransactions<
NetworkTypes: Network<
TransactionResponse = WithOtherFields<alloy_rpc_types::Transaction>,
ReceiptResponse = AnyTransactionReceipt,
>,
> + TraceExt,
EthApi: EthApiSpec + EthTransactions + TraceExt,
{
/// Injects a raw transaction into the node tx pool via RPC server
pub async fn inject_tx(&self, raw_tx: Bytes) -> Result<B256, EthApi::Error> {
Expand Down
1 change: 0 additions & 1 deletion crates/node/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ reth-tracing.workspace = true
reth-transaction-pool.workspace = true

## ethereum
alloy-network.workspace = true
alloy-primitives.workspace = true

## async
Expand Down
21 changes: 4 additions & 17 deletions crates/node/builder/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
pub mod add_ons;
mod states;

use reth_rpc_types::WithOtherFields;
pub use states::*;

use std::sync::Arc;
Expand All @@ -30,10 +29,7 @@ use reth_node_core::{
dirs::{ChainPath, DataDirPath},
node_config::NodeConfig,
primitives::Head,
rpc::{
eth::{helpers::AddDevSigners, FullEthApiServer},
types::AnyTransactionReceipt,
},
rpc::eth::{helpers::AddDevSigners, FullEthApiServer},
};
use reth_primitives::revm_primitives::EnvKzgSettings;
use reth_provider::{providers::BlockchainProvider, ChainSpecProvider, FullProvider};
Expand Down Expand Up @@ -346,12 +342,7 @@ where
<N::ComponentsBuilder as NodeComponentsBuilder<RethFullAdapter<DB, N>>>::Components,
>
>
+ FullEthApiServer<
NetworkTypes: alloy_network::Network<
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
ReceiptResponse = AnyTransactionReceipt,
>,
>
+ FullEthApiServer
+ AddDevSigners
>,
{
Expand Down Expand Up @@ -497,12 +488,8 @@ where
AO: NodeAddOns<
NodeAdapter<RethFullAdapter<DB, T>, CB::Components>,
EthApi: EthApiBuilderProvider<NodeAdapter<RethFullAdapter<DB, T>, CB::Components>>
+ FullEthApiServer<
NetworkTypes: alloy_network::Network<
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
ReceiptResponse = AnyTransactionReceipt,
>,
> + AddDevSigners,
+ FullEthApiServer
+ AddDevSigners,
>,
{
/// Launches the node with the [`DefaultNodeLauncher`] that sets up engine API consensus and rpc
Expand Down
15 changes: 4 additions & 11 deletions crates/node/builder/src/launch/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ use reth_node_core::{
dirs::{ChainPath, DataDirPath},
exit::NodeExitFuture,
primitives::Head,
rpc::{
eth::{helpers::AddDevSigners, FullEthApiServer},
types::AnyTransactionReceipt,
},
rpc::eth::{helpers::AddDevSigners, FullEthApiServer},
version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA},
};
use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
use reth_payload_primitives::PayloadBuilder;
use reth_provider::providers::BlockchainProvider2;
use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi};
use reth_rpc_types::{engine::ClientVersionV1, WithOtherFields};
use reth_rpc_types::engine::ClientVersionV1;
use reth_tasks::TaskExecutor;
use reth_tokio_util::EventSender;
use reth_tracing::tracing::{debug, error, info};
Expand Down Expand Up @@ -81,12 +78,8 @@ where
AO: NodeAddOns<
NodeAdapter<T, CB::Components>,
EthApi: EthApiBuilderProvider<NodeAdapter<T, CB::Components>>
+ FullEthApiServer<
NetworkTypes: alloy_network::Network<
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
ReceiptResponse = AnyTransactionReceipt,
>,
> + AddDevSigners,
+ FullEthApiServer
+ AddDevSigners,
>,
{
type Node = NodeHandle<NodeAdapter<T, CB::Components>, AO>;
Expand Down
18 changes: 6 additions & 12 deletions crates/node/builder/src/launch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,14 @@ use reth_node_api::{
use reth_node_core::{
dirs::{ChainPath, DataDirPath},
exit::NodeExitFuture,
rpc::{
eth::{helpers::AddDevSigners, FullEthApiServer},
types::AnyTransactionReceipt,
},
rpc::eth::{helpers::AddDevSigners, FullEthApiServer},
version::{CARGO_PKG_VERSION, CLIENT_CODE, NAME_CLIENT, VERGEN_GIT_SHA},
};
use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
use reth_primitives::format_ether;
use reth_provider::providers::BlockchainProvider;
use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi};
use reth_rpc_types::{engine::ClientVersionV1, WithOtherFields};
use reth_rpc_types::engine::ClientVersionV1;
use reth_tasks::TaskExecutor;
use reth_tracing::tracing::{debug, info};
use reth_transaction_pool::TransactionPool;
Expand All @@ -55,13 +52,14 @@ use crate::{
};

/// Alias for [`reth_rpc_eth_types::EthApiBuilderCtx`], adapter for [`FullNodeComponents`].
pub type EthApiBuilderCtx<N> = reth_rpc_eth_types::EthApiBuilderCtx<
pub type EthApiBuilderCtx<N, Eth> = reth_rpc_eth_types::EthApiBuilderCtx<
<N as FullNodeTypes>::Provider,
<N as FullNodeComponents>::Pool,
<N as FullNodeComponents>::Evm,
<N as FullNodeComponents>::Network,
TaskExecutor,
<N as FullNodeTypes>::Provider,
Eth,
>;

/// A general purpose trait that launches a new node of any kind.
Expand Down Expand Up @@ -114,12 +112,8 @@ where
AO: NodeAddOns<
NodeAdapter<T, CB::Components>,
EthApi: EthApiBuilderProvider<NodeAdapter<T, CB::Components>>
+ FullEthApiServer<
NetworkTypes: alloy_network::Network<
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
ReceiptResponse = AnyTransactionReceipt,
>,
> + AddDevSigners,
+ FullEthApiServer
+ AddDevSigners,
>,
{
type Node = NodeHandle<NodeAdapter<T, CB::Components>, AO>;
Expand Down
16 changes: 4 additions & 12 deletions crates/node/builder/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use reth_node_core::{
rpc::{
api::EngineApiServer,
eth::{EthApiTypes, FullEthApiServer},
types::AnyTransactionReceipt,
},
};
use reth_payload_builder::PayloadBuilderHandle;
Expand All @@ -25,7 +24,6 @@ use reth_rpc_builder::{
RpcModuleBuilder, RpcRegistryInner, RpcServerHandle, TransportRpcModules,
};
use reth_rpc_layer::JwtSecret;
use reth_rpc_types::WithOtherFields;
use reth_tasks::TaskExecutor;
use reth_tracing::tracing::{debug, info};

Expand Down Expand Up @@ -305,13 +303,7 @@ pub async fn launch_rpc_servers<Node, Engine, EthApi>(
where
Node: FullNodeComponents<Types: NodeTypesWithDB<ChainSpec = ChainSpec>> + Clone,
Engine: EngineApiServer<<Node::Types as NodeTypesWithEngine>::Engine>,
EthApi: EthApiBuilderProvider<Node>
+ FullEthApiServer<
NetworkTypes: alloy_network::Network<
TransactionResponse = WithOtherFields<reth_rpc_types::Transaction>,
ReceiptResponse = AnyTransactionReceipt,
>,
>,
EthApi: EthApiBuilderProvider<Node> + FullEthApiServer,
{
let auth_config = config.rpc.auth_server_config(jwt_secret)?;
let module_config = config.rpc.transport_rpc_module_config();
Expand Down Expand Up @@ -386,15 +378,15 @@ where
pub trait EthApiBuilderProvider<N: FullNodeComponents>: BuilderProvider<N> + EthApiTypes {
/// Returns the eth api builder.
#[allow(clippy::type_complexity)]
fn eth_api_builder() -> Box<dyn Fn(&EthApiBuilderCtx<N>) -> Self + Send>;
fn eth_api_builder() -> Box<dyn Fn(&EthApiBuilderCtx<N, Self>) -> Self + Send>;
}

impl<N, F> EthApiBuilderProvider<N> for F
where
N: FullNodeComponents,
for<'a> F: BuilderProvider<N, Ctx<'a> = &'a EthApiBuilderCtx<N>> + EthApiTypes,
for<'a> F: BuilderProvider<N, Ctx<'a> = &'a EthApiBuilderCtx<N, Self>> + EthApiTypes,
{
fn eth_api_builder() -> Box<dyn Fn(&EthApiBuilderCtx<N>) -> Self + Send> {
fn eth_api_builder() -> Box<dyn Fn(&EthApiBuilderCtx<N, Self>) -> Self + Send> {
F::builder()
}
}
1 change: 1 addition & 0 deletions crates/optimism/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ serde_json.workspace = true
# misc
thiserror.workspace = true
tracing.workspace = true
derive_more.workspace = true

[dev-dependencies]
reth-optimism-chainspec.workspace = true
Expand Down
Loading

0 comments on commit b5adf24

Please sign in to comment.