@@ -1024,6 +1024,18 @@ pub fn boot_to_epoch_3_reward_set(
1024
1024
info ! ( "Bootstrapped to Epoch 3.0 reward set calculation height: {epoch_3_reward_set_calculation}." ) ;
1025
1025
}
1026
1026
1027
+ /// Wait for a block commit, without producing a block
1028
+ fn wait_for_first_naka_block_commit ( timeout_secs : u64 , naka_commits_submitted : & Arc < AtomicU64 > ) {
1029
+ let start = Instant :: now ( ) ;
1030
+ while naka_commits_submitted. load ( Ordering :: SeqCst ) < 1 {
1031
+ if start. elapsed ( ) > Duration :: from_secs ( timeout_secs) {
1032
+ error ! ( "Timed out waiting for block commit" ) ;
1033
+ panic ! ( ) ;
1034
+ }
1035
+ thread:: sleep ( Duration :: from_millis ( 100 ) ) ;
1036
+ }
1037
+ }
1038
+
1027
1039
#[ test]
1028
1040
#[ ignore]
1029
1041
/// This test spins up a nakamoto-neon node.
@@ -1134,12 +1146,7 @@ fn simple_neon_integration() {
1134
1146
info ! ( "Nakamoto miner started..." ) ;
1135
1147
blind_signer ( & naka_conf, & signers, proposals_submitted) ;
1136
1148
1137
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
1138
- next_block_and ( & mut btc_regtest_controller, 60 , || {
1139
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
1140
- Ok ( commits_count >= 1 )
1141
- } )
1142
- . unwrap ( ) ;
1149
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
1143
1150
1144
1151
// Mine 15 nakamoto tenures
1145
1152
for _i in 0 ..15 {
@@ -1232,6 +1239,10 @@ fn simple_neon_integration() {
1232
1239
assert ! ( tip. anchored_header. as_stacks_nakamoto( ) . is_some( ) ) ;
1233
1240
assert ! ( tip. stacks_block_height >= block_height_pre_3_0 + 30 ) ;
1234
1241
1242
+ // Check that we aren't missing burn blocks
1243
+ let bhh = u64:: from ( tip. burn_header_height ) ;
1244
+ test_observer:: contains_burn_block_range ( 220 ..=bhh) . unwrap ( ) ;
1245
+
1235
1246
// make sure prometheus returns an updated height
1236
1247
#[ cfg( feature = "monitoring_prom" ) ]
1237
1248
{
@@ -1355,12 +1366,7 @@ fn mine_multiple_per_tenure_integration() {
1355
1366
info ! ( "Nakamoto miner started..." ) ;
1356
1367
blind_signer ( & naka_conf, & signers, proposals_submitted) ;
1357
1368
1358
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
1359
- next_block_and ( & mut btc_regtest_controller, 60 , || {
1360
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
1361
- Ok ( commits_count >= 1 )
1362
- } )
1363
- . unwrap ( ) ;
1369
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
1364
1370
1365
1371
// Mine `tenure_count` nakamoto tenures
1366
1372
for tenure_ix in 0 ..tenure_count {
@@ -1672,12 +1678,7 @@ fn correct_burn_outs() {
1672
1678
) ;
1673
1679
assert_eq ! ( stacker_response. stacker_set. rewarded_addresses. len( ) , 1 ) ;
1674
1680
1675
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
1676
- next_block_and ( & mut btc_regtest_controller, 60 , || {
1677
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
1678
- Ok ( commits_count >= 1 )
1679
- } )
1680
- . unwrap ( ) ;
1681
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
1681
1682
1682
1683
info ! ( "Bootstrapped to Epoch-3.0 boundary, mining nakamoto blocks" ) ;
1683
1684
@@ -1874,12 +1875,7 @@ fn block_proposal_api_endpoint() {
1874
1875
1875
1876
info ! ( "Nakamoto miner started..." ) ;
1876
1877
1877
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
1878
- next_block_and ( & mut btc_regtest_controller, 60 , || {
1879
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
1880
- Ok ( commits_count >= 1 )
1881
- } )
1882
- . unwrap ( ) ;
1878
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
1883
1879
1884
1880
// Mine 3 nakamoto tenures
1885
1881
for _ in 0 ..3 {
@@ -2218,12 +2214,7 @@ fn miner_writes_proposed_block_to_stackerdb() {
2218
2214
info ! ( "Nakamoto miner started..." ) ;
2219
2215
blind_signer ( & naka_conf, & signers, proposals_submitted) ;
2220
2216
2221
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
2222
- next_block_and ( & mut btc_regtest_controller, 60 , || {
2223
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
2224
- Ok ( commits_count >= 1 )
2225
- } )
2226
- . unwrap ( ) ;
2217
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
2227
2218
2228
2219
// Mine 1 nakamoto tenure
2229
2220
next_block_and_mine_commit (
@@ -2353,12 +2344,7 @@ fn vote_for_aggregate_key_burn_op() {
2353
2344
info ! ( "Nakamoto miner started..." ) ;
2354
2345
blind_signer ( & naka_conf, & signers, proposals_submitted) ;
2355
2346
2356
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
2357
- next_block_and ( & mut btc_regtest_controller, 60 , || {
2358
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
2359
- Ok ( commits_count >= 1 )
2360
- } )
2361
- . unwrap ( ) ;
2347
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
2362
2348
2363
2349
// submit a pre-stx op
2364
2350
let mut miner_signer = Keychain :: default ( naka_conf. node . seed . clone ( ) ) . generate_op_signer ( ) ;
@@ -2612,12 +2598,7 @@ fn follower_bootup() {
2612
2598
info ! ( "Nakamoto miner started..." ) ;
2613
2599
blind_signer ( & naka_conf, & signers, proposals_submitted) ;
2614
2600
2615
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
2616
- next_block_and ( & mut btc_regtest_controller, 60 , || {
2617
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
2618
- Ok ( commits_count >= 1 )
2619
- } )
2620
- . unwrap ( ) ;
2601
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
2621
2602
2622
2603
let mut follower_conf = naka_conf. clone ( ) ;
2623
2604
follower_conf. events_observers . clear ( ) ;
@@ -2916,12 +2897,7 @@ fn stack_stx_burn_op_integration_test() {
2916
2897
info ! ( "Nakamoto miner started..." ) ;
2917
2898
blind_signer ( & naka_conf, & signers, proposals_submitted) ;
2918
2899
2919
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
2920
- next_block_and ( & mut btc_regtest_controller, 60 , || {
2921
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
2922
- Ok ( commits_count >= 1 )
2923
- } )
2924
- . unwrap ( ) ;
2900
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
2925
2901
2926
2902
let block_height = btc_regtest_controller. get_headers_height ( ) ;
2927
2903
@@ -3360,12 +3336,7 @@ fn forked_tenure_is_ignored() {
3360
3336
blind_signer ( & naka_conf, & signers, proposals_submitted) ;
3361
3337
3362
3338
info ! ( "Starting tenure A." ) ;
3363
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
3364
- next_block_and ( & mut btc_regtest_controller, 60 , || {
3365
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
3366
- Ok ( commits_count >= 1 )
3367
- } )
3368
- . unwrap ( ) ;
3339
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
3369
3340
3370
3341
// In the next block, the miner should win the tenure and submit a stacks block
3371
3342
let commits_before = commits_submitted. load ( Ordering :: SeqCst ) ;
@@ -3662,12 +3633,7 @@ fn check_block_heights() {
3662
3633
let preheights = heights0_value. expect_tuple ( ) . unwrap ( ) ;
3663
3634
info ! ( "Heights from pre-epoch 3.0: {}" , preheights) ;
3664
3635
3665
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
3666
- next_block_and ( & mut btc_regtest_controller, 60 , || {
3667
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
3668
- Ok ( commits_count >= 1 )
3669
- } )
3670
- . unwrap ( ) ;
3636
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
3671
3637
3672
3638
let info = get_chain_info_result ( & naka_conf) . unwrap ( ) ;
3673
3639
info ! ( "Chain info: {:?}" , info) ;
@@ -4051,12 +4017,7 @@ fn nakamoto_attempt_time() {
4051
4017
4052
4018
info ! ( "Nakamoto miner started..." ) ;
4053
4019
4054
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
4055
- next_block_and ( & mut btc_regtest_controller, 60 , || {
4056
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
4057
- Ok ( commits_count >= 1 )
4058
- } )
4059
- . unwrap ( ) ;
4020
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
4060
4021
4061
4022
// Mine 3 nakamoto tenures
4062
4023
for _ in 0 ..3 {
@@ -4340,12 +4301,7 @@ fn clarity_burn_state() {
4340
4301
info ! ( "Nakamoto miner started..." ) ;
4341
4302
blind_signer ( & naka_conf, & signers, proposals_submitted) ;
4342
4303
4343
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
4344
- next_block_and ( & mut btc_regtest_controller, 60 , || {
4345
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
4346
- Ok ( commits_count >= 1 )
4347
- } )
4348
- . unwrap ( ) ;
4304
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
4349
4305
4350
4306
let mut sender_nonce = 0 ;
4351
4307
@@ -4624,12 +4580,7 @@ fn signer_chainstate() {
4624
4580
false ,
4625
4581
) ;
4626
4582
4627
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
4628
- next_block_and ( & mut btc_regtest_controller, 60 , || {
4629
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
4630
- Ok ( commits_count >= 1 )
4631
- } )
4632
- . unwrap ( ) ;
4583
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
4633
4584
4634
4585
let mut signer_db =
4635
4586
SignerDb :: new ( format ! ( "{}/signer_db_path" , naka_conf. node. working_dir) ) . unwrap ( ) ;
@@ -5155,12 +5106,7 @@ fn continue_tenure_extend() {
5155
5106
info ! ( "Nakamoto miner started..." ) ;
5156
5107
blind_signer ( & naka_conf, & signers, proposals_submitted) ;
5157
5108
5158
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
5159
- next_block_and ( & mut btc_regtest_controller, 60 , || {
5160
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
5161
- Ok ( commits_count >= 1 )
5162
- } )
5163
- . unwrap ( ) ;
5109
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
5164
5110
5165
5111
// Mine a regular nakamoto tenure
5166
5112
next_block_and_mine_commit (
@@ -5443,12 +5389,7 @@ fn check_block_times() {
5443
5389
. unwrap ( ) ;
5444
5390
info ! ( "Time from pre-epoch 3.0: {}" , time0) ;
5445
5391
5446
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
5447
- next_block_and ( & mut btc_regtest_controller, 60 , || {
5448
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
5449
- Ok ( commits_count >= 1 )
5450
- } )
5451
- . unwrap ( ) ;
5392
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
5452
5393
5453
5394
// This version uses the Clarity 1 / 2 function
5454
5395
let contract1_name = "test-contract-1" ;
@@ -5928,12 +5869,7 @@ fn check_block_info() {
5928
5869
let tuple0 = result0. expect_tuple ( ) . unwrap ( ) . data_map ;
5929
5870
info ! ( "Info from pre-epoch 3.0: {:?}" , tuple0) ;
5930
5871
5931
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
5932
- next_block_and ( & mut btc_regtest_controller, 60 , || {
5933
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
5934
- Ok ( commits_count >= 1 )
5935
- } )
5936
- . unwrap ( ) ;
5872
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
5937
5873
5938
5874
// This version uses the Clarity 1 / 2 function
5939
5875
let contract1_name = "test-contract-1" ;
@@ -6436,12 +6372,7 @@ fn check_block_info_rewards() {
6436
6372
let tuple0 = result0. expect_tuple ( ) . unwrap ( ) . data_map ;
6437
6373
info ! ( "Info from pre-epoch 3.0: {:?}" , tuple0) ;
6438
6374
6439
- // Wait one block to confirm the VRF register, wait until a block commit is submitted
6440
- next_block_and ( & mut btc_regtest_controller, 60 , || {
6441
- let commits_count = commits_submitted. load ( Ordering :: SeqCst ) ;
6442
- Ok ( commits_count >= 1 )
6443
- } )
6444
- . unwrap ( ) ;
6375
+ wait_for_first_naka_block_commit ( 60 , & commits_submitted) ;
6445
6376
6446
6377
// This version uses the Clarity 1 / 2 function
6447
6378
let contract1_name = "test-contract-1" ;
0 commit comments