@@ -1166,6 +1166,7 @@ pub fn wait_for_block_acceptance_from_signers(
1166
1166
/// with the provided signer signature hash
1167
1167
pub fn wait_for_block_rejections_from_signers (
1168
1168
timeout_secs : u64 ,
1169
+ signer_signature_hash : & Sha512Trunc256Sum ,
1169
1170
expected_signers : & [ StacksPublicKey ] ,
1170
1171
) -> Result < Vec < BlockRejection > , String > {
1171
1172
let mut result = Vec :: new ( ) ;
@@ -1182,7 +1183,9 @@ pub fn wait_for_block_rejections_from_signers(
1182
1183
let rejected_pubkey = rejection
1183
1184
. recover_public_key ( )
1184
1185
. expect ( "Failed to recover public key from rejection" ) ;
1185
- if expected_signers. contains ( & rejected_pubkey) {
1186
+ if rejection. signer_signature_hash == * signer_signature_hash
1187
+ && expected_signers. contains ( & rejected_pubkey)
1188
+ {
1186
1189
Some ( ( rejected_pubkey, rejection) )
1187
1190
} else {
1188
1191
None
@@ -5566,8 +5569,12 @@ fn locally_accepted_blocks_overriden_by_global_rejection() {
5566
5569
let proposed_block_n_1 =
5567
5570
wait_for_block_proposal ( 30 , info_before. stacks_tip_height + 1 , & miner_pk)
5568
5571
. expect ( "Timed out waiting for block N+1' to be proposed" ) ;
5569
- wait_for_block_rejections_from_signers ( short_timeout_secs, & rejecting_signers)
5570
- . expect ( "Timed out waiting for block rejection of N+1" ) ;
5572
+ wait_for_block_rejections_from_signers (
5573
+ short_timeout_secs,
5574
+ & proposed_block_n_1. header . signer_signature_hash ( ) ,
5575
+ & rejecting_signers,
5576
+ )
5577
+ . expect ( "Timed out waiting for block rejection of N+1" ) ;
5571
5578
let info_after = signer_test. get_peer_info ( ) ;
5572
5579
assert_eq ! ( info_before, info_after) ;
5573
5580
@@ -5707,12 +5714,17 @@ fn locally_rejected_blocks_overriden_by_global_acceptance() {
5707
5714
sender_nonce += 1 ;
5708
5715
info ! ( "Submitted tx {tx} in to mine block N+1" ) ;
5709
5716
// The rejecting signers will reject the block, but it will still be accepted globally
5710
- wait_for_block_rejections_from_signers ( short_timeout, & rejecting_signers)
5711
- . expect ( "Timed out waiting for block rejection of N+1" ) ;
5712
5717
let block_n_1 =
5713
5718
wait_for_block_pushed_by_miner_key ( 30 , info_before. stacks_tip_height + 1 , & miner_pk)
5714
5719
. expect ( "Timed out waiting for block N+1 to be mined" ) ;
5715
5720
5721
+ wait_for_block_rejections_from_signers (
5722
+ short_timeout,
5723
+ & block_n_1. header . signer_signature_hash ( ) ,
5724
+ & rejecting_signers,
5725
+ )
5726
+ . expect ( "Timed out waiting for block rejection of N+1" ) ;
5727
+
5716
5728
// Assert the block was mined and the tip advanced to N+1
5717
5729
let info_after = signer_test. get_peer_info ( ) ;
5718
5730
assert_eq ! ( info_after. stacks_tip, block_n_1. header. block_hash( ) ) ;
@@ -6062,8 +6074,14 @@ fn reorg_locally_accepted_blocks_across_tenures_fails() {
6062
6074
. running_nodes
6063
6075
. btc_regtest_controller
6064
6076
. build_next_block ( 1 ) ;
6065
- wait_for_block_rejections_from_signers ( 30 , & non_ignoring_signers)
6066
- . expect ( "Timed out waiting for block rejections of N+1" ) ;
6077
+ let proposal = wait_for_block_proposal ( 30 , info_before. stacks_tip_height + 1 , & miner_pk)
6078
+ . expect ( "Timed out waiting for block N+1 to be proposed" ) ;
6079
+ wait_for_block_rejections_from_signers (
6080
+ 30 ,
6081
+ & proposal. header . signer_signature_hash ( ) ,
6082
+ & non_ignoring_signers,
6083
+ )
6084
+ . expect ( "Timed out waiting for block rejections of N+1" ) ;
6067
6085
6068
6086
let info_after = signer_test. get_peer_info ( ) ;
6069
6087
// Ensure that the block was NOT accepted globally so the stacks tip has NOT advanced to N+1'
@@ -7167,7 +7185,8 @@ fn block_validation_check_rejection_timeout_heuristic() {
7167
7185
None ,
7168
7186
None ,
7169
7187
) ;
7170
-
7188
+ let miner_sk = signer_test. running_nodes . conf . miner . mining_key . unwrap ( ) ;
7189
+ let miner_pk = StacksPublicKey :: from_private ( & miner_sk) ;
7171
7190
let all_signers: Vec < _ > = signer_test
7172
7191
. signer_stacks_private_keys
7173
7192
. iter ( )
@@ -7179,6 +7198,7 @@ fn block_validation_check_rejection_timeout_heuristic() {
7179
7198
// note we just use mined nakamoto_blocks as the second block is not going to be confirmed
7180
7199
7181
7200
let mut test_rejections = |signer_split_index : usize , expected_timeout : u64 | {
7201
+ test_observer:: clear ( ) ;
7182
7202
let blocks_before = test_observer:: get_mined_nakamoto_blocks ( ) . len ( ) ;
7183
7203
let ( ignore_signers, reject_signers) = all_signers. split_at ( signer_split_index) ;
7184
7204
@@ -7187,14 +7207,23 @@ fn block_validation_check_rejection_timeout_heuristic() {
7187
7207
TEST_REJECT_ALL_BLOCK_PROPOSAL . set ( reject_signers. to_vec ( ) ) ;
7188
7208
TEST_IGNORE_ALL_BLOCK_PROPOSALS . set ( ignore_signers. to_vec ( ) ) ;
7189
7209
7210
+ let height_before = signer_test. get_peer_info ( ) . stacks_tip_height ;
7190
7211
next_block_and (
7191
7212
& mut signer_test. running_nodes . btc_regtest_controller ,
7192
7213
30 ,
7193
7214
|| Ok ( test_observer:: get_mined_nakamoto_blocks ( ) . len ( ) > blocks_before) ,
7194
7215
)
7195
7216
. unwrap ( ) ;
7196
7217
7197
- wait_for_block_rejections_from_signers ( timeout. as_secs ( ) , & reject_signers) . unwrap ( ) ;
7218
+ let proposal = wait_for_block_proposal ( 30 , height_before + 1 , & miner_pk)
7219
+ . expect ( "Timed out waiting for block proposal" ) ;
7220
+
7221
+ wait_for_block_rejections_from_signers (
7222
+ timeout. as_secs ( ) ,
7223
+ & proposal. header . signer_signature_hash ( ) ,
7224
+ & reject_signers,
7225
+ )
7226
+ . unwrap ( ) ;
7198
7227
7199
7228
wait_for ( 60 , || {
7200
7229
Ok ( signer_test
@@ -7381,7 +7410,7 @@ fn block_validation_pending_table() {
7381
7410
. iter ( )
7382
7411
. map ( |c| StacksPublicKey :: from_private ( & c. stacks_private_key ) )
7383
7412
. collect :: < Vec < _ > > ( ) ;
7384
- wait_for_block_rejections_from_signers ( 30 , & signer_keys)
7413
+ wait_for_block_rejections_from_signers ( 30 , & block . header . signer_signature_hash ( ) , & signer_keys)
7385
7414
. expect ( "Timed out waiting for block rejections" ) ;
7386
7415
7387
7416
info ! ( "------------------------- Shutdown -------------------------" ) ;
@@ -8607,7 +8636,7 @@ fn incoming_signers_ignore_block_proposals() {
8607
8636
signer_test. propose_block ( block, short_timeout) ;
8608
8637
// Verify the signers rejected the second block via the endpoint
8609
8638
signer_test. wait_for_validate_reject_response ( short_timeout, signer_signature_hash_2) ;
8610
- wait_for_block_rejections_from_signers ( 30 , & all_signers)
8639
+ wait_for_block_rejections_from_signers ( 30 , & signer_signature_hash_2 , & all_signers)
8611
8640
. expect ( "Timed out waiting for block rejections" ) ;
8612
8641
no_next_signer_messages ( ) ;
8613
8642
@@ -8625,7 +8654,7 @@ fn incoming_signers_ignore_block_proposals() {
8625
8654
///
8626
8655
/// Test Execution:
8627
8656
/// The node mines to the next reward cycle.
8628
- /// Sends a status request to the signers to ensure both the current and previous reward cycle signers are active.
8657
+ /// Sends a status request to the signers to ensure both the current and previoustimeout_heur reward cycle signers are active.
8629
8658
/// A valid Nakamoto block is proposed.
8630
8659
/// Two invalid Nakamoto blocks are proposed.
8631
8660
///
@@ -11617,10 +11646,10 @@ fn mark_miner_as_invalid_if_reorg_is_rejected() {
11617
11646
let signer_signature_hash = block_n_1_prime. header . signer_signature_hash ( ) ;
11618
11647
wait_for_block_acceptance_from_signers ( 30 , & signer_signature_hash, & approving_signers)
11619
11648
. expect ( "Timed out waiting for block acceptance from approving signers" ) ;
11620
- let rejections = wait_for_block_rejections_from_signers ( 30 , & rejecting_signers)
11621
- . expect ( "Timed out waiting for block rejection from rejecting signers" ) ;
11649
+ let rejections =
11650
+ wait_for_block_rejections_from_signers ( 30 , & signer_signature_hash, & rejecting_signers)
11651
+ . expect ( "Timed out waiting for block rejection from rejecting signers" ) ;
11622
11652
for rejection in rejections {
11623
- assert_eq ! ( rejection. signer_signature_hash, signer_signature_hash) ;
11624
11653
assert_eq ! (
11625
11654
rejection. response_data. reject_reason,
11626
11655
RejectReason :: ReorgNotAllowed ,
@@ -11638,10 +11667,10 @@ fn mark_miner_as_invalid_if_reorg_is_rejected() {
11638
11667
info ! ( "------------------------- Wait for 5 rejections -------------------------" ) ;
11639
11668
11640
11669
let signer_signature_hash = block_n_1_prime. header . signer_signature_hash ( ) ;
11641
- let rejections = wait_for_block_rejections_from_signers ( 30 , & all_signers)
11642
- . expect ( "Timed out waiting for block rejection from all signers" ) ;
11670
+ let rejections =
11671
+ wait_for_block_rejections_from_signers ( 30 , & signer_signature_hash, & all_signers)
11672
+ . expect ( "Timed out waiting for block rejection from all signers" ) ;
11643
11673
for rejection in rejections {
11644
- assert_eq ! ( rejection. signer_signature_hash, signer_signature_hash) ;
11645
11674
assert ! (
11646
11675
rejection. response_data. reject_reason == RejectReason :: ReorgNotAllowed
11647
11676
|| rejection. response_data. reject_reason == RejectReason :: InvalidMiner
0 commit comments