From 4cbd1990163a005e0bca0b3e1f94ccd28dbf2e04 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 8 Feb 2023 17:06:20 +0100 Subject: [PATCH] fix(rpc): remove unused rpc transaction fields (#1228) --- .../rpc/rpc-types/src/eth/transaction/mod.rs | 42 +++++++++---------- .../src/eth/transaction/signature.rs | 14 +++++++ 2 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 crates/rpc/rpc-types/src/eth/transaction/signature.rs diff --git a/crates/rpc/rpc-types/src/eth/transaction/mod.rs b/crates/rpc/rpc-types/src/eth/transaction/mod.rs index 9b5b65367c..5841d661e4 100644 --- a/crates/rpc/rpc-types/src/eth/transaction/mod.rs +++ b/crates/rpc/rpc-types/src/eth/transaction/mod.rs @@ -1,17 +1,19 @@ mod receipt; mod request; +mod signature; mod typed; pub use receipt::TransactionReceipt; pub use request::TransactionRequest; +pub use signature::Signature; pub use typed::*; use reth_primitives::{ - rpc::transaction::eip2930::AccessListItem, Address, Bytes, H256, H512, U128, U256, U64, + rpc::transaction::eip2930::AccessListItem, Address, Bytes, H256, U128, U256, U64, }; use serde::{Deserialize, Serialize}; -/// Transaction object +/// Transaction object used in RPC #[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Transaction { @@ -34,36 +36,32 @@ pub struct Transaction { /// Gas Price #[serde(skip_serializing_if = "Option::is_none")] pub gas_price: Option, + /// Gas amount + pub gas: U256, /// Max BaseFeePerGas the user is willing to pay. #[serde(skip_serializing_if = "Option::is_none")] pub max_fee_per_gas: Option, /// The miner's tip. #[serde(skip_serializing_if = "Option::is_none")] pub max_priority_fee_per_gas: Option, - /// Gas - pub gas: U256, /// Data pub input: Bytes, - /// Creates contract - pub creates: Option
, - /// Raw transaction data - pub raw: Bytes, - /// Public key of the signer. - pub public_key: Option, - /// The network id of the transaction, if any. + /// All _flattened_ fields of the transaction signature. + /// + /// Note: this is an option so special transaction types without a signature (e.g. ) can be supported. + #[serde(flatten, skip_serializing_if = "Option::is_none")] + pub signature: Option, + /// The chain id of the transaction, if any. pub chain_id: Option, - /// The standardised V field of the signature (0 or 1). - pub standard_v: U256, - /// The standardised V field of the signature. - pub v: U256, - /// The R field of the signature. - pub r: U256, - /// The S field of the signature. - pub s: U256, + /// EIP2930 + /// /// Pre-pay to warm storage access. - #[cfg_attr(feature = "std", serde(skip_serializing_if = "Option::is_none"))] + #[serde(skip_serializing_if = "Option::is_none")] pub access_list: Option>, - /// EIP-2718 type + /// EIP2718 + /// + /// Transaction type, Some(2) for EIP-1559 transaction, + /// Some(1) for AccessList transaction, None for Legacy #[serde(rename = "type", skip_serializing_if = "Option::is_none")] - pub transaction_type: Option, + pub transaction_type: Option, } diff --git a/crates/rpc/rpc-types/src/eth/transaction/signature.rs b/crates/rpc/rpc-types/src/eth/transaction/signature.rs new file mode 100644 index 0000000000..88ac34bf93 --- /dev/null +++ b/crates/rpc/rpc-types/src/eth/transaction/signature.rs @@ -0,0 +1,14 @@ +//! Signature related RPC values +use reth_primitives::U256; +use serde::{Deserialize, Serialize}; + +/// Container type for all signature fields in RPC +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, Serialize, Deserialize)] +pub struct Signature { + /// The R field of the signature; the point on the curve. + pub r: U256, + /// The S field of the signature; the point on the curve. + pub s: U256, + /// The standardised V field of the signature (0 or 1). + pub v: U256, +}