Skip to content

Commit 9806e07

Browse files
eeemmmmmmmattsse
andauthored
fix: replace tx_hash method with TxHashRef trait bound (paradigmxyz#18357) (paradigmxyz#18362)
Co-authored-by: Matthias Seitz <[email protected]>
1 parent 3ebfd7a commit 9806e07

File tree

28 files changed

+92
-91
lines changed

28 files changed

+92
-91
lines changed

crates/cli/commands/src/re_execute.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use crate::common::{
44
AccessRights, CliComponentsBuilder, CliNodeComponents, CliNodeTypes, Environment,
55
EnvironmentArgs,
66
};
7-
use alloy_consensus::{BlockHeader, TxReceipt};
7+
use alloy_consensus::{transaction::TxHashRef, BlockHeader, TxReceipt};
88
use clap::Parser;
99
use eyre::WrapErr;
1010
use reth_chainspec::{EthChainSpec, EthereumHardforks, Hardforks};
1111
use reth_cli::chainspec::ChainSpecParser;
1212
use reth_consensus::FullConsensus;
1313
use reth_evm::{execute::Executor, ConfigureEvm};
14-
use reth_primitives_traits::{format_gas_throughput, BlockBody, GotExpected, SignedTransaction};
14+
use reth_primitives_traits::{format_gas_throughput, BlockBody, GotExpected};
1515
use reth_provider::{
1616
BlockNumReader, BlockReader, ChainSpecProvider, DatabaseProviderFactory, ReceiptProvider,
1717
StaticFileProviderFactory, TransactionVariant,

crates/consensus/common/src/validation.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ use reth_primitives_traits::{
1010
constants::{
1111
GAS_LIMIT_BOUND_DIVISOR, MAXIMUM_GAS_LIMIT_BLOCK, MAX_TX_GAS_LIMIT_OSAKA, MINIMUM_GAS_LIMIT,
1212
},
13-
Block, BlockBody, BlockHeader, GotExpected, SealedBlock, SealedHeader, SignedTransaction,
13+
transaction::TxHashRef,
14+
Block, BlockBody, BlockHeader, GotExpected, SealedBlock, SealedHeader,
1415
};
1516

1617
/// The maximum RLP length of a block, defined in [EIP-7934](https://eips.ethereum.org/EIPS/eip-7934).

crates/e2e-test-utils/src/node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{network::NetworkTestContext, payload::PayloadTestContext, rpc::RpcTestContext};
2-
use alloy_consensus::BlockHeader;
2+
use alloy_consensus::{transaction::TxHashRef, BlockHeader};
33
use alloy_eips::BlockId;
44
use alloy_primitives::{BlockHash, BlockNumber, Bytes, Sealable, B256};
55
use alloy_rpc_types_engine::ForkchoiceState;
@@ -14,7 +14,7 @@ use reth_node_api::{
1414
PrimitivesTy,
1515
};
1616
use reth_node_builder::{rpc::RethRpcAddOns, FullNode, NodeTypes};
17-
use reth_node_core::primitives::SignedTransaction;
17+
1818
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
1919
use reth_provider::{
2020
BlockReader, BlockReaderIdExt, CanonStateNotificationStream, CanonStateSubscriptions,

crates/engine/tree/src/tree/metrics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::tree::MeteredStateHook;
2+
use alloy_consensus::transaction::TxHashRef;
23
use alloy_evm::{
34
block::{BlockExecutor, ExecutableTx},
45
Evm,

crates/engine/tree/src/tree/payload_processor/prewarm.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ use crate::tree::{
2020
precompile_cache::{CachedPrecompile, PrecompileCacheMap},
2121
ExecutionEnv, StateProviderBuilder,
2222
};
23+
use alloy_consensus::transaction::TxHashRef;
2324
use alloy_evm::Database;
2425
use alloy_primitives::{keccak256, map::B256Set, B256};
2526
use metrics::{Counter, Gauge, Histogram};
2627
use reth_evm::{execute::ExecutableTxFor, ConfigureEvm, Evm, EvmFor, SpecFor};
2728
use reth_metrics::Metrics;
28-
use reth_primitives_traits::{NodePrimitives, SignedTransaction};
29+
use reth_primitives_traits::NodePrimitives;
2930
use reth_provider::{BlockReader, StateProviderFactory, StateReader};
3031
use reth_revm::{database::StateProviderDatabase, db::BundleState, state::EvmState};
3132
use reth_trie::MultiProofTargets;

crates/ethereum/primitives/src/transaction.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use alloc::vec::Vec;
55
use alloy_consensus::{
6-
transaction::{RlpEcdsaDecodableTx, RlpEcdsaEncodableTx, SignerRecoverable},
6+
transaction::{RlpEcdsaDecodableTx, RlpEcdsaEncodableTx, SignerRecoverable, TxHashRef},
77
EthereumTxEnvelope, SignableTransaction, Signed, TxEip1559, TxEip2930, TxEip4844, TxEip7702,
88
TxLegacy, TxType, Typed2718,
99
};
@@ -658,12 +658,14 @@ impl SignerRecoverable for TransactionSigned {
658658
}
659659
}
660660

661-
impl SignedTransaction for TransactionSigned {
661+
impl TxHashRef for TransactionSigned {
662662
fn tx_hash(&self) -> &TxHash {
663663
self.hash.get_or_init(|| self.recalculate_hash())
664664
}
665665
}
666666

667+
impl SignedTransaction for TransactionSigned {}
668+
667669
#[cfg(test)]
668670
mod tests {
669671
use super::*;

crates/net/eth-wire-types/src/broadcast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ pub struct BlockRangeUpdate {
801801
#[cfg(test)]
802802
mod tests {
803803
use super::*;
804-
use alloy_consensus::Typed2718;
804+
use alloy_consensus::{transaction::TxHashRef, Typed2718};
805805
use alloy_eips::eip2718::Encodable2718;
806806
use alloy_primitives::{b256, hex, Signature, U256};
807807
use reth_ethereum_primitives::{Transaction, TransactionSigned};

crates/net/network/src/transactions/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Transactions management for the p2p network.
22
3+
use alloy_consensus::transaction::TxHashRef;
4+
35
/// Aggregation on configurable parameters for [`TransactionsManager`].
46
pub mod config;
57
/// Default and spec'd bounds.

crates/optimism/primitives/src/transaction/signed.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use crate::transaction::OpTransaction;
55
use alloc::vec::Vec;
66
use alloy_consensus::{
7-
transaction::{RlpEcdsaDecodableTx, RlpEcdsaEncodableTx, SignerRecoverable},
7+
transaction::{RlpEcdsaDecodableTx, RlpEcdsaEncodableTx, SignerRecoverable, TxHashRef},
88
Sealed, SignableTransaction, Signed, Transaction, TxEip1559, TxEip2930, TxEip7702, TxLegacy,
99
Typed2718,
1010
};
@@ -142,11 +142,13 @@ impl SignerRecoverable for OpTransactionSigned {
142142
}
143143
}
144144

145-
impl SignedTransaction for OpTransactionSigned {
145+
impl TxHashRef for OpTransactionSigned {
146146
fn tx_hash(&self) -> &TxHash {
147147
self.hash.get_or_init(|| self.recalculate_hash())
148148
}
149+
}
149150

151+
impl SignedTransaction for OpTransactionSigned {
150152
fn recalculate_hash(&self) -> B256 {
151153
keccak256(self.encoded_2718())
152154
}

crates/primitives-traits/src/block/body.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ use crate::{
55
MaybeSerdeBincodeCompat, SignedTransaction,
66
};
77
use alloc::{fmt, vec::Vec};
8-
use alloy_consensus::{transaction::Recovered, Transaction, Typed2718};
8+
use alloy_consensus::{
9+
transaction::{Recovered, TxHashRef},
10+
Transaction, Typed2718,
11+
};
912
use alloy_eips::{eip2718::Encodable2718, eip4895::Withdrawals};
1013
use alloy_primitives::{Address, Bytes, B256};
1114

0 commit comments

Comments
 (0)