Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.

Commit 1ac6dca

Browse files
committed
use FBPooledTransaction
1 parent 20df5db commit 1ac6dca

2 files changed

Lines changed: 38 additions & 26 deletions

File tree

crates/op-rbuilder/src/builders/context.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,7 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
646646
let total_backrun_da_size: u64 = stored_bundle
647647
.backrun_txs
648648
.iter()
649-
.map(|tx| {
650-
op_alloy_flz::tx_estimated_size_fjord_bytes(
651-
tx.encoded_2718().as_slice(),
652-
)
653-
})
649+
.map(|tx| tx.estimated_da_size())
654650
.sum();
655651

656652
if let Err(result) = info.is_tx_over_limits(
@@ -678,7 +674,8 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
678674
let mut pending_results = Vec::with_capacity(stored_bundle.backrun_txs.len());
679675

680676
for backrun_tx in &stored_bundle.backrun_txs {
681-
let ResultAndState { result, state } = match evm.transact(backrun_tx) {
677+
let consensus_tx = backrun_tx.clone_into_consensus();
678+
let ResultAndState { result, state } = match evm.transact(&consensus_tx) {
682679
Ok(res) => res,
683680
Err(err) => {
684681
return Err(PayloadBuilderError::evm(err));
@@ -690,28 +687,25 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
690687
info!(
691688
target: "payload_builder",
692689
target_tx = ?tx_hash,
693-
failed_tx = ?backrun_tx.tx_hash(),
690+
failed_tx = ?backrun_tx.hash(),
694691
bundle_id = ?stored_bundle.bundle_id,
695692
gas_used = result.gas_used(),
696693
"Backrun bundle reverted (all-or-nothing)"
697694
);
698695
continue 'bundle_loop;
699696
}
700697

701-
pending_results.push((backrun_tx, result, state));
698+
pending_results.push((backrun_tx.clone(), consensus_tx, result, state));
702699
}
703700

704-
for (backrun_tx, result, state) in pending_results {
701+
for (backrun_tx, consensus_tx, result, state) in pending_results {
705702
let backrun_gas_used = result.gas_used();
706703

707704
info.cumulative_gas_used += backrun_gas_used;
708-
info.cumulative_da_bytes_used +=
709-
op_alloy_flz::tx_estimated_size_fjord_bytes(
710-
backrun_tx.encoded_2718().as_slice(),
711-
);
705+
info.cumulative_da_bytes_used += backrun_tx.estimated_da_size();
712706

713707
let ctx = ReceiptBuilderCtx {
714-
tx: backrun_tx.inner(),
708+
tx: consensus_tx.inner(),
715709
evm: &evm,
716710
result,
717711
state: &state,
@@ -726,9 +720,8 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
726720
.expect("fee is always valid; execution succeeded");
727721
info.total_fees += U256::from(miner_fee) * U256::from(backrun_gas_used);
728722

729-
info.executed_senders.push(backrun_tx.signer());
730-
info.executed_transactions
731-
.push(backrun_tx.clone().into_inner());
723+
info.executed_senders.push(backrun_tx.sender());
724+
info.executed_transactions.push(consensus_tx.into_inner());
732725
}
733726

734727
self.metrics.backrun_bundles_landed_total.increment(1);

crates/op-rbuilder/src/tx_data_store.rs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
use crate::metrics::OpRBuilderMetrics;
2-
use alloy_consensus::{Transaction, transaction::Recovered};
1+
use crate::{metrics::OpRBuilderMetrics, tx::FBPooledTransaction};
2+
use alloy_consensus::Transaction;
33
use alloy_primitives::{Address, TxHash};
44
use concurrent_queue::ConcurrentQueue;
55
use jsonrpsee::{
66
core::{RpcResult, async_trait},
77
proc_macros::rpc,
88
};
9-
use op_alloy_consensus::OpTxEnvelope;
9+
use reth_optimism_txpool::OpPooledTransaction;
10+
use reth_transaction_pool::PoolTransaction;
1011
use std::{
1112
fmt::Debug,
1213
sync::{
@@ -23,7 +24,7 @@ use uuid::Uuid;
2324
pub struct StoredBackrunBundle {
2425
pub bundle_id: Uuid,
2526
pub sender: Address,
26-
pub backrun_txs: Vec<Recovered<OpTxEnvelope>>,
27+
pub backrun_txs: Vec<FBPooledTransaction>,
2728
pub total_priority_fee: u128,
2829
}
2930

@@ -114,8 +115,26 @@ impl TxDataStore {
114115
}
115116

116117
let target_tx_hash = bundle.txs[0].tx_hash();
117-
let backrun_txs: Vec<Recovered<OpTxEnvelope>> = bundle.txs[1..].to_vec();
118-
let backrun_sender = backrun_txs[0].signer();
118+
119+
// Convert OpTxEnvelope transactions to FBPooledTransaction
120+
let backrun_txs: Vec<FBPooledTransaction> = bundle.txs[1..]
121+
.iter()
122+
.filter_map(|tx| {
123+
let (envelope, signer) = tx.clone().into_parts();
124+
let pooled_envelope: op_alloy_consensus::OpPooledTransaction =
125+
envelope.try_into().ok()?;
126+
let recovered_pooled =
127+
alloy_consensus::transaction::Recovered::new_unchecked(pooled_envelope, signer);
128+
let pooled = OpPooledTransaction::from_pooled(recovered_pooled);
129+
Some(FBPooledTransaction::from(pooled))
130+
})
131+
.collect();
132+
133+
if backrun_txs.is_empty() {
134+
return Err("No valid poolable transactions in backrun bundle".to_string());
135+
}
136+
137+
let backrun_sender = backrun_txs[0].sender();
119138

120139
self.evict_if_needed();
121140
let _ = self.data.lru.push(target_tx_hash);
@@ -307,7 +326,7 @@ impl BaseApiExtServer for TxDataStoreExt {
307326
#[cfg(test)]
308327
mod tests {
309328
use super::*;
310-
use alloy_consensus::SignableTransaction;
329+
use alloy_consensus::{SignableTransaction, transaction::Recovered};
311330
use alloy_primitives::{Address, B256, TxHash, U256};
312331
use alloy_provider::network::TxSignerSync;
313332
use alloy_signer_local::PrivateKeySigner;
@@ -425,7 +444,7 @@ mod tests {
425444
assert_eq!(data.backrun_bundles.len(), 1);
426445
assert_eq!(data.backrun_bundles[0].backrun_txs.len(), 1);
427446
assert_eq!(
428-
data.backrun_bundles[0].backrun_txs[0].tx_hash(),
447+
*data.backrun_bundles[0].backrun_txs[0].hash(),
429448
backrun_tx1.tx_hash()
430449
);
431450

@@ -437,7 +456,7 @@ mod tests {
437456
let data = store.get(&target_tx_hash);
438457
assert_eq!(data.backrun_bundles.len(), 1);
439458
assert_eq!(
440-
data.backrun_bundles[0].backrun_txs[0].tx_hash(),
459+
*data.backrun_bundles[0].backrun_txs[0].hash(),
441460
backrun_tx2.tx_hash()
442461
);
443462

0 commit comments

Comments
 (0)