@@ -109,8 +109,7 @@ use stacks_signer::v0::SpawnedSigner;
109
109
110
110
use super :: bitcoin_regtest:: BitcoinCoreController ;
111
111
use crate :: nakamoto_node:: miner:: {
112
- TEST_BLOCK_ANNOUNCE_STALL , TEST_BROADCAST_PROPOSAL_STALL , TEST_MINE_STALL ,
113
- TEST_P2P_BROADCAST_SKIP , TEST_P2P_BROADCAST_STALL ,
112
+ fault_injection_stall_miner, fault_injection_unstall_miner, TEST_BLOCK_ANNOUNCE_STALL , TEST_BROADCAST_PROPOSAL_STALL , TEST_P2P_BROADCAST_SKIP , TEST_P2P_BROADCAST_STALL
114
113
} ;
115
114
use crate :: nakamoto_node:: relayer:: TEST_MINER_THREAD_STALL ;
116
115
use crate :: neon:: Counters ;
@@ -6020,7 +6019,7 @@ fn nakamoto_attempt_time() {
6020
6019
6021
6020
// Stall the miner to make sure it waits until all transactions are
6022
6021
// submitted before it mines a block
6023
- TEST_MINE_STALL . set ( true ) ;
6022
+ fault_injection_stall_miner ( ) ;
6024
6023
6025
6024
let mut sender_nonce = account. nonce ;
6026
6025
for _ in 0 ..txs_per_block {
@@ -6036,7 +6035,7 @@ fn nakamoto_attempt_time() {
6036
6035
submit_tx ( & http_origin, & transfer_tx) ;
6037
6036
}
6038
6037
6039
- TEST_MINE_STALL . set ( false ) ;
6038
+ fault_injection_unstall_miner ( ) ;
6040
6039
6041
6040
// Miner should have made a new block by now
6042
6041
let wait_start = Instant :: now ( ) ;
@@ -6304,7 +6303,7 @@ fn clarity_burn_state() {
6304
6303
result. expect_result_ok ( ) . expect ( "Read-only call failed" ) ;
6305
6304
6306
6305
// Pause mining to prevent the stacks block from being mined before the tenure change is processed
6307
- TEST_MINE_STALL . set ( true ) ;
6306
+ fault_injection_stall_miner ( ) ;
6308
6307
// Submit a tx for the next block (the next block will be a new tenure, so the burn block height will increment)
6309
6308
let call_tx = make_contract_call (
6310
6309
& sender_sk,
@@ -6329,7 +6328,7 @@ fn clarity_burn_state() {
6329
6328
Ok ( commits_submitted. load ( Ordering :: SeqCst ) > commits_before)
6330
6329
} )
6331
6330
. unwrap ( ) ;
6332
- TEST_MINE_STALL . set ( false ) ;
6331
+ fault_injection_unstall_miner ( ) ;
6333
6332
wait_for ( 20 , || {
6334
6333
Ok ( coord_channel
6335
6334
. lock ( )
@@ -10368,7 +10367,7 @@ fn clarity_cost_spend_down() {
10368
10367
. expect ( "Mutex poisoned" )
10369
10368
. get_stacks_blocks_processed ( ) ;
10370
10369
// Pause mining so we can add all our transactions to the mempool at once.
10371
- TEST_MINE_STALL . set ( true ) ;
10370
+ fault_injection_stall_miner ( ) ;
10372
10371
for _nmb_tx in 0 ..nmb_txs_per_signer {
10373
10372
for sender_sk in sender_sks. iter ( ) {
10374
10373
let sender_nonce = get_and_increment_nonce ( sender_sk, & mut sender_nonces) ;
@@ -10394,7 +10393,7 @@ fn clarity_cost_spend_down() {
10394
10393
}
10395
10394
}
10396
10395
}
10397
- TEST_MINE_STALL . set ( false ) ;
10396
+ fault_injection_unstall_miner ( ) ;
10398
10397
wait_for ( 120 , || {
10399
10398
let blocks_processed = coord_channel
10400
10399
. lock ( )
@@ -10672,7 +10671,7 @@ fn test_tenure_extend_from_flashblocks() {
10672
10671
assert_eq ! ( sort_tip. consensus_hash, election_tip. consensus_hash) ;
10673
10672
10674
10673
// stop the relayer thread from starting a miner thread, and stop the miner thread from mining
10675
- TEST_MINE_STALL . set ( true ) ;
10674
+ fault_injection_stall_miner ( ) ;
10676
10675
TEST_MINER_THREAD_STALL . set ( true ) ;
10677
10676
10678
10677
// mine another Bitcoin block right away, and force it to be a flash block
@@ -10738,7 +10737,7 @@ fn test_tenure_extend_from_flashblocks() {
10738
10737
10739
10738
// unstall miner thread and allow block-commits again
10740
10739
counters. naka_skip_commit_op . set ( false ) ;
10741
- TEST_MINE_STALL . set ( false ) ;
10740
+ fault_injection_unstall_miner ( ) ;
10742
10741
10743
10742
// wait for the miner directive to be processed
10744
10743
wait_for ( 60 , || {
@@ -11509,7 +11508,7 @@ fn large_mempool_base(strategy: MemPoolWalkStrategy, set_fee: impl Fn() -> u64)
11509
11508
info ! ( "Pause mining and fill the mempool with the transfers" ) ;
11510
11509
11511
11510
// Pause block mining
11512
- TEST_MINE_STALL . set ( true ) ;
11511
+ fault_injection_stall_miner ( ) ;
11513
11512
11514
11513
let db_tx = conn. transaction ( ) . unwrap ( ) ;
11515
11514
let timer = Instant :: now ( ) ;
@@ -11549,7 +11548,7 @@ fn large_mempool_base(strategy: MemPoolWalkStrategy, set_fee: impl Fn() -> u64)
11549
11548
let proposed_blocks_before = test_observer:: get_mined_nakamoto_blocks ( ) . len ( ) ;
11550
11549
11551
11550
// Unpause block mining
11552
- TEST_MINE_STALL . set ( false ) ;
11551
+ fault_injection_unstall_miner ( ) ;
11553
11552
11554
11553
// Wait for the first block to be proposed.
11555
11554
wait_for ( 30 , || {
@@ -11846,7 +11845,7 @@ fn larger_mempool() {
11846
11845
info ! ( "Pause mining and fill the mempool with the transfers" ) ;
11847
11846
11848
11847
// Pause block mining
11849
- TEST_MINE_STALL . set ( true ) ;
11848
+ fault_injection_stall_miner ( ) ;
11850
11849
11851
11850
let timer = Instant :: now ( ) ;
11852
11851
@@ -11890,7 +11889,7 @@ fn larger_mempool() {
11890
11889
let timer = Instant :: now ( ) ;
11891
11890
11892
11891
// Unpause block mining
11893
- TEST_MINE_STALL . set ( false ) ;
11892
+ fault_injection_unstall_miner ( ) ;
11894
11893
11895
11894
// Wait for the first block to be proposed.
11896
11895
wait_for ( 10 , || {
@@ -12184,7 +12183,7 @@ fn handle_considered_txs_foreign_key_failure() {
12184
12183
let height_before = get_chain_info ( & naka_conf) . stacks_tip_height ;
12185
12184
12186
12185
// Initiate the transaction stall, then submit transactions.
12187
- TEST_MINE_STALL . set ( true ) ;
12186
+ fault_injection_stall_miner ( ) ;
12188
12187
TEST_TX_STALL . set ( true ) ;
12189
12188
12190
12189
let bad_transfer_tx = make_stacks_transfer_serialized (
@@ -12198,7 +12197,7 @@ fn handle_considered_txs_foreign_key_failure() {
12198
12197
let txid = submit_tx ( & http_origin, & bad_transfer_tx) ;
12199
12198
info ! ( "Bad transaction submitted: {txid}" ) ;
12200
12199
12201
- TEST_MINE_STALL . set ( false ) ;
12200
+ fault_injection_unstall_miner ( ) ;
12202
12201
12203
12202
// Sleep long enough to ensure that the miner has started processing the tx
12204
12203
sleep_ms ( 5_000 ) ;
@@ -12432,7 +12431,7 @@ fn miner_constructs_replay_block() {
12432
12431
12433
12432
// Pause mining to prevent any of the submitted txs getting mined.
12434
12433
info ! ( "Stalling mining..." ) ;
12435
- TEST_MINE_STALL . set ( true ) ;
12434
+ fault_injection_stall_miner ( ) ;
12436
12435
let burn_height_before = get_chain_info ( & naka_conf) . burn_block_height ;
12437
12436
// Mine 1 bitcoin block to trigger a new block found transaction
12438
12437
next_block_and ( & mut btc_regtest_controller, 60 , || {
@@ -12515,7 +12514,7 @@ fn miner_constructs_replay_block() {
12515
12514
let blocks_before = test_observer:: get_blocks ( ) . len ( ) ;
12516
12515
assert_eq ! ( observed_before, 0 ) ;
12517
12516
info ! ( "Resuming mining..." ) ;
12518
- TEST_MINE_STALL . set ( false ) ;
12517
+ fault_injection_unstall_miner ( ) ;
12519
12518
12520
12519
info ! ( "Waiting for two stacks block to be mined..." ) ;
12521
12520
wait_for ( 30 , || {
0 commit comments