diff --git a/bin/reth/src/commands/debug_cmd/build_block.rs b/bin/reth/src/commands/debug_cmd/build_block.rs index 185e5649d..31209ab72 100644 --- a/bin/reth/src/commands/debug_cmd/build_block.rs +++ b/bin/reth/src/commands/debug_cmd/build_block.rs @@ -24,10 +24,7 @@ use reth_execution_types::ExecutionOutcome; use reth_fs_util as fs; use reth_node_api::{BlockTy, EngineApiMessageVersion, PayloadBuilderAttributes}; use reth_node_ethereum::{consensus::EthBeaconConsensus, EthEvmConfig, EthExecutorProvider}; -use reth_primitives_traits::{ - transaction::signed::SignedTransactionIntoRecoveredExt, Block as _, SealedBlock, SealedHeader, - SignedTransaction, -}; +use reth_primitives_traits::{Block as _, SealedBlock, SealedHeader, SignedTransaction}; use reth_provider::{ providers::{BlockchainProvider, ProviderNodeTypes}, BlockHashReader, BlockReader, BlockWriter, ChainSpecProvider, ProviderFactory, diff --git a/crates/chain-state/src/test_utils.rs b/crates/chain-state/src/test_utils.rs index 53c63845f..3e576f16f 100644 --- a/crates/chain-state/src/test_utils.rs +++ b/crates/chain-state/src/test_utils.rs @@ -18,8 +18,8 @@ use rand::{thread_rng, Rng}; use reth_chainspec::{ChainSpec, EthereumHardfork, MIN_TRANSACTION_GAS}; use reth_execution_types::{Chain, ExecutionOutcome}; use reth_primitives::{ - transaction::SignedTransactionIntoRecoveredExt, BlockBody, EthPrimitives, NodePrimitives, - Receipt, Recovered, RecoveredBlock, SealedBlock, SealedHeader, Transaction, TransactionSigned, + transaction::SignedTransaction, BlockBody, EthPrimitives, NodePrimitives, Receipt, Recovered, + RecoveredBlock, SealedBlock, SealedHeader, Transaction, TransactionSigned, }; use reth_primitives_traits::{ proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root}, diff --git a/crates/engine/util/src/reorg.rs b/crates/engine/util/src/reorg.rs index 50e19656a..5473db2a6 100644 --- a/crates/engine/util/src/reorg.rs +++ b/crates/engine/util/src/reorg.rs @@ -19,7 +19,7 @@ use reth_evm::{ }; use reth_payload_primitives::EngineApiMessageVersion; use reth_payload_validator::ExecutionPayloadValidator; -use reth_primitives::{transaction::SignedTransactionIntoRecoveredExt, Block, BlockBody, Receipt}; +use reth_primitives::{Block, BlockBody, Receipt}; use reth_primitives_traits::{block::Block as _, proofs, SignedTransaction}; use reth_provider::{BlockReader, ExecutionOutcome, ProviderError, StateProviderFactory}; use reth_revm::{ diff --git a/crates/evm/execution-types/src/chain.rs b/crates/evm/execution-types/src/chain.rs index 064cd62a1..5fb436930 100644 --- a/crates/evm/execution-types/src/chain.rs +++ b/crates/evm/execution-types/src/chain.rs @@ -8,8 +8,8 @@ use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash}; use core::{fmt, ops::RangeInclusive}; use reth_execution_errors::{BlockExecutionError, InternalBlockExecutionError}; use reth_primitives_traits::{ - transaction::signed::SignedTransactionIntoRecoveredExt, Block, BlockBody, NodePrimitives, - RecoveredBlock, SealedHeader, SignedTransaction, + transaction::signed::SignedTransaction, Block, BlockBody, NodePrimitives, RecoveredBlock, + SealedHeader, }; use reth_trie_common::updates::TrieUpdates; use revm_database::BundleState; diff --git a/crates/net/network/src/transactions/mod.rs b/crates/net/network/src/transactions/mod.rs index 5cd84af86..f9c6d48a0 100644 --- a/crates/net/network/src/transactions/mod.rs +++ b/crates/net/network/src/transactions/mod.rs @@ -49,7 +49,7 @@ use reth_network_p2p::{ }; use reth_network_peers::PeerId; use reth_network_types::ReputationChangeKind; -use reth_primitives::{transaction::SignedTransactionIntoRecoveredExt, TransactionSigned}; +use reth_primitives::TransactionSigned; use reth_primitives_traits::SignedTransaction; use reth_tokio_util::EventStream; use reth_transaction_pool::{ diff --git a/crates/optimism/payload/src/builder.rs b/crates/optimism/payload/src/builder.rs index 333fc45ec..45f1895d4 100644 --- a/crates/optimism/payload/src/builder.rs +++ b/crates/optimism/payload/src/builder.rs @@ -31,9 +31,7 @@ use reth_optimism_storage::predeploys; use reth_payload_builder_primitives::PayloadBuilderError; use reth_payload_primitives::PayloadBuilderAttributes; use reth_payload_util::{BestPayloadTransactions, NoopPayloadTransactions, PayloadTransactions}; -use reth_primitives::{ - transaction::SignedTransactionIntoRecoveredExt, BlockBody, NodePrimitives, SealedHeader, -}; +use reth_primitives::{transaction::SignedTransaction, BlockBody, NodePrimitives, SealedHeader}; use reth_primitives_traits::{block::Block as _, proofs, RecoveredBlock}; use reth_provider::{ BlockExecutionResult, HashedPostStateProvider, ProviderError, StateProofProvider, diff --git a/crates/primitives-traits/src/block/recovered.rs b/crates/primitives-traits/src/block/recovered.rs index 934a59884..bf232a7d1 100644 --- a/crates/primitives-traits/src/block/recovered.rs +++ b/crates/primitives-traits/src/block/recovered.rs @@ -2,7 +2,7 @@ use crate::{ block::{error::SealedBlockRecoveryError, SealedBlock}, - transaction::signed::{RecoveryError, SignedTransactionIntoRecoveredExt}, + transaction::signed::{RecoveryError, SignedTransaction}, Block, BlockBody, InMemorySize, SealedHeader, }; use alloc::vec::Vec; diff --git a/crates/primitives-traits/src/transaction/signed.rs b/crates/primitives-traits/src/transaction/signed.rs index 9979a3fcf..03a0eda26 100644 --- a/crates/primitives-traits/src/transaction/signed.rs +++ b/crates/primitives-traits/src/transaction/signed.rs @@ -99,6 +99,41 @@ pub trait SignedTransaction: fn recalculate_hash(&self) -> B256 { keccak256(self.encoded_2718()) } + + /// Tries to recover signer and return [`Recovered`] by cloning the type. + #[auto_impl(keep_default_for(&, Arc))] + fn try_clone_into_recovered(&self) -> Result, RecoveryError> { + self.recover_signer().map(|signer| Recovered::new_unchecked(self.clone(), signer)) + } + + /// Tries to recover signer and return [`Recovered`]. + /// + /// Returns `Err(Self)` if the transaction's signature is invalid, see also + /// [`SignedTransaction::recover_signer`]. + #[auto_impl(keep_default_for(&, Arc))] + fn try_into_recovered(self) -> Result, Self> { + match self.recover_signer() { + Ok(signer) => Ok(Recovered::new_unchecked(self, signer)), + Err(_) => Err(self), + } + } + + /// Consumes the type, recover signer and return [`Recovered`] _without + /// ensuring that the signature has a low `s` value_ (EIP-2). + /// + /// Returns `None` if the transaction's signature is invalid. + #[auto_impl(keep_default_for(&, Arc))] + fn into_recovered_unchecked(self) -> Result, RecoveryError> { + self.recover_signer_unchecked().map(|signer| Recovered::new_unchecked(self, signer)) + } + + /// Returns the [`Recovered`] transaction with the given sender. + /// + /// Note: assumes the given signer is the signer of this transaction. + #[auto_impl(keep_default_for(&, Arc))] + fn with_signer(self, signer: Address) -> Recovered { + Recovered::new_unchecked(self, signer) + } } impl SignedTransaction for PooledTransaction { @@ -183,42 +218,6 @@ impl SignedTransaction for op_alloy_consensus::OpPooledTransaction { } } -/// Extension trait for [`SignedTransaction`] to convert it into [`Recovered`]. -pub trait SignedTransactionIntoRecoveredExt: SignedTransaction { - /// Tries to recover signer and return [`Recovered`] by cloning the type. - fn try_clone_into_recovered(&self) -> Result, RecoveryError> { - self.recover_signer().map(|signer| Recovered::new_unchecked(self.clone(), signer)) - } - - /// Tries to recover signer and return [`Recovered`]. - /// - /// Returns `Err(Self)` if the transaction's signature is invalid, see also - /// [`SignedTransaction::recover_signer`]. - fn try_into_recovered(self) -> Result, Self> { - match self.recover_signer() { - Ok(signer) => Ok(Recovered::new_unchecked(self, signer)), - Err(_) => Err(self), - } - } - - /// Consumes the type, recover signer and return [`Recovered`] _without - /// ensuring that the signature has a low `s` value_ (EIP-2). - /// - /// Returns `None` if the transaction's signature is invalid. - fn into_recovered_unchecked(self) -> Result, RecoveryError> { - self.recover_signer_unchecked().map(|signer| Recovered::new_unchecked(self, signer)) - } - - /// Returns the [`Recovered`] transaction with the given sender. - /// - /// Note: assumes the given signer is the signer of this transaction. - fn with_signer(self, signer: Address) -> Recovered { - Recovered::new_unchecked(self, signer) - } -} - -impl SignedTransactionIntoRecoveredExt for T where T: SignedTransaction {} - /// Opaque error type for sender recovery. #[derive(Debug, Default, thiserror::Error)] #[error("Failed to recover the signer")] diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 4bd2cc975..c9c11335e 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -11,7 +11,7 @@ pub use reth_primitives_traits::{ error::{ InvalidTransactionError, TransactionConversionError, TryFromRecoveredTransactionError, }, - signed::SignedTransactionIntoRecoveredExt, + signed::SignedTransaction, }, FillTxEnv, WithEncoded, }; diff --git a/crates/rpc/rpc-eth-api/src/helpers/transaction.rs b/crates/rpc/rpc-eth-api/src/helpers/transaction.rs index 012eb1ecb..e3cec8578 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/transaction.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/transaction.rs @@ -14,8 +14,7 @@ use alloy_primitives::{Address, Bytes, TxHash, B256}; use alloy_rpc_types_eth::{transaction::TransactionRequest, BlockNumberOrTag, TransactionInfo}; use futures::Future; use reth_node_api::BlockBody; -use reth_primitives::{transaction::SignedTransactionIntoRecoveredExt, RecoveredBlock}; -use reth_primitives_traits::SignedTransaction; +use reth_primitives::{transaction::SignedTransaction, RecoveredBlock}; use reth_provider::{ BlockNumReader, BlockReaderIdExt, ProviderBlock, ProviderReceipt, ProviderTx, ReceiptProvider, TransactionsProvider, diff --git a/crates/rpc/rpc-eth-types/src/utils.rs b/crates/rpc/rpc-eth-types/src/utils.rs index 5d498ffaf..cb63f7eec 100644 --- a/crates/rpc/rpc-eth-types/src/utils.rs +++ b/crates/rpc/rpc-eth-types/src/utils.rs @@ -1,7 +1,7 @@ //! Commonly used code snippets use super::{EthApiError, EthResult}; -use reth_primitives::{transaction::SignedTransactionIntoRecoveredExt, Recovered}; +use reth_primitives::Recovered; use reth_primitives_traits::SignedTransaction; use std::future::Future; diff --git a/crates/transaction-pool/src/maintain.rs b/crates/transaction-pool/src/maintain.rs index 5fe171755..a02f79a6d 100644 --- a/crates/transaction-pool/src/maintain.rs +++ b/crates/transaction-pool/src/maintain.rs @@ -19,7 +19,7 @@ use reth_chain_state::CanonStateNotification; use reth_chainspec::{ChainSpecProvider, EthChainSpec}; use reth_execution_types::ChangedAccount; use reth_fs_util::FsPathError; -use reth_primitives::{transaction::SignedTransactionIntoRecoveredExt, SealedHeader}; +use reth_primitives::SealedHeader; use reth_primitives_traits::{NodePrimitives, SignedTransaction}; use reth_storage_api::{errors::provider::ProviderError, BlockReaderIdExt, StateProviderFactory}; use reth_tasks::TaskSpawner; diff --git a/crates/transaction-pool/src/test_utils/gen.rs b/crates/transaction-pool/src/test_utils/gen.rs index 80275c7e4..697e25e0c 100644 --- a/crates/transaction-pool/src/test_utils/gen.rs +++ b/crates/transaction-pool/src/test_utils/gen.rs @@ -4,9 +4,7 @@ use alloy_eips::{eip1559::MIN_PROTOCOL_BASE_FEE, eip2718::Encodable2718, eip2930 use alloy_primitives::{Address, Bytes, TxKind, B256, U256}; use rand::Rng; use reth_chainspec::MAINNET; -use reth_primitives::{ - transaction::SignedTransactionIntoRecoveredExt, Transaction, TransactionSigned, -}; +use reth_primitives::{transaction::SignedTransaction, Transaction, TransactionSigned}; use reth_primitives_traits::crypto::secp256k1::sign_message; /// A generator for transactions for testing purposes. diff --git a/crates/transaction-pool/src/test_utils/mock.rs b/crates/transaction-pool/src/test_utils/mock.rs index 874a5de7a..de35158a5 100644 --- a/crates/transaction-pool/src/test_utils/mock.rs +++ b/crates/transaction-pool/src/test_utils/mock.rs @@ -29,10 +29,7 @@ use rand::{ prelude::Distribution, }; use reth_primitives::{ - transaction::{ - SignedTransactionIntoRecoveredExt, TransactionConversionError, - TryFromRecoveredTransactionError, - }, + transaction::{TransactionConversionError, TryFromRecoveredTransactionError}, PooledTransaction, Recovered, Transaction, TransactionSigned, TxType, }; use reth_primitives_traits::{InMemorySize, SignedTransaction}; diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index 676b23db6..5f65f663d 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -17,9 +17,8 @@ use futures_util::{ready, Stream}; use reth_eth_wire_types::HandleMempoolData; use reth_execution_types::ChangedAccount; use reth_primitives::{ - kzg::KzgSettings, - transaction::{SignedTransactionIntoRecoveredExt, TransactionConversionError}, - PooledTransaction, Recovered, SealedBlock, TransactionSigned, + kzg::KzgSettings, transaction::TransactionConversionError, PooledTransaction, Recovered, + SealedBlock, TransactionSigned, }; use reth_primitives_traits::{Block, InMemorySize, SignedTransaction}; #[cfg(feature = "serde")] diff --git a/crates/transaction-pool/src/validate/eth.rs b/crates/transaction-pool/src/validate/eth.rs index 42e5dda79..e4dd8bb52 100644 --- a/crates/transaction-pool/src/validate/eth.rs +++ b/crates/transaction-pool/src/validate/eth.rs @@ -924,7 +924,7 @@ mod tests { use alloy_consensus::Transaction; use alloy_eips::eip2718::Decodable2718; use alloy_primitives::{hex, U256}; - use reth_primitives::{transaction::SignedTransactionIntoRecoveredExt, PooledTransaction}; + use reth_primitives::{transaction::SignedTransaction, PooledTransaction}; use reth_provider::test_utils::{ExtendedAccount, MockEthProvider}; fn get_transaction() -> EthPooledTransaction {