Skip to content

Commit cf1d13c

Browse files
committed
Add fast blocks test to CI
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 25cd9d9 commit cf1d13c

File tree

2 files changed

+42
-13
lines changed

2 files changed

+42
-13
lines changed

.github/workflows/bitcoin-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ jobs:
120120
- tests::signer::v0::signing_in_0th_tenure_of_reward_cycle
121121
- tests::signer::v0::continue_after_tenure_extend
122122
- tests::signer::v0::multiple_miners_with_custom_chain_id
123+
- tests::signer::v0::continue_after_fast_block_no_sortition
123124
- tests::nakamoto_integrations::burn_ops_integration_test
124125
- tests::nakamoto_integrations::check_block_heights
125126
- tests::nakamoto_integrations::clarity_burn_state

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

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use stacks::net::api::postblock_proposal::{ValidateRejectCode, TEST_VALIDATE_STA
4343
use stacks::net::relay::fault_injection::set_ignore_block;
4444
use stacks::types::chainstate::{StacksAddress, StacksBlockId, StacksPrivateKey, StacksPublicKey};
4545
use stacks::types::PublicKey;
46-
use stacks::util::hash::{hex_bytes, MerkleHashFunc};
46+
use stacks::util::hash::{hex_bytes, Hash160, MerkleHashFunc};
4747
use stacks::util::secp256k1::{Secp256k1PrivateKey, Secp256k1PublicKey};
4848
use stacks::util_lib::boot::boot_code_id;
4949
use stacks::util_lib::signed_structured_data::pox4::{
@@ -5023,11 +5023,14 @@ fn miner_recovers_when_broadcast_block_delay_across_tenures_occurs() {
50235023
/// Miner 1 wins the first Nakamoto tenure A. Miner 1 mines a regular stacks block N.
50245024
/// Miner 2 wins the second Nakamoto tenure B and proposes block N+1, but it is rejected by the signers.
50255025
/// 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'
50295030
/// 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'
50315034
#[test]
50325035
#[ignore]
50335036
fn continue_after_fast_block_no_sortition() {
@@ -5152,6 +5155,9 @@ fn continue_after_fast_block_no_sortition() {
51525155

51535156
// Make sure Miner 2 cannot win a sortition at first.
51545157
rl2_skip_commit_op.set(true);
5158+
5159+
info!("------------------------- Boot to Epoch 3.0 -------------------------");
5160+
51555161
let run_loop_2_thread = thread::Builder::new()
51565162
.name("run_loop_2".into())
51575163
.spawn(move || run_loop_2.start(None, 0))
@@ -5170,6 +5176,11 @@ fn continue_after_fast_block_no_sortition() {
51705176
})
51715177
.expect("Timed out waiting for boostrapped node to catch up to the miner");
51725178

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+
51735184
info!("------------------------- Reached Epoch 3.0 -------------------------");
51745185

51755186
let burnchain = signer_test.running_nodes.conf.get_burnchain();
@@ -5189,15 +5200,22 @@ fn continue_after_fast_block_no_sortition() {
51895200
let starting_burn_height = get_burn_height();
51905201
let mut btc_blocks_mined = 0;
51915202

5192-
info!("------------------------- Miner 1 Mines a Normal Tenure A -------------------------");
5193-
let blocks_processed_before_1 = blocks_mined1.load(Ordering::SeqCst);
51945203
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
51965205
signer_test
51975206
.running_nodes
51985207
.nakamoto_test_skip_commit_op
51995208
.set(true);
52005209

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+
52015219
signer_test
52025220
.running_nodes
52035221
.btc_regtest_controller
@@ -5210,7 +5228,12 @@ fn continue_after_fast_block_no_sortition() {
52105228

52115229
// wait for the new block to be processed
52125230
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)
52145237
})
52155238
.unwrap();
52165239

@@ -5219,21 +5242,22 @@ fn continue_after_fast_block_no_sortition() {
52195242
blocks_mined1.load(Ordering::SeqCst)
52205243
);
52215244

5245+
info!("------------------------- Make Signers Reject All Subsequent Proposals -------------------------");
5246+
52225247
let stacks_height_before = signer_test
52235248
.stacks_client
52245249
.get_peer_info()
52255250
.expect("Failed to get peer info")
52265251
.stacks_tip_height;
52275252

5228-
info!("------------------------- Make Signers Reject All Subsequent Proposals -------------------------");
52295253
// Make all signers ignore block proposals
52305254
let ignoring_signers = all_signers.to_vec();
52315255
TEST_REJECT_ALL_BLOCK_PROPOSAL
52325256
.lock()
52335257
.unwrap()
52345258
.replace(ignoring_signers.clone());
52355259

5236-
info!("------------------------- Unpause Miner 2's Block Commits -------------------------");
5260+
info!("------------------------- Submit Miner 2 Block Commit -------------------------");
52375261
let rejections_before = signer_test
52385262
.running_nodes
52395263
.nakamoto_blocks_rejected
@@ -5243,7 +5267,6 @@ fn continue_after_fast_block_no_sortition() {
52435267
// Unpause miner 2's block commits
52445268
rl2_skip_commit_op.set(false);
52455269

5246-
info!("------------------------- Wait for Miner 2's Block Commit Submission -------------------------");
52475270
// Ensure the miner 2 submits a block commit before mining the bitcoin block
52485271
wait_for(30, || {
52495272
Ok(rl2_commits.load(Ordering::SeqCst) > rl2_commits_before)
@@ -5337,7 +5360,7 @@ fn continue_after_fast_block_no_sortition() {
53375360
let stacks_height_before = stacks_height;
53385361

53395362
let blocks_processed_before_2 = blocks_mined2.load(Ordering::SeqCst);
5340-
info!("----- Enabling signers to approve proposals -----";
5363+
info!("------------------------- Enabling signers to approve proposals -------------------------";
53415364
"stacks_height" => stacks_height_before,
53425365
);
53435366

@@ -5348,6 +5371,7 @@ fn continue_after_fast_block_no_sortition() {
53485371
.unwrap()
53495372
.replace(Vec::new());
53505373

5374+
info!("------------------------- Mining Interim Block -------------------------");
53515375
// 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
53525376
// rejected already by the signers
53535377
let transfer_tx = make_stacks_transfer(
@@ -5383,6 +5407,10 @@ fn continue_after_fast_block_no_sortition() {
53835407
)
53845408
.expect("Timed out waiting for test observer to see new block");
53855409

5410+
info!(
5411+
"------------------------- Verify Tenure Extend Tx from Miner B -------------------------"
5412+
);
5413+
53865414
let blocks = test_observer::get_blocks();
53875415
let tenure_extend_block = if nmb_old_blocks + 1 == test_observer::get_blocks().len() {
53885416
blocks.last().unwrap()

0 commit comments

Comments
 (0)