Skip to content

Commit

Permalink
rpc-types: replace reth TransactionRequest by alloy (#11091)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Sep 21, 2024
1 parent 5113e29 commit b9712c5
Show file tree
Hide file tree
Showing 27 changed files with 43 additions and 24 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/optimism/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ reth-optimism-forks.workspace = true

# ethereum
alloy-primitives.workspace = true
alloy-rpc-types-eth.workspace = true
op-alloy-network.workspace = true
op-alloy-rpc-types.workspace = true
op-alloy-consensus.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/rpc/src/eth/call.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloy_primitives::{Bytes, TxKind, U256};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use reth_chainspec::ChainSpec;
use reth_evm::ConfigureEvm;
use reth_node_api::{FullNodeComponents, NodeTypes};
Expand All @@ -11,7 +12,6 @@ use reth_rpc_eth_api::{
FromEthApiError, IntoEthApiError,
};
use reth_rpc_eth_types::{revm_utils::CallFees, RpcInvalidTransactionError};
use reth_rpc_types::TransactionRequest;

use crate::{OpEthApi, OpEthApiError};

Expand Down
1 change: 1 addition & 0 deletions crates/rpc/rpc-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ reth-network-peers.workspace = true
alloy-eips.workspace = true
alloy-json-rpc.workspace = true
alloy-primitives.workspace = true
alloy-rpc-types-eth.workspace = true

# misc
jsonrpsee = { workspace = true, features = ["server", "macros"] }
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-api/src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloy_primitives::{Address, Bytes, B256};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use reth_primitives::{BlockId, BlockNumberOrTag};
use reth_rpc_types::{
Expand All @@ -7,7 +8,7 @@ use reth_rpc_types::{
BlockTraceResult, GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace,
TraceResult,
},
Block, Bundle, StateContext, TransactionRequest,
Block, Bundle, StateContext,
};

/// Debug rpc interface.
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-api/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use alloy_eips::{eip4844::BlobAndProofV1, BlockId, BlockNumberOrTag};
use alloy_json_rpc::RpcObject;
use alloy_primitives::{Address, BlockHash, Bytes, B256, U256, U64};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use reth_engine_primitives::EngineTypes;
use reth_rpc_types::{
Expand All @@ -16,7 +17,6 @@ use reth_rpc_types::{
},
state::StateOverride,
BlockOverrides, EIP1186AccountProofResponse, Filter, JsonStorageKey, Log, SyncStatus,
TransactionRequest,
};
// NOTE: We can't use associated types in the `EngineApi` trait because of jsonrpsee, so we use a
// generic here. It would be nice if the rpc macro would understand which types need to have serde.
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-api/src/trace.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloy_primitives::{Bytes, B256};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use reth_primitives::BlockId;
use reth_rpc_types::{
Expand All @@ -8,7 +9,7 @@ use reth_rpc_types::{
opcode::{BlockOpcodeGas, TransactionOpcodeGas},
parity::*,
},
BlockOverrides, Index, TransactionRequest,
BlockOverrides, Index,
};
use std::collections::HashSet;

Expand Down
1 change: 1 addition & 0 deletions crates/rpc/rpc-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ reth-node-api.workspace = true
reth-rpc-types-compat.workspace = true

alloy-primitives.workspace = true
alloy-rpc-types-eth.workspace = true

tokio = { workspace = true, features = ["rt", "rt-multi-thread"] }
serde_json.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-builder/tests/it/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use crate::utils::{launch_http, launch_http_ws, launch_ws};
use alloy_primitives::{hex_literal::hex, Address, Bytes, TxHash, B256, B64, U256, U64};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use jsonrpsee::{
core::{
client::{ClientT, SubscriptionClientT},
Expand All @@ -22,7 +23,7 @@ use reth_rpc_api::{
use reth_rpc_server_types::RethRpcModule;
use reth_rpc_types::{
trace::filter::TraceFilter, Block, FeeHistory, Filter, Index, Log,
PendingTransactionFilterKind, SyncStatus, Transaction, TransactionReceipt, TransactionRequest,
PendingTransactionFilterKind, SyncStatus, Transaction, TransactionReceipt,
};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::Value;
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/rpc-eth-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ alloy-dyn-abi = { workspace = true, features = ["eip712"] }
alloy-json-rpc.workspace = true
alloy-network.workspace = true
alloy-primitives.workspace = true
alloy-rpc-types-eth.workspace = true

# rpc
jsonrpsee = { workspace = true, features = ["server", "macros"] }
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-eth-api/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use alloy_dyn_abi::TypedData;
use alloy_json_rpc::RpcObject;
use alloy_primitives::{Address, Bytes, B256, B64, U256, U64};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use reth_primitives::{transaction::AccessListResult, BlockId, BlockNumberOrTag};
use reth_rpc_server_types::{result::internal_rpc_err, ToRpcResult};
Expand All @@ -11,7 +12,7 @@ use reth_rpc_types::{
simulate::{SimulatePayload, SimulatedBlock},
state::{EvmOverrides, StateOverride},
BlockOverrides, Bundle, EIP1186AccountProofResponse, EthCallResponse, FeeHistory, Header,
Index, StateContext, SyncStatus, TransactionRequest, Work,
Index, StateContext, SyncStatus, Work,
};
use tracing::trace;

Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-eth-api/src/helpers/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
AsEthApiError, FromEthApiError, FromEvmError, FullEthApiTypes, IntoEthApiError, RpcBlock,
};
use alloy_primitives::{Bytes, TxKind, B256, U256};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use futures::Future;
use reth_chainspec::MIN_TRANSACTION_GAS;
use reth_evm::{ConfigureEvm, ConfigureEvmEnv};
Expand Down Expand Up @@ -33,7 +34,7 @@ use reth_rpc_server_types::constants::gas_oracle::{CALL_STIPEND_GAS, ESTIMATE_GA
use reth_rpc_types::{
simulate::{SimBlock, SimulatePayload, SimulatedBlock},
state::{EvmOverrides, StateOverride},
BlockId, Bundle, EthCallResponse, StateContext, TransactionInfo, TransactionRequest,
BlockId, Bundle, EthCallResponse, StateContext, TransactionInfo,
};
use revm::{Database, DatabaseCommit, GetInspector};
use revm_inspectors::{access_list::AccessListInspector, transfer::TransferInspector};
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-eth-api/src/helpers/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use alloy_dyn_abi::TypedData;
use alloy_primitives::{Address, Bytes, TxHash, TxKind, B256, U256};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use futures::Future;
use reth_primitives::{
BlockId, Receipt, SealedBlockWithSenders, TransactionMeta, TransactionSigned,
Expand All @@ -17,7 +18,7 @@ use reth_rpc_types::{
EIP1559TransactionRequest, EIP2930TransactionRequest, EIP4844TransactionRequest,
LegacyTransactionRequest,
},
BlockNumberOrTag, TransactionInfo, TransactionRequest, TypedTransactionRequest,
BlockNumberOrTag, TransactionInfo, TypedTransactionRequest,
};
use reth_rpc_types_compat::transaction::{from_recovered, from_recovered_with_block_context};
use reth_transaction_pool::{PoolTransaction, TransactionOrigin, TransactionPool};
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/rpc-eth-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ reth-trie.workspace = true
alloy-primitives.workspace = true
alloy-consensus.workspace = true
alloy-sol-types.workspace = true
alloy-rpc-types-eth.workspace = true
revm.workspace = true
revm-inspectors.workspace = true
revm-primitives = { workspace = true, features = ["dev"] }
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc-eth-types/src/revm_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ where
.unwrap_or_default())
}

/// Helper type for representing the fees of a [`reth_rpc_types::TransactionRequest`]
/// Helper type for representing the fees of a `TransactionRequest`
#[derive(Debug)]
pub struct CallFees {
/// EIP-1559 priority fee
Expand All @@ -85,7 +85,7 @@ pub struct CallFees {
// === impl CallFees ===

impl CallFees {
/// Ensures the fields of a [`reth_rpc_types::TransactionRequest`] are not conflicting.
/// Ensures the fields of a `TransactionRequest` are not conflicting.
///
/// # EIP-4844 transactions
///
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-eth-types/src/simulate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Utilities for serving `eth_simulateV1`

use alloy_consensus::{TxEip4844Variant, TxType, TypedTransaction};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use jsonrpsee_types::ErrorObject;
use reth_primitives::{
logs_bloom,
Expand All @@ -11,7 +12,7 @@ use reth_revm::database::StateProviderDatabase;
use reth_rpc_server_types::result::rpc_err;
use reth_rpc_types::{
simulate::{SimCallResult, SimulateError, SimulatedBlock},
Block, BlockTransactionsKind, ToRpcError, TransactionRequest,
Block, BlockTransactionsKind, ToRpcError,
};
use reth_rpc_types_compat::{block::from_block, TransactionCompat};
use reth_storage_api::StateRootProvider;
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/rpc-testing-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ reth-rpc-api = { workspace = true, features = ["client"] }

# ethereum
alloy-primitives.workspace = true
alloy-rpc-types-eth.workspace = true

# async
futures.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-testing-util/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{
};

use alloy_primitives::{TxHash, B256};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use futures::{Stream, StreamExt};
use jsonrpsee::core::client::Error as RpcError;
use reth_primitives::{BlockId, Receipt};
Expand All @@ -16,7 +17,7 @@ use reth_rpc_types::{
common::TraceResult,
geth::{GethDebugTracerType, GethDebugTracingOptions, GethTrace},
},
Block, Transaction, TransactionRequest,
Block, Transaction,
};

const NOOP_TRACER: &str = include_str!("../assets/noop-tracer.js");
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc-testing-util/src/trace.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Helpers for testing trace calls.

use alloy_primitives::{Bytes, TxHash, B256};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use futures::{Stream, StreamExt};
use jsonrpsee::core::client::Error as RpcError;
use reth_primitives::BlockId;
Expand All @@ -11,7 +12,7 @@ use reth_rpc_types::{
parity::{LocalizedTransactionTrace, TraceResults, TraceType},
tracerequest::TraceCallRequest,
},
Index, TransactionRequest,
Index,
};
use std::{
collections::HashSet,
Expand Down
2 changes: 0 additions & 2 deletions crates/rpc/rpc-types/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//! RPC types for transactions
mod request;
mod typed;
pub use request::TransactionRequest;
pub use typed::*;
1 change: 0 additions & 1 deletion crates/rpc/rpc-types/src/eth/transaction/request.rs

This file was deleted.

4 changes: 0 additions & 4 deletions crates/rpc/rpc-types/src/eth/transaction/typed.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
//! The [`TransactionRequest`][crate::TransactionRequest] is a universal representation for a
//! transaction deserialized from the json input of an RPC call. Depending on what fields are set,
//! it can be converted into the container type [`TypedTransactionRequest`].

use alloy_primitives::{Address, Bytes, TxKind, B256, U256};
use alloy_rpc_types::{AccessList, BlobTransactionSidecar};

Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub use alloy_rpc_types_debug as debug;
// Ethereum specific rpc types related to typed transaction requests and the engine API.
#[cfg(feature = "jsonrpsee-types")]
pub use eth::error::ToRpcError;
pub use eth::transaction::{self, TransactionRequest, TypedTransactionRequest};
pub use eth::transaction::{self, TypedTransactionRequest};
#[cfg(feature = "jsonrpsee-types")]
pub use eth::{
engine,
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ alloy-genesis.workspace = true
alloy-network.workspace = true
alloy-primitives.workspace = true
alloy-rlp.workspace = true
alloy-rpc-types-eth.workspace = true
revm = { workspace = true, features = [
"optional_block_gas_limit",
"optional_eip3607",
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use alloy_primitives::{Address, Bytes, B256, U256};
use alloy_rlp::{Decodable, Encodable};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use async_trait::async_trait;
use jsonrpsee::core::RpcResult;
use reth_chainspec::{ChainSpec, EthereumHardforks};
Expand Down Expand Up @@ -27,7 +28,7 @@ use reth_rpc_types::{
BlockTraceResult, FourByteFrame, GethDebugBuiltInTracerType, GethDebugTracerType,
GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, NoopFrame, TraceResult,
},
Block as RpcBlock, BlockError, Bundle, StateContext, TransactionRequest,
Block as RpcBlock, BlockError, Bundle, StateContext,
};
use reth_tasks::pool::BlockingTaskGuard;
use reth_trie::{HashedPostState, HashedStorage};
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc/src/engine.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloy_primitives::{Address, Bytes, B256, U256, U64};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use jsonrpsee::core::RpcResult as Result;
use reth_primitives::{BlockId, BlockNumberOrTag};
use reth_rpc_api::{EngineEthApiServer, EthApiServer, EthFilterApiServer};
Expand All @@ -7,7 +8,7 @@ pub use reth_rpc_engine_api::EngineApi;
use reth_rpc_eth_api::{FullEthApiTypes, RpcBlock, RpcReceipt, RpcTransaction};
use reth_rpc_types::{
state::StateOverride, BlockOverrides, EIP1186AccountProofResponse, Filter, JsonStorageKey, Log,
SyncStatus, TransactionRequest,
SyncStatus,
};
use tracing_futures::Instrument;

Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/rpc/src/trace.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{collections::HashSet, sync::Arc};

use alloy_primitives::{Bytes, B256, U256};
use alloy_rpc_types_eth::transaction::TransactionRequest;
use async_trait::async_trait;
use jsonrpsee::core::RpcResult;
use reth_chainspec::{ChainSpec, EthereumHardforks};
Expand All @@ -25,7 +26,7 @@ use reth_rpc_types::{
parity::*,
tracerequest::TraceCallRequest,
},
BlockOverrides, Index, TransactionRequest,
BlockOverrides, Index,
};
use reth_tasks::pool::BlockingTaskGuard;
use revm::{
Expand Down

0 comments on commit b9712c5

Please sign in to comment.