Skip to content

Commit 1607145

Browse files
committed
test: improvements to allow_reorg_within_first_proposal_burn_block_timing_secs
This now seems to reproduce the problem that we saw on mainnet. The problem persists in `develop`.
1 parent 4c25a90 commit 1607145

File tree

1 file changed

+75
-18
lines changed
  • testnet/stacks-node/src/tests/signer

1 file changed

+75
-18
lines changed

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10846,9 +10846,10 @@ fn allow_reorg_within_first_proposal_burn_block_timing_secs() {
1084610846
let recipient = PrincipalData::from(StacksAddress::burn_address(false));
1084710847
let sender_sk = Secp256k1PrivateKey::new();
1084810848
let sender_addr = tests::to_addr(&sender_sk);
10849+
let mut sender_nonce = 0;
1084910850
let send_amt = 100;
1085010851
let send_fee = 180;
10851-
let num_txs = 1;
10852+
let num_txs = 3;
1085210853

1085310854
let btc_miner_1_seed = vec![1, 1, 1, 1];
1085410855
let btc_miner_2_seed = vec![2, 2, 2, 2];
@@ -11127,6 +11128,73 @@ fn allow_reorg_within_first_proposal_burn_block_timing_secs() {
1112711128
assert!(tip.sortition);
1112811129
assert_eq!(tip.miner_pk_hash.unwrap(), mining_pkh_2);
1112911130

11131+
info!("------------------------- Miner 2 Mines N+2 and N+3 -------------------------");
11132+
let blocks_processed_before_2 = blocks_mined2.load(Ordering::SeqCst);
11133+
let stacks_height_before = signer_test
11134+
.stacks_client
11135+
.get_peer_info()
11136+
.expect("Failed to get peer info")
11137+
.stacks_tip_height;
11138+
let info_before = get_chain_info(&conf);
11139+
11140+
// submit a tx so that the miner will ATTEMPT to mine a stacks block N+2
11141+
let transfer_tx = make_stacks_transfer(
11142+
&sender_sk,
11143+
sender_nonce,
11144+
send_fee,
11145+
signer_test.running_nodes.conf.burnchain.chain_id,
11146+
&recipient,
11147+
send_amt,
11148+
);
11149+
let tx = submit_tx(&http_origin, &transfer_tx);
11150+
info!("Submitted tx {tx} in attempt to mine block N+2");
11151+
sender_nonce += 1;
11152+
11153+
wait_for(30, || {
11154+
Ok(signer_test
11155+
.stacks_client
11156+
.get_peer_info()
11157+
.expect("Failed to get peer info")
11158+
.stacks_tip_height
11159+
> stacks_height_before
11160+
&& blocks_mined2.load(Ordering::SeqCst) > blocks_processed_before_2
11161+
&& get_chain_info(&conf).stacks_tip_height > info_before.stacks_tip_height)
11162+
})
11163+
.expect("Timed out waiting for Miner 2 to Mine Block N+2");
11164+
11165+
let blocks_processed_before_2 = blocks_mined2.load(Ordering::SeqCst);
11166+
let stacks_height_before = signer_test
11167+
.stacks_client
11168+
.get_peer_info()
11169+
.expect("Failed to get peer info")
11170+
.stacks_tip_height;
11171+
let info_before = get_chain_info(&conf);
11172+
11173+
// submit a tx so that the miner will ATTEMPT to mine a stacks block N+3
11174+
let transfer_tx = make_stacks_transfer(
11175+
&sender_sk,
11176+
sender_nonce,
11177+
send_fee,
11178+
signer_test.running_nodes.conf.burnchain.chain_id,
11179+
&recipient,
11180+
send_amt,
11181+
);
11182+
let tx = submit_tx(&http_origin, &transfer_tx);
11183+
info!("Submitted tx {tx} in attempt to mine block N+2");
11184+
sender_nonce += 1;
11185+
11186+
wait_for(30, || {
11187+
Ok(signer_test
11188+
.stacks_client
11189+
.get_peer_info()
11190+
.expect("Failed to get peer info")
11191+
.stacks_tip_height
11192+
> stacks_height_before
11193+
&& blocks_mined2.load(Ordering::SeqCst) > blocks_processed_before_2
11194+
&& get_chain_info(&conf).stacks_tip_height > info_before.stacks_tip_height)
11195+
})
11196+
.expect("Timed out waiting for Miner 2 to Mine Block N+3");
11197+
1113011198
info!("------------------------- Miner 1 Wins the Next Tenure -------------------------");
1113111199

1113211200
let blocks_processed_before_1 = blocks_mined1.load(Ordering::SeqCst);
@@ -11147,18 +11215,12 @@ fn allow_reorg_within_first_proposal_burn_block_timing_secs() {
1114711215
info!("------------------------- Miner 1 Mines N+2 -------------------------");
1114811216

1114911217
let blocks_processed_before_1 = blocks_mined1.load(Ordering::SeqCst);
11150-
let stacks_height_before = signer_test
11151-
.stacks_client
11152-
.get_peer_info()
11153-
.expect("Failed to get peer info")
11154-
.stacks_tip_height;
11155-
let info_before = get_chain_info(&conf);
1115611218
let mined_before = test_observer::get_mined_nakamoto_blocks().len();
1115711219

11158-
// submit a tx so that the miner will ATTEMPT to mine a stacks block N
11220+
// submit a tx so that the miner will ATTEMPT to mine a stacks block N+2
1115911221
let transfer_tx = make_stacks_transfer(
1116011222
&sender_sk,
11161-
0,
11223+
sender_nonce,
1116211224
send_fee,
1116311225
signer_test.running_nodes.conf.burnchain.chain_id,
1116411226
&recipient,
@@ -11168,15 +11230,10 @@ fn allow_reorg_within_first_proposal_burn_block_timing_secs() {
1116811230
info!("Submitted tx {tx} in attempt to mine block N+2");
1116911231

1117011232
wait_for(30, || {
11171-
Ok(signer_test
11172-
.stacks_client
11173-
.get_peer_info()
11174-
.expect("Failed to get peer info")
11175-
.stacks_tip_height
11176-
> stacks_height_before
11177-
&& blocks_mined1.load(Ordering::SeqCst) > blocks_processed_before_1
11178-
&& get_chain_info(&conf).stacks_tip_height > info_before.stacks_tip_height
11179-
&& test_observer::get_mined_nakamoto_blocks().len() > mined_before)
11233+
Ok(
11234+
blocks_mined1.load(Ordering::SeqCst) > blocks_processed_before_1
11235+
&& test_observer::get_mined_nakamoto_blocks().len() > mined_before,
11236+
)
1118011237
})
1118111238
.expect("Timed out waiting for Miner 1 to Mine Block N+2");
1118211239

0 commit comments

Comments
 (0)