Skip to content

Commit 032d33e

Browse files
committed
Fix reorgning signers test and allow caller to specify expected signer state machine update version number
Signed-off-by: Jacinta Ferrant <jacinta.ferrant@gmail.com>
1 parent d6ba211 commit 032d33e

File tree

1 file changed

+52
-24
lines changed
  • testnet/stacks-node/src/tests/signer

1 file changed

+52
-24
lines changed

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

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ use stacks_signer::client::{SignerSlotID, StackerDB};
7979
use stacks_signer::config::{build_signer_config_tomls, GlobalConfig as SignerConfig, Network};
8080
use stacks_signer::signerdb::SignerDb;
8181
use stacks_signer::v0::signer::TEST_REPEAT_PROPOSAL_RESPONSE;
82+
use stacks_signer::v0::signer_state::SUPPORTED_SIGNER_PROTOCOL_VERSION;
8283
use stacks_signer::v0::tests::{
8384
TEST_IGNORE_ALL_BLOCK_PROPOSALS, TEST_PAUSE_BLOCK_BROADCAST, TEST_REJECT_ALL_BLOCK_PROPOSAL,
8485
TEST_SKIP_BLOCK_BROADCAST, TEST_SKIP_SIGNER_CLEANUP, TEST_STALL_BLOCK_VALIDATION_SUBMISSION,
@@ -1434,6 +1435,7 @@ pub fn wait_for_state_machine_update(
14341435
expected_burn_block: &ConsensusHash,
14351436
expected_burn_block_height: u64,
14361437
expected_miner_info: Option<(Hash160, u64)>,
1438+
version: u64,
14371439
) -> Result<(), String> {
14381440
wait_for(timeout_secs, || {
14391441
let stackerdb_events = test_observer::get_stackerdb_chunks();
@@ -1446,18 +1448,25 @@ pub fn wait_for_state_machine_update(
14461448
let SignerMessage::StateMachineUpdate(update) = message else {
14471449
continue;
14481450
};
1449-
let (burn_block, burn_block_height, current_miner) = match &update.content {
1450-
StateMachineUpdateContent::V0 {
1451-
burn_block,
1452-
burn_block_height,
1453-
current_miner,
1454-
}
1455-
| StateMachineUpdateContent::V1 {
1456-
burn_block,
1457-
burn_block_height,
1458-
current_miner,
1459-
..
1460-
} => (burn_block, burn_block_height, current_miner),
1451+
let (burn_block, burn_block_height, current_miner) = match (version, &update.content) {
1452+
(
1453+
0,
1454+
StateMachineUpdateContent::V0 {
1455+
burn_block,
1456+
burn_block_height,
1457+
current_miner,
1458+
},
1459+
) => (burn_block, burn_block_height, current_miner),
1460+
(
1461+
1,
1462+
StateMachineUpdateContent::V1 {
1463+
burn_block,
1464+
burn_block_height,
1465+
current_miner,
1466+
..
1467+
},
1468+
) => (burn_block, burn_block_height, current_miner),
1469+
(other, _) => panic!("Unsupported protocol version: {other}"),
14611470
};
14621471
if *burn_block_height != expected_burn_block_height || burn_block != expected_burn_block
14631472
{
@@ -13747,6 +13756,7 @@ fn signers_send_state_message_updates() {
1374713756
&get_burn_consensus_hash(),
1374813757
starting_burn_height + 1,
1374913758
Some((miner_pkh_1, starting_peer_height)),
13759+
SUPPORTED_SIGNER_PROTOCOL_VERSION,
1375013760
)
1375113761
.expect("Timed out waiting for signers to send a state update");
1375213762

@@ -13775,6 +13785,7 @@ fn signers_send_state_message_updates() {
1377513785
&get_burn_consensus_hash(),
1377613786
starting_burn_height + 2,
1377713787
Some((miner_pkh_2, starting_peer_height + 1)),
13788+
SUPPORTED_SIGNER_PROTOCOL_VERSION,
1377813789
)
1377913790
.expect("Timed out waiting for signers to send their state update");
1378013791

@@ -13793,6 +13804,7 @@ fn signers_send_state_message_updates() {
1379313804
&get_burn_consensus_hash(),
1379413805
starting_burn_height + 2,
1379513806
Some((miner_pkh_1, starting_peer_height)),
13807+
SUPPORTED_SIGNER_PROTOCOL_VERSION,
1379613808
)
1379713809
.expect("Timed out waiting for signers to send their state update");
1379813810

@@ -14385,18 +14397,34 @@ fn reorging_signers_capitulate_to_nonreorging_signers_during_tenure_fork() {
1438514397
let SignerMessage::StateMachineUpdate(update) = message else {
1438614398
continue;
1438714399
};
14388-
let StateMachineUpdateContent::V0 {
14389-
burn_block,
14390-
burn_block_height,
14391-
current_miner:
14392-
StateMachineUpdateMinerState::ActiveMiner {
14393-
current_miner_pkh, ..
14394-
},
14395-
..
14396-
} = update.content
14397-
else {
14398-
continue;
14399-
};
14400+
let (burn_block, burn_block_height, current_miner_pkh) =
14401+
match (SUPPORTED_SIGNER_PROTOCOL_VERSION, update.content) {
14402+
(
14403+
0,
14404+
StateMachineUpdateContent::V0 {
14405+
burn_block,
14406+
burn_block_height,
14407+
current_miner:
14408+
StateMachineUpdateMinerState::ActiveMiner {
14409+
current_miner_pkh, ..
14410+
},
14411+
..
14412+
},
14413+
)
14414+
| (
14415+
1,
14416+
StateMachineUpdateContent::V1 {
14417+
burn_block,
14418+
burn_block_height,
14419+
current_miner:
14420+
StateMachineUpdateMinerState::ActiveMiner {
14421+
current_miner_pkh, ..
14422+
},
14423+
..
14424+
},
14425+
) => (burn_block, burn_block_height, current_miner_pkh),
14426+
_ => continue,
14427+
};
1440014428
if burn_block == tenure_c_block_proposal.header.consensus_hash
1440114429
&& burn_block_height == burn_height_before + 1
1440214430
&& current_miner_pkh == miner_pkh_1

0 commit comments

Comments
 (0)