Skip to content

Commit

Permalink
refactor: rename TransactionSignedEcRecovered to RecoveredTx (#13074
Browse files Browse the repository at this point in the history
)
  • Loading branch information
klkvr authored Dec 2, 2024
1 parent 9831953 commit 9ed9fa2
Show file tree
Hide file tree
Showing 28 changed files with 170 additions and 223 deletions.
6 changes: 3 additions & 3 deletions crates/blockchain-tree/src/blockchain_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ mod tests {
use reth_node_types::FullNodePrimitives;
use reth_primitives::{
proofs::{calculate_receipt_root, calculate_transaction_root},
Account, BlockBody, Transaction, TransactionSigned, TransactionSignedEcRecovered,
Account, BlockBody, RecoveredTx, Transaction, TransactionSigned,
};
use reth_provider::{
providers::ProviderNodeTypes,
Expand Down Expand Up @@ -1574,7 +1574,7 @@ mod tests {
}

let single_tx_cost = U256::from(INITIAL_BASE_FEE * MIN_TRANSACTION_GAS);
let mock_tx = |nonce: u64| -> TransactionSignedEcRecovered {
let mock_tx = |nonce: u64| -> RecoveredTx {
TransactionSigned::new_unhashed(
Transaction::Eip1559(TxEip1559 {
chain_id: chain_spec.chain.id(),
Expand All @@ -1591,7 +1591,7 @@ mod tests {

let mock_block = |number: u64,
parent: Option<B256>,
body: Vec<TransactionSignedEcRecovered>,
body: Vec<RecoveredTx>,
num_of_signer_txs: u64|
-> SealedBlockWithSenders {
let signed_body =
Expand Down
7 changes: 3 additions & 4 deletions crates/chain-state/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ use reth_chainspec::{ChainSpec, EthereumHardfork, MIN_TRANSACTION_GAS};
use reth_execution_types::{Chain, ExecutionOutcome};
use reth_primitives::{
proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root},
BlockBody, EthPrimitives, NodePrimitives, Receipt, Receipts, SealedBlock,
BlockBody, EthPrimitives, NodePrimitives, Receipt, Receipts, RecoveredTx, SealedBlock,
SealedBlockWithSenders, SealedHeader, Transaction, TransactionSigned,
TransactionSignedEcRecovered,
};
use reth_storage_api::NodePrimitivesProvider;
use reth_trie::{root::state_root_unhashed, updates::TrieUpdates, HashedPostState};
Expand Down Expand Up @@ -91,7 +90,7 @@ impl TestBlockBuilder {
) -> SealedBlockWithSenders {
let mut rng = thread_rng();

let mock_tx = |nonce: u64| -> TransactionSignedEcRecovered {
let mock_tx = |nonce: u64| -> RecoveredTx {
let tx = Transaction::Eip1559(TxEip1559 {
chain_id: self.chain_spec.chain.id(),
nonce,
Expand All @@ -109,7 +108,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<TransactionSignedEcRecovered> = (0..num_txs)
let transactions: Vec<RecoveredTx> = (0..num_txs)
.map(|_| {
let tx = mock_tx(self.signer_build_account_info.nonce);
self.signer_build_account_info.nonce += 1;
Expand Down
9 changes: 4 additions & 5 deletions crates/evm/execution-types/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
transaction::SignedTransactionIntoRecoveredExt, SealedBlockFor, SealedBlockWithSenders,
SealedHeader, TransactionSignedEcRecovered,
transaction::SignedTransactionIntoRecoveredExt, RecoveredTx, SealedBlockFor,
SealedBlockWithSenders, SealedHeader,
};
use reth_primitives_traits::{Block, BlockBody, NodePrimitives, SignedTransaction};
use reth_trie::updates::TrieUpdates;
Expand Down Expand Up @@ -436,14 +436,13 @@ impl<B: Block<Body: BlockBody<Transaction: SignedTransaction>>> ChainBlocks<'_,
self.blocks.values().flat_map(|block| block.transactions_with_sender())
}

/// Returns an iterator over all [`TransactionSignedEcRecovered`] in the blocks
/// Returns an iterator over all [`RecoveredTx`] 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<Item = TransactionSignedEcRecovered<<B::Body as BlockBody>::Transaction>> + '_
{
) -> impl Iterator<Item = RecoveredTx<<B::Body as BlockBody>::Transaction>> + '_ {
self.transactions_with_sender().map(|(signer, tx)| tx.clone().with_signer(*signer))
}

Expand Down
5 changes: 2 additions & 3 deletions crates/optimism/node/src/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ mod tests {
use alloy_primitives::{PrimitiveSignature as Signature, TxKind, U256};
use op_alloy_consensus::TxDeposit;
use reth_chainspec::MAINNET;
use reth_primitives::{Transaction, TransactionSigned, TransactionSignedEcRecovered};
use reth_primitives::{RecoveredTx, Transaction, TransactionSigned};
use reth_provider::test_utils::MockEthProvider;
use reth_transaction_pool::{
blobstore::InMemoryBlobStore, validate::EthTransactionValidatorBuilder,
Expand Down Expand Up @@ -266,8 +266,7 @@ mod tests {
});
let signature = Signature::test_signature();
let signed_tx = TransactionSigned::new_unhashed(deposit_tx, signature);
let signed_recovered =
TransactionSignedEcRecovered::from_signed_transaction(signed_tx, signer);
let signed_recovered = RecoveredTx::from_signed_transaction(signed_tx, signer);
let len = signed_recovered.encode_2718_len();
let pooled_tx = EthPooledTransaction::new(signed_recovered, len);
let outcome = validator.validate_one(origin, pooled_tx);
Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/node/tests/it/priority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use reth_optimism_node::{
use reth_optimism_payload_builder::builder::OpPayloadTransactions;
use reth_optimism_primitives::OpPrimitives;
use reth_payload_util::{PayloadTransactions, PayloadTransactionsChain, PayloadTransactionsFixed};
use reth_primitives::{SealedBlock, Transaction, TransactionSigned, TransactionSignedEcRecovered};
use reth_primitives::{RecoveredTx, SealedBlock, Transaction, TransactionSigned};
use reth_provider::providers::BlockchainProvider2;
use reth_tasks::TaskManager;
use reth_transaction_pool::pool::BestPayloadTransactions;
Expand Down Expand Up @@ -64,7 +64,7 @@ impl OpPayloadTransactions for CustomTxPriority {
..Default::default()
};
let signature = sender.sign_transaction_sync(&mut end_of_block_tx).unwrap();
let end_of_block_tx = TransactionSignedEcRecovered::from_signed_transaction(
let end_of_block_tx = RecoveredTx::from_signed_transaction(
TransactionSigned::new_unhashed(Transaction::Eip1559(end_of_block_tx), signature),
sender.address(),
);
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ where
))
}

// Convert the transaction to a [TransactionSignedEcRecovered]. This is
// Convert the transaction to a [RecoveredTx]. This is
// purely for the purposes of utilizing the `evm_config.tx_env`` function.
// Deposit transactions do not have signatures, so if the tx is a deposit, this
// will just pull in its `from` address.
Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/payload/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#[derive(Debug, thiserror::Error)]
pub enum OpPayloadBuilderError {
/// Thrown when a transaction fails to convert to a
/// [`reth_primitives::TransactionSignedEcRecovered`].
#[error("failed to convert deposit transaction to TransactionSignedEcRecovered")]
/// [`reth_primitives::RecoveredTx`].
#[error("failed to convert deposit transaction to RecoveredTx")]
TransactionEcRecoverFailed,
/// Thrown when the L1 block info could not be parsed from the calldata of the
/// first transaction supplied in the payload attributes.
Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use alloy_rpc_types_eth::TransactionInfo;
use op_alloy_consensus::OpTxEnvelope;
use op_alloy_rpc_types::Transaction;
use reth_node_api::FullNodeComponents;
use reth_primitives::{TransactionSigned, TransactionSignedEcRecovered};
use reth_primitives::{RecoveredTx, TransactionSigned};
use reth_provider::{BlockReaderIdExt, ReceiptProvider, TransactionsProvider};
use reth_rpc_eth_api::{
helpers::{EthSigner, EthTransactions, LoadTransaction, SpawnBlocking},
Expand Down Expand Up @@ -81,7 +81,7 @@ where

fn fill(
&self,
tx: TransactionSignedEcRecovered,
tx: RecoveredTx,
tx_info: TransactionInfo,
) -> Result<Self::Transaction, Self::Error> {
let from = tx.signer();
Expand Down
4 changes: 2 additions & 2 deletions crates/payload/util/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_primitives::Address;
use reth_primitives::TransactionSignedEcRecovered;
use reth_primitives::RecoveredTx;

/// Iterator that returns transactions for the block building process in the order they should be
/// included in the block.
Expand All @@ -12,7 +12,7 @@ pub trait PayloadTransactions {
&mut self,
// In the future, `ctx` can include access to state for block building purposes.
ctx: (),
) -> Option<TransactionSignedEcRecovered>;
) -> Option<RecoveredTx>;

/// Exclude descendants of the transaction with given sender and nonce from the iterator,
/// because this transaction won't be included in the block.
Expand Down
8 changes: 4 additions & 4 deletions crates/payload/util/src/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::PayloadTransactions;
use alloy_consensus::Transaction;
use alloy_primitives::Address;
use reth_primitives::TransactionSignedEcRecovered;
use reth_primitives::RecoveredTx;

/// An implementation of [`crate::traits::PayloadTransactions`] that yields
/// a pre-defined set of transactions.
Expand All @@ -26,8 +26,8 @@ impl<T> PayloadTransactionsFixed<T> {
}
}

impl PayloadTransactions for PayloadTransactionsFixed<TransactionSignedEcRecovered> {
fn next(&mut self, _ctx: ()) -> Option<TransactionSignedEcRecovered> {
impl PayloadTransactions for PayloadTransactionsFixed<RecoveredTx> {
fn next(&mut self, _ctx: ()) -> Option<RecoveredTx> {
(self.index < self.transactions.len()).then(|| {
let tx = self.transactions[self.index].clone();
self.index += 1;
Expand Down Expand Up @@ -92,7 +92,7 @@ where
B: PayloadTransactions,
A: PayloadTransactions,
{
fn next(&mut self, ctx: ()) -> Option<TransactionSignedEcRecovered> {
fn next(&mut self, ctx: ()) -> Option<RecoveredTx> {
while let Some(tx) = self.before.next(ctx) {
if let Some(before_max_gas) = self.before_max_gas {
if self.before_gas + tx.transaction.gas_limit() <= before_max_gas {
Expand Down
14 changes: 3 additions & 11 deletions crates/primitives/src/block.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
traits::BlockExt, transaction::SignedTransactionIntoRecoveredExt, BlockBodyTxExt, GotExpected,
SealedHeader, TransactionSigned, TransactionSignedEcRecovered,
RecoveredTx, SealedHeader, TransactionSigned,
};
use alloc::vec::Vec;
use alloy_consensus::Header;
Expand Down Expand Up @@ -206,11 +206,7 @@ impl<B: reth_primitives_traits::Block> BlockWithSenders<B> {
#[inline]
pub fn into_transactions_ecrecovered(
self,
) -> impl Iterator<
Item = TransactionSignedEcRecovered<
<B::Body as reth_primitives_traits::BlockBody>::Transaction,
>,
>
) -> impl Iterator<Item = RecoveredTx<<B::Body as reth_primitives_traits::BlockBody>::Transaction>>
where
<B::Body as reth_primitives_traits::BlockBody>::Transaction: SignedTransaction,
{
Expand Down Expand Up @@ -560,11 +556,7 @@ impl<B: reth_primitives_traits::Block> SealedBlockWithSenders<B> {
#[inline]
pub fn into_transactions_ecrecovered(
self,
) -> impl Iterator<
Item = TransactionSignedEcRecovered<
<B::Body as reth_primitives_traits::BlockBody>::Transaction,
>,
>
) -> impl Iterator<Item = RecoveredTx<<B::Body as reth_primitives_traits::BlockBody>::Transaction>>
where
<B::Body as reth_primitives_traits::BlockBody>::Transaction: SignedTransaction,
{
Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ pub use static_file::StaticFileSegment;
pub use transaction::{
util::secp256k1::{public_key_to_address, recover_signer_unchecked, sign_message},
BlobTransaction, InvalidTransactionError, PooledTransactionsElement,
PooledTransactionsElementEcRecovered, Transaction, TransactionMeta, TransactionSigned,
TransactionSignedEcRecovered, TransactionSignedNoHash, TxType,
PooledTransactionsElementEcRecovered, RecoveredTx, Transaction, TransactionMeta,
TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxType,
};

// Re-exports
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/transaction/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub enum TransactionConversionError {
}

/// Represents error variants than can happen when trying to convert a
/// [`TransactionSignedEcRecovered`](crate::TransactionSignedEcRecovered) transaction.
/// [`RecoveredTx`](crate::RecoveredTx) transaction.
#[derive(Debug, Clone, Eq, PartialEq, derive_more::Display)]
pub enum TryFromRecoveredTransactionError {
/// Thrown if the transaction type is unsupported.
Expand Down
Loading

0 comments on commit 9ed9fa2

Please sign in to comment.