1- use crate :: metrics:: OpRBuilderMetrics ;
2- use alloy_consensus:: { Transaction , transaction :: Recovered } ;
1+ use crate :: { metrics:: OpRBuilderMetrics , tx :: FBPooledTransaction } ;
2+ use alloy_consensus:: Transaction ;
33use alloy_primitives:: { Address , TxHash } ;
44use concurrent_queue:: ConcurrentQueue ;
55use 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 ;
1011use std:: {
1112 fmt:: Debug ,
1213 sync:: {
@@ -23,7 +24,7 @@ use uuid::Uuid;
2324pub 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) ]
308327mod 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