From c1e7aaadc8cd816bbbfe8f8ac24d00919f64f9be Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Sun, 10 Nov 2024 15:43:19 +0100 Subject: [PATCH 01/14] Implement Transaction for SignedTransaction types --- .../src/transaction/signed.rs | 108 +++++++++++++++++- 1 file changed, 102 insertions(+), 6 deletions(-) diff --git a/crates/primitives-traits/src/transaction/signed.rs b/crates/primitives-traits/src/transaction/signed.rs index c40403865dff..a043d0db10a3 100644 --- a/crates/primitives-traits/src/transaction/signed.rs +++ b/crates/primitives-traits/src/transaction/signed.rs @@ -2,17 +2,24 @@ use alloc::fmt; use core::hash::Hash; -use reth_codecs::Compact; -use alloy_consensus::Transaction; -use alloy_eips::eip2718::{Decodable2718, Encodable2718}; -use alloy_primitives::{keccak256, Address, PrimitiveSignature as Signature, TxHash, B256}; +use alloy_eips::{ + eip2718::{Decodable2718, Encodable2718}, + eip2930::AccessList, + eip7702::SignedAuthorization, +}; +use alloy_primitives::{ + keccak256, Address, Bytes, ChainId, PrimitiveSignature as Signature, TxHash, TxKind, B256, U256, +}; +use reth_codecs::Compact; use revm_primitives::TxEnv; +use crate::{FullTransaction, Transaction}; + /// Helper trait that unifies all behaviour required by block to support full node operations. -pub trait FullSignedTx: SignedTransaction + Compact {} +pub trait FullSignedTx: SignedTransaction + Compact {} -impl FullSignedTx for T where T: SignedTransaction + Compact {} +impl FullSignedTx for T where T: SignedTransaction + Compact {} /// A signed transaction. pub trait SignedTransaction: @@ -29,6 +36,7 @@ pub trait SignedTransaction: + alloy_rlp::Decodable + Encodable2718 + Decodable2718 + + Transaction { /// Transaction type that is signed. type Transaction: Transaction; @@ -75,3 +83,91 @@ pub trait SignedTransaction: /// Fills [`TxEnv`] with an [`Address`] and transaction. fn fill_tx_env(&self, tx_env: &mut TxEnv, sender: Address); } + +impl alloy_consensus::Transaction for T { + fn chain_id(&self) -> Option { + self.transaction().chain_id() + } + + fn nonce(&self) -> u64 { + self.transaction().nonce() + } + + fn gas_limit(&self) -> u64 { + self.transaction().gas_limit() + } + + fn gas_price(&self) -> Option { + self.transaction().gas_price() + } + + fn max_fee_per_gas(&self) -> u128 { + self.transaction().max_fee_per_gas() + } + + fn max_priority_fee_per_gas(&self) -> Option { + self.transaction().max_priority_fee_per_gas() + } + + fn max_fee_per_blob_gas(&self) -> Option { + self.transaction().max_fee_per_blob_gas() + } + + fn priority_fee_or_price(&self) -> u128 { + self.transaction().priority_fee_or_price() + } + + fn kind(&self) -> TxKind { + self.transaction().kind() + } + + fn value(&self) -> U256 { + self.transaction().value() + } + + fn input(&self) -> &Bytes { + self.transaction().input() + } + + fn ty(&self) -> u8 { + self.transaction().ty() + } + + fn access_list(&self) -> Option<&AccessList> { + self.transaction().access_list() + } + + fn blob_versioned_hashes(&self) -> Option<&[B256]> { + self.transaction().blob_versioned_hashes() + } + + fn authorization_list(&self) -> Option<&[SignedAuthorization]> { + self.transaction().authorization_list() + } +} + +impl Transaction for T { + fn signature_hash(&self) -> B256 { + self.transaction().signature_hash() + } + + fn kind(&self) -> TxKind { + self.transaction().kind() + } + + fn is_dynamic_fee(&self) -> bool { + self.transaction().is_dynamic_fee() + } + + fn effective_gas_price(&self, base_fee: Option) -> u128 { + self.transaction().effective_gas_price(base_fee) + } + + fn encode_without_signature(&self, out: &mut dyn bytes::BufMut) { + self.transaction().encode_without_signature(out) + } + + fn size(&self) -> usize { + self.transaction().size() + } +} From 8e0da8fbbe7fa4a9cfc6e476208792c80d8c9baf Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Sun, 10 Nov 2024 17:10:44 +0100 Subject: [PATCH 02/14] Improve usability transaction primitive traits --- crates/primitives-traits/src/lib.rs | 13 ++- .../primitives-traits/src/transaction/mod.rs | 68 +++++++------ .../src/transaction/signed.rs | 95 +++---------------- crates/primitives/src/transaction/mod.rs | 44 ++++++++- 4 files changed, 107 insertions(+), 113 deletions(-) diff --git a/crates/primitives-traits/src/lib.rs b/crates/primitives-traits/src/lib.rs index ec93f2a21632..2897dd6340a8 100644 --- a/crates/primitives-traits/src/lib.rs +++ b/crates/primitives-traits/src/lib.rs @@ -27,7 +27,7 @@ pub use receipt::Receipt; pub mod transaction; pub use transaction::{ signed::{FullSignedTx, SignedTransaction}, - FullTransaction, Transaction, + AlloyTransactionExt, FullTransaction, Transaction, }; mod integer_list; @@ -56,7 +56,7 @@ pub use tx_type::TxType; pub mod header; #[cfg(any(test, feature = "arbitrary", feature = "test-utils"))] pub use header::test_utils; -pub use header::{BlockHeader, Header, HeaderError, SealedHeader}; +pub use header::{Header, HeaderError, SealedHeader}; /// Bincode-compatible serde implementations for common abstracted types in Reth. /// @@ -69,3 +69,12 @@ pub use header::{BlockHeader, Header, HeaderError, SealedHeader}; pub mod serde_bincode_compat { pub use super::header::{serde_bincode_compat as header, serde_bincode_compat::*}; } + +/// Helper trait that requires arbitrary implementation if the feature is enabled. +#[cfg(feature = "arbitrary")] +pub trait MaybeArbitrary: for<'a> arbitrary::Arbitrary<'a> {} +#[cfg(not(feature = "arbitrary"))] +pub trait MaybeArbitrary {} + +#[cfg(feature = "arbitrary")] +impl MaybeArbitrary for T where T: for<'a> arbitrary::Arbitrary<'a> {} diff --git a/crates/primitives-traits/src/transaction/mod.rs b/crates/primitives-traits/src/transaction/mod.rs index a1ad81ab3270..1c4572704624 100644 --- a/crates/primitives-traits/src/transaction/mod.rs +++ b/crates/primitives-traits/src/transaction/mod.rs @@ -1,13 +1,20 @@ //! Transaction abstraction +pub mod signed; + use core::{fmt::Debug, hash::Hash}; -use alloy_primitives::{TxKind, B256}; +use alloy_primitives::B256; use reth_codecs::Compact; use serde::{Deserialize, Serialize}; -pub mod signed; +use crate::{MaybeArbitrary, TxType}; + +/// Helper trait that unifies all behaviour required by transaction to support full node operations. +pub trait FullTransaction: Transaction + Compact {} + +impl FullTransaction for T where T: Transaction + Compact {} #[allow(dead_code)] /// Abstraction of a transaction. @@ -19,43 +26,50 @@ pub trait Transaction: + PartialEq + Hash + Serialize + + for<'de> Deserialize<'de> + alloy_rlp::Encodable + alloy_rlp::Decodable - + for<'de> Deserialize<'de> - + alloy_consensus::Transaction + + AlloyTransactionExt + MaybeArbitrary { +} + +impl Transaction for T where + T: Debug + + Default + + Clone + + Eq + + PartialEq + + Hash + + Serialize + + for<'de> Deserialize<'de> + + alloy_rlp::Encodable + + alloy_rlp::Decodable + + AlloyTransactionExt + + MaybeArbitrary +{ +} + +/// Extension trait of [`alloy_consensus::Transaction`]. +pub trait AlloyTransactionExt: alloy_consensus::Transaction { + /// Transaction envelope type ID. + type Type: TxType; + /// Heavy operation that return signature hash over rlp encoded transaction. /// It is only for signature signing or signer recovery. fn signature_hash(&self) -> B256; - /// Gets the transaction's [`TxKind`], which is the address of the recipient or - /// [`TxKind::Create`] if the transaction is a contract creation. - fn kind(&self) -> TxKind; - - /// Returns true if the tx supports dynamic fees + /// Returns `true` if the tx supports dynamic fees fn is_dynamic_fee(&self) -> bool; /// Returns the effective gas price for the given base fee. fn effective_gas_price(&self, base_fee: Option) -> u128; - /// This encodes the transaction _without_ the signature, and is only suitable for creating a - /// hash intended for signing. - fn encode_without_signature(&self, out: &mut dyn bytes::BufMut); - - /// Calculates a heuristic for the in-memory size of the [Transaction]. + /// Calculates a heuristic for the in-memory size of the transaction. fn size(&self) -> usize; -} - -#[cfg(not(feature = "arbitrary"))] -/// Helper trait that requires arbitrary implementation if the feature is enabled. -pub trait MaybeArbitrary {} -#[cfg(feature = "arbitrary")] -/// Helper trait that requires arbitrary implementation if the feature is enabled. -pub trait MaybeArbitrary: for<'a> arbitrary::Arbitrary<'a> {} - -/// Helper trait that unifies all behaviour required by transaction to support full node operations. -pub trait FullTransaction: Transaction + Compact {} - -impl FullTransaction for T where T: Transaction + Compact {} + /// Returns the transaction type. + fn tx_type(&self) -> Self::Type { + Self::Type::try_from(self.ty()).expect("should decode tx type id") + } +} diff --git a/crates/primitives-traits/src/transaction/signed.rs b/crates/primitives-traits/src/transaction/signed.rs index a043d0db10a3..6928f098c324 100644 --- a/crates/primitives-traits/src/transaction/signed.rs +++ b/crates/primitives-traits/src/transaction/signed.rs @@ -3,18 +3,12 @@ use alloc::fmt; use core::hash::Hash; -use alloy_eips::{ - eip2718::{Decodable2718, Encodable2718}, - eip2930::AccessList, - eip7702::SignedAuthorization, -}; -use alloy_primitives::{ - keccak256, Address, Bytes, ChainId, PrimitiveSignature as Signature, TxHash, TxKind, B256, U256, -}; +use alloy_eips::eip2718::{Decodable2718, Encodable2718}; +use alloy_primitives::{keccak256, Address, PrimitiveSignature, TxHash, B256}; use reth_codecs::Compact; use revm_primitives::TxEnv; -use crate::{FullTransaction, Transaction}; +use crate::{transaction::AlloyTransactionExt, FullTransaction, MaybeArbitrary, Transaction}; /// Helper trait that unifies all behaviour required by block to support full node operations. pub trait FullSignedTx: SignedTransaction + Compact {} @@ -36,7 +30,8 @@ pub trait SignedTransaction: + alloy_rlp::Decodable + Encodable2718 + Decodable2718 - + Transaction + + AlloyTransactionExt + + MaybeArbitrary { /// Transaction type that is signed. type Transaction: Transaction; @@ -48,7 +43,7 @@ pub trait SignedTransaction: fn transaction(&self) -> &Self::Transaction; /// Returns reference to signature. - fn signature(&self) -> &Signature; + fn signature(&self) -> &PrimitiveSignature; /// Recover signer from signature and hash. /// @@ -71,8 +66,10 @@ pub trait SignedTransaction: /// Create a new signed transaction from a transaction and its signature. /// /// This will also calculate the transaction hash using its encoding. - fn from_transaction_and_signature(transaction: Self::Transaction, signature: Signature) - -> Self; + fn from_transaction_and_signature( + transaction: Self::Transaction, + signature: PrimitiveSignature, + ) -> Self; /// Calculate transaction hash, eip2728 transaction does not contain rlp header and start with /// tx type. @@ -84,77 +81,13 @@ pub trait SignedTransaction: fn fill_tx_env(&self, tx_env: &mut TxEnv, sender: Address); } -impl alloy_consensus::Transaction for T { - fn chain_id(&self) -> Option { - self.transaction().chain_id() - } - - fn nonce(&self) -> u64 { - self.transaction().nonce() - } - - fn gas_limit(&self) -> u64 { - self.transaction().gas_limit() - } - - fn gas_price(&self) -> Option { - self.transaction().gas_price() - } - - fn max_fee_per_gas(&self) -> u128 { - self.transaction().max_fee_per_gas() - } - - fn max_priority_fee_per_gas(&self) -> Option { - self.transaction().max_priority_fee_per_gas() - } - - fn max_fee_per_blob_gas(&self) -> Option { - self.transaction().max_fee_per_blob_gas() - } - - fn priority_fee_or_price(&self) -> u128 { - self.transaction().priority_fee_or_price() - } - - fn kind(&self) -> TxKind { - self.transaction().kind() - } +impl AlloyTransactionExt for T { + type Type = ::Type; - fn value(&self) -> U256 { - self.transaction().value() - } - - fn input(&self) -> &Bytes { - self.transaction().input() - } - - fn ty(&self) -> u8 { - self.transaction().ty() - } - - fn access_list(&self) -> Option<&AccessList> { - self.transaction().access_list() - } - - fn blob_versioned_hashes(&self) -> Option<&[B256]> { - self.transaction().blob_versioned_hashes() - } - - fn authorization_list(&self) -> Option<&[SignedAuthorization]> { - self.transaction().authorization_list() - } -} - -impl Transaction for T { fn signature_hash(&self) -> B256 { self.transaction().signature_hash() } - fn kind(&self) -> TxKind { - self.transaction().kind() - } - fn is_dynamic_fee(&self) -> bool { self.transaction().is_dynamic_fee() } @@ -163,10 +96,6 @@ impl Transaction for T { self.transaction().effective_gas_price(base_fee) } - fn encode_without_signature(&self, out: &mut dyn bytes::BufMut) { - self.transaction().encode_without_signature(out) - } - fn size(&self) -> usize { self.transaction().size() } diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 685fd29a3c04..6620aff900a3 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -63,7 +63,7 @@ use tx_type::{ }; use alloc::vec::Vec; -use reth_primitives_traits::SignedTransaction; +use reth_primitives_traits::{transaction::AlloyTransactionExt, SignedTransaction}; use revm_primitives::{AuthorizationList, TxEnv}; /// Either a transaction hash or number. @@ -833,6 +833,48 @@ impl alloy_consensus::Transaction for Transaction { } } +impl AlloyTransactionExt for Transaction { + type Type = TxType; + + fn signature_hash(&self) -> B256 { + match self { + Self::Legacy(tx) => tx.signature_hash(), + Self::Eip2930(tx) => tx.signature_hash(), + Self::Eip1559(tx) => tx.signature_hash(), + Self::Eip4844(tx) => tx.signature_hash(), + Self::Eip7702(tx) => tx.signature_hash(), + } + } + + fn is_dynamic_fee(&self) -> bool { + match self { + Self::Legacy(_) | Self::Eip2930(_) => false, + Self::Eip1559(_) | Self::Eip4844(_) | Self::Eip7702(_) => true, + } + } + + fn effective_gas_price(&self, base_fee: Option) -> u128 { + match self { + Self::Legacy(tx) => tx.gas_price, + Self::Eip2930(tx) => tx.gas_price, + Self::Eip1559(dynamic_tx) => dynamic_tx.effective_gas_price(base_fee), + Self::Eip4844(dynamic_tx) => dynamic_tx.effective_gas_price(base_fee), + Self::Eip7702(dynamic_tx) => dynamic_tx.effective_gas_price(base_fee), + } + } + + #[inline] + fn size(&self) -> usize { + match self { + Self::Legacy(tx) => tx.size(), + Self::Eip2930(tx) => tx.size(), + Self::Eip1559(tx) => tx.size(), + Self::Eip4844(tx) => tx.size(), + Self::Eip7702(tx) => tx.size(), + } + } +} + /// Signed transaction without its Hash. Used type for inserting into the DB. /// /// This can by converted to [`TransactionSigned`] by calling [`TransactionSignedNoHash::hash`]. From 68108f8f779be97b4f4305cf03f317f3747b15c3 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Sun, 10 Nov 2024 17:53:04 +0100 Subject: [PATCH 03/14] Add blanket impl for TxType --- crates/primitives-traits/src/tx_type.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/primitives-traits/src/tx_type.rs b/crates/primitives-traits/src/tx_type.rs index 058f02a7ee62..f87f75467447 100644 --- a/crates/primitives-traits/src/tx_type.rs +++ b/crates/primitives-traits/src/tx_type.rs @@ -1,7 +1,8 @@ +use core::fmt::{Debug, Display}; + use alloy_eips::eip2718::Eip2718Error; use alloy_primitives::{U64, U8}; use alloy_rlp::{Decodable, Encodable}; -use core::fmt::{Debug, Display}; /// Trait representing the behavior of a transaction type. pub trait TxType: @@ -25,3 +26,25 @@ pub trait TxType: + 'static { } + +impl TxType for T where + T: Into + + Into + + PartialEq + + Eq + + PartialEq + + TryFrom + + TryFrom + + TryFrom + + Debug + + Display + + Clone + + Copy + + Default + + Encodable + + Decodable + + Send + + Sync + + 'static +{ +} From 99c9943a78b8480f37af37739d1761e6de97ee07 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Sun, 10 Nov 2024 18:14:28 +0100 Subject: [PATCH 04/14] Fix conflicts --- crates/primitives-traits/src/lib.rs | 5 +++- .../primitives-traits/src/transaction/mod.rs | 4 ---- crates/primitives-traits/src/tx_type.rs | 23 +++++++++---------- crates/primitives/src/transaction/mod.rs | 8 +++++++ crates/primitives/src/transaction/tx_type.rs | 21 ++++++++++++++++- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/crates/primitives-traits/src/lib.rs b/crates/primitives-traits/src/lib.rs index 2897dd6340a8..0d4ca7fe77ee 100644 --- a/crates/primitives-traits/src/lib.rs +++ b/crates/primitives-traits/src/lib.rs @@ -56,7 +56,7 @@ pub use tx_type::TxType; pub mod header; #[cfg(any(test, feature = "arbitrary", feature = "test-utils"))] pub use header::test_utils; -pub use header::{Header, HeaderError, SealedHeader}; +pub use header::{BlockHeader, Header, HeaderError, SealedHeader}; /// Bincode-compatible serde implementations for common abstracted types in Reth. /// @@ -73,8 +73,11 @@ pub mod serde_bincode_compat { /// Helper trait that requires arbitrary implementation if the feature is enabled. #[cfg(feature = "arbitrary")] pub trait MaybeArbitrary: for<'a> arbitrary::Arbitrary<'a> {} +/// Helper trait that requires arbitrary implementation if the feature is enabled. #[cfg(not(feature = "arbitrary"))] pub trait MaybeArbitrary {} #[cfg(feature = "arbitrary")] impl MaybeArbitrary for T where T: for<'a> arbitrary::Arbitrary<'a> {} +#[cfg(not(feature = "arbitrary"))] +impl MaybeArbitrary for T {} diff --git a/crates/primitives-traits/src/transaction/mod.rs b/crates/primitives-traits/src/transaction/mod.rs index 1c4572704624..a17e13cd4342 100644 --- a/crates/primitives-traits/src/transaction/mod.rs +++ b/crates/primitives-traits/src/transaction/mod.rs @@ -27,8 +27,6 @@ pub trait Transaction: + Hash + Serialize + for<'de> Deserialize<'de> - + alloy_rlp::Encodable - + alloy_rlp::Decodable + AlloyTransactionExt + MaybeArbitrary { @@ -43,8 +41,6 @@ impl Transaction for T where + Hash + Serialize + for<'de> Deserialize<'de> - + alloy_rlp::Encodable - + alloy_rlp::Decodable + AlloyTransactionExt + MaybeArbitrary { diff --git a/crates/primitives-traits/src/tx_type.rs b/crates/primitives-traits/src/tx_type.rs index f87f75467447..4e08f8fcfbf7 100644 --- a/crates/primitives-traits/src/tx_type.rs +++ b/crates/primitives-traits/src/tx_type.rs @@ -1,6 +1,5 @@ -use core::fmt::{Debug, Display}; +use core::fmt; -use alloy_eips::eip2718::Eip2718Error; use alloy_primitives::{U64, U8}; use alloy_rlp::{Decodable, Encodable}; @@ -11,11 +10,11 @@ pub trait TxType: + PartialEq + Eq + PartialEq - + TryFrom - + TryFrom - + TryFrom - + Debug - + Display + + TryFrom + + TryFrom + + TryFrom + + fmt::Debug + + fmt::Display + Clone + Copy + Default @@ -33,11 +32,11 @@ impl TxType for T where + PartialEq + Eq + PartialEq - + TryFrom - + TryFrom - + TryFrom - + Debug - + Display + + TryFrom + + TryFrom + + TryFrom + + fmt::Debug + + fmt::Display + Clone + Copy + Default diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 6620aff900a3..a05b5ce64809 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -843,6 +843,8 @@ impl AlloyTransactionExt for Transaction { Self::Eip1559(tx) => tx.signature_hash(), Self::Eip4844(tx) => tx.signature_hash(), Self::Eip7702(tx) => tx.signature_hash(), + #[cfg(feature = "optimism")] + _ => todo!("use op type for op"), } } @@ -850,6 +852,8 @@ impl AlloyTransactionExt for Transaction { match self { Self::Legacy(_) | Self::Eip2930(_) => false, Self::Eip1559(_) | Self::Eip4844(_) | Self::Eip7702(_) => true, + #[cfg(feature = "optimism")] + _ => todo!("use op type for op"), } } @@ -860,6 +864,8 @@ impl AlloyTransactionExt for Transaction { Self::Eip1559(dynamic_tx) => dynamic_tx.effective_gas_price(base_fee), Self::Eip4844(dynamic_tx) => dynamic_tx.effective_gas_price(base_fee), Self::Eip7702(dynamic_tx) => dynamic_tx.effective_gas_price(base_fee), + #[cfg(feature = "optimism")] + _ => todo!("use op type for op"), } } @@ -871,6 +877,8 @@ impl AlloyTransactionExt for Transaction { Self::Eip1559(tx) => tx.size(), Self::Eip4844(tx) => tx.size(), Self::Eip7702(tx) => tx.size(), + #[cfg(feature = "optimism")] + _ => todo!("use op type for op"), } } } diff --git a/crates/primitives/src/transaction/tx_type.rs b/crates/primitives/src/transaction/tx_type.rs index 0cfb2ff9d67e..46e370861133 100644 --- a/crates/primitives/src/transaction/tx_type.rs +++ b/crates/primitives/src/transaction/tx_type.rs @@ -4,6 +4,7 @@ use alloy_consensus::constants::{ }; use alloy_primitives::{U64, U8}; use alloy_rlp::{Decodable, Encodable}; +use derive_more::Display; use serde::{Deserialize, Serialize}; /// Identifier parameter for legacy transaction @@ -36,24 +37,42 @@ pub const DEPOSIT_TX_TYPE_ID: u8 = 126; /// /// Other required changes when adding a new type can be seen on [PR#3953](https://github.com/paradigmxyz/reth/pull/3953/files). #[derive( - Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Default, Serialize, Deserialize, Hash, + Clone, + Copy, + Debug, + PartialEq, + Eq, + PartialOrd, + Ord, + Default, + Serialize, + Deserialize, + Hash, + Display, )] #[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))] #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(compact))] +#[display("tx type: {_variant}")] pub enum TxType { /// Legacy transaction pre EIP-2929 #[default] + #[display("legacy (0)")] Legacy = 0_isize, /// AccessList transaction + #[display("eip2930 (1)")] Eip2930 = 1_isize, /// Transaction with Priority fee + #[display("eip1559 (2)")] Eip1559 = 2_isize, /// Shard Blob Transactions - EIP-4844 + #[display("eip4844 (3)")] Eip4844 = 3_isize, /// EOA Contract Code Transactions - EIP-7702 + #[display("eip7702 (4)")] Eip7702 = 4_isize, /// Optimism Deposit transaction. #[cfg(feature = "optimism")] + #[display("deposit (126)")] Deposit = 126_isize, } From ae6d4b8aaad8e03df1981385f5526e574bee7654 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Sun, 10 Nov 2024 18:35:26 +0100 Subject: [PATCH 05/14] Fix arbitrary feature gate --- crates/primitives-traits/src/lib.rs | 8 ++++---- crates/primitives/Cargo.toml | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/primitives-traits/src/lib.rs b/crates/primitives-traits/src/lib.rs index 0d4ca7fe77ee..320b1e595d00 100644 --- a/crates/primitives-traits/src/lib.rs +++ b/crates/primitives-traits/src/lib.rs @@ -71,13 +71,13 @@ pub mod serde_bincode_compat { } /// Helper trait that requires arbitrary implementation if the feature is enabled. -#[cfg(feature = "arbitrary")] +#[cfg(any(feature = "test-utils", feature = "arbitrary"))] pub trait MaybeArbitrary: for<'a> arbitrary::Arbitrary<'a> {} /// Helper trait that requires arbitrary implementation if the feature is enabled. -#[cfg(not(feature = "arbitrary"))] +#[cfg(not(any(feature = "test-utils", feature = "arbitrary")))] pub trait MaybeArbitrary {} -#[cfg(feature = "arbitrary")] +#[cfg(any(feature = "test-utils", feature = "arbitrary"))] impl MaybeArbitrary for T where T: for<'a> arbitrary::Arbitrary<'a> {} -#[cfg(not(feature = "arbitrary"))] +#[cfg(not(any(feature = "test-utils", feature = "arbitrary")))] impl MaybeArbitrary for T {} diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 5bef33e15efd..11f1ad7e60a8 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -147,6 +147,7 @@ test-utils = [ "reth-chainspec/test-utils", "reth-codecs?/test-utils", "reth-trie-common/test-utils", + "arbitrary", ] serde-bincode-compat = [ "alloy-consensus/serde-bincode-compat", From d0cbfc9fedb923508720332f5d4898b2fa090d84 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Tue, 12 Nov 2024 12:21:04 +0100 Subject: [PATCH 06/14] Add todo --- crates/primitives-traits/src/transaction/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/primitives-traits/src/transaction/mod.rs b/crates/primitives-traits/src/transaction/mod.rs index 42a8457fbd29..1594768b8389 100644 --- a/crates/primitives-traits/src/transaction/mod.rs +++ b/crates/primitives-traits/src/transaction/mod.rs @@ -62,6 +62,7 @@ pub trait AlloyTransactionExt: alloy_consensus::Transaction { fn signature_hash(&self) -> B256; /// Returns `true` if the tx supports dynamic fees + // todo: remove when released https://github.com/alloy-rs/alloy/pull/1638 fn is_dynamic_fee(&self) -> bool; /// Returns the effective gas price for the given base fee. From ffe638a25214b947224ab082522080b3c7be6bb8 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Tue, 12 Nov 2024 13:06:56 +0100 Subject: [PATCH 07/14] Fix merge conflicts --- .../primitives-traits/src/transaction/mod.rs | 2 +- .../src/transaction/signed.rs | 4 ---- crates/primitives-traits/src/tx_type.rs | 22 ------------------- crates/primitives/src/transaction/mod.rs | 13 ----------- 4 files changed, 1 insertion(+), 40 deletions(-) diff --git a/crates/primitives-traits/src/transaction/mod.rs b/crates/primitives-traits/src/transaction/mod.rs index 1594768b8389..7d0b4640cca1 100644 --- a/crates/primitives-traits/src/transaction/mod.rs +++ b/crates/primitives-traits/src/transaction/mod.rs @@ -15,7 +15,7 @@ pub trait FullTransaction: Transaction + Compact {} impl FullTransaction for T where T: Transaction + Compact {} -#[allow(dead_code)] +/// Abstraction of a transaction. pub trait Transaction: Send + Sync diff --git a/crates/primitives-traits/src/transaction/signed.rs b/crates/primitives-traits/src/transaction/signed.rs index 9f0f351bcf38..b437eedf89a3 100644 --- a/crates/primitives-traits/src/transaction/signed.rs +++ b/crates/primitives-traits/src/transaction/signed.rs @@ -97,8 +97,4 @@ impl AlloyTransactionExt for T { fn effective_gas_price(&self, base_fee: Option) -> u128 { self.transaction().effective_gas_price(base_fee) } - - fn size(&self) -> usize { - self.transaction().size() - } } diff --git a/crates/primitives-traits/src/tx_type.rs b/crates/primitives-traits/src/tx_type.rs index 98494ed26ee0..c678d3c4a2cd 100644 --- a/crates/primitives-traits/src/tx_type.rs +++ b/crates/primitives-traits/src/tx_type.rs @@ -46,25 +46,3 @@ impl TxType for T where + alloy_rlp::Decodable { } - -impl TxType for T where - T: Send - + Sync - + Unpin - + Clone - + Copy - + Default - + fmt::Debug - + fmt::Display - + PartialEq - + Eq - + PartialEq - + Into - + Into - + TryFrom - + TryFrom - + TryFrom - + Encodable - + Decodable -{ -} diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 2ce5cc4c269e..a3f555a3b22e 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -871,19 +871,6 @@ impl AlloyTransactionExt for Transaction { _ => todo!("use op type for op"), } } - - #[inline] - fn size(&self) -> usize { - match self { - Self::Legacy(tx) => tx.size(), - Self::Eip2930(tx) => tx.size(), - Self::Eip1559(tx) => tx.size(), - Self::Eip4844(tx) => tx.size(), - Self::Eip7702(tx) => tx.size(), - #[cfg(feature = "optimism")] - _ => todo!("use op type for op"), - } - } } /// Signed transaction without its Hash. Used type for inserting into the DB. From 385f5d6899f7c9fd40124dde46605e7565a1e8ba Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Tue, 12 Nov 2024 13:15:08 +0100 Subject: [PATCH 08/14] Fix lint --- crates/primitives-traits/src/tx_type.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/primitives-traits/src/tx_type.rs b/crates/primitives-traits/src/tx_type.rs index 884656380e6d..078d8ac947ba 100644 --- a/crates/primitives-traits/src/tx_type.rs +++ b/crates/primitives-traits/src/tx_type.rs @@ -1,7 +1,6 @@ use core::fmt; use alloy_primitives::{U64, U8}; -use alloy_rlp::{Decodable, Encodable}; use reth_codecs::Compact; /// Helper trait that unifies all behaviour required by transaction type ID to support full node From 9c973ae345c7ff46a7ca51f551b4ed596ca7db29 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Tue, 12 Nov 2024 13:24:57 +0100 Subject: [PATCH 09/14] Fix merge conflicts --- Cargo.lock | 170 ++++++++++++----------- Cargo.toml | 2 +- crates/primitives/src/transaction/mod.rs | 13 ++ 3 files changed, 104 insertions(+), 81 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd3a93eda7ac..78b0cd834e98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -91,9 +91,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611cc2ae7d2e242c457e4be7f97036b8ad9ca152b499f53faf99b1ed8fc2553f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "alloy-chains" @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b19fd285b55dd39ae0dbc37481ad9f5f48898726f76335a2d6167a85a5fa41da" +checksum = "ef11c6b2dfbf77dca7bafc6759860391395f07c04d5486f2a2e2563d2961639b" dependencies = [ "alloy-eips", "alloy-primitives", @@ -131,9 +131,9 @@ dependencies = [ [[package]] name = "alloy-contract" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f42b1cb3fa8cba51b45795097a0d58a34569ca5db9eda48f63230e22fbc5cb5" +checksum = "8faa407ef916bfe0677c52c9b2258ce0698c53e9e15a837d1501e3ae9e57421a" dependencies = [ "alloy-dyn-abi", "alloy-json-abi", @@ -198,9 +198,9 @@ dependencies = [ [[package]] name = "alloy-eips" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21aff0f2c921246398cad88e32a1d8ec14359b183afbc3dcb816873714cafc1a" +checksum = "33d6c0c1744a7af7d325dca6b5c5bb431a6307c0961088f7a236ca2694c4a87e" dependencies = [ "alloy-eip2930", "alloy-eip7702", @@ -219,9 +219,9 @@ dependencies = [ [[package]] name = "alloy-genesis" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76d899cfbfa13c5ed044383b7ae0e6a4d6ffcad3fd25e4acf71ff1c255ddae0" +checksum = "95a5a0a01ef6ec3cd3ebd52a7b3bc7f8a92b23e478e69c07abd94abf05e6b48e" dependencies = [ "alloy-primitives", "alloy-serde", @@ -242,9 +242,9 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e244937365749c09c403d3054de39cc7dd46e3c3a12e5b164106af4903011ab1" +checksum = "65fd0e2cff5ab68defc5050ff9e81cb053c5b52cf4809fc8786664898e29ae75" dependencies = [ "alloy-primitives", "alloy-sol-types", @@ -256,9 +256,9 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a28811461dc37e28db92b6d3a8c03a5883f2100b270a6294af00710bf4a0be4" +checksum = "96c9eca0c04ca8a663966ce7f5b19c03927f2b4d82910cb76cb4008490cfa838" dependencies = [ "alloy-consensus", "alloy-eips", @@ -279,9 +279,9 @@ dependencies = [ [[package]] name = "alloy-network-primitives" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e517c44a97e753f10dc0736215ba4677da5e2fbc1451e3e76902e02cd6cff12" +checksum = "e4c3050f19dc93a7f09fef670c8db04a15e7e2901494ca40decbce323be69643" dependencies = [ "alloy-consensus", "alloy-eips", @@ -292,9 +292,9 @@ dependencies = [ [[package]] name = "alloy-node-bindings" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15bf1a4b35b071c2d6f21fd3d32b8c5466cb7ed31fd4a4473a4e2ce180729121" +checksum = "b5ebd44d0ab30f1018dc1ff01686ea1a3ae732601841a4fb277c9d0b3a34bf50" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -341,9 +341,9 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56befb85784c7eb4f163b9aed7cdcaba09d5b07f8e59d6c12ad0ce1acf67c0fd" +checksum = "df8e5a28e7c4c04afc0f20b2aecf6f9214d6cfd5009187c0b8616a8f8918739c" dependencies = [ "alloy-chains", "alloy-consensus", @@ -382,9 +382,9 @@ dependencies = [ [[package]] name = "alloy-pubsub" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6480f9596064db2ca8e1a4b710ea9a4ef420534e68640296a461b71f6bfadc1" +checksum = "365dd813ec271a14febc31ea8ed64185856534f5644511f0c7a2961db060d878" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -423,9 +423,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb49d38b3279a07e864d973323534a2c4a845e16f2c0153a509a3abcc01da7b1" +checksum = "0336362936bb9fef88f27d51f2ede8c15cdfdb7f81b042e74257770052547101" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -448,9 +448,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90be9542c6c9bb0d21ac08104ca0a3d1fb83e56f1c704f5cdcf6fb9e01fcbd75" +checksum = "ac9a46bc01bc27dbf4dd27d46986eda661ffe99e78aea3078a77b8c064072b01" dependencies = [ "alloy-primitives", "alloy-rpc-types-engine", @@ -461,9 +461,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-admin" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "410e7b9d67489d19ad52439b940fbf482e0823190d8245242bfff1eec44290d5" +checksum = "82845a6f1ed33ef4edf79aa7cb091df31a532675921fb85041fbd8d6e029093d" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -473,9 +473,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951f9106bb02ad00a2dc2eb7b400041a2c073d7fb8f33e2f1f29b2f71564f3f7" +checksum = "0e73c06c3e44866d304fe28e8cebc8354f99fe405cc7c9bd23ed92eaebca3c07" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -485,9 +485,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-beacon" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dab9821d5a73f56512ddd8e3db89a5bbb285353129b271c4ad6803a37c4e00ce" +checksum = "2f9f6f071674c62424b62e22307aa83a35a0b1b84820649cc82034a50389ddc6" dependencies = [ "alloy-eips", "alloy-primitives", @@ -499,9 +499,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-debug" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebe68f35cafc465442862421ae2d123bb58c8df25f837d8866bf5fc278b74a52" +checksum = "63a857818fe47dacaa7cc7a9cdcfee212cf1ebf119ab7bd157065d434671892d" dependencies = [ "alloy-primitives", "serde", @@ -509,9 +509,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-engine" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ed9e7b3233cb3e0aaeaedc4e21e1ea9d99e947a7206241a9f9521c138193978" +checksum = "2ee44332315ef1adde384e44db3b5724d74d0cd0e0856a681c4db2b4da3a423e" dependencies = [ "alloy-consensus", "alloy-eips", @@ -530,9 +530,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-eth" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be10f130b8be7c2351a3ea64b4bf07020fde5be8d1ac18db9a9a3496aa22bb19" +checksum = "d58fa055e02d04bc70443ecce984951fb5be02d2c843c640ca48237cdec66af1" dependencies = [ "alloy-consensus", "alloy-eips", @@ -551,9 +551,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-mev" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "110f7dbee6f047915eb8915751d96402f6d02cb6e5f64286f10949eaa5bed841" +checksum = "debf779b847b058b7c9cdef576f5ef539bc3032c5f6e5c1c2f51820b4f74e6d9" dependencies = [ "alloy-eips", "alloy-primitives", @@ -564,9 +564,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4f7f183d06db1457b58c6d618ff7ab92c97810138c148e09edb14ed2001069" +checksum = "1319edeae0e5f453424d658f8f450a5b1090b9ee6c0c014dc216b42f11c9dc57" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -578,9 +578,9 @@ dependencies = [ [[package]] name = "alloy-rpc-types-txpool" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f85580d4e78ffd765086ebf640004a773e3c335ebbfaa5666e13a0640c4957fe" +checksum = "5fcb4b823dcd7228a89be1be85a4fa8008ad6d91b169b61f75f36b6e7386f37b" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", @@ -590,9 +590,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1493df14770a23b1e32d22c66fa22508d09e0a99d6923a45f179ff7887ca0cef" +checksum = "feafd71e0e252b063fe4b07962beedf0445e66b07b4b44af178863d21e75b0fa" dependencies = [ "alloy-primitives", "arbitrary", @@ -602,9 +602,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebff64a3b4062eba217404700d1517b9bf3ff9a7a5b2dd03f1cf8aeec3e9a6b8" +checksum = "ebad84d52550351438ec7f151dbc551f870c31eecf23b473df5b779a91eee8ca" dependencies = [ "alloy-primitives", "async-trait", @@ -616,9 +616,9 @@ dependencies = [ [[package]] name = "alloy-signer-local" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc1f6602be452e3bb5b6c2fe0fa0f966465f9e9bfd6ad7691bfe1bd8b74bf432" +checksum = "ed742d76943b5ebaabfdf3d0d8b69a4377fc2981c7955a807e33a3469aed0cdc" dependencies = [ "alloy-consensus", "alloy-network", @@ -704,9 +704,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64534da7f71ecca86b3449adec19b7942fb0905b9f392f60054a02a5f686f71f" +checksum = "da63700a2b3176b3009a6d3672d0c657280a517dcec7659c991c55e863a83165" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -724,9 +724,9 @@ dependencies = [ [[package]] name = "alloy-transport-http" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617b5ab96f4fb64ef697a84c68ec8534c062baafbdb0529c34aaee43324f0d5a" +checksum = "6613c3abc567b710217d241650ef73cfb8df9bcdc2ef23fdedabf363637e2a00" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -739,9 +739,9 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10043df9ea36e3a38056cdfc3a70138343caef4eec6df66d6cbfdd348d245828" +checksum = "7087a28734aac88a606884cdde8c89ad053bd1c0580c787e31f917a8e4a7cbdd" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -758,9 +758,9 @@ dependencies = [ [[package]] name = "alloy-transport-ws" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a43ecdbc8f79cb5d7f54e2118626f873ded93c8c040fb714ce6be47dc5b526" +checksum = "672797b3f7bcbe67f712f9e8e5703b22f24594bd2b248a90916bdb58811b8b6e" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -1530,7 +1530,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "serde", ] @@ -1651,9 +1651,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.37" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" +checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8" dependencies = [ "jobserver", "libc", @@ -1998,9 +1998,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -4111,6 +4111,12 @@ dependencies = [ "serde", ] +[[package]] +name = "indoc" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" + [[package]] name = "infer" version = "0.2.3" @@ -4167,10 +4173,14 @@ dependencies = [ [[package]] name = "instability" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b23a0c8dfe501baac4adf6ebbfa6eddf8f0c07f56b058cc1288017e32397846c" +checksum = "b829f37dead9dc39df40c2d3376c179fdfd2ac771f53f55d3c30dc096a3c0c6e" dependencies = [ + "darling", + "indoc", + "pretty_assertions", + "proc-macro2", "quote", "syn 2.0.87", ] @@ -5287,9 +5297,9 @@ checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "op-alloy-consensus" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33097177de330b1a83e0a882ae752ad55f23962b1e310176d1623655c18421e" +checksum = "3b5745eca869a0b476fbd34025ac40c06a15c46ffc10d6b1c40d21475b05f835" dependencies = [ "alloy-consensus", "alloy-eips", @@ -5305,9 +5315,9 @@ dependencies = [ [[package]] name = "op-alloy-genesis" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2232ff799352932fc5484e1c63ee7bb1e74a79ac7b94a4f7318560fba21167de" +checksum = "aa6b2f26a84984213bc12649dfd8466a46ddeede3b8d2d936583000a8362b117" dependencies = [ "alloy-consensus", "alloy-eips", @@ -5354,9 +5364,9 @@ dependencies = [ [[package]] name = "op-alloy-rpc-types" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72298f3f9084773dc3feaf88b08db82ceb3e3e13f98280459d869accb3f14234" +checksum = "69b75a52c8659756cfe1119f7711e94749c8dec6ad82408f3c55641ae413fb83" dependencies = [ "alloy-consensus", "alloy-eips", @@ -6225,7 +6235,7 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.8", + "regex-automata 0.4.9", "regex-syntax 0.8.5", ] @@ -6240,9 +6250,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -9660,9 +9670,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.39" +version = "0.38.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" +checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" dependencies = [ "bitflags 2.6.0", "errno", @@ -9950,18 +9960,18 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 7608756b12a8..124dd700bfe7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -431,7 +431,7 @@ alloy-rlp = "0.3.4" alloy-sol-types = "0.8.11" alloy-trie = { version = "0.7", default-features = false } -alloy-consensus = { version = "0.6.2", default-features = false } +alloy-consensus = { version = "0.6.3", default-features = false } alloy-contract = { version = "0.6.2", default-features = false } alloy-eips = { version = "0.6.2", default-features = false } alloy-genesis = { version = "0.6.2", default-features = false } diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index a3f555a3b22e..641404ddbe89 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -823,6 +823,15 @@ impl alloy_consensus::Transaction for Transaction { } } + fn is_dynamic_fee(&self) -> bool { + match self { + Self::Legacy(_) | Self::Eip2930(_) => false, + Self::Eip1559(_) | Self::Eip4844(_) | Self::Eip7702(_) => true, + #[cfg(feature = "optimism")] + Self::Deposit(_) => false, + } + } + fn kind(&self) -> TxKind { match self { Self::Legacy(tx) => tx.kind(), @@ -1481,6 +1490,10 @@ impl alloy_consensus::Transaction for TransactionSigned { self.deref().priority_fee_or_price() } + fn is_dynamic_fee(&self) -> bool { + self.deref().is_dynamic_fee() + } + fn value(&self) -> U256 { self.deref().value() } From fcda0dc7decbdebf2b57505d7ae8c11b0d70fe8b Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Tue, 12 Nov 2024 13:28:15 +0100 Subject: [PATCH 10/14] Remove redundant trait method --- crates/primitives-traits/src/transaction/mod.rs | 4 ---- crates/primitives-traits/src/transaction/signed.rs | 4 ---- crates/primitives/src/transaction/mod.rs | 9 --------- 3 files changed, 17 deletions(-) diff --git a/crates/primitives-traits/src/transaction/mod.rs b/crates/primitives-traits/src/transaction/mod.rs index 7d0b4640cca1..b250aad5da45 100644 --- a/crates/primitives-traits/src/transaction/mod.rs +++ b/crates/primitives-traits/src/transaction/mod.rs @@ -61,10 +61,6 @@ pub trait AlloyTransactionExt: alloy_consensus::Transaction { /// It is only for signature signing or signer recovery. fn signature_hash(&self) -> B256; - /// Returns `true` if the tx supports dynamic fees - // todo: remove when released https://github.com/alloy-rs/alloy/pull/1638 - fn is_dynamic_fee(&self) -> bool; - /// Returns the effective gas price for the given base fee. fn effective_gas_price(&self, base_fee: Option) -> u128; diff --git a/crates/primitives-traits/src/transaction/signed.rs b/crates/primitives-traits/src/transaction/signed.rs index b437eedf89a3..bed4266c5144 100644 --- a/crates/primitives-traits/src/transaction/signed.rs +++ b/crates/primitives-traits/src/transaction/signed.rs @@ -90,10 +90,6 @@ impl AlloyTransactionExt for T { self.transaction().signature_hash() } - fn is_dynamic_fee(&self) -> bool { - self.transaction().is_dynamic_fee() - } - fn effective_gas_price(&self, base_fee: Option) -> u128 { self.transaction().effective_gas_price(base_fee) } diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 641404ddbe89..548b9f1dc54f 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -860,15 +860,6 @@ impl AlloyTransactionExt for Transaction { } } - fn is_dynamic_fee(&self) -> bool { - match self { - Self::Legacy(_) | Self::Eip2930(_) => false, - Self::Eip1559(_) | Self::Eip4844(_) | Self::Eip7702(_) => true, - #[cfg(feature = "optimism")] - _ => todo!("use op type for op"), - } - } - fn effective_gas_price(&self, base_fee: Option) -> u128 { match self { Self::Legacy(tx) => tx.gas_price, From 5816e4516e2ea8b11608faf21aecf562e2dd0537 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Tue, 12 Nov 2024 14:38:09 +0100 Subject: [PATCH 11/14] Rename AlloyTransactionExt to TransactionExt --- crates/primitives-traits/src/lib.rs | 2 +- crates/primitives-traits/src/transaction/mod.rs | 6 +++--- crates/primitives-traits/src/transaction/signed.rs | 8 ++++---- crates/primitives/src/transaction/mod.rs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/primitives-traits/src/lib.rs b/crates/primitives-traits/src/lib.rs index 57b99d67f799..947eb8569a9a 100644 --- a/crates/primitives-traits/src/lib.rs +++ b/crates/primitives-traits/src/lib.rs @@ -27,7 +27,7 @@ pub use receipt::{FullReceipt, Receipt}; pub mod transaction; pub use transaction::{ signed::{FullSignedTx, SignedTransaction}, - AlloyTransactionExt, FullTransaction, Transaction, + FullTransaction, Transaction, TransactionExt, }; mod integer_list; diff --git a/crates/primitives-traits/src/transaction/mod.rs b/crates/primitives-traits/src/transaction/mod.rs index b250aad5da45..328c24e5a834 100644 --- a/crates/primitives-traits/src/transaction/mod.rs +++ b/crates/primitives-traits/src/transaction/mod.rs @@ -28,7 +28,7 @@ pub trait Transaction: + Hash + Serialize + for<'de> Deserialize<'de> - + AlloyTransactionExt + + TransactionExt + InMemorySize + MaybeArbitrary { @@ -46,14 +46,14 @@ impl Transaction for T where + Hash + Serialize + for<'de> Deserialize<'de> - + AlloyTransactionExt + + TransactionExt + InMemorySize + MaybeArbitrary { } /// Extension trait of [`alloy_consensus::Transaction`]. -pub trait AlloyTransactionExt: alloy_consensus::Transaction { +pub trait TransactionExt: alloy_consensus::Transaction { /// Transaction envelope type ID. type Type: TxType; diff --git a/crates/primitives-traits/src/transaction/signed.rs b/crates/primitives-traits/src/transaction/signed.rs index bed4266c5144..64ff715517c4 100644 --- a/crates/primitives-traits/src/transaction/signed.rs +++ b/crates/primitives-traits/src/transaction/signed.rs @@ -8,7 +8,7 @@ use alloy_primitives::{keccak256, Address, PrimitiveSignature, TxHash, B256}; use reth_codecs::Compact; use revm_primitives::TxEnv; -use crate::{transaction::AlloyTransactionExt, FullTransaction, MaybeArbitrary, Transaction}; +use crate::{transaction::TransactionExt, FullTransaction, MaybeArbitrary, Transaction}; /// Helper trait that unifies all behaviour required by block to support full node operations. pub trait FullSignedTx: SignedTransaction + Compact {} @@ -32,7 +32,7 @@ pub trait SignedTransaction: + alloy_rlp::Decodable + Encodable2718 + Decodable2718 - + AlloyTransactionExt + + TransactionExt + MaybeArbitrary { /// Transaction type that is signed. @@ -83,8 +83,8 @@ pub trait SignedTransaction: fn fill_tx_env(&self, tx_env: &mut TxEnv, sender: Address); } -impl AlloyTransactionExt for T { - type Type = ::Type; +impl TransactionExt for T { + type Type = ::Type; fn signature_hash(&self) -> B256 { self.transaction().signature_hash() diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 548b9f1dc54f..c64c6a04c471 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -64,7 +64,7 @@ use tx_type::{ }; use alloc::vec::Vec; -use reth_primitives_traits::{transaction::AlloyTransactionExt, SignedTransaction}; +use reth_primitives_traits::{transaction::TransactionExt, SignedTransaction}; use revm_primitives::{AuthorizationList, TxEnv}; /// Either a transaction hash or number. @@ -845,7 +845,7 @@ impl alloy_consensus::Transaction for Transaction { } } -impl AlloyTransactionExt for Transaction { +impl TransactionExt for Transaction { type Type = TxType; fn signature_hash(&self) -> B256 { From 1e42d0154fce1efb6189f9248bf28170e0aa0dee Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Tue, 12 Nov 2024 14:47:46 +0100 Subject: [PATCH 12/14] Fix merge conflicts --- crates/primitives/src/transaction/mod.rs | 41 +++++++++--------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index c517a65391a7..1c1092f0ae3d 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -760,6 +760,18 @@ impl alloy_consensus::Transaction for Transaction { } } + fn kind(&self) -> TxKind { + match self { + Self::Legacy(tx) => tx.kind(), + Self::Eip2930(tx) => tx.kind(), + Self::Eip1559(tx) => tx.kind(), + Self::Eip4844(tx) => tx.kind(), + Self::Eip7702(tx) => tx.kind(), + #[cfg(feature = "optimism")] + Self::Deposit(tx) => tx.kind(), + } + } + fn value(&self) -> U256 { match self { Self::Legacy(tx) => tx.value(), @@ -831,27 +843,6 @@ impl alloy_consensus::Transaction for Transaction { Self::Deposit(tx) => tx.authorization_list(), } } - - fn is_dynamic_fee(&self) -> bool { - match self { - Self::Legacy(_) | Self::Eip2930(_) => false, - Self::Eip1559(_) | Self::Eip4844(_) | Self::Eip7702(_) => true, - #[cfg(feature = "optimism")] - Self::Deposit(_) => false, - } - } - - fn kind(&self) -> TxKind { - match self { - Self::Legacy(tx) => tx.kind(), - Self::Eip2930(tx) => tx.kind(), - Self::Eip1559(tx) => tx.kind(), - Self::Eip4844(tx) => tx.kind(), - Self::Eip7702(tx) => tx.kind(), - #[cfg(feature = "optimism")] - Self::Deposit(tx) => tx.kind(), - } - } } impl TransactionExt for Transaction { @@ -1494,6 +1485,10 @@ impl alloy_consensus::Transaction for TransactionSigned { self.deref().is_dynamic_fee() } + fn kind(&self) -> TxKind { + self.deref().kind() + } + fn value(&self) -> U256 { self.deref().value() } @@ -1517,10 +1512,6 @@ impl alloy_consensus::Transaction for TransactionSigned { fn authorization_list(&self) -> Option<&[SignedAuthorization]> { self.deref().authorization_list() } - - fn kind(&self) -> TxKind { - self.deref().kind() - } } impl From for TransactionSigned { From 4c3a52cf365c9130cd6d6ef2f74b3cad94660c5a Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Tue, 12 Nov 2024 16:15:25 +0100 Subject: [PATCH 13/14] Add todo --- crates/primitives-traits/src/transaction/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/primitives-traits/src/transaction/mod.rs b/crates/primitives-traits/src/transaction/mod.rs index 328c24e5a834..dff443815d0e 100644 --- a/crates/primitives-traits/src/transaction/mod.rs +++ b/crates/primitives-traits/src/transaction/mod.rs @@ -62,6 +62,7 @@ pub trait TransactionExt: alloy_consensus::Transaction { fn signature_hash(&self) -> B256; /// Returns the effective gas price for the given base fee. + // todo: remove when released: https://github.com/alloy-rs/alloy/pull/1640 fn effective_gas_price(&self, base_fee: Option) -> u128; /// Returns the transaction type. From da6a57326fc2e6bcb71950060495f67221701912 Mon Sep 17 00:00:00 2001 From: Emilia Hane Date: Wed, 13 Nov 2024 14:09:00 +0100 Subject: [PATCH 14/14] Fix merge conflicts --- crates/primitives-traits/src/transaction/mod.rs | 4 ---- crates/primitives-traits/src/transaction/signed.rs | 4 ---- crates/primitives/src/transaction/mod.rs | 2 ++ 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/primitives-traits/src/transaction/mod.rs b/crates/primitives-traits/src/transaction/mod.rs index dff443815d0e..bb6f6a711e3e 100644 --- a/crates/primitives-traits/src/transaction/mod.rs +++ b/crates/primitives-traits/src/transaction/mod.rs @@ -61,10 +61,6 @@ pub trait TransactionExt: alloy_consensus::Transaction { /// It is only for signature signing or signer recovery. fn signature_hash(&self) -> B256; - /// Returns the effective gas price for the given base fee. - // todo: remove when released: https://github.com/alloy-rs/alloy/pull/1640 - fn effective_gas_price(&self, base_fee: Option) -> u128; - /// Returns the transaction type. fn tx_type(&self) -> Self::Type { Self::Type::try_from(self.ty()).expect("should decode tx type id") diff --git a/crates/primitives-traits/src/transaction/signed.rs b/crates/primitives-traits/src/transaction/signed.rs index 64ff715517c4..455a9886eb8f 100644 --- a/crates/primitives-traits/src/transaction/signed.rs +++ b/crates/primitives-traits/src/transaction/signed.rs @@ -89,8 +89,4 @@ impl TransactionExt for T { fn signature_hash(&self) -> B256 { self.transaction().signature_hash() } - - fn effective_gas_price(&self, base_fee: Option) -> u128 { - self.transaction().effective_gas_price(base_fee) - } } diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 1206291572e0..d1a95b09be24 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -870,6 +870,8 @@ impl TransactionExt for Transaction { pub struct TransactionSignedNoHash { /// The transaction signature values pub signature: Signature, + /// Raw transaction info + #[deref] #[as_ref] pub transaction: Transaction, }