@@ -15377,19 +15377,10 @@ fn bitcoin_reorg_extended_tenure() {
15377
15377
.expect("Timed out waiting for contract-call");
15378
15378
}
15379
15379
15380
- let tenure_0_stacks_height = get_chain_info(&conf_1).stacks_tip_height;
15381
15380
miners.pause_commits_miner_1();
15382
15381
miners
15383
15382
.mine_bitcoin_blocks_and_confirm(&sortdb, 1, 60)
15384
15383
.unwrap();
15385
- miners.signer_test.check_signer_states_normal();
15386
- let tip_sn = SortitionDB::get_canonical_burn_chain_tip(sortdb.conn()).unwrap();
15387
- assert_eq!(tip_sn.miner_pk_hash, Some(mining_pkh_1));
15388
-
15389
- wait_for(60, || {
15390
- Ok(get_chain_info(&conf_1).stacks_tip_height > tenure_0_stacks_height)
15391
- })
15392
- .expect("Timed out waiting for Miner 1 to mine the first block of Tenure 1");
15393
15384
15394
15385
for _ in 0..2 {
15395
15386
miners
@@ -15398,6 +15389,10 @@ fn bitcoin_reorg_extended_tenure() {
15398
15389
.expect("Timed out waiting for contract-call");
15399
15390
}
15400
15391
15392
+ miners.signer_test.check_signer_states_normal();
15393
+ let tip_sn = SortitionDB::get_canonical_burn_chain_tip(sortdb.conn()).unwrap();
15394
+ assert_eq!(tip_sn.miner_pk_hash, Some(mining_pkh_1));
15395
+
15401
15396
let last_active_sortition = get_sortition_info(&conf_1);
15402
15397
assert!(last_active_sortition.was_sortition);
15403
15398
@@ -15456,20 +15451,37 @@ fn bitcoin_reorg_extended_tenure() {
15456
15451
info!("Bitcoin fork triggered"; "ch" => %before_fork, "btc_height" => burn_block_height);
15457
15452
info!("Chain info before fork: {:?}", get_chain_info(&conf_1));
15458
15453
15454
+ let mut after_fork = get_chain_info(&conf_1).pox_consensus;
15459
15455
wait_for(60, || {
15460
- let after_fork = get_chain_info(&conf_1).pox_consensus;
15456
+ after_fork = get_chain_info(&conf_1).pox_consensus;
15461
15457
Ok(after_fork != before_fork)
15462
15458
})
15463
15459
.unwrap();
15464
15460
15465
15461
info!("Chain info after fork: {:?}", get_chain_info(&conf_1));
15466
15462
15463
+ // get at least one block produced before we stall broadcasts
15464
+ // to check signer approvals
15467
15465
miners
15468
15466
.signer_test
15469
15467
.submit_burn_block_call_and_wait(&miners.sender_sk)
15470
15468
.expect("Timed out waiting for contract-call");
15471
15469
15472
- let latest = get_chain_info(&conf_1);
15470
+ // stall p2p broadcast and signer block announcements
15471
+ // so that we can ensure all the signers approve the proposal
15472
+ // before it gets accepted by stacks-nodes
15473
+ TEST_P2P_BROADCAST_STALL.set(true);
15474
+ stacks_signer::v0::tests::TEST_SKIP_BLOCK_BROADCAST.set(true);
15475
+
15476
+ // the signer signature hash is the same as the block header hash.
15477
+ // we use the latest_signer_sighash to make sure we're getting block responses for the
15478
+ // block we expect to be mined after the next contract call is submitted.
15479
+ let latest_signer_sighash = Sha512Trunc256Sum(get_chain_info(&conf_1).stacks_tip.0);
15480
+
15481
+ miners
15482
+ .signer_test
15483
+ .submit_contract_call(&miners.sender_sk, "burn-height-local", "run-update", &[])
15484
+ .unwrap();
15473
15485
15474
15486
let rc = miners.signer_test.get_current_reward_cycle();
15475
15487
let slot_ids = miners.signer_test.get_signer_indices(rc);
@@ -15479,21 +15491,39 @@ fn bitcoin_reorg_extended_tenure() {
15479
15491
.iter()
15480
15492
.filter_map(|slot_id| {
15481
15493
let latest_br = miners.signer_test.get_latest_block_response(slot_id.0);
15482
- if latest_br.get_signer_signature_hash().0 == latest.stacks_tip.0 {
15494
+ if latest_br.get_signer_signature_hash() != latest_signer_sighash {
15483
15495
Some(latest_br)
15484
15496
} else {
15485
15497
None
15486
15498
}
15487
15499
})
15488
15500
.collect();
15489
- Ok(block_responses.len() == num_signers)
15501
+ let Some(sighash) = block_responses
15502
+ .first()
15503
+ .map(BlockResponse::get_signer_signature_hash)
15504
+ else {
15505
+ return Ok(false);
15506
+ };
15507
+ let all_same_block = block_responses
15508
+ .iter()
15509
+ .all(|x| x.get_signer_signature_hash() == sighash);
15510
+ let all_responded = block_responses.len() == num_signers;
15511
+ Ok(all_same_block && all_responded)
15490
15512
})
15491
15513
.unwrap();
15492
15514
15493
15515
assert!(block_responses
15494
15516
.iter()
15495
15517
.all(|resp| resp.as_block_accepted().is_some()));
15496
15518
15519
+ TEST_P2P_BROADCAST_STALL.set(false);
15520
+ stacks_signer::v0::tests::TEST_SKIP_BLOCK_BROADCAST.set(false);
15521
+
15522
+ miners
15523
+ .signer_test
15524
+ .submit_burn_block_call_and_wait(&miners.sender_sk)
15525
+ .expect("Timed out waiting for contract-call");
15526
+
15497
15527
miners.submit_commit_miner_1(&sortdb);
15498
15528
miners
15499
15529
.mine_bitcoin_blocks_and_confirm(&sortdb, 1, 60)
0 commit comments