@@ -102,6 +102,9 @@ impl<T: SignedTransaction> SequenceManager<T> {
102102 // Ring buffer automatically evicts oldest entry when full
103103 let txs = std:: mem:: take ( & mut self . pending_transactions ) ;
104104 self . completed_cache . push ( ( completed, txs) ) ;
105+
106+ // ensure cache is wiped on new flashblock
107+ let _ = self . pending . take_cached_reads ( ) ;
105108 }
106109
107110 self . pending_transactions
@@ -123,7 +126,7 @@ impl<T: SignedTransaction> SequenceManager<T> {
123126 ///
124127 /// Returns None if nothing is buildable right now.
125128 pub ( crate ) fn next_buildable_args (
126- & self ,
129+ & mut self ,
127130 local_tip_hash : B256 ,
128131 local_tip_timestamp : u64 ,
129132 ) -> Option < BuildArgs < Vec < WithEncoded < Recovered < T > > > > > {
@@ -132,9 +135,9 @@ impl<T: SignedTransaction> SequenceManager<T> {
132135 let ( base, last_flashblock, transactions, cached_state, source_name) =
133136 // Priority 1: Try current pending sequence
134137 if let Some ( base) = self . pending . payload_base ( ) . filter ( |b| b. parent_hash == local_tip_hash) {
138+ let cached_state = self . pending . take_cached_reads ( ) . map ( |r| ( base. parent_hash , r) ) ;
135139 let last_fb = self . pending . last_flashblock ( ) ?;
136140 let transactions = self . pending_transactions . clone ( ) ;
137- let cached_state = self . pending . cached_reads ( ) . as_ref ( ) . map ( |r| ( base. parent_hash , r. clone ( ) ) ) ;
138141 ( base, last_fb, transactions, cached_state, "pending" )
139142 }
140143 // Priority 2: Try cached sequence with exact parent match
@@ -311,7 +314,7 @@ mod tests {
311314
312315 #[ test]
313316 fn test_next_buildable_args_returns_none_when_empty ( ) {
314- let manager: SequenceManager < OpTxEnvelope > = SequenceManager :: new ( true ) ;
317+ let mut manager: SequenceManager < OpTxEnvelope > = SequenceManager :: new ( true ) ;
315318 let local_tip_hash = B256 :: random ( ) ;
316319 let local_tip_timestamp = 1000 ;
317320
0 commit comments