@@ -785,8 +785,11 @@ impl MultipleMinerTest {
785
785
.unwrap()
786
786
.block_height;
787
787
788
+ debug!("HERE Building {nmb_blocks} BTC blocks.");
788
789
self.btc_regtest_controller_mut()
789
790
.build_next_block(nmb_blocks);
791
+
792
+ debug!("HERE Waiting to for burn chain tip to advance {nmb_blocks} blocks.");
790
793
wait_for(timeout_secs, || {
791
794
let burn_block = SortitionDB::get_canonical_burn_chain_tip(sortdb.conn())
792
795
.unwrap()
@@ -795,6 +798,10 @@ impl MultipleMinerTest {
795
798
&& self.get_peer_info().burn_block_height >= burn_block_before + nmb_blocks)
796
799
})?;
797
800
let peer_after = self.get_peer_info();
801
+ debug!(
802
+ "HERE Waiting for updates for burn block {} with block height {}.",
803
+ peer_after.pox_consensus, peer_after.burn_block_height
804
+ );
798
805
wait_for_state_machine_update(
799
806
timeout_secs,
800
807
&peer_after.pox_consensus,
@@ -1841,33 +1848,12 @@ fn miner_gather_signatures() {
1841
1848
info!("------------------------- Test Setup -------------------------");
1842
1849
let num_signers = 5;
1843
1850
let signer_test: SignerTest<SpawnedSigner> = SignerTest::new(num_signers, vec![]);
1844
- let miner_sk = signer_test.running_nodes.conf.miner.mining_key.unwrap();
1845
- let miner_pk = StacksPublicKey::from_private(&miner_sk);
1846
- let miner_pkh = Hash160::from_node_public_key(&miner_pk);
1847
1851
1848
1852
signer_test.boot_to_epoch_3();
1849
1853
1850
1854
info!("------------------------- Test Mine and Verify Confirmed Nakamoto Block -------------------------");
1851
1855
TEST_MINE_SKIP.set(true);
1852
- let info_before = get_chain_info(&signer_test.running_nodes.conf);
1853
- next_block_and(
1854
- &signer_test.running_nodes.btc_regtest_controller,
1855
- 30,
1856
- || {
1857
- let info = get_chain_info(&signer_test.running_nodes.conf);
1858
- Ok(info.burn_block_height > info_before.burn_block_height)
1859
- },
1860
- )
1861
- .expect("Failed to process bitcoin block");
1862
- let info_after = get_chain_info(&signer_test.running_nodes.conf);
1863
- wait_for_state_machine_update(
1864
- 30,
1865
- &info_after.pox_consensus,
1866
- info_after.burn_block_height,
1867
- Some((miner_pkh, info_before.stacks_tip_height)),
1868
- &signer_test.signer_addresses_versions(),
1869
- )
1870
- .expect("Failed to update state machine");
1856
+ signer_test.mine_bitcoin_block();
1871
1857
TEST_MINE_SKIP.set(false);
1872
1858
signer_test.check_signer_states_normal();
1873
1859
@@ -7079,17 +7065,7 @@ fn empty_tenure_delayed() {
7079
7065
} = signer_test.running_nodes.counters.clone();
7080
7066
7081
7067
info!("------------------------- Test Mine Regular Tenure A -------------------------");
7082
- let info_before = signer_test.get_peer_info();
7083
- // Mine a regular tenure, but wait for commits to be submitted
7084
- next_block_and(
7085
- &signer_test.running_nodes.btc_regtest_controller,
7086
- 60,
7087
- || {
7088
- let info = signer_test.get_peer_info();
7089
- Ok(info.stacks_tip_height > info_before.stacks_tip_height)
7090
- },
7091
- )
7092
- .unwrap();
7068
+ signer_test.mine_nakamoto_block(Duration::from_secs(30), true);
7093
7069
signer_test.check_signer_states_normal();
7094
7070
7095
7071
info!("------------------------- Test Mine Empty Tenure B -------------------------");
@@ -7251,7 +7227,6 @@ fn empty_sortition_before_approval() {
7251
7227
.expect("Timed out waiting for commit to be submitted for Tenure A");
7252
7228
7253
7229
let info = get_chain_info(&signer_test.running_nodes.conf);
7254
- let burn_height_before = info.burn_block_height;
7255
7230
let stacks_height_before = info.stacks_tip_height;
7256
7231
7257
7232
info!("Forcing miner to ignore signatures for next block");
@@ -7274,15 +7249,7 @@ fn empty_sortition_before_approval() {
7274
7249
info!("------------------------- Test Mine Empty Tenure B -------------------------");
7275
7250
7276
7251
// Trigger an empty tenure
7277
- next_block_and(
7278
- &signer_test.running_nodes.btc_regtest_controller,
7279
- 60,
7280
- || {
7281
- let burn_height = get_chain_info(&signer_test.running_nodes.conf).burn_block_height;
7282
- Ok(burn_height == burn_height_before + 2)
7283
- },
7284
- )
7285
- .expect("Failed to mine empty tenure");
7252
+ signer_test.mine_bitcoin_block();
7286
7253
signer_test.check_signer_states_normal_missed_sortition();
7287
7254
7288
7255
info!("Unpause block commits");
@@ -10530,19 +10497,10 @@ fn block_commit_delay() {
10530
10497
TEST_REJECT_ALL_BLOCK_PROPOSAL.set(all_signers);
10531
10498
10532
10499
info!("------------------------- Test Mine Burn Block -------------------------");
10533
- let burn_height_before = get_chain_info(&signer_test.running_nodes.conf).burn_block_height;
10534
10500
let commits_before = commits_submitted.load(Ordering::SeqCst);
10535
10501
10536
10502
// Mine a burn block and wait for it to be processed.
10537
- next_block_and(
10538
- &signer_test.running_nodes.btc_regtest_controller,
10539
- 60,
10540
- || {
10541
- let burn_height = get_chain_info(&signer_test.running_nodes.conf).burn_block_height;
10542
- Ok(burn_height > burn_height_before)
10543
- },
10544
- )
10545
- .unwrap();
10503
+ signer_test.mine_bitcoin_block();
10546
10504
10547
10505
// Sleep an extra minute to ensure no block commits are sent
10548
10506
sleep_ms(60_000);
@@ -11105,17 +11063,7 @@ fn new_tenure_while_validating_previous_scenario() {
11105
11063
11106
11064
info!("----- Mining a new BTC block -----");
11107
11065
TEST_MINE_SKIP.set(true);
11108
- next_block_and(
11109
- &signer_test.running_nodes.btc_regtest_controller,
11110
- 30,
11111
- || {
11112
- Ok(
11113
- get_chain_info(&signer_test.running_nodes.conf).burn_block_height
11114
- > info_before.burn_block_height,
11115
- )
11116
- },
11117
- )
11118
- .unwrap();
11066
+ signer_test.mine_bitcoin_block();
11119
11067
11120
11068
let info = signer_test.get_peer_info();
11121
11069
wait_for_state_machine_update_by_miner_tenure_id(
@@ -11853,17 +11801,7 @@ fn global_acceptance_depends_on_block_announcement() {
11853
11801
TEST_REJECT_ALL_BLOCK_PROPOSAL.set(Vec::new());
11854
11802
TEST_IGNORE_SIGNERS.set(false);
11855
11803
test_observer::clear();
11856
- next_block_and(
11857
- &signer_test.running_nodes.btc_regtest_controller,
11858
- 60,
11859
- || {
11860
- Ok(
11861
- get_chain_info(&signer_test.running_nodes.conf).burn_block_height
11862
- > info_before.burn_block_height,
11863
- )
11864
- },
11865
- )
11866
- .unwrap();
11804
+ signer_test.mine_bitcoin_block();
11867
11805
11868
11806
let info = get_chain_info(&signer_test.running_nodes.conf);
11869
11807
info!(
@@ -13167,16 +13105,8 @@ fn reorg_attempts_activity_timeout_exceeded() {
13167
13105
13168
13106
info!("------------------------- Start Tenure B -------------------------");
13169
13107
test_observer::clear();
13170
- let chain_before = get_chain_info(&signer_test.running_nodes.conf);
13171
- next_block_and(
13172
- &signer_test.running_nodes.btc_regtest_controller,
13173
- 60,
13174
- || {
13175
- let chain_info = get_chain_info(&signer_test.running_nodes.conf);
13176
- Ok(chain_info.burn_block_height > chain_before.burn_block_height)
13177
- },
13178
- )
13179
- .unwrap();
13108
+ let chain_before = chain_after;
13109
+ signer_test.mine_bitcoin_block();
13180
13110
let chain_after = get_chain_info(&signer_test.running_nodes.conf);
13181
13111
wait_for_state_machine_update_by_miner_tenure_id(
13182
13112
30,
@@ -13977,14 +13907,8 @@ fn disallow_reorg_within_first_proposal_burn_block_timing_secs_but_more_than_one
13977
13907
get_chain_info(&conf_1).stacks_tip_height,
13978
13908
block_n_height + 3
13979
13909
);
13980
- let burn_height_before = get_chain_info(&conf_1).burn_block_height;
13981
13910
info!("------------------------- Miner 1 Wins the Next Tenure, Mines N+1', got rejected -------------------------");
13982
- next_block_and(miners.btc_regtest_controller_mut(), 30, || {
13983
- let info = get_chain_info(&conf_1);
13984
- Ok(info.burn_block_height == burn_height_before + 1)
13985
- })
13986
- .expect("Failed to advance chain tip");
13987
-
13911
+ miners.signer_test.mine_bitcoin_block();
13988
13912
// assure we have a successful sortition that miner 1 won
13989
13913
verify_sortition_winner(&sortdb, &miner_pkh_1);
13990
13914
// wait for a block N+1' proposal from miner1
@@ -15503,6 +15427,7 @@ fn mark_miner_as_invalid_if_reorg_is_rejected_v1() {
15503
15427
15504
15428
info!("------------------------- Miner 1 Mines a Nakamoto Block N -------------------------");
15505
15429
let info_before = get_chain_info(&conf_1);
15430
+ // Because rl1 is not submitting commits, we cannot use mine_nakamoto_block (commit will never advance)
15506
15431
next_block_and(&miners.btc_regtest_controller_mut(), 30, || {
15507
15432
let chain_info = get_chain_info(&conf_1);
15508
15433
Ok(chain_info.stacks_tip_height > info_before.stacks_tip_height)
@@ -15532,12 +15457,7 @@ fn mark_miner_as_invalid_if_reorg_is_rejected_v1() {
15532
15457
fault_injection_stall_miner();
15533
15458
15534
15459
info!("------------------------- Mine 2 wins the Next Tenure -------------------------");
15535
- let info_before = info_after;
15536
- next_block_and(&miners.btc_regtest_controller_mut(), 30, || {
15537
- let chain_info = get_chain_info(&conf_1);
15538
- Ok(chain_info.burn_block_height > info_before.burn_block_height)
15539
- })
15540
- .expect("Failed to build BTC block");
15460
+ miners.signer_test.mine_bitcoin_block();
15541
15461
verify_sortition_winner(&sortdb, &miner_pkh_2);
15542
15462
miners.signer_test.check_signer_states_normal();
15543
15463
@@ -15559,12 +15479,7 @@ fn mark_miner_as_invalid_if_reorg_is_rejected_v1() {
15559
15479
15560
15480
info!("------------------------- Miner 1 Wins the Next Tenure, Mines N+1' -------------------------");
15561
15481
test_observer::clear();
15562
- let info_before = info_after;
15563
- next_block_and(&miners.btc_regtest_controller_mut(), 30, || {
15564
- let chain_info = get_chain_info(&conf_1);
15565
- Ok(chain_info.burn_block_height > info_before.burn_block_height)
15566
- })
15567
- .expect("Failed to build BTC block");
15482
+ miners.signer_test.mine_bitcoin_block();
15568
15483
15569
15484
let block_n_1_prime = wait_for_block_proposal(30, block_n_height + 1, &miner_pk_1)
15570
15485
.expect("Failed to get block proposal N+1'");
@@ -17174,16 +17089,7 @@ fn burn_block_height_behavior() {
17174
17089
skip_commit_op.set(true);
17175
17090
17176
17091
// Mine a regular tenure
17177
- let info_before = signer_test.get_peer_info();
17178
- next_block_and(
17179
- &signer_test.running_nodes.btc_regtest_controller,
17180
- 60,
17181
- || {
17182
- let chain_info = get_chain_info(&signer_test.running_nodes.conf);
17183
- Ok(chain_info.stacks_tip_height > info_before.stacks_tip_height)
17184
- },
17185
- )
17186
- .expect("Timed out waiting for block");
17092
+ signer_test.mine_nakamoto_block(Duration::from_secs(30), true);
17187
17093
17188
17094
let info = get_chain_info(&signer_test.running_nodes.conf);
17189
17095
let stacks_height_before = info.stacks_tip_height;
@@ -18302,14 +18208,9 @@ fn signer_loads_stackerdb_updates_on_startup() {
18302
18208
skip_commit_op_rl1.set(true);
18303
18209
18304
18210
info!("------------------------- Miner A Wins Tenure A -------------------------");
18305
- let info_before = get_chain_info(&conf_1);
18306
18211
// Let's not mine anything until we see consensus on new tenure start.
18307
18212
TEST_MINE_SKIP.set(true);
18308
- next_block_and(&miners.btc_regtest_controller_mut(), 60, || {
18309
- let info = get_chain_info(&conf_1);
18310
- Ok(info.burn_block_height > info_before.burn_block_height)
18311
- })
18312
- .unwrap();
18213
+ miners.signer_test.mine_bitcoin_block();
18313
18214
let chain_after = get_chain_info(&conf_1);
18314
18215
wait_for_state_machine_update_by_miner_tenure_id(
18315
18216
30,
@@ -18335,14 +18236,9 @@ fn signer_loads_stackerdb_updates_on_startup() {
18335
18236
18336
18237
info!("------------------------- Miner B Wins Tenure B -------------------------");
18337
18238
miners.submit_commit_miner_2(&sortdb);
18338
- let chain_before = get_chain_info(&conf_1);
18339
18239
// Let's not mine anything until we see consensus on new tenure start.
18340
18240
TEST_MINE_SKIP.set(true);
18341
- next_block_and(&miners.btc_regtest_controller_mut(), 60, || {
18342
- let info = get_chain_info(&conf_1);
18343
- Ok(info.burn_block_height > chain_before.burn_block_height)
18344
- })
18345
- .unwrap();
18241
+ miners.signer_test.mine_bitcoin_block();
18346
18242
let chain_after = get_chain_info(&conf_1);
18347
18243
wait_for_state_machine_update_by_miner_tenure_id(
18348
18244
30,
0 commit comments