@@ -398,6 +398,10 @@ impl SignerTest<SpawnedSigner> {
398
398
}
399
399
}
400
400
401
+ fn get_miner_key ( & self ) -> & Secp256k1PrivateKey {
402
+ self . running_nodes . conf . miner . mining_key . as_ref ( ) . unwrap ( )
403
+ }
404
+
401
405
/// Propose a block to the signers
402
406
fn propose_block ( & mut self , block : NakamotoBlock , timeout : Duration ) {
403
407
let miners_contract_id = boot_code_id ( MINERS_NAME , false ) ;
@@ -409,6 +413,9 @@ impl SignerTest<SpawnedSigner> {
409
413
. get_headers_height ( ) ;
410
414
let reward_cycle = self . get_current_reward_cycle ( ) ;
411
415
let signer_signature_hash = block. header . signer_signature_hash ( ) ;
416
+ let signed_by = block. header . recover_miner_pk ( ) . expect (
417
+ "FATAL: signer tests should only propose blocks that have been signed by the signer test miner. Otherwise, signers won't even consider them via this channel."
418
+ ) ;
412
419
let message = SignerMessage :: BlockProposal ( BlockProposal {
413
420
block,
414
421
burn_height,
@@ -421,6 +428,9 @@ impl SignerTest<SpawnedSigner> {
421
428
. miner
422
429
. mining_key
423
430
. expect ( "No mining key" ) ;
431
+ assert_eq ! ( signed_by, Secp256k1PublicKey :: from_private( & miner_sk) ,
432
+ "signer tests should only propose blocks that have been signed by the signer test miner. Otherwise, signers won't even consider them via this channel." ) ;
433
+
424
434
// Submit the block proposal to the miner's slot
425
435
let mut accepted = false ;
426
436
let mut version = 0 ;
@@ -1258,6 +1268,10 @@ fn block_proposal_rejection() {
1258
1268
1259
1269
// First propose a block to the signers that does not have the correct consensus hash or BitVec. This should be rejected BEFORE
1260
1270
// the block is submitted to the node for validation.
1271
+ block
1272
+ . header
1273
+ . sign_miner ( signer_test. get_miner_key ( ) )
1274
+ . unwrap ( ) ;
1261
1275
let block_signer_signature_hash_1 = block. header . signer_signature_hash ( ) ;
1262
1276
signer_test. propose_block ( block. clone ( ) , short_timeout) ;
1263
1277
@@ -1270,6 +1284,10 @@ fn block_proposal_rejection() {
1270
1284
block. header . consensus_hash = view. cur_sortition . consensus_hash ;
1271
1285
block. header . chain_length = 35 ; // We have mined 35 blocks so far.
1272
1286
1287
+ block
1288
+ . header
1289
+ . sign_miner ( signer_test. get_miner_key ( ) )
1290
+ . unwrap ( ) ;
1273
1291
let block_signer_signature_hash_2 = block. header . signer_signature_hash ( ) ;
1274
1292
signer_test. propose_block ( block, short_timeout) ;
1275
1293
@@ -7193,6 +7211,10 @@ fn block_validation_response_timeout() {
7193
7211
block. header . consensus_hash = view. cur_sortition . consensus_hash ;
7194
7212
block. header . chain_length = info_before. stacks_tip_height + 1 ;
7195
7213
7214
+ block
7215
+ . header
7216
+ . sign_miner ( signer_test. get_miner_key ( ) )
7217
+ . unwrap ( ) ;
7196
7218
let block_signer_signature_hash_1 = block. header . signer_signature_hash ( ) ;
7197
7219
signer_test. propose_block ( block, timeout) ;
7198
7220
@@ -7478,6 +7500,10 @@ fn block_validation_pending_table() {
7478
7500
block. header . pox_treatment = BitVec :: ones ( 1 ) . unwrap ( ) ;
7479
7501
block. header . consensus_hash = view. cur_sortition . consensus_hash ;
7480
7502
block. header . chain_length = peer_info. stacks_tip_height + 1 ;
7503
+ block
7504
+ . header
7505
+ . sign_miner ( signer_test. get_miner_key ( ) )
7506
+ . unwrap ( ) ;
7481
7507
let block_signer_signature_hash = block. header . signer_signature_hash ( ) ;
7482
7508
signer_test. propose_block ( block. clone ( ) , short_timeout) ;
7483
7509
@@ -8135,11 +8161,19 @@ fn block_proposal_max_age_rejections() {
8135
8161
. block_proposal_max_age_secs
8136
8162
. saturating_add ( 1 ) ,
8137
8163
) ;
8164
+ block
8165
+ . header
8166
+ . sign_miner ( signer_test. get_miner_key ( ) )
8167
+ . unwrap ( ) ;
8138
8168
let block_signer_signature_hash_1 = block. header . signer_signature_hash ( ) ;
8139
8169
signer_test. propose_block ( block. clone ( ) , short_timeout) ;
8140
8170
8141
8171
// Next propose a recent invalid block
8142
8172
block. header . timestamp = get_epoch_time_secs ( ) ;
8173
+ block
8174
+ . header
8175
+ . sign_miner ( signer_test. get_miner_key ( ) )
8176
+ . unwrap ( ) ;
8143
8177
let block_signer_signature_hash_2 = block. header . signer_signature_hash ( ) ;
8144
8178
signer_test. propose_block ( block, short_timeout) ;
8145
8179
@@ -8740,6 +8774,10 @@ fn incoming_signers_ignore_block_proposals() {
8740
8774
txs : vec ! [ ] ,
8741
8775
} ;
8742
8776
block. header . timestamp = get_epoch_time_secs ( ) ;
8777
+ block
8778
+ . header
8779
+ . sign_miner ( signer_test. get_miner_key ( ) )
8780
+ . unwrap ( ) ;
8743
8781
let signer_signature_hash_1 = block. header . signer_signature_hash ( ) ;
8744
8782
8745
8783
info ! ( "------------------------- Test Attempt to Mine Invalid Block {signer_signature_hash_1} -------------------------" ) ;
@@ -8758,6 +8796,10 @@ fn incoming_signers_ignore_block_proposals() {
8758
8796
block. header . consensus_hash = view. cur_sortition . consensus_hash ;
8759
8797
block. header . chain_length =
8760
8798
get_chain_info ( & signer_test. running_nodes . conf ) . stacks_tip_height + 1 ;
8799
+ block
8800
+ . header
8801
+ . sign_miner ( signer_test. get_miner_key ( ) )
8802
+ . unwrap ( ) ;
8761
8803
let signer_signature_hash_2 = block. header . signer_signature_hash ( ) ;
8762
8804
8763
8805
info ! ( "------------------------- Test Attempt to Mine Invalid Block {signer_signature_hash_2} -------------------------" ) ;
@@ -8926,6 +8968,10 @@ fn outgoing_signers_ignore_block_proposals() {
8926
8968
block. header . consensus_hash = view. cur_sortition . consensus_hash ;
8927
8969
block. header . chain_length =
8928
8970
get_chain_info ( & signer_test. running_nodes . conf ) . stacks_tip_height + 1 ;
8971
+ block
8972
+ . header
8973
+ . sign_miner ( signer_test. get_miner_key ( ) )
8974
+ . unwrap ( ) ;
8929
8975
let signer_signature_hash = block. header . signer_signature_hash ( ) ;
8930
8976
8931
8977
info ! ( "------------------------- Test Attempt to Mine Invalid Block {signer_signature_hash} -------------------------" ) ;
0 commit comments