From d6affd8e16ff037fb5d866b395158d88a2eefebe Mon Sep 17 00:00:00 2001 From: Khanh Hoa Date: Sun, 5 Jan 2025 13:38:39 +0700 Subject: [PATCH] bet --- Cargo.lock | 1 + crates/consensus/common/Cargo.toml | 1 + crates/consensus/common/src/validation.rs | 3 ++- crates/ethereum/primitives/src/transaction.rs | 9 +++++++++ crates/primitives/src/transaction/mod.rs | 11 ----------- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 087fd7798923..1bf128cfbeed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6932,6 +6932,7 @@ dependencies = [ "rand 0.8.5", "reth-chainspec", "reth-consensus", + "reth-ethereum-primitives", "reth-primitives", "reth-primitives-traits", "reth-storage-api", diff --git a/crates/consensus/common/Cargo.toml b/crates/consensus/common/Cargo.toml index bc7f80a515b9..c7640ff695d0 100644 --- a/crates/consensus/common/Cargo.toml +++ b/crates/consensus/common/Cargo.toml @@ -25,6 +25,7 @@ alloy-eips.workspace = true [dev-dependencies] alloy-consensus.workspace = true reth-storage-api.workspace = true +reth-ethereum-primitives.workspace = true rand.workspace = true mockall = "0.13" diff --git a/crates/consensus/common/src/validation.rs b/crates/consensus/common/src/validation.rs index 8754fe818520..a6f5b2f94396 100644 --- a/crates/consensus/common/src/validation.rs +++ b/crates/consensus/common/src/validation.rs @@ -347,7 +347,8 @@ mod tests { use mockall::mock; use rand::Rng; use reth_chainspec::ChainSpecBuilder; - use reth_primitives::{proofs, Account, BlockBody, Transaction, TransactionSigned}; + use reth_ethereum_primitives::{Transaction, TransactionSigned}; + use reth_primitives::{proofs, Account, BlockBody}; use reth_storage_api::{ errors::provider::ProviderResult, AccountReader, HeaderProvider, WithdrawalsProvider, }; diff --git a/crates/ethereum/primitives/src/transaction.rs b/crates/ethereum/primitives/src/transaction.rs index d1221aeffe62..b466ca3c3da8 100644 --- a/crates/ethereum/primitives/src/transaction.rs +++ b/crates/ethereum/primitives/src/transaction.rs @@ -290,6 +290,15 @@ impl PartialEq for TransactionSigned { } } +impl TransactionSigned { + /// Creates a new signed transaction from the given transaction and signature without the hash. + /// + /// Note: this only calculates the hash on the first [`TransactionSigned::hash`] call. + pub fn new_unhashed(transaction: Transaction, signature: Signature) -> Self { + Self { hash: Default::default(), signature, transaction } + } +} + impl Typed2718 for TransactionSigned { fn ty(&self) -> u8 { self.transaction.ty() diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 9dcca9ee21ac..e6e4d5f73ce7 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -779,17 +779,6 @@ impl From for Transaction { } /// Signed transaction. -/// -/// # Deprecation Notice -/// -/// This type will be deprecated in favor of the Ethereum-specific type from reth-ethereum-primitives. -/// New code should use `reth_ethereum_primitives::Transaction` instead. -/// -/// This type is currently used as a default transaction type in several places: -/// - As the default Block transaction type -/// - In testing code -/// -/// These usages will be gradually migrated to use the Ethereum-specific type. #[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests(rlp))] #[derive(Debug, Clone, Eq, AsRef, Deref, Serialize, Deserialize)] pub struct TransactionSigned {