@@ -43,7 +43,7 @@ use stacks::net::api::postblock_proposal::{ValidateRejectCode, TEST_VALIDATE_STA
43
43
use stacks:: net:: relay:: fault_injection:: set_ignore_block;
44
44
use stacks:: types:: chainstate:: { StacksAddress , StacksBlockId , StacksPrivateKey , StacksPublicKey } ;
45
45
use stacks:: types:: PublicKey ;
46
- use stacks:: util:: hash:: { hex_bytes, MerkleHashFunc } ;
46
+ use stacks:: util:: hash:: { hex_bytes, Hash160 , MerkleHashFunc } ;
47
47
use stacks:: util:: secp256k1:: { Secp256k1PrivateKey , Secp256k1PublicKey } ;
48
48
use stacks:: util_lib:: boot:: boot_code_id;
49
49
use stacks:: util_lib:: signed_structured_data:: pox4:: {
@@ -5023,11 +5023,14 @@ fn miner_recovers_when_broadcast_block_delay_across_tenures_occurs() {
5023
5023
/// Miner 1 wins the first Nakamoto tenure A. Miner 1 mines a regular stacks block N.
5024
5024
/// Miner 2 wins the second Nakamoto tenure B and proposes block N+1, but it is rejected by the signers.
5025
5025
/// An empty burn block is mined
5026
- /// TODO: which behaviour do we want to enforce? Should we allow both? If so, we should force both explicitly
5027
- /// Miner 1 should issue a tenure extend and propose block N+1' which is accepted by the signers OR
5028
- /// Miner 2 should issue a new TenureChangePayload followed by a TenureExtend.
5026
+ /// Miner 2 issue a new TenureChangePayload in block N+1'
5027
+ /// Signers accept the new TenureChangePayload and the stacks tip should advance to N+1'
5028
+ /// Miner 2 issue a TenureExtend in block proposal N+2'
5029
+ /// Signers accept the TenureExtend and the stacks tip should advance to N+2'
5029
5030
/// Asserts:
5030
- /// - The stacks tip advances to N+1'
5031
+ /// - Block N+1' contains the TenureChangePayload
5032
+ /// - Block N+2 contains the TenureExtend
5033
+ /// - The stacks tip advances to N+2'
5031
5034
#[ test]
5032
5035
#[ ignore]
5033
5036
fn continue_after_fast_block_no_sortition ( ) {
@@ -5152,6 +5155,9 @@ fn continue_after_fast_block_no_sortition() {
5152
5155
5153
5156
// Make sure Miner 2 cannot win a sortition at first.
5154
5157
rl2_skip_commit_op. set ( true ) ;
5158
+
5159
+ info ! ( "------------------------- Boot to Epoch 3.0 -------------------------" ) ;
5160
+
5155
5161
let run_loop_2_thread = thread:: Builder :: new ( )
5156
5162
. name ( "run_loop_2" . into ( ) )
5157
5163
. spawn ( move || run_loop_2. start ( None , 0 ) )
@@ -5170,6 +5176,11 @@ fn continue_after_fast_block_no_sortition() {
5170
5176
} )
5171
5177
. expect ( "Timed out waiting for boostrapped node to catch up to the miner" ) ;
5172
5178
5179
+ let mining_pkh_1 = Hash160 :: from_node_public_key ( & StacksPublicKey :: from_private ( & conf. miner . mining_key . unwrap ( ) ) ) ;
5180
+ let mining_pkh_2 = Hash160 :: from_node_public_key ( & StacksPublicKey :: from_private ( & conf_node_2. miner . mining_key . unwrap ( ) ) ) ;
5181
+ debug ! ( "The miner key for miner 1 is {mining_pkh_1}" ) ;
5182
+ debug ! ( "The miner key for miner 2 is {mining_pkh_2}" ) ;
5183
+
5173
5184
info ! ( "------------------------- Reached Epoch 3.0 -------------------------" ) ;
5174
5185
5175
5186
let burnchain = signer_test. running_nodes . conf . get_burnchain ( ) ;
@@ -5189,15 +5200,22 @@ fn continue_after_fast_block_no_sortition() {
5189
5200
let starting_burn_height = get_burn_height ( ) ;
5190
5201
let mut btc_blocks_mined = 0 ;
5191
5202
5192
- info ! ( "------------------------- Miner 1 Mines a Normal Tenure A -------------------------" ) ;
5193
- let blocks_processed_before_1 = blocks_mined1. load ( Ordering :: SeqCst ) ;
5194
5203
info ! ( "------------------------- Pause Miner 1's Block Commit -------------------------" ) ;
5195
- // Make sure miner 1 doesn't submit a block commit for the next tenure BEFORE mining the bitcoin block
5204
+ // Make sure miner 1 doesn't submit any further block commits for the next tenure BEFORE mining the bitcoin block
5196
5205
signer_test
5197
5206
. running_nodes
5198
5207
. nakamoto_test_skip_commit_op
5199
5208
. set ( true ) ;
5200
5209
5210
+ info ! ( "------------------------- Miner 1 Mines a Normal Tenure A -------------------------" ) ;
5211
+ let blocks_processed_before_1 = blocks_mined1. load ( Ordering :: SeqCst ) ;
5212
+
5213
+ let stacks_height_before = signer_test
5214
+ . stacks_client
5215
+ . get_peer_info ( )
5216
+ . expect ( "Failed to get peer info" )
5217
+ . stacks_tip_height ;
5218
+
5201
5219
signer_test
5202
5220
. running_nodes
5203
5221
. btc_regtest_controller
@@ -5210,7 +5228,12 @@ fn continue_after_fast_block_no_sortition() {
5210
5228
5211
5229
// wait for the new block to be processed
5212
5230
wait_for ( 60 , || {
5213
- Ok ( blocks_mined1. load ( Ordering :: SeqCst ) > blocks_processed_before_1)
5231
+ let stacks_height = signer_test
5232
+ . stacks_client
5233
+ . get_peer_info ( )
5234
+ . expect ( "Failed to get peer info" )
5235
+ . stacks_tip_height ;
5236
+ Ok ( blocks_mined1. load ( Ordering :: SeqCst ) > blocks_processed_before_1 && stacks_height > stacks_height_before)
5214
5237
} )
5215
5238
. unwrap ( ) ;
5216
5239
@@ -5219,21 +5242,22 @@ fn continue_after_fast_block_no_sortition() {
5219
5242
blocks_mined1. load( Ordering :: SeqCst )
5220
5243
) ;
5221
5244
5245
+ info ! ( "------------------------- Make Signers Reject All Subsequent Proposals -------------------------" ) ;
5246
+
5222
5247
let stacks_height_before = signer_test
5223
5248
. stacks_client
5224
5249
. get_peer_info ( )
5225
5250
. expect ( "Failed to get peer info" )
5226
5251
. stacks_tip_height ;
5227
5252
5228
- info ! ( "------------------------- Make Signers Reject All Subsequent Proposals -------------------------" ) ;
5229
5253
// Make all signers ignore block proposals
5230
5254
let ignoring_signers = all_signers. to_vec ( ) ;
5231
5255
TEST_REJECT_ALL_BLOCK_PROPOSAL
5232
5256
. lock ( )
5233
5257
. unwrap ( )
5234
5258
. replace ( ignoring_signers. clone ( ) ) ;
5235
5259
5236
- info ! ( "------------------------- Unpause Miner 2's Block Commits -------------------------" ) ;
5260
+ info ! ( "------------------------- Submit Miner 2 Block Commit -------------------------" ) ;
5237
5261
let rejections_before = signer_test
5238
5262
. running_nodes
5239
5263
. nakamoto_blocks_rejected
@@ -5243,7 +5267,6 @@ fn continue_after_fast_block_no_sortition() {
5243
5267
// Unpause miner 2's block commits
5244
5268
rl2_skip_commit_op. set ( false ) ;
5245
5269
5246
- info ! ( "------------------------- Wait for Miner 2's Block Commit Submission -------------------------" ) ;
5247
5270
// Ensure the miner 2 submits a block commit before mining the bitcoin block
5248
5271
wait_for ( 30 , || {
5249
5272
Ok ( rl2_commits. load ( Ordering :: SeqCst ) > rl2_commits_before)
@@ -5337,7 +5360,7 @@ fn continue_after_fast_block_no_sortition() {
5337
5360
let stacks_height_before = stacks_height;
5338
5361
5339
5362
let blocks_processed_before_2 = blocks_mined2. load ( Ordering :: SeqCst ) ;
5340
- info ! ( "----- Enabling signers to approve proposals -----" ;
5363
+ info ! ( "------------------------- Enabling signers to approve proposals -------------------- -----" ;
5341
5364
"stacks_height" => stacks_height_before,
5342
5365
) ;
5343
5366
@@ -5348,6 +5371,7 @@ fn continue_after_fast_block_no_sortition() {
5348
5371
. unwrap ( )
5349
5372
. replace ( Vec :: new ( ) ) ;
5350
5373
5374
+ info ! ( "------------------------- Mining Interim Block -------------------------" ) ;
5351
5375
// submit a tx so that the miner will mine an extra block just in case due to timing constraints, the first block with the tenure extend was
5352
5376
// rejected already by the signers
5353
5377
let transfer_tx = make_stacks_transfer (
@@ -5383,6 +5407,10 @@ fn continue_after_fast_block_no_sortition() {
5383
5407
)
5384
5408
. expect ( "Timed out waiting for test observer to see new block" ) ;
5385
5409
5410
+ info ! (
5411
+ "------------------------- Verify Tenure Extend Tx from Miner B -------------------------"
5412
+ ) ;
5413
+
5386
5414
let blocks = test_observer:: get_blocks ( ) ;
5387
5415
let tenure_extend_block = if nmb_old_blocks + 1 == test_observer:: get_blocks ( ) . len ( ) {
5388
5416
blocks. last ( ) . unwrap ( )
0 commit comments