@@ -227,8 +227,8 @@ pub struct BlockMinerThread {
227
227
burn_tip_at_start : ConsensusHash ,
228
228
/// flag to indicate an abort driven from the relayer
229
229
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 ,
232
232
/// Storage for persisting non-confidential miner information
233
233
miner_db : MinerDB ,
234
234
}
@@ -264,7 +264,7 @@ impl BlockMinerThread {
264
264
abort_flag : Arc :: new ( AtomicBool :: new ( false ) ) ,
265
265
tenure_cost : ExecutionCost :: ZERO ,
266
266
tenure_budget : ExecutionCost :: ZERO ,
267
- reset_nonce_cache : true ,
267
+ reset_mempool_caches : true ,
268
268
miner_db : MinerDB :: open_with_config ( & rt. config ) ?,
269
269
} )
270
270
}
@@ -528,13 +528,23 @@ impl BlockMinerThread {
528
528
thread:: sleep ( Duration :: from_millis ( ABORT_TRY_AGAIN_MS ) ) ;
529
529
return Ok ( ( ) ) ;
530
530
}
531
-
532
- if self . reset_nonce_cache {
531
+ if self . reset_mempool_caches
532
+ || self . config . miner . mempool_walk_strategy
533
+ == MemPoolWalkStrategy :: NextNonceWithHighestFeeRate
534
+ {
533
535
let mut mem_pool = self
534
536
. config
535
537
. connect_mempool_db ( )
536
538
. 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
+ }
538
548
}
539
549
540
550
let Some ( new_block) = self . mine_block_and_handle_result ( coordinator) ? else {
@@ -619,13 +629,7 @@ impl BlockMinerThread {
619
629
"Miner did not find any transactions to mine, sleeping for {:?}" ,
620
630
self . config. miner. empty_mempool_sleep_time
621
631
) ;
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 ;
629
633
630
634
// Pause the miner to wait for transactions to arrive
631
635
let now = Instant :: now ( ) ;
@@ -740,13 +744,7 @@ impl BlockMinerThread {
740
744
) ;
741
745
742
746
// 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 ;
750
748
}
751
749
752
750
// update mined-block counters and mined-tenure counters
@@ -1456,7 +1454,7 @@ impl BlockMinerThread {
1456
1454
// If we attempt to build a block, we should reset the nonce cache.
1457
1455
// In the special case where no transactions are found, this flag will
1458
1456
// be reset to false.
1459
- self . reset_nonce_cache = true ;
1457
+ self . reset_mempool_caches = true ;
1460
1458
1461
1459
let replay_transactions = if self . config . miner . replay_transactions {
1462
1460
coordinator
0 commit comments