@@ -227,8 +227,8 @@ pub struct BlockMinerThread {
227227 burn_tip_at_start : ConsensusHash ,
228228 /// flag to indicate an abort driven from the relayer
229229 abort_flag : Arc < AtomicBool > ,
230- /// Should the nonce cache be reset before mining the next block?
231- reset_nonce_cache : bool ,
230+ /// Should the nonce and considered transactions cache be reset before mining the next block?
231+ reset_mempool_caches : bool ,
232232 /// Storage for persisting non-confidential miner information
233233 miner_db : MinerDB ,
234234}
@@ -264,7 +264,7 @@ impl BlockMinerThread {
264264 abort_flag : Arc :: new ( AtomicBool :: new ( false ) ) ,
265265 tenure_cost : ExecutionCost :: ZERO ,
266266 tenure_budget : ExecutionCost :: ZERO ,
267- reset_nonce_cache : true ,
267+ reset_mempool_caches : true ,
268268 miner_db : MinerDB :: open_with_config ( & rt. config ) ?,
269269 } )
270270 }
@@ -528,13 +528,23 @@ impl BlockMinerThread {
528528 thread:: sleep ( Duration :: from_millis ( ABORT_TRY_AGAIN_MS ) ) ;
529529 return Ok ( ( ) ) ;
530530 }
531-
532- if self . reset_nonce_cache {
531+ if self . reset_mempool_caches
532+ || self . config . miner . mempool_walk_strategy
533+ == MemPoolWalkStrategy :: NextNonceWithHighestFeeRate
534+ {
533535 let mut mem_pool = self
534536 . config
535537 . connect_mempool_db ( )
536538 . expect ( "Database failure opening mempool" ) ;
537- mem_pool. reset_mempool_caches ( ) ?;
539+
540+ if self . reset_mempool_caches {
541+ mem_pool. reset_mempool_caches ( ) ?;
542+ } else {
543+ // Even if the nonce cache is still valid, NextNonceWithHighestFeeRate strategy
544+ // needs to reset this cache after each block. This prevents skipping transactions
545+ // that were previously considered, but not included in previous blocks.
546+ mem_pool. reset_considered_txs_cache ( ) ?;
547+ }
538548 }
539549
540550 let Some ( new_block) = self . mine_block_and_handle_result ( coordinator) ? else {
@@ -619,13 +629,7 @@ impl BlockMinerThread {
619629 "Miner did not find any transactions to mine, sleeping for {:?}" ,
620630 self . config. miner. empty_mempool_sleep_time
621631 ) ;
622- // For NextNonceWithHighestFeeRate strategy, keep reset_nonce_cache = true
623- // to ensure considered_txs table is cleared for each block attempt
624- if self . config . miner . mempool_walk_strategy
625- != MemPoolWalkStrategy :: NextNonceWithHighestFeeRate
626- {
627- self . reset_nonce_cache = false ;
628- }
632+ self . reset_mempool_caches = false ;
629633
630634 // Pause the miner to wait for transactions to arrive
631635 let now = Instant :: now ( ) ;
@@ -740,13 +744,7 @@ impl BlockMinerThread {
740744 ) ;
741745
742746 // We successfully mined, so the mempool caches are valid.
743- // For NextNonceWithHighestFeeRate strategy, keep reset_nonce_cache = true
744- // to ensure considered_txs table is cleared for each block attempt
745- if self . config . miner . mempool_walk_strategy
746- != MemPoolWalkStrategy :: NextNonceWithHighestFeeRate
747- {
748- self . reset_nonce_cache = false ;
749- }
747+ self . reset_mempool_caches = false ;
750748 }
751749
752750 // update mined-block counters and mined-tenure counters
@@ -1456,7 +1454,7 @@ impl BlockMinerThread {
14561454 // If we attempt to build a block, we should reset the nonce cache.
14571455 // In the special case where no transactions are found, this flag will
14581456 // be reset to false.
1459- self . reset_nonce_cache = true ;
1457+ self . reset_mempool_caches = true ;
14601458
14611459 let replay_transactions = if self . config . miner . replay_transactions {
14621460 coordinator
0 commit comments