Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename reth_primitives::RecoveredTx functions to match alloy::Recovered #13663

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/reth/src/commands/debug_cmd/build_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {

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();
Expand Down
3 changes: 1 addition & 2 deletions crates/blockchain-tree/src/blockchain_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1592,8 +1592,7 @@ mod tests {
body: Vec<RecoveredTx<TransactionSigned>>,
num_of_signer_txs: u64|
-> SealedBlockWithSenders {
let signed_body =
body.clone().into_iter().map(|tx| tx.into_signed()).collect::<Vec<_>>();
let signed_body = body.clone().into_iter().map(|tx| tx.into_tx()).collect::<Vec<_>>();
let transactions_root = calculate_transaction_root(&signed_body);
let receipts = body
.iter()
Expand Down
4 changes: 2 additions & 2 deletions crates/chain-state/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<N: NodePrimitives> TestBlockBuilder<N> {
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::<Vec<_>>(),
&transactions.clone().into_iter().map(|tx| tx.into_tx()).collect::<Vec<_>>(),
),
receipts_root: calculate_receipt_root(&receipts),
beneficiary: Address::random(),
Expand All @@ -171,7 +171,7 @@ impl<N: NodePrimitives> TestBlockBuilder<N> {
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()),
},
Expand Down
4 changes: 2 additions & 2 deletions crates/ethereum/payload/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/benches/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/src/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ impl<T: SignedTransaction> PropagateTransaction<T> {
{
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 }
}

Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/tests/it/txgossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async fn test_4844_tx_gossip_penalization() {
}

let signed_txs: Vec<Arc<TransactionSigned>> =
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();

Expand Down
4 changes: 2 additions & 2 deletions crates/optimism/node/src/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl TryFrom<RecoveredTx<OpTransactionSigned>> for OpPooledTransaction {
type Error = TransactionConversionError;

fn try_from(value: RecoveredTx<OpTransactionSigned>) -> Result<Self, Self::Error> {
let (tx, signer) = value.to_components();
let (tx, signer) = value.into_parts();
let pooled: RecoveredTx<op_alloy_consensus::OpPooledTransaction> =
RecoveredTx::from_signed_transaction(tx.try_into()?, signer);
Ok(pooled.into())
Expand All @@ -83,7 +83,7 @@ impl PoolTransaction for OpPooledTransaction {
fn try_consensus_into_pooled(
tx: RecoveredTx<Self::Consensus>,
) -> Result<RecoveredTx<Self::Pooled>, Self::TryFromConsensusError> {
let (tx, signer) = tx.to_components();
let (tx, signer) = tx.into_parts();
Ok(RecoveredTx::from_signed_transaction(tx.try_into()?, signer))
}

Expand Down
8 changes: 4 additions & 4 deletions crates/optimism/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/rpc/src/eth/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where
) -> Result<Self::Transaction, Self::Error> {
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;

Expand Down
14 changes: 7 additions & 7 deletions crates/payload/util/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,24 @@ where
fn next(&mut self, ctx: ()) -> Option<RecoveredTx<Self::Transaction>> {
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);
}
}

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);
}
Expand Down
6 changes: 3 additions & 3 deletions crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,17 +1546,17 @@ impl<T> RecoveredTx<T> {
}

/// 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)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/transaction/pooled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub type PooledTransactionsElementEcRecovered<T = PooledTransaction> = Recovered
impl PooledTransactionsElementEcRecovered {
/// Transform back to [`RecoveredTx`]
pub fn into_ecrecovered_transaction(self) -> RecoveredTx<TransactionSigned> {
let (tx, signer) = self.to_components();
let (tx, signer) = self.into_parts();
RecoveredTx::from_signed_transaction(tx.into(), signer)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-eth-api/src/helpers/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc-eth-api/src/helpers/pending_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-eth-api/src/helpers/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc-types-compat/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ pub fn transaction_to_call_request<T: alloy_consensus::Transaction>(
tx: RecoveredTx<T>,
) -> TransactionRequest {
let from = tx.signer();
TransactionRequest::from_transaction_with_sender(tx.into_signed(), from)
TransactionRequest::from_transaction_with_sender(tx.into_tx(), from)
}
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/eth/helpers/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ where
) -> Result<Self::Transaction, Self::Error> {
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) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/eth/sim_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ where
match &body[idx] {
BundleItem::Tx { tx, can_revert } => {
let recovered_tx = recover_raw_transaction::<PoolPooledTx<Eth::Pool>>(tx)?;
let (tx, signer) = recovered_tx.to_components();
let (tx, signer) = recovered_tx.into_parts();
let tx: PoolConsensusTx<Eth::Pool> =
<Eth::Pool as TransactionPool>::Transaction::pooled_into_consensus(tx);

Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/maintain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>();

let num_txs = local_transactions.len();
Expand Down
2 changes: 1 addition & 1 deletion crates/transaction-pool/src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ where
};

size += encoded_len;
elements.push(pooled.into_signed());
elements.push(pooled.into_tx());

if limit.exceeds(size) {
break
Expand Down
8 changes: 4 additions & 4 deletions crates/transaction-pool/src/test_utils/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ impl PoolTransaction for MockTransaction {
fn try_consensus_into_pooled(
tx: RecoveredTx<Self::Consensus>,
) -> Result<RecoveredTx<Self::Pooled>, 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)
Expand Down Expand Up @@ -871,7 +871,7 @@ impl EthPoolTransaction for MockTransaction {
self,
sidecar: Arc<BlobTransactionSidecar>,
) -> Option<RecoveredTx<Self::Pooled>> {
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()
Expand All @@ -881,7 +881,7 @@ impl EthPoolTransaction for MockTransaction {
tx: RecoveredTx<Self::Consensus>,
sidecar: BlobTransactionSidecar,
) -> Option<Self> {
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()
Expand Down Expand Up @@ -909,7 +909,7 @@ impl TryFrom<RecoveredTx<TransactionSigned>> for MockTransaction {

fn try_from(tx: RecoveredTx<TransactionSigned>) -> Result<Self, Self::Error> {
let sender = tx.signer();
let transaction = tx.into_signed();
let transaction = tx.into_tx();
let hash = transaction.hash();
let size = transaction.size();

Expand Down
6 changes: 3 additions & 3 deletions crates/transaction-pool/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ impl<T: SignedTransaction> EthPooledTransaction<T> {
impl From<PooledTransactionsElementEcRecovered> 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
Expand Down Expand Up @@ -1280,7 +1280,7 @@ impl PoolTransaction for EthPooledTransaction {
fn try_consensus_into_pooled(
tx: RecoveredTx<Self::Consensus>,
) -> Result<RecoveredTx<Self::Pooled>, Self::TryFromConsensusError> {
let (tx, signer) = tx.to_components();
let (tx, signer) = tx.into_parts();
let pooled = tx
.try_into_pooled()
.map_err(|_| TryFromRecoveredTransactionError::BlobSidecarMissing)?;
Expand Down Expand Up @@ -1427,7 +1427,7 @@ impl EthPoolTransaction for EthPooledTransaction {
tx: RecoveredTx<Self::Consensus>,
sidecar: BlobTransactionSidecar,
) -> Option<Self> {
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))
Expand Down
4 changes: 2 additions & 2 deletions docs/crates/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ fn on_new_transactions(&mut self, hashes: impl IntoIterator<Item = TxHash>) {
.get_all(hashes)
.into_iter()
.map(|tx| {
(*tx.hash(), Arc::new(tx.transaction.to_recovered_transaction().into_signed()))
(*tx.hash(), Arc::new(tx.transaction.to_recovered_transaction().into_tx()))
})
.collect(),
);
Expand Down Expand Up @@ -1098,7 +1098,7 @@ fn on_get_pooled_transactions(
.pool
.get_all(request.0)
.into_iter()
.map(|tx| tx.transaction.to_recovered_transaction().into_signed())
.map(|tx| tx.transaction.to_recovered_transaction().into_tx())
.collect::<Vec<_>>();

// we sent a response at which point we assume that the peer is aware of the transaction
Expand Down
Loading