From 64214fd1861d1367fe10432d4d300b407b0cc563 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 20 Jan 2025 19:07:14 +0100 Subject: [PATCH] chore: deprecate recoveredtx alias (#13887) --- crates/chain-state/src/test_utils.rs | 6 +- crates/evm/execution-types/src/chain.rs | 6 +- crates/optimism/node/src/txpool.rs | 36 ++++---- crates/optimism/node/tests/it/priority.rs | 4 +- crates/optimism/payload/src/error.rs | 2 +- crates/optimism/rpc/src/eth/transaction.rs | 4 +- crates/payload/util/src/traits.rs | 6 +- crates/payload/util/src/transaction.rs | 8 +- crates/primitives/src/lib.rs | 7 +- crates/primitives/src/transaction/mod.rs | 4 +- crates/primitives/src/transaction/pooled.rs | 4 +- crates/rpc/rpc-eth-types/src/transaction.rs | 12 +-- crates/rpc/rpc-eth-types/src/utils.rs | 4 +- .../rpc/rpc-types-compat/src/transaction.rs | 10 +-- crates/rpc/rpc/src/eth/helpers/types.rs | 4 +- crates/transaction-pool/src/lib.rs | 4 +- crates/transaction-pool/src/noop.rs | 4 +- crates/transaction-pool/src/pool/best.rs | 4 +- crates/transaction-pool/src/pool/mod.rs | 6 +- .../transaction-pool/src/test_utils/mock.rs | 32 +++---- crates/transaction-pool/src/traits.rs | 84 +++++++++---------- crates/transaction-pool/src/validate/mod.rs | 4 +- 22 files changed, 130 insertions(+), 125 deletions(-) diff --git a/crates/chain-state/src/test_utils.rs b/crates/chain-state/src/test_utils.rs index 1eb68e670..0b7c4891b 100644 --- a/crates/chain-state/src/test_utils.rs +++ b/crates/chain-state/src/test_utils.rs @@ -20,7 +20,7 @@ use reth_execution_types::{Chain, ExecutionOutcome}; use reth_primitives::{ proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root}, transaction::SignedTransactionIntoRecoveredExt, - BlockBody, EthPrimitives, NodePrimitives, Receipt, Receipts, RecoveredBlock, RecoveredTx, + BlockBody, EthPrimitives, NodePrimitives, Receipt, Receipts, Recovered, RecoveredBlock, SealedBlock, SealedHeader, Transaction, TransactionSigned, }; use reth_primitives_traits::Account; @@ -97,7 +97,7 @@ impl TestBlockBuilder { ) -> RecoveredBlock { let mut rng = thread_rng(); - let mock_tx = |nonce: u64| -> RecoveredTx<_> { + let mock_tx = |nonce: u64| -> Recovered<_> { let tx = Transaction::Eip1559(TxEip1559 { chain_id: self.chain_spec.chain.id(), nonce, @@ -115,7 +115,7 @@ impl TestBlockBuilder { let num_txs = rng.gen_range(0..5); let signer_balance_decrease = Self::single_tx_cost() * U256::from(num_txs); - let transactions: Vec> = (0..num_txs) + let transactions: Vec> = (0..num_txs) .map(|_| { let tx = mock_tx(self.signer_build_account_info.nonce); self.signer_build_account_info.nonce += 1; diff --git a/crates/evm/execution-types/src/chain.rs b/crates/evm/execution-types/src/chain.rs index 67ed25133..66d4338df 100644 --- a/crates/evm/execution-types/src/chain.rs +++ b/crates/evm/execution-types/src/chain.rs @@ -8,7 +8,7 @@ use alloy_primitives::{Address, BlockHash, BlockNumber, TxHash}; use core::{fmt, ops::RangeInclusive}; use reth_execution_errors::{BlockExecutionError, InternalBlockExecutionError}; use reth_primitives::{ - transaction::SignedTransactionIntoRecoveredExt, RecoveredBlock, RecoveredTx, SealedHeader, + transaction::SignedTransactionIntoRecoveredExt, Recovered, RecoveredBlock, SealedHeader, }; use reth_primitives_traits::{Block, BlockBody, NodePrimitives, SignedTransaction}; use reth_trie::updates::TrieUpdates; @@ -442,13 +442,13 @@ impl>> ChainBlocks<'_, self.blocks.values().flat_map(|block| block.transactions_with_sender()) } - /// Returns an iterator over all [`RecoveredTx`] in the blocks + /// Returns an iterator over all [`Recovered`] in the blocks /// /// Note: This clones the transactions since it is assumed this is part of a shared [Chain]. #[inline] pub fn transactions_ecrecovered( &self, - ) -> impl Iterator::Transaction>> + '_ { + ) -> impl Iterator::Transaction>> + '_ { self.transactions_with_sender().map(|(signer, tx)| tx.clone().with_signer(*signer)) } diff --git a/crates/optimism/node/src/txpool.rs b/crates/optimism/node/src/txpool.rs index 51506e7a9..a0e6c6119 100644 --- a/crates/optimism/node/src/txpool.rs +++ b/crates/optimism/node/src/txpool.rs @@ -11,7 +11,7 @@ use reth_node_api::{Block, BlockBody}; use reth_optimism_evm::RethL1BlockInfo; use reth_optimism_primitives::{OpBlock, OpTransactionSigned}; use reth_primitives::{ - transaction::TransactionConversionError, GotExpected, InvalidTransactionError, RecoveredTx, + transaction::TransactionConversionError, GotExpected, InvalidTransactionError, Recovered, SealedBlock, }; use reth_primitives_traits::SignedTransaction; @@ -50,7 +50,7 @@ pub struct OpPooledTransaction { impl OpPooledTransaction { /// Create new instance of [Self]. - pub fn new(transaction: RecoveredTx, encoded_length: usize) -> Self { + pub fn new(transaction: Recovered, encoded_length: usize) -> Self { Self { inner: EthPooledTransaction::new(transaction, encoded_length), estimated_tx_compressed_size: Default::default(), @@ -77,8 +77,8 @@ fn tx_estimated_size_fjord(input: &[u8]) -> u64 { fastlz_size.saturating_mul(836_500).saturating_sub(42_585_600).max(100_000_000) } -impl From> for OpPooledTransaction { - fn from(tx: RecoveredTx) -> Self { +impl From> for OpPooledTransaction { + fn from(tx: Recovered) -> Self { let encoded_len = tx.encode_2718_len(); let tx = tx.map_transaction(|tx| tx.into()); Self { @@ -88,37 +88,37 @@ impl From> for OpPooledTran } } -impl TryFrom> for OpPooledTransaction { +impl TryFrom> for OpPooledTransaction { type Error = TransactionConversionError; - fn try_from(value: RecoveredTx) -> Result { + fn try_from(value: Recovered) -> Result { let (tx, signer) = value.into_parts(); - let pooled: RecoveredTx = - RecoveredTx::new_unchecked(tx.try_into()?, signer); + let pooled: Recovered = + Recovered::new_unchecked(tx.try_into()?, signer); Ok(pooled.into()) } } -impl From for RecoveredTx { +impl From for Recovered { fn from(value: OpPooledTransaction) -> Self { value.inner.transaction } } impl PoolTransaction for OpPooledTransaction { - type TryFromConsensusError = >>::Error; + type TryFromConsensusError = >>::Error; type Consensus = OpTransactionSigned; type Pooled = op_alloy_consensus::OpPooledTransaction; - fn clone_into_consensus(&self) -> RecoveredTx { + fn clone_into_consensus(&self) -> Recovered { self.inner.transaction().clone() } fn try_consensus_into_pooled( - tx: RecoveredTx, - ) -> Result, Self::TryFromConsensusError> { + tx: Recovered, + ) -> Result, Self::TryFromConsensusError> { let (tx, signer) = tx.into_parts(); - Ok(RecoveredTx::new_unchecked(tx.try_into()?, signer)) + Ok(Recovered::new_unchecked(tx.try_into()?, signer)) } fn hash(&self) -> &TxHash { @@ -210,12 +210,12 @@ impl EthPoolTransaction for OpPooledTransaction { fn try_into_pooled_eip4844( self, _sidecar: Arc, - ) -> Option> { + ) -> Option> { None } fn try_from_eip4844( - _tx: RecoveredTx, + _tx: Recovered, _sidecar: BlobTransactionSidecar, ) -> Option { None @@ -463,7 +463,7 @@ mod tests { use op_alloy_consensus::{OpTypedTransaction, TxDeposit}; use reth_chainspec::MAINNET; use reth_optimism_primitives::OpTransactionSigned; - use reth_primitives::RecoveredTx; + use reth_primitives::Recovered; use reth_provider::test_utils::MockEthProvider; use reth_transaction_pool::{ blobstore::InMemoryBlobStore, validate::EthTransactionValidatorBuilder, TransactionOrigin, @@ -492,7 +492,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = OpTransactionSigned::new_unhashed(deposit_tx, signature); - let signed_recovered = RecoveredTx::new_unchecked(signed_tx, signer); + let signed_recovered = Recovered::new_unchecked(signed_tx, signer); let len = signed_recovered.encode_2718_len(); let pooled_tx = OpPooledTransaction::new(signed_recovered, len); let outcome = validator.validate_one(origin, pooled_tx); diff --git a/crates/optimism/node/tests/it/priority.rs b/crates/optimism/node/tests/it/priority.rs index defce4466..b8d48de2d 100644 --- a/crates/optimism/node/tests/it/priority.rs +++ b/crates/optimism/node/tests/it/priority.rs @@ -28,7 +28,7 @@ use reth_optimism_node::{ use reth_optimism_payload_builder::builder::OpPayloadTransactions; use reth_optimism_primitives::{OpPrimitives, OpTransactionSigned}; use reth_payload_util::{PayloadTransactions, PayloadTransactionsChain, PayloadTransactionsFixed}; -use reth_primitives::RecoveredTx; +use reth_primitives::Recovered; use reth_provider::providers::BlockchainProvider; use reth_tasks::TaskManager; use reth_transaction_pool::{pool::BestPayloadTransactions, PoolTransaction}; @@ -67,7 +67,7 @@ impl OpPayloadTransactions for CustomTxPriority { ..Default::default() }; let signature = sender.sign_transaction_sync(&mut end_of_block_tx).unwrap(); - let end_of_block_tx = RecoveredTx::new_unchecked( + let end_of_block_tx = Recovered::new_unchecked( OpTransactionSigned::new_unhashed( OpTypedTransaction::Eip1559(end_of_block_tx), signature, diff --git a/crates/optimism/payload/src/error.rs b/crates/optimism/payload/src/error.rs index 6b2a85e7a..451d003cb 100644 --- a/crates/optimism/payload/src/error.rs +++ b/crates/optimism/payload/src/error.rs @@ -4,7 +4,7 @@ #[derive(Debug, thiserror::Error)] pub enum OpPayloadBuilderError { /// Thrown when a transaction fails to convert to a - /// [`reth_primitives::RecoveredTx`]. + /// [`reth_primitives::Recovered`]. #[error("failed to convert deposit transaction to RecoveredTx")] TransactionEcRecoverFailed, /// Thrown when the L1 block info could not be parsed from the calldata of the diff --git a/crates/optimism/rpc/src/eth/transaction.rs b/crates/optimism/rpc/src/eth/transaction.rs index 30f9fe2c3..a2a425dc7 100644 --- a/crates/optimism/rpc/src/eth/transaction.rs +++ b/crates/optimism/rpc/src/eth/transaction.rs @@ -7,7 +7,7 @@ use op_alloy_consensus::{OpTxEnvelope, OpTypedTransaction}; use op_alloy_rpc_types::{OpTransactionRequest, Transaction}; use reth_node_api::FullNodeComponents; use reth_optimism_primitives::{OpReceipt, OpTransactionSigned}; -use reth_primitives::RecoveredTx; +use reth_primitives::Recovered; use reth_primitives_traits::transaction::signed::SignedTransaction; use reth_provider::{ BlockReader, BlockReaderIdExt, ProviderTx, ReceiptProvider, TransactionsProvider, @@ -84,7 +84,7 @@ where fn fill( &self, - tx: RecoveredTx, + tx: Recovered, tx_info: TransactionInfo, ) -> Result { let from = tx.signer(); diff --git a/crates/payload/util/src/traits.rs b/crates/payload/util/src/traits.rs index 3baed7d9d..43e38312f 100644 --- a/crates/payload/util/src/traits.rs +++ b/crates/payload/util/src/traits.rs @@ -1,5 +1,5 @@ use alloy_primitives::Address; -use reth_primitives::RecoveredTx; +use reth_primitives::Recovered; /// Iterator that returns transactions for the block building process in the order they should be /// included in the block. @@ -15,7 +15,7 @@ pub trait PayloadTransactions { &mut self, // In the future, `ctx` can include access to state for block building purposes. ctx: (), - ) -> Option>; + ) -> Option>; /// Exclude descendants of the transaction with given sender and nonce from the iterator, /// because this transaction won't be included in the block. @@ -35,7 +35,7 @@ impl Default for NoopPayloadTransactions { impl PayloadTransactions for NoopPayloadTransactions { type Transaction = T; - fn next(&mut self, _ctx: ()) -> Option> { + fn next(&mut self, _ctx: ()) -> Option> { None } diff --git a/crates/payload/util/src/transaction.rs b/crates/payload/util/src/transaction.rs index e6e41d7b1..0893e8d10 100644 --- a/crates/payload/util/src/transaction.rs +++ b/crates/payload/util/src/transaction.rs @@ -1,7 +1,7 @@ use crate::PayloadTransactions; use alloy_consensus::Transaction; use alloy_primitives::Address; -use reth_primitives::RecoveredTx; +use reth_primitives::Recovered; /// An implementation of [`crate::traits::PayloadTransactions`] that yields /// a pre-defined set of transactions. @@ -26,10 +26,10 @@ impl PayloadTransactionsFixed { } } -impl PayloadTransactions for PayloadTransactionsFixed> { +impl PayloadTransactions for PayloadTransactionsFixed> { type Transaction = T; - fn next(&mut self, _ctx: ()) -> Option> { + fn next(&mut self, _ctx: ()) -> Option> { (self.index < self.transactions.len()).then(|| { let tx = self.transactions[self.index].clone(); self.index += 1; @@ -96,7 +96,7 @@ where { type Transaction = A::Transaction; - fn next(&mut self, ctx: ()) -> Option> { + fn next(&mut self, ctx: ()) -> Option> { while let Some(tx) = self.before.next(ctx) { if let Some(before_max_gas) = self.before_max_gas { if self.before_gas + tx.tx().gas_limit() <= before_max_gas { diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 5b5ae7bde..cf2788ff7 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -40,9 +40,14 @@ pub use reth_primitives_traits::{ pub use static_file::StaticFileSegment; pub use alloy_consensus::{ - transaction::{PooledTransaction, Recovered as RecoveredTx, TransactionMeta}, + transaction::{PooledTransaction, Recovered, TransactionMeta}, ReceiptWithBloom, }; + +/// Recovered transaction +#[deprecated(note = "use `Recovered` instead")] +pub type RecoveredTx = Recovered; + pub use transaction::{ util::secp256k1::{public_key_to_address, recover_signer_unchecked, sign_message}, InvalidTransactionError, Transaction, TransactionSigned, TxType, diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 0871b796e..4bd2cc975 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -1,6 +1,6 @@ //! Transaction types. -use crate::RecoveredTx; +use crate::Recovered; pub use alloy_consensus::transaction::PooledTransaction; use once_cell as _; #[allow(deprecated)] @@ -31,4 +31,4 @@ pub use reth_ethereum_primitives::{Transaction, TransactionSigned}; /// Type alias kept for backward compatibility. #[deprecated(note = "Use `Recovered` instead")] -pub type TransactionSignedEcRecovered = RecoveredTx; +pub type TransactionSignedEcRecovered = Recovered; diff --git a/crates/primitives/src/transaction/pooled.rs b/crates/primitives/src/transaction/pooled.rs index 858e02d0e..43a1a70e0 100644 --- a/crates/primitives/src/transaction/pooled.rs +++ b/crates/primitives/src/transaction/pooled.rs @@ -1,9 +1,9 @@ //! Defines the types for blob transactions, legacy, and other EIP-2718 transactions included in a //! response to `GetPooledTransactions`. -use crate::RecoveredTx; +use crate::Recovered; use alloy_consensus::transaction::PooledTransaction; /// A signed pooled transaction with recovered signer. #[deprecated(note = "use `Recovered` instead")] -pub type PooledTransactionsElementEcRecovered = RecoveredTx; +pub type PooledTransactionsElementEcRecovered = Recovered; diff --git a/crates/rpc/rpc-eth-types/src/transaction.rs b/crates/rpc/rpc-eth-types/src/transaction.rs index 549ca0e8b..c9a2196bf 100644 --- a/crates/rpc/rpc-eth-types/src/transaction.rs +++ b/crates/rpc/rpc-eth-types/src/transaction.rs @@ -4,7 +4,7 @@ use alloy_primitives::B256; use alloy_rpc_types_eth::TransactionInfo; -use reth_primitives::{RecoveredTx, TransactionSigned}; +use reth_primitives::{Recovered, TransactionSigned}; use reth_primitives_traits::SignedTransaction; use reth_rpc_types_compat::TransactionCompat; @@ -12,13 +12,13 @@ use reth_rpc_types_compat::TransactionCompat; #[derive(Debug, Clone, Eq, PartialEq)] pub enum TransactionSource { /// Transaction exists in the pool (Pending) - Pool(RecoveredTx), + Pool(Recovered), /// Transaction already included in a block /// /// This can be a historical block or a pending block (received from the CL) Block { /// Transaction fetched via provider - transaction: RecoveredTx, + transaction: Recovered, /// Index of the transaction in the block index: u64, /// Hash of the block. @@ -34,7 +34,7 @@ pub enum TransactionSource { impl TransactionSource { /// Consumes the type and returns the wrapped transaction. - pub fn into_recovered(self) -> RecoveredTx { + pub fn into_recovered(self) -> Recovered { self.into() } @@ -60,7 +60,7 @@ impl TransactionSource { } /// Returns the transaction and block related info, if not pending - pub fn split(self) -> (RecoveredTx, TransactionInfo) { + pub fn split(self) -> (Recovered, TransactionInfo) { match self { Self::Pool(tx) => { let hash = tx.trie_hash(); @@ -83,7 +83,7 @@ impl TransactionSource { } } -impl From> for RecoveredTx { +impl From> for Recovered { fn from(value: TransactionSource) -> Self { match value { TransactionSource::Pool(tx) => tx, diff --git a/crates/rpc/rpc-eth-types/src/utils.rs b/crates/rpc/rpc-eth-types/src/utils.rs index f12c819ae..95cb2d72d 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, RecoveredTx}; +use reth_primitives::{transaction::SignedTransactionIntoRecoveredExt, Recovered}; use reth_primitives_traits::SignedTransaction; use std::future::Future; @@ -11,7 +11,7 @@ use std::future::Future; /// malformed. /// /// See [`alloy_eips::eip2718::Decodable2718::decode_2718`] -pub fn recover_raw_transaction(mut data: &[u8]) -> EthResult> { +pub fn recover_raw_transaction(mut data: &[u8]) -> EthResult> { if data.is_empty() { return Err(EthApiError::EmptyRawTransactionData) } diff --git a/crates/rpc/rpc-types-compat/src/transaction.rs b/crates/rpc/rpc-types-compat/src/transaction.rs index f2c641d2f..d1274494a 100644 --- a/crates/rpc/rpc-types-compat/src/transaction.rs +++ b/crates/rpc/rpc-types-compat/src/transaction.rs @@ -4,7 +4,7 @@ use core::error; use std::fmt; use alloy_rpc_types_eth::{request::TransactionRequest, TransactionInfo}; -use reth_primitives::{RecoveredTx, TransactionSigned}; +use reth_primitives::{Recovered, TransactionSigned}; use serde::{Deserialize, Serialize}; /// Builds RPC transaction w.r.t. network. @@ -26,7 +26,7 @@ pub trait TransactionCompat: /// Wrapper for `fill()` with default `TransactionInfo` /// Create a new rpc transaction result for a _pending_ signed transaction, setting block /// environment related fields to `None`. - fn fill_pending(&self, tx: RecoveredTx) -> Result { + fn fill_pending(&self, tx: Recovered) -> Result { self.fill(tx, TransactionInfo::default()) } @@ -37,7 +37,7 @@ pub trait TransactionCompat: /// transaction was mined. fn fill( &self, - tx: RecoveredTx, + tx: Recovered, tx_inf: TransactionInfo, ) -> Result; @@ -51,9 +51,9 @@ pub trait TransactionCompat: fn otterscan_api_truncate_input(tx: &mut Self::Transaction); } -/// Convert [`RecoveredTx`] to [`TransactionRequest`] +/// Convert [`Recovered`] to [`TransactionRequest`] pub fn transaction_to_call_request( - tx: RecoveredTx, + tx: Recovered, ) -> TransactionRequest { let from = tx.signer(); TransactionRequest::from_transaction_with_sender(tx.into_tx(), from) diff --git a/crates/rpc/rpc/src/eth/helpers/types.rs b/crates/rpc/rpc/src/eth/helpers/types.rs index 4678a3bdc..8384e1dd5 100644 --- a/crates/rpc/rpc/src/eth/helpers/types.rs +++ b/crates/rpc/rpc/src/eth/helpers/types.rs @@ -5,7 +5,7 @@ use alloy_network::{Ethereum, Network}; use alloy_primitives::PrimitiveSignature as Signature; use alloy_rpc_types::TransactionRequest; use alloy_rpc_types_eth::{Transaction, TransactionInfo}; -use reth_primitives::{RecoveredTx, TransactionSigned}; +use reth_primitives::{Recovered, TransactionSigned}; use reth_primitives_traits::SignedTransaction; use reth_rpc_eth_api::EthApiTypes; use reth_rpc_eth_types::EthApiError; @@ -40,7 +40,7 @@ where fn fill( &self, - tx: RecoveredTx, + tx: Recovered, tx_info: TransactionInfo, ) -> Result { let from = tx.signer(); diff --git a/crates/transaction-pool/src/lib.rs b/crates/transaction-pool/src/lib.rs index c85d84a80..19f44df3b 100644 --- a/crates/transaction-pool/src/lib.rs +++ b/crates/transaction-pool/src/lib.rs @@ -176,7 +176,7 @@ use alloy_primitives::{Address, TxHash, B256, U256}; use aquamarine as _; use reth_eth_wire_types::HandleMempoolData; use reth_execution_types::ChangedAccount; -use reth_primitives::RecoveredTx; +use reth_primitives::Recovered; use reth_primitives_traits::Block; use reth_storage_api::StateProviderFactory; use std::{collections::HashSet, sync::Arc}; @@ -423,7 +423,7 @@ where fn get_pooled_transaction_element( &self, tx_hash: TxHash, - ) -> Option::Transaction as PoolTransaction>::Pooled>> + ) -> Option::Transaction as PoolTransaction>::Pooled>> { self.pool.get_pooled_transaction_element(tx_hash) } diff --git a/crates/transaction-pool/src/noop.rs b/crates/transaction-pool/src/noop.rs index 8d880994a..9a064c56e 100644 --- a/crates/transaction-pool/src/noop.rs +++ b/crates/transaction-pool/src/noop.rs @@ -22,7 +22,7 @@ use alloy_eips::{ }; use alloy_primitives::{Address, TxHash, B256, U256}; use reth_eth_wire_types::HandleMempoolData; -use reth_primitives::RecoveredTx; +use reth_primitives::Recovered; use std::{collections::HashSet, marker::PhantomData, sync::Arc}; use tokio::sync::{mpsc, mpsc::Receiver}; @@ -143,7 +143,7 @@ impl TransactionPool for NoopTransactionPool { fn get_pooled_transaction_element( &self, _tx_hash: TxHash, - ) -> Option::Pooled>> { + ) -> Option::Pooled>> { None } diff --git a/crates/transaction-pool/src/pool/best.rs b/crates/transaction-pool/src/pool/best.rs index aa9e7ec12..7d58e3984 100644 --- a/crates/transaction-pool/src/pool/best.rs +++ b/crates/transaction-pool/src/pool/best.rs @@ -7,7 +7,7 @@ use crate::{ use alloy_primitives::Address; use core::fmt; use reth_payload_util::PayloadTransactions; -use reth_primitives::{InvalidTransactionError, RecoveredTx}; +use reth_primitives::{InvalidTransactionError, Recovered}; use std::{ collections::{BTreeMap, BTreeSet, HashSet, VecDeque}, sync::Arc, @@ -251,7 +251,7 @@ where { type Transaction = T::Consensus; - fn next(&mut self, _ctx: ()) -> Option> { + fn next(&mut self, _ctx: ()) -> Option> { loop { let tx = self.best.next()?; if self.invalid.contains(&tx.sender()) { diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index 983a86306..348e76947 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -88,7 +88,7 @@ use reth_eth_wire_types::HandleMempoolData; use reth_execution_types::ChangedAccount; use alloy_eips::eip4844::BlobTransactionSidecar; -use reth_primitives::RecoveredTx; +use reth_primitives::Recovered; use rustc_hash::FxHashMap; use std::{collections::HashSet, fmt, sync::Arc, time::Instant}; use tokio::sync::mpsc; @@ -316,7 +316,7 @@ where fn to_pooled_transaction( &self, transaction: Arc>, - ) -> Option::Transaction as PoolTransaction>::Pooled>> + ) -> Option::Transaction as PoolTransaction>::Pooled>> where ::Transaction: EthPoolTransaction, { @@ -371,7 +371,7 @@ where pub fn get_pooled_transaction_element( &self, tx_hash: TxHash, - ) -> Option::Transaction as PoolTransaction>::Pooled>> + ) -> Option::Transaction as PoolTransaction>::Pooled>> where ::Transaction: EthPoolTransaction, { diff --git a/crates/transaction-pool/src/test_utils/mock.rs b/crates/transaction-pool/src/test_utils/mock.rs index 1cd4445e8..e766cbc90 100644 --- a/crates/transaction-pool/src/test_utils/mock.rs +++ b/crates/transaction-pool/src/test_utils/mock.rs @@ -30,7 +30,7 @@ use rand::{ }; use reth_primitives::{ transaction::{SignedTransactionIntoRecoveredExt, TryFromRecoveredTransactionError}, - PooledTransaction, RecoveredTx, Transaction, TransactionSigned, TxType, + PooledTransaction, Recovered, Transaction, TransactionSigned, TxType, }; use reth_primitives_traits::{InMemorySize, SignedTransaction}; use std::{ops::Range, sync::Arc, time::Instant, vec::IntoIter}; @@ -668,22 +668,22 @@ impl PoolTransaction for MockTransaction { type Pooled = PooledTransaction; fn try_from_consensus( - tx: RecoveredTx, + tx: Recovered, ) -> Result { tx.try_into() } - fn into_consensus(self) -> RecoveredTx { + fn into_consensus(self) -> Recovered { self.into() } - fn from_pooled(pooled: RecoveredTx) -> Self { + fn from_pooled(pooled: Recovered) -> Self { pooled.into() } fn try_consensus_into_pooled( - tx: RecoveredTx, - ) -> Result, Self::TryFromConsensusError> { + tx: Recovered, + ) -> Result, Self::TryFromConsensusError> { let (tx, signer) = tx.into_parts(); Self::Pooled::try_from(tx) .map(|tx| tx.with_signer(signer)) @@ -869,7 +869,7 @@ impl EthPoolTransaction for MockTransaction { fn try_into_pooled_eip4844( self, sidecar: Arc, - ) -> Option> { + ) -> Option> { let (tx, signer) = self.into_consensus().into_parts(); tx.try_into_pooled_eip4844(Arc::unwrap_or_clone(sidecar)) .map(|tx| tx.with_signer(signer)) @@ -877,7 +877,7 @@ impl EthPoolTransaction for MockTransaction { } fn try_from_eip4844( - tx: RecoveredTx, + tx: Recovered, sidecar: BlobTransactionSidecar, ) -> Option { let (tx, signer) = tx.into_parts(); @@ -903,10 +903,10 @@ impl EthPoolTransaction for MockTransaction { } } -impl TryFrom> for MockTransaction { +impl TryFrom> for MockTransaction { type Error = TryFromRecoveredTransactionError; - fn try_from(tx: RecoveredTx) -> Result { + fn try_from(tx: Recovered) -> Result { let sender = tx.signer(); let transaction = tx.into_tx(); let hash = *transaction.tx_hash(); @@ -1044,16 +1044,16 @@ impl TryFrom> for MockTransaction { } } -impl From> for MockTransaction { - fn from(tx: RecoveredTx) -> Self { +impl From> for MockTransaction { + fn from(tx: Recovered) -> Self { let (tx, signer) = tx.into_parts(); - RecoveredTx::::new_unchecked(tx.into(), signer).try_into().expect( + Recovered::::new_unchecked(tx.into(), signer).try_into().expect( "Failed to convert from PooledTransactionsElementEcRecovered to MockTransaction", ) } } -impl From for RecoveredTx { +impl From for Recovered { fn from(tx: MockTransaction) -> Self { let signed_tx = TransactionSigned::new(tx.clone().into(), Signature::test_signature(), *tx.hash()); @@ -1180,9 +1180,9 @@ impl proptest::arbitrary::Arbitrary for MockTransaction { arb::<(TransactionSigned, Address)>() .prop_map(|(signed_transaction, signer)| { - RecoveredTx::new_unchecked(signed_transaction, signer) + Recovered::new_unchecked(signed_transaction, signer) .try_into() - .expect("Failed to create an Arbitrary MockTransaction via RecoveredTx") + .expect("Failed to create an Arbitrary MockTransaction from a Recovered tx") }) .boxed() } diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index 38f3c7564..8ac0e6c79 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -21,7 +21,7 @@ use reth_execution_types::ChangedAccount; use reth_primitives::{ kzg::KzgSettings, transaction::{SignedTransactionIntoRecoveredExt, TryFromRecoveredTransactionError}, - PooledTransaction, RecoveredTx, SealedBlock, Transaction, TransactionSigned, + PooledTransaction, Recovered, SealedBlock, Transaction, TransactionSigned, }; use reth_primitives_traits::{Block, SignedTransaction}; #[cfg(feature = "serde")] @@ -257,7 +257,7 @@ pub trait TransactionPool: Send + Sync + Clone { fn get_pooled_transaction_element( &self, tx_hash: TxHash, - ) -> Option::Pooled>>; + ) -> Option::Pooled>>; /// Returns an iterator that yields transactions that are ready for block production. /// @@ -570,18 +570,18 @@ pub struct AllPoolTransactions { // === impl AllPoolTransactions === impl AllPoolTransactions { - /// Returns an iterator over all pending [`RecoveredTx`] transactions. - pub fn pending_recovered(&self) -> impl Iterator> + '_ { + /// Returns an iterator over all pending [`Recovered`] transactions. + pub fn pending_recovered(&self) -> impl Iterator> + '_ { self.pending.iter().map(|tx| tx.transaction.clone().into()) } - /// Returns an iterator over all queued [`RecoveredTx`] transactions. - pub fn queued_recovered(&self) -> impl Iterator> + '_ { + /// Returns an iterator over all queued [`Recovered`] transactions. + pub fn queued_recovered(&self) -> impl Iterator> + '_ { self.queued.iter().map(|tx| tx.transaction.clone().into()) } /// Returns an iterator over all transactions, both pending and queued. - pub fn all(&self) -> impl Iterator> + '_ { + pub fn all(&self) -> impl Iterator> + '_ { self.pending.iter().chain(self.queued.iter()).map(|tx| tx.transaction.clone().into()) } } @@ -968,9 +968,9 @@ pub trait PoolTransaction: + Send + Sync + Clone - + TryFrom, Error = Self::TryFromConsensusError> - + Into> - + From> + + TryFrom, Error = Self::TryFromConsensusError> + + Into> + + From> { /// Associated error type for the `try_from_consensus` method. type TryFromConsensusError: fmt::Display; @@ -983,7 +983,7 @@ pub trait PoolTransaction: /// Define a method to convert from the `Consensus` type to `Self` fn try_from_consensus( - tx: RecoveredTx, + tx: Recovered, ) -> Result { tx.try_into() } @@ -991,29 +991,29 @@ pub trait PoolTransaction: /// Clone the transaction into a consensus variant. /// /// This method is preferred when the [`PoolTransaction`] already wraps the consensus variant. - fn clone_into_consensus(&self) -> RecoveredTx { + fn clone_into_consensus(&self) -> Recovered { self.clone().into_consensus() } /// Define a method to convert from the `Self` type to `Consensus` - fn into_consensus(self) -> RecoveredTx { + fn into_consensus(self) -> Recovered { self.into() } /// Define a method to convert from the `Pooled` type to `Self` - fn from_pooled(pooled: RecoveredTx) -> Self { + fn from_pooled(pooled: Recovered) -> Self { pooled.into() } /// Tries to convert the `Consensus` type into the `Pooled` type. - fn try_into_pooled(self) -> Result, Self::TryFromConsensusError> { + fn try_into_pooled(self) -> Result, Self::TryFromConsensusError> { Self::try_consensus_into_pooled(self.into_consensus()) } /// Tries to convert the `Consensus` type into the `Pooled` type. fn try_consensus_into_pooled( - tx: RecoveredTx, - ) -> Result, Self::TryFromConsensusError>; + tx: Recovered, + ) -> Result, Self::TryFromConsensusError>; /// Converts the `Pooled` type into the `Consensus` type. fn pooled_into_consensus(tx: Self::Pooled) -> Self::Consensus { @@ -1160,13 +1160,13 @@ pub trait EthPoolTransaction: PoolTransaction { fn try_into_pooled_eip4844( self, sidecar: Arc, - ) -> Option>; + ) -> Option>; /// Tries to convert the `Consensus` type with a blob sidecar into the `Pooled` type. /// /// Returns `None` if passed transaction is not a blob transaction. fn try_from_eip4844( - tx: RecoveredTx, + tx: Recovered, sidecar: BlobTransactionSidecar, ) -> Option; @@ -1183,12 +1183,12 @@ pub trait EthPoolTransaction: PoolTransaction { /// The default [`PoolTransaction`] for the [Pool](crate::Pool) for Ethereum. /// -/// This type is essentially a wrapper around [`RecoveredTx`] with additional +/// This type is essentially a wrapper around [`Recovered`] with additional /// fields derived from the transaction that are frequently used by the pools for ordering. #[derive(Debug, Clone, PartialEq, Eq)] pub struct EthPooledTransaction { /// `EcRecovered` transaction, the consensus format. - pub transaction: RecoveredTx, + pub transaction: Recovered, /// For EIP-1559 transactions: `max_fee_per_gas * gas_limit + tx_value`. /// For legacy transactions: `gas_price * gas_limit + tx_value`. @@ -1209,7 +1209,7 @@ impl EthPooledTransaction { /// /// Caution: In case of blob transactions, this does marks the blob sidecar as /// [`EthBlobTransactionSidecar::Missing`] - pub fn new(transaction: RecoveredTx, encoded_length: usize) -> Self { + pub fn new(transaction: Recovered, encoded_length: usize) -> Self { let mut blob_sidecar = EthBlobTransactionSidecar::None; let gas_cost = U256::from(transaction.max_fee_per_gas()) @@ -1234,14 +1234,14 @@ impl EthPooledTransaction { } /// Return the reference to the underlying transaction. - pub const fn transaction(&self) -> &RecoveredTx { + pub const fn transaction(&self) -> &Recovered { &self.transaction } } /// Conversion from the network transaction type to the pool transaction type. -impl From> for EthPooledTransaction { - fn from(tx: RecoveredTx) -> Self { +impl From> for EthPooledTransaction { + fn from(tx: Recovered) -> Self { let encoded_length = tx.encode_2718_len(); let (tx, signer) = tx.into_parts(); match tx { @@ -1251,14 +1251,14 @@ impl From> for EthPooledTransaction { let (tx, blob) = tx.into_parts(); let tx = Signed::new_unchecked(tx, sig, hash); let tx = TransactionSigned::from(tx); - let tx = RecoveredTx::new_unchecked(tx, signer); + let tx = Recovered::new_unchecked(tx, signer); let mut pooled = Self::new(tx, encoded_length); pooled.blob_sidecar = EthBlobTransactionSidecar::Present(blob); pooled } tx => { // no blob sidecar - let tx = RecoveredTx::new_unchecked(tx.into(), signer); + let tx = Recovered::new_unchecked(tx.into(), signer); Self::new(tx, encoded_length) } } @@ -1272,17 +1272,17 @@ impl PoolTransaction for EthPooledTransaction { type Pooled = PooledTransaction; - fn clone_into_consensus(&self) -> RecoveredTx { + fn clone_into_consensus(&self) -> Recovered { self.transaction().clone() } fn try_consensus_into_pooled( - tx: RecoveredTx, - ) -> Result, Self::TryFromConsensusError> { + tx: Recovered, + ) -> Result, Self::TryFromConsensusError> { let (tx, signer) = tx.into_parts(); let pooled = tx.try_into().map_err(|_| TryFromRecoveredTransactionError::BlobSidecarMissing)?; - Ok(RecoveredTx::new_unchecked(pooled, signer)) + Ok(Recovered::new_unchecked(pooled, signer)) } /// Returns hash of the transaction. @@ -1413,16 +1413,16 @@ impl EthPoolTransaction for EthPooledTransaction { fn try_into_pooled_eip4844( self, sidecar: Arc, - ) -> Option> { + ) -> Option> { let (signed_transaction, signer) = self.into_consensus().into_parts(); let pooled_transaction = signed_transaction.try_into_pooled_eip4844(Arc::unwrap_or_clone(sidecar)).ok()?; - Some(RecoveredTx::new_unchecked(pooled_transaction, signer)) + Some(Recovered::new_unchecked(pooled_transaction, signer)) } fn try_from_eip4844( - tx: RecoveredTx, + tx: Recovered, sidecar: BlobTransactionSidecar, ) -> Option { let (tx, signer) = tx.into_parts(); @@ -1451,10 +1451,10 @@ impl EthPoolTransaction for EthPooledTransaction { } } -impl TryFrom> for EthPooledTransaction { +impl TryFrom> for EthPooledTransaction { type Error = TryFromRecoveredTransactionError; - fn try_from(tx: RecoveredTx) -> Result { + fn try_from(tx: Recovered) -> Result { // ensure we can handle the transaction type and its format match tx.ty() { 0..=EIP1559_TX_TYPE_ID | EIP7702_TX_TYPE_ID => { @@ -1478,7 +1478,7 @@ impl TryFrom> for EthPooledTransaction { } } -impl From for RecoveredTx { +impl From for Recovered { fn from(tx: EthPooledTransaction) -> Self { tx.transaction } @@ -1690,7 +1690,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = TransactionSigned::new_unhashed(tx, signature); - let transaction = RecoveredTx::new_unchecked(signed_tx, Default::default()); + let transaction = Recovered::new_unchecked(signed_tx, Default::default()); let pooled_tx = EthPooledTransaction::new(transaction.clone(), 200); // Check that the pooled transaction is created correctly @@ -1711,7 +1711,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = TransactionSigned::new_unhashed(tx, signature); - let transaction = RecoveredTx::new_unchecked(signed_tx, Default::default()); + let transaction = Recovered::new_unchecked(signed_tx, Default::default()); let pooled_tx = EthPooledTransaction::new(transaction.clone(), 200); // Check that the pooled transaction is created correctly @@ -1732,7 +1732,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = TransactionSigned::new_unhashed(tx, signature); - let transaction = RecoveredTx::new_unchecked(signed_tx, Default::default()); + let transaction = Recovered::new_unchecked(signed_tx, Default::default()); let pooled_tx = EthPooledTransaction::new(transaction.clone(), 200); // Check that the pooled transaction is created correctly @@ -1755,7 +1755,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = TransactionSigned::new_unhashed(tx, signature); - let transaction = RecoveredTx::new_unchecked(signed_tx, Default::default()); + let transaction = Recovered::new_unchecked(signed_tx, Default::default()); let pooled_tx = EthPooledTransaction::new(transaction.clone(), 300); // Check that the pooled transaction is created correctly @@ -1778,7 +1778,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = TransactionSigned::new_unhashed(tx, signature); - let transaction = RecoveredTx::new_unchecked(signed_tx, Default::default()); + let transaction = Recovered::new_unchecked(signed_tx, Default::default()); let pooled_tx = EthPooledTransaction::new(transaction.clone(), 200); // Check that the pooled transaction is created correctly diff --git a/crates/transaction-pool/src/validate/mod.rs b/crates/transaction-pool/src/validate/mod.rs index a567bdbe5..0ba716e0b 100644 --- a/crates/transaction-pool/src/validate/mod.rs +++ b/crates/transaction-pool/src/validate/mod.rs @@ -9,7 +9,7 @@ use crate::{ use alloy_eips::eip4844::BlobTransactionSidecar; use alloy_primitives::{Address, TxHash, B256, U256}; use futures_util::future::Either; -use reth_primitives::{RecoveredTx, SealedBlock}; +use reth_primitives::{Recovered, SealedBlock}; use std::{fmt, future::Future, time::Instant}; mod constants; @@ -391,7 +391,7 @@ impl ValidPoolTransaction { /// Converts to this type into the consensus transaction of the pooled transaction. /// /// Note: this takes `&self` since indented usage is via `Arc`. - pub fn to_consensus(&self) -> RecoveredTx { + pub fn to_consensus(&self) -> Recovered { self.transaction.clone_into_consensus() }