From 9806e07cf89bf95d274b46ad5050463ac9efd169 Mon Sep 17 00:00:00 2001 From: emmmm <155267286+eeemmmmmm@users.noreply.github.com> Date: Mon, 22 Sep 2025 05:31:17 -0400 Subject: [PATCH] fix: replace tx_hash method with TxHashRef trait bound (#18357) (#18362) Co-authored-by: Matthias Seitz --- crates/cli/commands/src/re_execute.rs | 4 +- crates/consensus/common/src/validation.rs | 3 +- crates/e2e-test-utils/src/node.rs | 4 +- crates/engine/tree/src/tree/metrics.rs | 1 + .../src/tree/payload_processor/prewarm.rs | 3 +- crates/ethereum/primitives/src/transaction.rs | 6 ++- crates/net/eth-wire-types/src/broadcast.rs | 2 +- crates/net/network/src/transactions/mod.rs | 2 + .../primitives/src/transaction/signed.rs | 6 ++- crates/primitives-traits/src/block/body.rs | 5 ++- .../primitives-traits/src/block/recovered.rs | 3 +- crates/primitives-traits/src/extended.rs | 23 +++++++---- .../primitives-traits/src/transaction/mod.rs | 4 +- .../src/transaction/signed.rs | 40 +++---------------- crates/rpc/rpc-eth-api/src/helpers/block.rs | 6 +-- crates/rpc/rpc-eth-api/src/helpers/call.rs | 4 +- crates/rpc/rpc-eth-api/src/helpers/trace.rs | 4 +- .../rpc-eth-api/src/helpers/transaction.rs | 2 +- crates/rpc/rpc-eth-types/src/simulate.rs | 6 +-- crates/rpc/rpc/src/debug.rs | 9 +++-- crates/rpc/rpc/src/eth/bundle.rs | 4 +- crates/rpc/rpc/src/eth/sim_bundle.rs | 4 +- .../src/providers/database/provider.rs | 4 +- .../storage/provider/src/test_utils/mock.rs | 8 +++- crates/transaction-pool/src/maintain.rs | 2 +- crates/transaction-pool/src/traits.rs | 2 +- examples/custom-node/src/pool.rs | 12 ++++-- examples/custom-node/src/primitives/tx.rs | 10 +++-- 28 files changed, 92 insertions(+), 91 deletions(-) diff --git a/crates/cli/commands/src/re_execute.rs b/crates/cli/commands/src/re_execute.rs index a555297488..3b8ba305a4 100644 --- a/crates/cli/commands/src/re_execute.rs +++ b/crates/cli/commands/src/re_execute.rs @@ -4,14 +4,14 @@ use crate::common::{ AccessRights, CliComponentsBuilder, CliNodeComponents, CliNodeTypes, Environment, EnvironmentArgs, }; -use alloy_consensus::{BlockHeader, TxReceipt}; +use alloy_consensus::{transaction::TxHashRef, BlockHeader, TxReceipt}; use clap::Parser; use eyre::WrapErr; use reth_chainspec::{EthChainSpec, EthereumHardforks, Hardforks}; use reth_cli::chainspec::ChainSpecParser; use reth_consensus::FullConsensus; use reth_evm::{execute::Executor, ConfigureEvm}; -use reth_primitives_traits::{format_gas_throughput, BlockBody, GotExpected, SignedTransaction}; +use reth_primitives_traits::{format_gas_throughput, BlockBody, GotExpected}; use reth_provider::{ BlockNumReader, BlockReader, ChainSpecProvider, DatabaseProviderFactory, ReceiptProvider, StaticFileProviderFactory, TransactionVariant, diff --git a/crates/consensus/common/src/validation.rs b/crates/consensus/common/src/validation.rs index 02694502b5..e14a316427 100644 --- a/crates/consensus/common/src/validation.rs +++ b/crates/consensus/common/src/validation.rs @@ -10,7 +10,8 @@ use reth_primitives_traits::{ constants::{ GAS_LIMIT_BOUND_DIVISOR, MAXIMUM_GAS_LIMIT_BLOCK, MAX_TX_GAS_LIMIT_OSAKA, MINIMUM_GAS_LIMIT, }, - Block, BlockBody, BlockHeader, GotExpected, SealedBlock, SealedHeader, SignedTransaction, + transaction::TxHashRef, + Block, BlockBody, BlockHeader, GotExpected, SealedBlock, SealedHeader, }; /// The maximum RLP length of a block, defined in [EIP-7934](https://eips.ethereum.org/EIPS/eip-7934). diff --git a/crates/e2e-test-utils/src/node.rs b/crates/e2e-test-utils/src/node.rs index 72698134d7..8611da2dae 100644 --- a/crates/e2e-test-utils/src/node.rs +++ b/crates/e2e-test-utils/src/node.rs @@ -1,5 +1,5 @@ use crate::{network::NetworkTestContext, payload::PayloadTestContext, rpc::RpcTestContext}; -use alloy_consensus::BlockHeader; +use alloy_consensus::{transaction::TxHashRef, BlockHeader}; use alloy_eips::BlockId; use alloy_primitives::{BlockHash, BlockNumber, Bytes, Sealable, B256}; use alloy_rpc_types_engine::ForkchoiceState; @@ -14,7 +14,7 @@ use reth_node_api::{ PrimitivesTy, }; use reth_node_builder::{rpc::RethRpcAddOns, FullNode, NodeTypes}; -use reth_node_core::primitives::SignedTransaction; + use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes}; use reth_provider::{ BlockReader, BlockReaderIdExt, CanonStateNotificationStream, CanonStateSubscriptions, diff --git a/crates/engine/tree/src/tree/metrics.rs b/crates/engine/tree/src/tree/metrics.rs index b0f4c360a4..a5ebcf5254 100644 --- a/crates/engine/tree/src/tree/metrics.rs +++ b/crates/engine/tree/src/tree/metrics.rs @@ -1,4 +1,5 @@ use crate::tree::MeteredStateHook; +use alloy_consensus::transaction::TxHashRef; use alloy_evm::{ block::{BlockExecutor, ExecutableTx}, Evm, diff --git a/crates/engine/tree/src/tree/payload_processor/prewarm.rs b/crates/engine/tree/src/tree/payload_processor/prewarm.rs index 8917d13f06..ca3aff3c37 100644 --- a/crates/engine/tree/src/tree/payload_processor/prewarm.rs +++ b/crates/engine/tree/src/tree/payload_processor/prewarm.rs @@ -20,12 +20,13 @@ use crate::tree::{ precompile_cache::{CachedPrecompile, PrecompileCacheMap}, ExecutionEnv, StateProviderBuilder, }; +use alloy_consensus::transaction::TxHashRef; use alloy_evm::Database; use alloy_primitives::{keccak256, map::B256Set, B256}; use metrics::{Counter, Gauge, Histogram}; use reth_evm::{execute::ExecutableTxFor, ConfigureEvm, Evm, EvmFor, SpecFor}; use reth_metrics::Metrics; -use reth_primitives_traits::{NodePrimitives, SignedTransaction}; +use reth_primitives_traits::NodePrimitives; use reth_provider::{BlockReader, StateProviderFactory, StateReader}; use reth_revm::{database::StateProviderDatabase, db::BundleState, state::EvmState}; use reth_trie::MultiProofTargets; diff --git a/crates/ethereum/primitives/src/transaction.rs b/crates/ethereum/primitives/src/transaction.rs index c6de2521a0..f2ec4ad9cd 100644 --- a/crates/ethereum/primitives/src/transaction.rs +++ b/crates/ethereum/primitives/src/transaction.rs @@ -3,7 +3,7 @@ use alloc::vec::Vec; use alloy_consensus::{ - transaction::{RlpEcdsaDecodableTx, RlpEcdsaEncodableTx, SignerRecoverable}, + transaction::{RlpEcdsaDecodableTx, RlpEcdsaEncodableTx, SignerRecoverable, TxHashRef}, EthereumTxEnvelope, SignableTransaction, Signed, TxEip1559, TxEip2930, TxEip4844, TxEip7702, TxLegacy, TxType, Typed2718, }; @@ -658,12 +658,14 @@ impl SignerRecoverable for TransactionSigned { } } -impl SignedTransaction for TransactionSigned { +impl TxHashRef for TransactionSigned { fn tx_hash(&self) -> &TxHash { self.hash.get_or_init(|| self.recalculate_hash()) } } +impl SignedTransaction for TransactionSigned {} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/net/eth-wire-types/src/broadcast.rs b/crates/net/eth-wire-types/src/broadcast.rs index 15e7bb70eb..1900cf004a 100644 --- a/crates/net/eth-wire-types/src/broadcast.rs +++ b/crates/net/eth-wire-types/src/broadcast.rs @@ -801,7 +801,7 @@ pub struct BlockRangeUpdate { #[cfg(test)] mod tests { use super::*; - use alloy_consensus::Typed2718; + use alloy_consensus::{transaction::TxHashRef, Typed2718}; use alloy_eips::eip2718::Encodable2718; use alloy_primitives::{b256, hex, Signature, U256}; use reth_ethereum_primitives::{Transaction, TransactionSigned}; diff --git a/crates/net/network/src/transactions/mod.rs b/crates/net/network/src/transactions/mod.rs index 68df78fb0f..841a0f063f 100644 --- a/crates/net/network/src/transactions/mod.rs +++ b/crates/net/network/src/transactions/mod.rs @@ -1,5 +1,7 @@ //! Transactions management for the p2p network. +use alloy_consensus::transaction::TxHashRef; + /// Aggregation on configurable parameters for [`TransactionsManager`]. pub mod config; /// Default and spec'd bounds. diff --git a/crates/optimism/primitives/src/transaction/signed.rs b/crates/optimism/primitives/src/transaction/signed.rs index 7527675468..820cc11271 100644 --- a/crates/optimism/primitives/src/transaction/signed.rs +++ b/crates/optimism/primitives/src/transaction/signed.rs @@ -4,7 +4,7 @@ use crate::transaction::OpTransaction; use alloc::vec::Vec; use alloy_consensus::{ - transaction::{RlpEcdsaDecodableTx, RlpEcdsaEncodableTx, SignerRecoverable}, + transaction::{RlpEcdsaDecodableTx, RlpEcdsaEncodableTx, SignerRecoverable, TxHashRef}, Sealed, SignableTransaction, Signed, Transaction, TxEip1559, TxEip2930, TxEip7702, TxLegacy, Typed2718, }; @@ -142,11 +142,13 @@ impl SignerRecoverable for OpTransactionSigned { } } -impl SignedTransaction for OpTransactionSigned { +impl TxHashRef for OpTransactionSigned { fn tx_hash(&self) -> &TxHash { self.hash.get_or_init(|| self.recalculate_hash()) } +} +impl SignedTransaction for OpTransactionSigned { fn recalculate_hash(&self) -> B256 { keccak256(self.encoded_2718()) } diff --git a/crates/primitives-traits/src/block/body.rs b/crates/primitives-traits/src/block/body.rs index ad07362831..4dc9a67e88 100644 --- a/crates/primitives-traits/src/block/body.rs +++ b/crates/primitives-traits/src/block/body.rs @@ -5,7 +5,10 @@ use crate::{ MaybeSerdeBincodeCompat, SignedTransaction, }; use alloc::{fmt, vec::Vec}; -use alloy_consensus::{transaction::Recovered, Transaction, Typed2718}; +use alloy_consensus::{ + transaction::{Recovered, TxHashRef}, + Transaction, Typed2718, +}; use alloy_eips::{eip2718::Encodable2718, eip4895::Withdrawals}; use alloy_primitives::{Address, Bytes, B256}; diff --git a/crates/primitives-traits/src/block/recovered.rs b/crates/primitives-traits/src/block/recovered.rs index a0af65b456..d139345bf5 100644 --- a/crates/primitives-traits/src/block/recovered.rs +++ b/crates/primitives-traits/src/block/recovered.rs @@ -659,7 +659,8 @@ mod rpc_compat { use crate::{block::error::BlockRecoveryError, SealedHeader}; use alloc::vec::Vec; use alloy_consensus::{ - transaction::Recovered, Block as CBlock, BlockBody, BlockHeader, Sealable, + transaction::{Recovered, TxHashRef}, + Block as CBlock, BlockBody, BlockHeader, Sealable, }; use alloy_rpc_types_eth::{Block, BlockTransactions, BlockTransactionsKind, TransactionInfo}; diff --git a/crates/primitives-traits/src/extended.rs b/crates/primitives-traits/src/extended.rs index b2731aa5a9..45530fc8c5 100644 --- a/crates/primitives-traits/src/extended.rs +++ b/crates/primitives-traits/src/extended.rs @@ -3,7 +3,10 @@ use crate::{ transaction::signed::{RecoveryError, SignedTransaction}, }; use alloc::vec::Vec; -use alloy_consensus::{transaction::SignerRecoverable, EthereumTxEnvelope, Transaction}; +use alloy_consensus::{ + transaction::{SignerRecoverable, TxHashRef}, + EthereumTxEnvelope, Transaction, +}; use alloy_eips::{ eip2718::{Eip2718Error, Eip2718Result, IsTyped2718}, eip2930::AccessList, @@ -155,19 +158,23 @@ where } } -impl SignedTransaction for Extended +impl TxHashRef for Extended where - B: SignedTransaction + IsTyped2718, - T: SignedTransaction, + B: TxHashRef, + T: TxHashRef, { fn tx_hash(&self) -> &TxHash { - match self { - Self::BuiltIn(tx) => tx.tx_hash(), - Self::Other(tx) => tx.tx_hash(), - } + delegate!(self => tx.tx_hash()) } } +impl SignedTransaction for Extended +where + B: SignedTransaction + IsTyped2718 + TxHashRef, + T: SignedTransaction + TxHashRef, +{ +} + impl Typed2718 for Extended where B: Typed2718, diff --git a/crates/primitives-traits/src/transaction/mod.rs b/crates/primitives-traits/src/transaction/mod.rs index f11c3346ae..5620d4916b 100644 --- a/crates/primitives-traits/src/transaction/mod.rs +++ b/crates/primitives-traits/src/transaction/mod.rs @@ -18,7 +18,9 @@ pub mod signed; pub mod error; pub mod recover; -pub use alloy_consensus::transaction::{SignerRecoverable, TransactionInfo, TransactionMeta}; +pub use alloy_consensus::transaction::{ + SignerRecoverable, TransactionInfo, TransactionMeta, TxHashRef, +}; use crate::{InMemorySize, MaybeCompact, MaybeSerde}; use core::{fmt, hash::Hash}; diff --git a/crates/primitives-traits/src/transaction/signed.rs b/crates/primitives-traits/src/transaction/signed.rs index 104555db0f..08a6758d8d 100644 --- a/crates/primitives-traits/src/transaction/signed.rs +++ b/crates/primitives-traits/src/transaction/signed.rs @@ -3,11 +3,11 @@ use crate::{InMemorySize, MaybeCompact, MaybeSerde, MaybeSerdeBincodeCompat}; use alloc::fmt; use alloy_consensus::{ - transaction::{Recovered, RlpEcdsaEncodableTx, SignerRecoverable}, + transaction::{Recovered, RlpEcdsaEncodableTx, SignerRecoverable, TxHashRef}, EthereumTxEnvelope, SignableTransaction, }; use alloy_eips::eip2718::{Decodable2718, Encodable2718}; -use alloy_primitives::{keccak256, Address, Signature, TxHash, B256}; +use alloy_primitives::{keccak256, Address, Signature, B256}; use alloy_rlp::{Decodable, Encodable}; use core::hash::Hash; @@ -45,10 +45,8 @@ pub trait SignedTransaction: + MaybeSerde + InMemorySize + SignerRecoverable + + TxHashRef { - /// Returns reference to transaction hash. - fn tx_hash(&self) -> &TxHash; - /// Returns whether this transaction type can be __broadcasted__ as full transaction over the /// network. /// @@ -136,15 +134,6 @@ where T: RlpEcdsaEncodableTx + SignableTransaction + Unpin, Self: Clone + PartialEq + Eq + Decodable + Decodable2718 + MaybeSerde + InMemorySize, { - fn tx_hash(&self) -> &TxHash { - match self { - Self::Legacy(tx) => tx.hash(), - Self::Eip2930(tx) => tx.hash(), - Self::Eip1559(tx) => tx.hash(), - Self::Eip7702(tx) => tx.hash(), - Self::Eip4844(tx) => tx.hash(), - } - } } #[cfg(feature = "op")] @@ -152,26 +141,7 @@ mod op { use super::*; use op_alloy_consensus::{OpPooledTransaction, OpTxEnvelope}; - impl SignedTransaction for OpPooledTransaction { - fn tx_hash(&self) -> &TxHash { - match self { - Self::Legacy(tx) => tx.hash(), - Self::Eip2930(tx) => tx.hash(), - Self::Eip1559(tx) => tx.hash(), - Self::Eip7702(tx) => tx.hash(), - } - } - } + impl SignedTransaction for OpPooledTransaction {} - impl SignedTransaction for OpTxEnvelope { - fn tx_hash(&self) -> &TxHash { - match self { - Self::Legacy(tx) => tx.hash(), - Self::Eip2930(tx) => tx.hash(), - Self::Eip1559(tx) => tx.hash(), - Self::Eip7702(tx) => tx.hash(), - Self::Deposit(tx) => tx.hash_ref(), - } - } - } + impl SignedTransaction for OpTxEnvelope {} } diff --git a/crates/rpc/rpc-eth-api/src/helpers/block.rs b/crates/rpc/rpc-eth-api/src/helpers/block.rs index 08bc368bec..dcb28c7e8a 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/block.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/block.rs @@ -5,15 +5,13 @@ use crate::{ node::RpcNodeCoreExt, EthApiTypes, FromEthApiError, FullEthApiTypes, RpcBlock, RpcNodeCore, RpcReceipt, }; -use alloy_consensus::TxReceipt; +use alloy_consensus::{transaction::TxHashRef, TxReceipt}; use alloy_eips::BlockId; use alloy_rlp::Encodable; use alloy_rpc_types_eth::{Block, BlockTransactions, Index}; use futures::Future; use reth_node_api::BlockBody; -use reth_primitives_traits::{ - AlloyBlockHeader, RecoveredBlock, SealedHeader, SignedTransaction, TransactionMeta, -}; +use reth_primitives_traits::{AlloyBlockHeader, RecoveredBlock, SealedHeader, TransactionMeta}; use reth_rpc_convert::{transaction::ConvertReceiptInput, RpcConvert, RpcHeader}; use reth_storage_api::{BlockIdReader, BlockReader, ProviderHeader, ProviderReceipt, ProviderTx}; use reth_transaction_pool::{PoolTransaction, TransactionPool}; diff --git a/crates/rpc/rpc-eth-api/src/helpers/call.rs b/crates/rpc/rpc-eth-api/src/helpers/call.rs index 5841cc422a..6364474f62 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/call.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/call.rs @@ -7,7 +7,7 @@ use super::{LoadBlock, LoadPendingBlock, LoadState, LoadTransaction, SpawnBlocki use crate::{ helpers::estimate::EstimateCall, FromEvmError, FullEthApiTypes, RpcBlock, RpcNodeCore, }; -use alloy_consensus::BlockHeader; +use alloy_consensus::{transaction::TxHashRef, BlockHeader}; use alloy_eips::eip2930::AccessListResult; use alloy_evm::overrides::{apply_block_overrides, apply_state_overrides, OverrideBlockHashes}; use alloy_network::TransactionBuilder; @@ -24,7 +24,7 @@ use reth_evm::{ TxEnvFor, }; use reth_node_api::BlockBody; -use reth_primitives_traits::{Recovered, SignedTransaction}; +use reth_primitives_traits::Recovered; use reth_revm::{ database::StateProviderDatabase, db::{CacheDB, State}, diff --git a/crates/rpc/rpc-eth-api/src/helpers/trace.rs b/crates/rpc/rpc-eth-api/src/helpers/trace.rs index 404234ea3d..a3c79416cf 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/trace.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/trace.rs @@ -2,7 +2,7 @@ use super::{Call, LoadBlock, LoadPendingBlock, LoadState, LoadTransaction}; use crate::FromEvmError; -use alloy_consensus::BlockHeader; +use alloy_consensus::{transaction::TxHashRef, BlockHeader}; use alloy_primitives::B256; use alloy_rpc_types_eth::{BlockId, TransactionInfo}; use futures::Future; @@ -12,7 +12,7 @@ use reth_evm::{ evm::EvmFactoryExt, system_calls::SystemCaller, tracing::TracingCtx, ConfigureEvm, Database, Evm, EvmEnvFor, EvmFor, HaltReasonFor, InspectorFor, TxEnvFor, }; -use reth_primitives_traits::{BlockBody, Recovered, RecoveredBlock, SignedTransaction}; +use reth_primitives_traits::{BlockBody, Recovered, RecoveredBlock}; use reth_revm::{database::StateProviderDatabase, db::CacheDB}; use reth_rpc_eth_types::{ cache::db::{StateCacheDb, StateCacheDbRefMutWrapper, StateProviderTraitObjWrapper}, diff --git a/crates/rpc/rpc-eth-api/src/helpers/transaction.rs b/crates/rpc/rpc-eth-api/src/helpers/transaction.rs index a8d2dc01c5..c9fa6a0431 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/transaction.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/transaction.rs @@ -8,7 +8,7 @@ use crate::{ RpcTransaction, }; use alloy_consensus::{ - transaction::{SignerRecoverable, TransactionMeta}, + transaction::{SignerRecoverable, TransactionMeta, TxHashRef}, BlockHeader, Transaction, }; use alloy_dyn_abi::TypedData; diff --git a/crates/rpc/rpc-eth-types/src/simulate.rs b/crates/rpc/rpc-eth-types/src/simulate.rs index 733390a196..5492e127b7 100644 --- a/crates/rpc/rpc-eth-types/src/simulate.rs +++ b/crates/rpc/rpc-eth-types/src/simulate.rs @@ -7,7 +7,7 @@ use crate::{ }, EthApiError, RevertError, }; -use alloy_consensus::{BlockHeader, Transaction as _}; +use alloy_consensus::{transaction::TxHashRef, BlockHeader, Transaction as _}; use alloy_eips::eip2718::WithEncoded; use alloy_network::TransactionBuilder; use alloy_rpc_types_eth::{ @@ -19,9 +19,7 @@ use reth_evm::{ execute::{BlockBuilder, BlockBuilderOutcome, BlockExecutor}, Evm, }; -use reth_primitives_traits::{ - BlockBody as _, BlockTy, NodePrimitives, Recovered, RecoveredBlock, SignedTransaction, -}; +use reth_primitives_traits::{BlockBody as _, BlockTy, NodePrimitives, Recovered, RecoveredBlock}; use reth_rpc_convert::{RpcBlock, RpcConvert, RpcTxReq}; use reth_rpc_server_types::result::rpc_err; use reth_storage_api::noop::NoopProvider; diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index 0eb7dd7c4d..1b64cc420b 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -1,4 +1,7 @@ -use alloy_consensus::{transaction::SignerRecoverable, BlockHeader}; +use alloy_consensus::{ + transaction::{SignerRecoverable, TxHashRef}, + BlockHeader, +}; use alloy_eips::{eip2718::Encodable2718, BlockId, BlockNumberOrTag}; use alloy_genesis::ChainConfig; use alloy_primitives::{uint, Address, Bytes, B256}; @@ -16,9 +19,7 @@ use async_trait::async_trait; use jsonrpsee::core::RpcResult; use reth_chainspec::{ChainSpecProvider, EthChainSpec, EthereumHardforks}; use reth_evm::{execute::Executor, ConfigureEvm, EvmEnvFor, TxEnvFor}; -use reth_primitives_traits::{ - Block as _, BlockBody, ReceiptWithBloom, RecoveredBlock, SignedTransaction, -}; +use reth_primitives_traits::{Block as _, BlockBody, ReceiptWithBloom, RecoveredBlock}; use reth_revm::{ database::StateProviderDatabase, db::{CacheDB, State}, diff --git a/crates/rpc/rpc/src/eth/bundle.rs b/crates/rpc/rpc/src/eth/bundle.rs index 0ff7fb1dde..48e3219daa 100644 --- a/crates/rpc/rpc/src/eth/bundle.rs +++ b/crates/rpc/rpc/src/eth/bundle.rs @@ -1,13 +1,13 @@ //! `Eth` bundle implementation and helpers. -use alloy_consensus::{EnvKzgSettings, Transaction as _}; +use alloy_consensus::{transaction::TxHashRef, EnvKzgSettings, Transaction as _}; use alloy_eips::eip7840::BlobParams; use alloy_primitives::{uint, Keccak256, U256}; use alloy_rpc_types_mev::{EthCallBundle, EthCallBundleResponse, EthCallBundleTransactionResult}; use jsonrpsee::core::RpcResult; use reth_chainspec::{ChainSpecProvider, EthChainSpec}; use reth_evm::{ConfigureEvm, Evm}; -use reth_primitives_traits::SignedTransaction; + use reth_revm::{database::StateProviderDatabase, db::CacheDB}; use reth_rpc_eth_api::{ helpers::{Call, EthTransactions, LoadPendingBlock}, diff --git a/crates/rpc/rpc/src/eth/sim_bundle.rs b/crates/rpc/rpc/src/eth/sim_bundle.rs index 67d94d8140..f704382175 100644 --- a/crates/rpc/rpc/src/eth/sim_bundle.rs +++ b/crates/rpc/rpc/src/eth/sim_bundle.rs @@ -1,6 +1,6 @@ //! `Eth` Sim bundle implementation and helpers. -use alloy_consensus::BlockHeader; +use alloy_consensus::{transaction::TxHashRef, BlockHeader}; use alloy_eips::BlockNumberOrTag; use alloy_evm::overrides::apply_block_overrides; use alloy_primitives::U256; @@ -11,7 +11,7 @@ use alloy_rpc_types_mev::{ }; use jsonrpsee::core::RpcResult; use reth_evm::{ConfigureEvm, Evm}; -use reth_primitives_traits::{Recovered, SignedTransaction}; +use reth_primitives_traits::Recovered; use reth_revm::{database::StateProviderDatabase, db::CacheDB}; use reth_rpc_api::MevSimApiServer; use reth_rpc_eth_api::{ diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index 400f9e23a5..02b2e112ed 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -19,7 +19,7 @@ use crate::{ TransactionsProviderExt, TrieWriter, }; use alloy_consensus::{ - transaction::{SignerRecoverable, TransactionMeta}, + transaction::{SignerRecoverable, TransactionMeta, TxHashRef}, BlockHeader, Header, TxReceipt, }; use alloy_eips::{eip2718::Encodable2718, BlockHashOrNumber}; @@ -47,7 +47,7 @@ use reth_execution_types::{Chain, ExecutionOutcome}; use reth_node_types::{BlockTy, BodyTy, HeaderTy, NodeTypes, ReceiptTy, TxTy}; use reth_primitives_traits::{ Account, Block as _, BlockBody as _, Bytecode, GotExpected, NodePrimitives, RecoveredBlock, - SealedHeader, SignedTransaction, StorageEntry, + SealedHeader, StorageEntry, }; use reth_prune_types::{ PruneCheckpoint, PruneMode, PruneModes, PruneSegment, MINIMUM_PRUNING_DISTANCE, diff --git a/crates/storage/provider/src/test_utils/mock.rs b/crates/storage/provider/src/test_utils/mock.rs index 9e47f8b6f1..af7a3c069a 100644 --- a/crates/storage/provider/src/test_utils/mock.rs +++ b/crates/storage/provider/src/test_utils/mock.rs @@ -5,7 +5,11 @@ use crate::{ StateProviderBox, StateProviderFactory, StateReader, StateRootProvider, TransactionVariant, TransactionsProvider, }; -use alloy_consensus::{constants::EMPTY_ROOT_HASH, transaction::TransactionMeta, BlockHeader}; +use alloy_consensus::{ + constants::EMPTY_ROOT_HASH, + transaction::{TransactionMeta, TxHashRef}, + BlockHeader, +}; use alloy_eips::{BlockHashOrNumber, BlockId, BlockNumberOrTag}; use alloy_primitives::{ keccak256, map::HashMap, Address, BlockHash, BlockNumber, Bytes, StorageKey, StorageValue, @@ -22,7 +26,7 @@ use reth_ethereum_primitives::EthPrimitives; use reth_execution_types::ExecutionOutcome; use reth_primitives_traits::{ Account, Block, BlockBody, Bytecode, GotExpected, NodePrimitives, RecoveredBlock, SealedHeader, - SignedTransaction, SignerRecoverable, + SignerRecoverable, }; use reth_prune_types::PruneModes; use reth_stages_types::{StageCheckpoint, StageId}; diff --git a/crates/transaction-pool/src/maintain.rs b/crates/transaction-pool/src/maintain.rs index 4bebe454cd..a2f33900b5 100644 --- a/crates/transaction-pool/src/maintain.rs +++ b/crates/transaction-pool/src/maintain.rs @@ -7,7 +7,7 @@ use crate::{ traits::{CanonicalStateUpdate, EthPoolTransaction, TransactionPool, TransactionPoolExt}, BlockInfo, PoolTransaction, PoolUpdateKind, TransactionOrigin, }; -use alloy_consensus::{BlockHeader, Typed2718}; +use alloy_consensus::{transaction::TxHashRef, BlockHeader, Typed2718}; use alloy_eips::{BlockNumberOrTag, Decodable2718, Encodable2718}; use alloy_primitives::{Address, BlockHash, BlockNumber}; use alloy_rlp::{Bytes, Encodable}; diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index f2ed3822a9..9552646652 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -60,7 +60,7 @@ use crate::{ validate::ValidPoolTransaction, AddedTransactionOutcome, AllTransactionsEvents, }; -use alloy_consensus::{error::ValueError, BlockHeader, Signed, Typed2718}; +use alloy_consensus::{error::ValueError, transaction::TxHashRef, BlockHeader, Signed, Typed2718}; use alloy_eips::{ eip2718::{Encodable2718, WithEncoded}, eip2930::AccessList, diff --git a/examples/custom-node/src/pool.rs b/examples/custom-node/src/pool.rs index 1d57fd8c4b..0959b3bcae 100644 --- a/examples/custom-node/src/pool.rs +++ b/examples/custom-node/src/pool.rs @@ -1,7 +1,9 @@ use crate::primitives::{CustomTransaction, TxPayment}; use alloy_consensus::{ - crypto::RecoveryError, error::ValueError, transaction::SignerRecoverable, Signed, - TransactionEnvelope, + crypto::RecoveryError, + error::ValueError, + transaction::{SignerRecoverable, TxHashRef}, + Signed, TransactionEnvelope, }; use alloy_primitives::{Address, Sealed, B256}; use op_alloy_consensus::{OpPooledTransaction, OpTransaction, TxDeposit}; @@ -70,15 +72,17 @@ impl SignerRecoverable for CustomPooledTransaction { } } -impl SignedTransaction for CustomPooledTransaction { +impl TxHashRef for CustomPooledTransaction { fn tx_hash(&self) -> &B256 { match self { - CustomPooledTransaction::Op(tx) => SignedTransaction::tx_hash(tx), + CustomPooledTransaction::Op(tx) => tx.tx_hash(), CustomPooledTransaction::Payment(tx) => tx.hash(), } } } +impl SignedTransaction for CustomPooledTransaction {} + impl InMemorySize for CustomPooledTransaction { fn size(&self) -> usize { match self { diff --git a/examples/custom-node/src/primitives/tx.rs b/examples/custom-node/src/primitives/tx.rs index 729b2345d8..f04bcc8862 100644 --- a/examples/custom-node/src/primitives/tx.rs +++ b/examples/custom-node/src/primitives/tx.rs @@ -1,6 +1,8 @@ use super::TxPayment; use alloy_consensus::{ - crypto::RecoveryError, transaction::SignerRecoverable, Signed, TransactionEnvelope, + crypto::RecoveryError, + transaction::{SignerRecoverable, TxHashRef}, + Signed, TransactionEnvelope, }; use alloy_eips::Encodable2718; use alloy_primitives::{Sealed, Signature, B256}; @@ -121,15 +123,17 @@ impl SignerRecoverable for CustomTransaction { } } -impl SignedTransaction for CustomTransaction { +impl TxHashRef for CustomTransaction { fn tx_hash(&self) -> &B256 { match self { - CustomTransaction::Op(tx) => SignedTransaction::tx_hash(tx), + CustomTransaction::Op(tx) => TxHashRef::tx_hash(tx), CustomTransaction::Payment(tx) => tx.hash(), } } } +impl SignedTransaction for CustomTransaction {} + impl InMemorySize for CustomTransaction { fn size(&self) -> usize { match self {