@@ -321,6 +321,7 @@ impl SignerTest<SpawnedSigner> {
321
321
// Verify that the signers signed the proposed block
322
322
let mut signer_index = 0 ;
323
323
let mut signature_index = 0 ;
324
+ let mut signing_keys = HashSet :: new ( ) ;
324
325
let validated = loop {
325
326
// Since we've already checked `signature.len()`, this means we've
326
327
// validated all the signatures in this loop
@@ -331,6 +332,9 @@ impl SignerTest<SpawnedSigner> {
331
332
error ! ( "Failed to validate the mined nakamoto block: ran out of signers to try to validate signatures" ) ;
332
333
break false ;
333
334
} ;
335
+ if !signing_keys. insert ( signer. signing_key ) {
336
+ panic ! ( "Duplicate signing key detected: {:?}" , signer. signing_key) ;
337
+ }
334
338
let stacks_public_key = Secp256k1PublicKey :: from_slice ( signer. signing_key . as_slice ( ) )
335
339
. expect ( "Failed to convert signing key to StacksPublicKey" ) ;
336
340
let valid = stacks_public_key
@@ -488,11 +492,7 @@ fn block_proposal_rejection() {
488
492
while !found_signer_signature_hash_1 && !found_signer_signature_hash_2 {
489
493
std:: thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
490
494
let chunks = test_observer:: get_stackerdb_chunks ( ) ;
491
- for chunk in chunks
492
- . into_iter ( )
493
- . map ( |chunk| chunk. modified_slots )
494
- . flatten ( )
495
- {
495
+ for chunk in chunks. into_iter ( ) . flat_map ( |chunk| chunk. modified_slots ) {
496
496
let Ok ( message) = SignerMessage :: consensus_deserialize ( & mut chunk. data . as_slice ( ) )
497
497
else {
498
498
continue ;
@@ -2982,6 +2982,13 @@ fn duplicate_signers() {
2982
2982
2983
2983
// First two signers have same private key
2984
2984
signer_stacks_private_keys[ 1 ] = signer_stacks_private_keys[ 0 ] ;
2985
+ let duplicate_pubkey = Secp256k1PublicKey :: from_private ( & signer_stacks_private_keys[ 0 ] ) ;
2986
+ let duplicate_pubkey_from_copy =
2987
+ Secp256k1PublicKey :: from_private ( & signer_stacks_private_keys[ 1 ] ) ;
2988
+ assert_eq ! (
2989
+ duplicate_pubkey, duplicate_pubkey_from_copy,
2990
+ "Recovered pubkeys don't match"
2991
+ ) ;
2985
2992
2986
2993
let mut signer_test: SignerTest < SpawnedSigner > = SignerTest :: new_with_config_modifications (
2987
2994
num_signers,
@@ -2992,37 +2999,13 @@ fn duplicate_signers() {
2992
2999
None ,
2993
3000
Some ( signer_stacks_private_keys) ,
2994
3001
) ;
2995
- let timeout = Duration :: from_secs ( 30 ) ;
2996
- let mined_blocks = signer_test. running_nodes . nakamoto_blocks_mined . clone ( ) ;
2997
- let blocks_mined_before = mined_blocks. load ( Ordering :: SeqCst ) ;
2998
3002
2999
3003
signer_test. boot_to_epoch_3 ( ) ;
3004
+ let timeout = Duration :: from_secs ( 30 ) ;
3000
3005
3001
- // give the system a chance to reach the Nakamoto start tip
3002
- // mine a Nakamoto block
3003
- wait_for ( 30 , || {
3004
- let blocks_mined = mined_blocks. load ( Ordering :: SeqCst ) ;
3005
- Ok ( blocks_mined > blocks_mined_before)
3006
- } )
3007
- . unwrap ( ) ;
3006
+ info ! ( "------------------------- Try mining one block -------------------------" ) ;
3008
3007
3009
- info ! ( "------------------------- Test Mine and Verify Confirmed Nakamoto Block -------------------------" ) ;
3010
3008
signer_test. mine_and_verify_confirmed_naka_block ( timeout, num_signers) ;
3011
3009
3012
- // Test prometheus metrics response
3013
- #[ cfg( feature = "monitoring_prom" ) ]
3014
- {
3015
- let metrics_response = signer_test. get_signer_metrics ( ) ;
3016
-
3017
- // Because 5 signers are running in the same process, the prometheus metrics
3018
- // are incremented once for every signer. This is why we expect the metric to be
3019
- // `5`, even though there is only one block proposed.
3020
- let expected_result = format ! ( "stacks_signer_block_proposals_received {}" , num_signers) ;
3021
- assert ! ( metrics_response. contains( & expected_result) ) ;
3022
- let expected_result = format ! (
3023
- "stacks_signer_block_responses_sent{{response_type=\" accepted\" }} {}" ,
3024
- num_signers
3025
- ) ;
3026
- assert ! ( metrics_response. contains( & expected_result) ) ;
3027
- }
3010
+ signer_test. shutdown ( ) ;
3028
3011
}
0 commit comments