Skip to content

Commit 923a805

Browse files
authored
chore(consensus): Cut down on reth-primitives::TransactionSigned usage (#13659)
1 parent 20d3fa6 commit 923a805

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/consensus/common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ alloy-eips.workspace = true
2525
[dev-dependencies]
2626
alloy-consensus.workspace = true
2727
reth-storage-api.workspace = true
28+
reth-ethereum-primitives.workspace = true
2829
rand.workspace = true
2930
mockall = "0.13"
3031

crates/consensus/common/src/validation.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ mod tests {
347347
use mockall::mock;
348348
use rand::Rng;
349349
use reth_chainspec::ChainSpecBuilder;
350-
use reth_primitives::{proofs, Account, BlockBody, Transaction, TransactionSigned};
350+
use reth_ethereum_primitives::{Transaction, TransactionSigned};
351+
use reth_primitives::{proofs, Account, BlockBody};
351352
use reth_storage_api::{
352353
errors::provider::ProviderResult, AccountReader, HeaderProvider, WithdrawalsProvider,
353354
};

crates/ethereum/primitives/src/transaction.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,15 @@ impl PartialEq for TransactionSigned {
290290
}
291291
}
292292

293+
impl TransactionSigned {
294+
/// Creates a new signed transaction from the given transaction and signature without the hash.
295+
///
296+
/// Note: this only calculates the hash on the first [`TransactionSigned::hash`] call.
297+
pub fn new_unhashed(transaction: Transaction, signature: Signature) -> Self {
298+
Self { hash: Default::default(), signature, transaction }
299+
}
300+
}
301+
293302
impl Typed2718 for TransactionSigned {
294303
fn ty(&self) -> u8 {
295304
self.transaction.ty()

0 commit comments

Comments
 (0)