@@ -6448,7 +6448,7 @@ fn test_pox_fork_out_of_order() {
6448
6448
let burnchain_blinded = get_burnchain_db ( path_blinded, None ) ;
6449
6449
let b = get_burnchain ( path, None ) ;
6450
6450
6451
- eprintln ! ( "Making block {}" , ix ) ;
6451
+ eprintln ! ( "Making block {ix}" ) ;
6452
6452
let ( op, block) = if ix == 0 {
6453
6453
make_genesis_block (
6454
6454
& b,
@@ -6461,9 +6461,7 @@ fn test_pox_fork_out_of_order() {
6461
6461
ix as u32 ,
6462
6462
)
6463
6463
} else {
6464
- let parent = if ix == 1 {
6465
- stacks_blocks[ 0 ] . 1 . header . block_hash ( )
6466
- } else if ix == 6 {
6464
+ let parent = if ix == 1 || ix == 6 {
6467
6465
stacks_blocks[ 0 ] . 1 . header . block_hash ( )
6468
6466
} else if ix == 11 {
6469
6467
stacks_blocks[ 5 ] . 1 . header . block_hash ( )
@@ -6506,8 +6504,7 @@ fn test_pox_fork_out_of_order() {
6506
6504
let ic = sort_db. index_handle_at_tip ( ) ;
6507
6505
let bhh = ic. get_last_anchor_block_hash ( ) . unwrap ( ) . unwrap ( ) ;
6508
6506
eprintln ! (
6509
- "Anchor block={}, selected at height={}" ,
6510
- & bhh,
6507
+ "Anchor block={bhh}, selected at height={}" ,
6511
6508
SortitionDB :: get_block_snapshot_for_winning_stacks_block(
6512
6509
& sort_db. index_conn( ) ,
6513
6510
& ic. context. chain_tip,
@@ -6537,7 +6534,7 @@ fn test_pox_fork_out_of_order() {
6537
6534
6538
6535
// load the block into staging
6539
6536
let block_hash = block. header . block_hash ( ) ;
6540
- eprintln ! ( "Block hash={}, ix={}" , & block_hash , ix ) ;
6537
+ eprintln ! ( "Block hash={block_hash }, ix={ix}" ) ;
6541
6538
6542
6539
assert_eq ! ( & tip. winning_stacks_block_hash, & block_hash) ;
6543
6540
stacks_blocks. push ( ( tip. sortition_id . clone ( ) , block. clone ( ) ) ) ;
@@ -6560,10 +6557,11 @@ fn test_pox_fork_out_of_order() {
6560
6557
assert_eq ! ( & pox_id. to_string( ) , "11111" ) ;
6561
6558
}
6562
6559
6560
+ // Because we no longer continue processing without an anchor block, the blinded signer has not advanced.
6563
6561
{
6564
6562
let ic = sort_db_blind. index_handle_at_tip ( ) ;
6565
6563
let pox_id = ic. get_pox_id ( ) . unwrap ( ) ;
6566
- assert_eq ! ( & pox_id. to_string( ) , "11000 " ) ;
6564
+ assert_eq ! ( & pox_id. to_string( ) , "11 " ) ;
6567
6565
}
6568
6566
6569
6567
// now, we reveal to the blinded coordinator, but out of order.
@@ -6586,38 +6584,27 @@ fn test_pox_fork_out_of_order() {
6586
6584
{
6587
6585
let ic = sort_db_blind. index_handle_at_tip ( ) ;
6588
6586
let pox_id = ic. get_pox_id ( ) . unwrap ( ) ;
6589
- assert_eq ! ( & pox_id. to_string( ) , "11110 " ) ;
6587
+ assert_eq ! ( & pox_id. to_string( ) , "1111 " ) ;
6590
6588
}
6591
6589
6592
6590
let block_height = eval_at_chain_tip ( path_blinded, & sort_db_blind, "block-height" ) ;
6593
6591
assert_eq ! ( block_height, Value :: UInt ( 1 ) ) ;
6594
6592
6595
6593
// reveal [6-10]
6596
- for ( _sort_id, block) in stacks_blocks[ 6 ..=10 ] . iter ( ) {
6597
- // cannot use sort_id from stacks_blocks, because the blinded coordinator
6598
- // has different sortition_id's for blocks 6-10 (because it's missing
6599
- // the 2nd anchor block).
6600
- let sort_id = SortitionDB :: get_block_snapshot_for_winning_stacks_block (
6601
- & sort_db_blind. index_conn ( ) ,
6602
- & SortitionDB :: get_canonical_sortition_tip ( sort_db_blind. conn ( ) ) . unwrap ( ) ,
6603
- & block. header . block_hash ( ) ,
6604
- )
6605
- . unwrap ( )
6606
- . unwrap ( )
6607
- . sortition_id ;
6594
+ for ( sort_id, block) in stacks_blocks[ 6 ..=10 ] . iter ( ) {
6608
6595
reveal_block (
6609
6596
path_blinded,
6610
6597
& sort_db_blind,
6611
6598
& mut coord_blind,
6612
- & sort_id,
6599
+ sort_id,
6613
6600
block,
6614
6601
) ;
6615
6602
}
6616
6603
6617
6604
{
6618
6605
let ic = sort_db_blind. index_handle_at_tip ( ) ;
6619
6606
let pox_id = ic. get_pox_id ( ) . unwrap ( ) ;
6620
- assert_eq ! ( & pox_id. to_string( ) , "11110 " ) ;
6607
+ assert_eq ! ( & pox_id. to_string( ) , "1111 " ) ;
6621
6608
}
6622
6609
6623
6610
let block_height = eval_at_chain_tip ( path_blinded, & sort_db_blind, "block-height" ) ;
@@ -6637,19 +6624,7 @@ fn test_pox_fork_out_of_order() {
6637
6624
) ;
6638
6625
6639
6626
// reveal [1-5]
6640
- for ( _sort_id, block) in stacks_blocks[ 1 ..=5 ] . iter ( ) {
6641
- // cannot use sort_id from stacks_blocks, because the blinded coordinator
6642
- // has different sortition_id's for blocks 6-10 (because it's missing
6643
- // the 2nd anchor block).
6644
- let sort_id = SortitionDB :: get_block_snapshot_for_winning_stacks_block (
6645
- & sort_db_blind. index_conn ( ) ,
6646
- & SortitionDB :: get_canonical_sortition_tip ( sort_db_blind. conn ( ) ) . unwrap ( ) ,
6647
- & block. header . block_hash ( ) ,
6648
- )
6649
- . unwrap ( )
6650
- . unwrap ( )
6651
- . sortition_id ;
6652
-
6627
+ for ( sort_id, block) in stacks_blocks[ 1 ..=5 ] . iter ( ) {
6653
6628
// before processing the last of these blocks, the stacks_block[9] should still
6654
6629
// be the canonical tip
6655
6630
let block_hash = eval_at_chain_tip (
@@ -6670,7 +6645,7 @@ fn test_pox_fork_out_of_order() {
6670
6645
path_blinded,
6671
6646
& sort_db_blind,
6672
6647
& mut coord_blind,
6673
- & sort_id,
6648
+ sort_id,
6674
6649
block,
6675
6650
) ;
6676
6651
}
@@ -6685,24 +6660,12 @@ fn test_pox_fork_out_of_order() {
6685
6660
assert_eq ! ( block_height, Value :: UInt ( 6 ) ) ;
6686
6661
6687
6662
// reveal [11-14]
6688
- for ( _sort_id, block) in stacks_blocks[ 11 ..] . iter ( ) {
6689
- // cannot use sort_id from stacks_blocks, because the blinded coordinator
6690
- // has different sortition_id's for blocks 6-10 (because it's missing
6691
- // the 2nd anchor block).
6692
- let sort_id = SortitionDB :: get_block_snapshot_for_winning_stacks_block (
6693
- & sort_db_blind. index_conn ( ) ,
6694
- & SortitionDB :: get_canonical_sortition_tip ( sort_db_blind. conn ( ) ) . unwrap ( ) ,
6695
- & block. header . block_hash ( ) ,
6696
- )
6697
- . unwrap ( )
6698
- . unwrap ( )
6699
- . sortition_id ;
6700
-
6663
+ for ( sort_id, block) in stacks_blocks[ 11 ..] . iter ( ) {
6701
6664
reveal_block (
6702
6665
path_blinded,
6703
6666
& sort_db_blind,
6704
6667
& mut coord_blind,
6705
- & sort_id,
6668
+ sort_id,
6706
6669
block,
6707
6670
) ;
6708
6671
}
@@ -6765,6 +6728,8 @@ fn reveal_block<T: BlockEventDispatcher, N: CoordinatorNotices, U: RewardSetProv
6765
6728
. unwrap ( ) ;
6766
6729
preprocess_block ( & mut chainstate, sort_db, & sortition, block. clone ( ) ) ;
6767
6730
coord. handle_new_stacks_block ( ) . unwrap ( ) ;
6731
+ // Force the coordinator to wake up and advance
6732
+ coord. handle_new_burnchain_block ( ) . unwrap ( ) ;
6768
6733
}
6769
6734
6770
6735
fn preprocess_block (
0 commit comments