From 965eca9eb5ca8480d7df59ffb8494d5312f1cfe5 Mon Sep 17 00:00:00 2001 From: bendanzhentan <455462586@qq.com> Date: Mon, 6 Jan 2025 19:27:35 +0800 Subject: [PATCH] chore(primitives): rename RecoveredTx functions to match alloy::Recovered's This is the first part of https://github.com/paradigmxyz/reth/issues/13651 --- .../src/commands/debug_cmd/build_block.rs | 2 +- crates/blockchain-tree/src/blockchain_tree.rs | 3 +- crates/chain-state/src/test_utils.rs | 4 +-- crates/ethereum/payload/src/lib.rs | 4 +-- crates/net/network/benches/broadcast.rs | 2 +- crates/net/network/src/transactions/mod.rs | 2 +- crates/net/network/tests/it/txgossip.rs | 2 +- crates/optimism/node/src/txpool.rs | 10 +++--- crates/optimism/node/tests/it/priority.rs | 2 +- crates/optimism/payload/src/builder.rs | 8 ++--- crates/optimism/rpc/src/eth/transaction.rs | 2 +- crates/payload/util/src/transaction.rs | 14 ++++---- crates/primitives/src/transaction/mod.rs | 35 ++++++++++--------- crates/primitives/src/transaction/pooled.rs | 17 +++++---- crates/rpc/rpc-eth-api/src/helpers/call.rs | 2 +- .../rpc-eth-api/src/helpers/pending_block.rs | 4 +-- crates/rpc/rpc-eth-api/src/helpers/trace.rs | 2 +- .../rpc/rpc-types-compat/src/transaction.rs | 2 +- crates/rpc/rpc/src/debug.rs | 2 +- crates/rpc/rpc/src/eth/helpers/types.rs | 2 +- crates/rpc/rpc/src/eth/sim_bundle.rs | 2 +- crates/rpc/rpc/src/trace.rs | 2 +- crates/rpc/rpc/src/txpool.rs | 2 +- crates/transaction-pool/src/maintain.rs | 2 +- crates/transaction-pool/src/pool/mod.rs | 2 +- .../transaction-pool/src/test_utils/mock.rs | 12 +++---- crates/transaction-pool/src/traits.rs | 22 ++++++------ 27 files changed, 82 insertions(+), 83 deletions(-) diff --git a/bin/reth/src/commands/debug_cmd/build_block.rs b/bin/reth/src/commands/debug_cmd/build_block.rs index 36559061d69f..edf85b3c5898 100644 --- a/bin/reth/src/commands/debug_cmd/build_block.rs +++ b/bin/reth/src/commands/debug_cmd/build_block.rs @@ -192,7 +192,7 @@ impl> Command { let pooled = transaction .clone() - .into_signed() + .into_tx() .try_into_pooled_eip4844(sidecar.clone()) .expect("should not fail to convert blob tx if it is already eip4844"); let encoded_length = pooled.encode_2718_len(); diff --git a/crates/blockchain-tree/src/blockchain_tree.rs b/crates/blockchain-tree/src/blockchain_tree.rs index af9d0199cf81..3964ea53b7e2 100644 --- a/crates/blockchain-tree/src/blockchain_tree.rs +++ b/crates/blockchain-tree/src/blockchain_tree.rs @@ -1592,8 +1592,7 @@ mod tests { body: Vec>, num_of_signer_txs: u64| -> SealedBlockWithSenders { - let signed_body = - body.clone().into_iter().map(|tx| tx.into_signed()).collect::>(); + let signed_body = body.clone().into_iter().map(|tx| tx.into_tx()).collect::>(); let transactions_root = calculate_transaction_root(&signed_body); let receipts = body .iter() diff --git a/crates/chain-state/src/test_utils.rs b/crates/chain-state/src/test_utils.rs index 58302608ebaa..2ce18ea6d74c 100644 --- a/crates/chain-state/src/test_utils.rs +++ b/crates/chain-state/src/test_utils.rs @@ -145,7 +145,7 @@ impl TestBlockBuilder { gas_limit: ETHEREUM_BLOCK_GAS_LIMIT, base_fee_per_gas: Some(INITIAL_BASE_FEE), transactions_root: calculate_transaction_root( - &transactions.clone().into_iter().map(|tx| tx.into_signed()).collect::>(), + &transactions.clone().into_iter().map(|tx| tx.into_tx()).collect::>(), ), receipts_root: calculate_receipt_root(&receipts), beneficiary: Address::random(), @@ -171,7 +171,7 @@ impl TestBlockBuilder { let block = SealedBlock::new( SealedHeader::seal(header), BlockBody { - transactions: transactions.into_iter().map(|tx| tx.into_signed()).collect(), + transactions: transactions.into_iter().map(|tx| tx.into_tx()).collect(), ommers: Vec::new(), withdrawals: Some(vec![].into()), }, diff --git a/crates/ethereum/payload/src/lib.rs b/crates/ethereum/payload/src/lib.rs index 144513856494..66ca1662b97e 100644 --- a/crates/ethereum/payload/src/lib.rs +++ b/crates/ethereum/payload/src/lib.rs @@ -285,7 +285,7 @@ where } // Configure the environment for the tx. - *evm.tx_mut() = evm_config.tx_env(tx.as_signed(), tx.signer()); + *evm.tx_mut() = evm_config.tx_env(tx.tx(), tx.signer()); let ResultAndState { result, state } = match evm.transact() { Ok(res) => res, @@ -354,7 +354,7 @@ where // append sender and transaction to the respective lists executed_senders.push(tx.signer()); - executed_txs.push(tx.into_signed()); + executed_txs.push(tx.into_tx()); } // check if we have a better block diff --git a/crates/net/network/benches/broadcast.rs b/crates/net/network/benches/broadcast.rs index 27a41278dbd7..bbbd00374968 100644 --- a/crates/net/network/benches/broadcast.rs +++ b/crates/net/network/benches/broadcast.rs @@ -64,7 +64,7 @@ pub fn broadcast_ingress_bench(c: &mut Criterion) { tx.sender(), ExtendedAccount::new(0, U256::from(100_000_000)), ); - txs.push(Arc::new(tx.transaction().clone().into_signed())); + txs.push(Arc::new(tx.transaction().clone().into_tx())); peer1.send_transactions(peer0_id, txs); } } diff --git a/crates/net/network/src/transactions/mod.rs b/crates/net/network/src/transactions/mod.rs index 67a033e70537..7c2a690877f0 100644 --- a/crates/net/network/src/transactions/mod.rs +++ b/crates/net/network/src/transactions/mod.rs @@ -1538,7 +1538,7 @@ impl PropagateTransaction { { let size = tx.encoded_length(); let transaction = tx.transaction.clone_into_consensus(); - let transaction = Arc::new(transaction.into_signed()); + let transaction = Arc::new(transaction.into_tx()); Self { size, transaction } } diff --git a/crates/net/network/tests/it/txgossip.rs b/crates/net/network/tests/it/txgossip.rs index c9911885ad87..f20ef6470833 100644 --- a/crates/net/network/tests/it/txgossip.rs +++ b/crates/net/network/tests/it/txgossip.rs @@ -80,7 +80,7 @@ async fn test_4844_tx_gossip_penalization() { } let signed_txs: Vec> = - txs.iter().map(|tx| Arc::new(tx.transaction().clone().into_signed())).collect(); + txs.iter().map(|tx| Arc::new(tx.transaction().clone().into_tx())).collect(); let network_handle = peer0.network(); diff --git a/crates/optimism/node/src/txpool.rs b/crates/optimism/node/src/txpool.rs index 9692e8cdb136..d770ec248472 100644 --- a/crates/optimism/node/src/txpool.rs +++ b/crates/optimism/node/src/txpool.rs @@ -58,9 +58,9 @@ impl TryFrom> for OpPooledTransaction { type Error = TransactionConversionError; fn try_from(value: RecoveredTx) -> Result { - let (tx, signer) = value.to_components(); + let (tx, signer) = value.into_parts(); let pooled: RecoveredTx = - RecoveredTx::from_signed_transaction(tx.try_into()?, signer); + RecoveredTx::new_unchecked(tx.try_into()?, signer); Ok(pooled.into()) } } @@ -83,8 +83,8 @@ impl PoolTransaction for OpPooledTransaction { fn try_consensus_into_pooled( tx: RecoveredTx, ) -> Result, Self::TryFromConsensusError> { - let (tx, signer) = tx.to_components(); - Ok(RecoveredTx::from_signed_transaction(tx.try_into()?, signer)) + let (tx, signer) = tx.into_parts(); + Ok(RecoveredTx::new_unchecked(tx.try_into()?, signer)) } fn hash(&self) -> &TxHash { @@ -459,7 +459,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = OpTransactionSigned::new_unhashed(deposit_tx, signature); - let signed_recovered = RecoveredTx::from_signed_transaction(signed_tx, signer); + let signed_recovered = RecoveredTx::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 510cd5cdb20b..d34dac483672 100644 --- a/crates/optimism/node/tests/it/priority.rs +++ b/crates/optimism/node/tests/it/priority.rs @@ -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::from_signed_transaction( + let end_of_block_tx = RecoveredTx::new_unchecked( OpTransactionSigned::new_unhashed( OpTypedTransaction::Eip1559(end_of_block_tx), signature, diff --git a/crates/optimism/payload/src/builder.rs b/crates/optimism/payload/src/builder.rs index 2a3f63880923..b87b01b37b2b 100644 --- a/crates/optimism/payload/src/builder.rs +++ b/crates/optimism/payload/src/builder.rs @@ -790,7 +790,7 @@ where )) })?; - *evm.tx_mut() = self.evm_config.tx_env(sequencer_tx.as_signed(), sequencer_tx.signer()); + *evm.tx_mut() = self.evm_config.tx_env(sequencer_tx.tx(), sequencer_tx.signer()); let ResultAndState { result, state } = match evm.transact() { Ok(res) => res, @@ -841,7 +841,7 @@ where // append sender and transaction to the respective lists info.executed_senders.push(sequencer_tx.signer()); - info.executed_transactions.push(sequencer_tx.into_signed()); + info.executed_transactions.push(sequencer_tx.into_tx()); } Ok(info) @@ -891,7 +891,7 @@ where } // Configure the environment for the tx. - *evm.tx_mut() = self.evm_config.tx_env(tx.as_signed(), tx.signer()); + *evm.tx_mut() = self.evm_config.tx_env(tx.tx(), tx.signer()); let ResultAndState { result, state } = match evm.transact() { Ok(res) => res, @@ -954,7 +954,7 @@ where // append sender and transaction to the respective lists info.executed_senders.push(tx.signer()); - info.executed_transactions.push(tx.into_signed()); + info.executed_transactions.push(tx.into_tx()); } Ok(None) diff --git a/crates/optimism/rpc/src/eth/transaction.rs b/crates/optimism/rpc/src/eth/transaction.rs index 05fbb0a95349..ba3b43d071f6 100644 --- a/crates/optimism/rpc/src/eth/transaction.rs +++ b/crates/optimism/rpc/src/eth/transaction.rs @@ -89,7 +89,7 @@ where ) -> Result { let from = tx.signer(); let hash = *tx.tx_hash(); - let OpTransactionSigned { transaction, signature, .. } = tx.into_signed(); + let OpTransactionSigned { transaction, signature, .. } = tx.into_tx(); let mut deposit_receipt_version = None; let mut deposit_nonce = None; diff --git a/crates/payload/util/src/transaction.rs b/crates/payload/util/src/transaction.rs index 71387946aef1..e6e41d7b1e9a 100644 --- a/crates/payload/util/src/transaction.rs +++ b/crates/payload/util/src/transaction.rs @@ -99,12 +99,12 @@ where 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.as_signed().gas_limit() <= before_max_gas { - self.before_gas += tx.as_signed().gas_limit(); + if self.before_gas + tx.tx().gas_limit() <= before_max_gas { + self.before_gas += tx.tx().gas_limit(); return Some(tx); } - self.before.mark_invalid(tx.signer(), tx.as_signed().nonce()); - self.after.mark_invalid(tx.signer(), tx.as_signed().nonce()); + self.before.mark_invalid(tx.signer(), tx.tx().nonce()); + self.after.mark_invalid(tx.signer(), tx.tx().nonce()); } else { return Some(tx); } @@ -112,11 +112,11 @@ where while let Some(tx) = self.after.next(ctx) { if let Some(after_max_gas) = self.after_max_gas { - if self.after_gas + tx.as_signed().gas_limit() <= after_max_gas { - self.after_gas += tx.as_signed().gas_limit(); + if self.after_gas + tx.tx().gas_limit() <= after_max_gas { + self.after_gas += tx.tx().gas_limit(); return Some(tx); } - self.after.mark_invalid(tx.signer(), tx.as_signed().nonce()); + self.after.mark_invalid(tx.signer(), tx.tx().nonce()); } else { return Some(tx); } diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index e6e4d5f73ce7..f241a06147f5 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -16,7 +16,7 @@ use alloy_eips::{ use alloy_primitives::{ keccak256, Address, Bytes, ChainId, PrimitiveSignature as Signature, TxHash, TxKind, B256, U256, }; -use alloy_rlp::{Decodable, Encodable, Error as RlpError, Header}; +use alloy_rlp::{Decodable, Encodable, Header}; use core::hash::{Hash, Hasher}; use derive_more::{AsRef, Deref}; use once_cell as _; @@ -912,7 +912,7 @@ impl TransactionSigned { /// Returns the [`RecoveredTx`] transaction with the given sender. #[inline] pub const fn with_signer(self, signer: Address) -> RecoveredTx { - RecoveredTx::from_signed_transaction(self, signer) + RecoveredTx::new_unchecked(self, signer) } /// Consumes the type, recover signer and return [`RecoveredTx`] @@ -920,7 +920,7 @@ impl TransactionSigned { /// Returns `None` if the transaction's signature is invalid, see also [`Self::recover_signer`]. pub fn into_ecrecovered(self) -> Option> { let signer = self.recover_signer()?; - Some(RecoveredTx { signed_transaction: self, signer }) + Some(RecoveredTx::new_unchecked(self, signer)) } /// Consumes the type, recover signer and return [`RecoveredTx`] _without @@ -930,7 +930,7 @@ impl TransactionSigned { /// [`Self::recover_signer_unchecked`]. pub fn into_ecrecovered_unchecked(self) -> Option> { let signer = self.recover_signer_unchecked()?; - Some(RecoveredTx { signed_transaction: self, signer }) + Some(RecoveredTx::new_unchecked(self, signer)) } /// Tries to recover signer and return [`RecoveredTx`]. _without ensuring that @@ -941,7 +941,7 @@ impl TransactionSigned { pub fn try_into_ecrecovered_unchecked(self) -> Result, Self> { match self.recover_signer_unchecked() { None => Err(self), - Some(signer) => Ok(RecoveredTx { signed_transaction: self, signer }), + Some(signer) => Ok(RecoveredTx::new_unchecked(self, signer)), } } @@ -1184,13 +1184,13 @@ impl alloy_consensus::Transaction for TransactionSigned { impl From> for TransactionSigned { fn from(recovered: RecoveredTx) -> Self { - recovered.signed_transaction + recovered.into_tx() } } impl From> for TransactionSigned { fn from(recovered: RecoveredTx) -> Self { - recovered.signed_transaction.into() + recovered.into_tx().into() } } @@ -1523,6 +1523,7 @@ pub type TransactionSignedEcRecovered = RecoveredTx; /// Signed transaction with recovered signer. #[derive(Debug, Clone, PartialEq, Hash, Eq, AsRef, Deref)] +#[non_exhaustive] pub struct RecoveredTx { /// Signer of the transaction signer: Address, @@ -1546,30 +1547,30 @@ impl RecoveredTx { } /// Returns a reference to [`TransactionSigned`] - pub const fn as_signed(&self) -> &T { + pub const fn tx(&self) -> &T { &self.signed_transaction } /// Transform back to [`TransactionSigned`] - pub fn into_signed(self) -> T { + pub fn into_tx(self) -> T { self.signed_transaction } /// Dissolve Self to its component - pub fn to_components(self) -> (T, Address) { + pub fn into_parts(self) -> (T, Address) { (self.signed_transaction, self.signer) } /// Create [`RecoveredTx`] from [`TransactionSigned`] and [`Address`] of the /// signer. #[inline] - pub const fn from_signed_transaction(signed_transaction: T, signer: Address) -> Self { + pub const fn new_unchecked(signed_transaction: T, signer: Address) -> Self { Self { signed_transaction, signer } } /// Applies the given closure to the inner transactions. pub fn map_transaction(self, f: impl FnOnce(T) -> Tx) -> RecoveredTx { - RecoveredTx::from_signed_transaction(f(self.signed_transaction), self.signer) + RecoveredTx::new_unchecked(f(self.signed_transaction), self.signer) } } @@ -1592,7 +1593,7 @@ impl Decodable for RecoveredTx { let signer = signed_transaction .recover_signer() .ok_or(RlpError::Custom("Unable to recover decoded transaction signer."))?; - Ok(Self { signer, signed_transaction }) + Ok(Self::new_unchecked(signed_transaction, signer)) } } @@ -1619,7 +1620,7 @@ pub trait SignedTransactionIntoRecoveredExt: SignedTransaction { /// Tries to recover signer and return [`RecoveredTx`] by cloning the type. fn try_ecrecovered(&self) -> Option> { let signer = self.recover_signer()?; - Some(RecoveredTx { signed_transaction: self.clone(), signer }) + Some(RecoveredTx::new_unchecked(self.clone(), signer)) } /// Tries to recover signer and return [`RecoveredTx`]. @@ -1629,7 +1630,7 @@ pub trait SignedTransactionIntoRecoveredExt: SignedTransaction { fn try_into_ecrecovered(self) -> Result, Self> { match self.recover_signer() { None => Err(self), - Some(signer) => Ok(RecoveredTx { signed_transaction: self, signer }), + Some(signer) => Ok(RecoveredTx::new_unchecked(self, signer)), } } @@ -1639,12 +1640,12 @@ pub trait SignedTransactionIntoRecoveredExt: SignedTransaction { /// Returns `None` if the transaction's signature is invalid. fn into_ecrecovered_unchecked(self) -> Option> { let signer = self.recover_signer_unchecked()?; - Some(RecoveredTx::from_signed_transaction(self, signer)) + Some(RecoveredTx::new_unchecked(self, signer)) } /// Returns the [`RecoveredTx`] transaction with the given sender. fn with_signer(self, signer: Address) -> RecoveredTx { - RecoveredTx::from_signed_transaction(self, signer) + RecoveredTx::new_unchecked(self, signer) } } diff --git a/crates/primitives/src/transaction/pooled.rs b/crates/primitives/src/transaction/pooled.rs index a056562a645d..628a328cfe1b 100644 --- a/crates/primitives/src/transaction/pooled.rs +++ b/crates/primitives/src/transaction/pooled.rs @@ -12,8 +12,8 @@ pub type PooledTransactionsElementEcRecovered = Recovered impl PooledTransactionsElementEcRecovered { /// Transform back to [`RecoveredTx`] pub fn into_ecrecovered_transaction(self) -> RecoveredTx { - let (tx, signer) = self.to_components(); - RecoveredTx::from_signed_transaction(tx.into(), signer) + let (tx, signer) = self.into_parts(); + RecoveredTx::new_unchecked(tx.into(), signer) } /// Converts from an EIP-4844 [`RecoveredTx`] to a @@ -24,11 +24,11 @@ impl PooledTransactionsElementEcRecovered { tx: RecoveredTx, sidecar: BlobTransactionSidecar, ) -> Result> { - let RecoveredTx { signer, signed_transaction } = tx; + let (signed_transaction, signer) = tx.into_parts(); let transaction = signed_transaction .try_into_pooled_eip4844(sidecar) - .map_err(|tx| RecoveredTx { signer, signed_transaction: tx })?; - Ok(Self::from_signed_transaction(transaction, signer)) + .map_err(|tx| RecoveredTx::new_unchecked(tx, signer))?; + Ok(Self::new_unchecked(transaction, signer)) } } @@ -37,10 +37,9 @@ impl TryFrom> for PooledTransactionsElementEcReco type Error = TransactionConversionError; fn try_from(tx: RecoveredTx) -> Result { - match PooledTransaction::try_from(tx.signed_transaction) { - Ok(pooled_transaction) => { - Ok(Self::from_signed_transaction(pooled_transaction, tx.signer)) - } + let (signed_transaction, signer) = tx.into_parts(); + match PooledTransaction::try_from(signed_transaction) { + Ok(pooled_transaction) => Ok(Self::new_unchecked(pooled_transaction, signer)), Err(_) => Err(TransactionConversionError::UnsupportedForP2P), } } diff --git a/crates/rpc/rpc-eth-api/src/helpers/call.rs b/crates/rpc/rpc-eth-api/src/helpers/call.rs index 1b20dd9d9fc2..2aecb500dd5e 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/call.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/call.rs @@ -682,7 +682,7 @@ pub trait Call: let env = EnvWithHandlerCfg::new_with_cfg_env( cfg_env_with_handler_cfg, block_env, - RpcNodeCore::evm_config(&this).tx_env(tx.as_signed(), tx.signer()), + RpcNodeCore::evm_config(&this).tx_env(tx.tx(), tx.signer()), ); let (res, _) = this.transact(&mut db, env)?; diff --git a/crates/rpc/rpc-eth-api/src/helpers/pending_block.rs b/crates/rpc/rpc-eth-api/src/helpers/pending_block.rs index 5f0512e3e76e..fd69422da68b 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/pending_block.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/pending_block.rs @@ -341,7 +341,7 @@ pub trait LoadPendingBlock: let env = Env::boxed( cfg.cfg_env.clone(), block_env.clone(), - Self::evm_config(self).tx_env(tx.as_signed(), tx.signer()), + Self::evm_config(self).tx_env(tx.tx(), tx.signer()), ); let mut evm = revm::Evm::builder().with_env(env).with_db(&mut db).build(); @@ -393,7 +393,7 @@ pub trait LoadPendingBlock: cumulative_gas_used += gas_used; // append transaction to the list of executed transactions - let (tx, sender) = tx.to_components(); + let (tx, sender) = tx.into_parts(); executed_txs.push(tx); senders.push(sender); results.push(result); diff --git a/crates/rpc/rpc-eth-api/src/helpers/trace.rs b/crates/rpc/rpc-eth-api/src/helpers/trace.rs index a5808b04ccbe..66c6b5a27a92 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/trace.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/trace.rs @@ -226,7 +226,7 @@ pub trait Trace: let env = EnvWithHandlerCfg::new_with_cfg_env( cfg_env_with_handler_cfg, block_env, - RpcNodeCore::evm_config(&this).tx_env(tx.as_signed(), tx.signer()), + RpcNodeCore::evm_config(&this).tx_env(tx.tx(), tx.signer()), ); let (res, _) = this.inspect(StateCacheDbRefMutWrapper(&mut db), env, &mut inspector)?; diff --git a/crates/rpc/rpc-types-compat/src/transaction.rs b/crates/rpc/rpc-types-compat/src/transaction.rs index b5515ce9e23d..065dfff04bf1 100644 --- a/crates/rpc/rpc-types-compat/src/transaction.rs +++ b/crates/rpc/rpc-types-compat/src/transaction.rs @@ -68,5 +68,5 @@ pub fn transaction_to_call_request( tx: RecoveredTx, ) -> TransactionRequest { let from = tx.signer(); - TransactionRequest::from_transaction_with_sender(tx.into_signed(), from) + TransactionRequest::from_transaction_with_sender(tx.into_tx(), from) } diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index 8421b371df0a..b88bac816f8b 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -273,7 +273,7 @@ where env: Env::boxed( cfg_env_with_handler_cfg.cfg_env.clone(), block_env, - this.eth_api().evm_config().tx_env(tx.as_signed(), tx.signer()), + this.eth_api().evm_config().tx_env(tx.tx(), tx.signer()), ), handler_cfg: cfg_env_with_handler_cfg.handler_cfg, }; diff --git a/crates/rpc/rpc/src/eth/helpers/types.rs b/crates/rpc/rpc/src/eth/helpers/types.rs index 82bb5877f755..48a6d0d8ab6c 100644 --- a/crates/rpc/rpc/src/eth/helpers/types.rs +++ b/crates/rpc/rpc/src/eth/helpers/types.rs @@ -44,7 +44,7 @@ where ) -> Result { let from = tx.signer(); let hash = tx.hash(); - let TransactionSigned { transaction, signature, .. } = tx.into_signed(); + let TransactionSigned { transaction, signature, .. } = tx.into_tx(); let inner: TxEnvelope = match transaction { reth_primitives::Transaction::Legacy(tx) => { diff --git a/crates/rpc/rpc/src/eth/sim_bundle.rs b/crates/rpc/rpc/src/eth/sim_bundle.rs index a9a6a17f50ee..de2597b64a3f 100644 --- a/crates/rpc/rpc/src/eth/sim_bundle.rs +++ b/crates/rpc/rpc/src/eth/sim_bundle.rs @@ -172,7 +172,7 @@ where match &body[idx] { BundleItem::Tx { tx, can_revert } => { let recovered_tx = recover_raw_transaction::>(tx)?; - let (tx, signer) = recovered_tx.to_components(); + let (tx, signer) = recovered_tx.into_parts(); let tx: PoolConsensusTx = ::Transaction::pooled_into_consensus(tx); diff --git a/crates/rpc/rpc/src/trace.rs b/crates/rpc/rpc/src/trace.rs index aaf8539ab454..33e32aec0281 100644 --- a/crates/rpc/rpc/src/trace.rs +++ b/crates/rpc/rpc/src/trace.rs @@ -121,7 +121,7 @@ where let env = EnvWithHandlerCfg::new_with_cfg_env( cfg_env_with_handler_cfg, block_env, - self.eth_api().evm_config().tx_env(tx.as_signed(), tx.signer()), + self.eth_api().evm_config().tx_env(tx.tx(), tx.signer()), ); let config = TracingInspectorConfig::from_parity_config(&trace_types); diff --git a/crates/rpc/rpc/src/txpool.rs b/crates/rpc/rpc/src/txpool.rs index a8d783406773..0d247f307567 100644 --- a/crates/rpc/rpc/src/txpool.rs +++ b/crates/rpc/rpc/src/txpool.rs @@ -103,7 +103,7 @@ where ) { let entry = inspect.entry(tx.sender()).or_default(); let tx = tx.clone_into_consensus(); - entry.insert(tx.nonce().to_string(), tx.into_signed().into()); + entry.insert(tx.nonce().to_string(), tx.into_tx().into()); } let AllPoolTransactions { pending, queued } = self.pool.all_transactions(); diff --git a/crates/transaction-pool/src/maintain.rs b/crates/transaction-pool/src/maintain.rs index 6ccd479c2b83..583b291685d5 100644 --- a/crates/transaction-pool/src/maintain.rs +++ b/crates/transaction-pool/src/maintain.rs @@ -600,7 +600,7 @@ where let local_transactions = local_transactions .into_iter() - .map(|tx| tx.transaction.clone_into_consensus().into_signed()) + .map(|tx| tx.transaction.clone_into_consensus().into_tx()) .collect::>(); let num_txs = local_transactions.len(); diff --git a/crates/transaction-pool/src/pool/mod.rs b/crates/transaction-pool/src/pool/mod.rs index 088fbe59bb65..a7c16d05aa8e 100644 --- a/crates/transaction-pool/src/pool/mod.rs +++ b/crates/transaction-pool/src/pool/mod.rs @@ -357,7 +357,7 @@ where }; size += encoded_len; - elements.push(pooled.into_signed()); + elements.push(pooled.into_tx()); if limit.exceeds(size) { break diff --git a/crates/transaction-pool/src/test_utils/mock.rs b/crates/transaction-pool/src/test_utils/mock.rs index 390538950db8..aa15fd152c71 100644 --- a/crates/transaction-pool/src/test_utils/mock.rs +++ b/crates/transaction-pool/src/test_utils/mock.rs @@ -685,7 +685,7 @@ impl PoolTransaction for MockTransaction { fn try_consensus_into_pooled( tx: RecoveredTx, ) -> Result, Self::TryFromConsensusError> { - let (tx, signer) = tx.to_components(); + let (tx, signer) = tx.into_parts(); Self::Pooled::try_from(tx) .map(|tx| tx.with_signer(signer)) .map_err(|_| TryFromRecoveredTransactionError::BlobSidecarMissing) @@ -871,7 +871,7 @@ impl EthPoolTransaction for MockTransaction { self, sidecar: Arc, ) -> Option> { - let (tx, signer) = self.into_consensus().to_components(); + let (tx, signer) = self.into_consensus().into_parts(); tx.try_into_pooled_eip4844(Arc::unwrap_or_clone(sidecar)) .map(|tx| tx.with_signer(signer)) .ok() @@ -881,7 +881,7 @@ impl EthPoolTransaction for MockTransaction { tx: RecoveredTx, sidecar: BlobTransactionSidecar, ) -> Option { - let (tx, signer) = tx.to_components(); + let (tx, signer) = tx.into_parts(); tx.try_into_pooled_eip4844(sidecar) .map(|tx| tx.with_signer(signer)) .ok() @@ -909,7 +909,7 @@ impl TryFrom> for MockTransaction { fn try_from(tx: RecoveredTx) -> Result { let sender = tx.signer(); - let transaction = tx.into_signed(); + let transaction = tx.into_tx(); let hash = transaction.hash(); let size = transaction.size(); @@ -1058,7 +1058,7 @@ impl From for RecoveredTx { let signed_tx = TransactionSigned::new(tx.clone().into(), Signature::test_signature(), *tx.hash()); - Self::from_signed_transaction(signed_tx, tx.sender()) + Self::new_unchecked(signed_tx, tx.sender()) } } @@ -1180,7 +1180,7 @@ impl proptest::arbitrary::Arbitrary for MockTransaction { arb::<(TransactionSigned, Address)>() .prop_map(|(signed_transaction, signer)| { - RecoveredTx::from_signed_transaction(signed_transaction, signer) + RecoveredTx::new_unchecked(signed_transaction, signer) .try_into() .expect("Failed to create an Arbitrary MockTransaction via RecoveredTx") }) diff --git a/crates/transaction-pool/src/traits.rs b/crates/transaction-pool/src/traits.rs index b2bf49292edd..abe3da38ad6f 100644 --- a/crates/transaction-pool/src/traits.rs +++ b/crates/transaction-pool/src/traits.rs @@ -1245,21 +1245,21 @@ impl EthPooledTransaction { impl From for EthPooledTransaction { fn from(tx: PooledTransactionsElementEcRecovered) -> Self { let encoded_length = tx.encode_2718_len(); - let (tx, signer) = tx.to_components(); + let (tx, signer) = tx.into_parts(); match tx { PooledTransaction::Eip4844(tx) => { // include the blob sidecar let (tx, sig, hash) = tx.into_parts(); let (tx, blob) = tx.into_parts(); let tx = TransactionSigned::new(tx.into(), sig, hash); - let tx = RecoveredTx::from_signed_transaction(tx, signer); + let tx = RecoveredTx::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::from_signed_transaction(tx.into(), signer); + let tx = RecoveredTx::new_unchecked(tx.into(), signer); Self::new(tx, encoded_length) } } @@ -1280,11 +1280,11 @@ impl PoolTransaction for EthPooledTransaction { fn try_consensus_into_pooled( tx: RecoveredTx, ) -> Result, Self::TryFromConsensusError> { - let (tx, signer) = tx.to_components(); + let (tx, signer) = tx.into_parts(); let pooled = tx .try_into_pooled() .map_err(|_| TryFromRecoveredTransactionError::BlobSidecarMissing)?; - Ok(RecoveredTx::from_signed_transaction(pooled, signer)) + Ok(RecoveredTx::new_unchecked(pooled, signer)) } /// Returns hash of the transaction. @@ -1427,7 +1427,7 @@ impl EthPoolTransaction for EthPooledTransaction { tx: RecoveredTx, sidecar: BlobTransactionSidecar, ) -> Option { - let (tx, signer) = tx.to_components(); + let (tx, signer) = tx.into_parts(); tx.try_into_pooled_eip4844(sidecar) .ok() .map(|tx| tx.with_signer(signer)) @@ -1692,7 +1692,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = TransactionSigned::new_unhashed(tx, signature); - let transaction = RecoveredTx::from_signed_transaction(signed_tx, Default::default()); + let transaction = RecoveredTx::new_unchecked(signed_tx, Default::default()); let pooled_tx = EthPooledTransaction::new(transaction.clone(), 200); // Check that the pooled transaction is created correctly @@ -1713,7 +1713,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = TransactionSigned::new_unhashed(tx, signature); - let transaction = RecoveredTx::from_signed_transaction(signed_tx, Default::default()); + let transaction = RecoveredTx::new_unchecked(signed_tx, Default::default()); let pooled_tx = EthPooledTransaction::new(transaction.clone(), 200); // Check that the pooled transaction is created correctly @@ -1734,7 +1734,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = TransactionSigned::new_unhashed(tx, signature); - let transaction = RecoveredTx::from_signed_transaction(signed_tx, Default::default()); + let transaction = RecoveredTx::new_unchecked(signed_tx, Default::default()); let pooled_tx = EthPooledTransaction::new(transaction.clone(), 200); // Check that the pooled transaction is created correctly @@ -1757,7 +1757,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = TransactionSigned::new_unhashed(tx, signature); - let transaction = RecoveredTx::from_signed_transaction(signed_tx, Default::default()); + let transaction = RecoveredTx::new_unchecked(signed_tx, Default::default()); let pooled_tx = EthPooledTransaction::new(transaction.clone(), 300); // Check that the pooled transaction is created correctly @@ -1780,7 +1780,7 @@ mod tests { }); let signature = Signature::test_signature(); let signed_tx = TransactionSigned::new_unhashed(tx, signature); - let transaction = RecoveredTx::from_signed_transaction(signed_tx, Default::default()); + let transaction = RecoveredTx::new_unchecked(signed_tx, Default::default()); let pooled_tx = EthPooledTransaction::new(transaction.clone(), 200); // Check that the pooled transaction is created correctly