Skip to content

Commit 2b134d8

Browse files
committed
fix: test cleanup/fix
1 parent 3150433 commit 2b134d8

File tree

2 files changed

+10
-53
lines changed

2 files changed

+10
-53
lines changed

stacks-signer/src/v0/signer_state.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,12 +788,15 @@ impl LocalStateMachine {
788788
};
789789
return Err(ClientError::InvalidResponse(err_msg).into());
790790
}
791-
tx_replay_set = self.handle_possible_bitcoin_fork(
791+
if let Some(new_replay_set) = self.handle_possible_bitcoin_fork(
792792
db,
793793
client,
794794
&expected_burn_block,
795795
&prior_state_machine,
796-
)?;
796+
tx_replay_set.is_some(),
797+
)? {
798+
tx_replay_set = Some(new_replay_set);
799+
}
797800
}
798801

799802
let CurrentAndLastSortition {
@@ -966,11 +969,12 @@ impl LocalStateMachine {
966969
client: &StacksClient,
967970
expected_burn_block: &NewBurnBlock,
968971
prior_state_machine: &SignerStateMachine,
972+
is_in_tx_replay_mode: bool,
969973
) -> Result<Option<Vec<StacksTransaction>>, SignerChainstateError> {
970974
if expected_burn_block.burn_block_height <= prior_state_machine.burn_block_height
971975
&& expected_burn_block.consensus_hash != prior_state_machine.burn_block
972976
// TODO: handle fork while still in replay
973-
&& prior_state_machine.tx_replay_set.is_none()
977+
&& !is_in_tx_replay_mode
974978
{
975979
info!("Signer State: fork detected";
976980
"expected_burn_block.height" => expected_burn_block.burn_block_height,

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

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3071,36 +3071,6 @@ fn tx_replay_forking_test() {
30713071
);
30723072
let conf = signer_test.running_nodes.conf.clone();
30733073
let http_origin = format!("http://{}", &conf.node.rpc_bind);
3074-
let _miner_address = Keychain::default(conf.node.seed.clone())
3075-
.origin_address(conf.is_mainnet())
3076-
.unwrap();
3077-
let miner_pk = signer_test
3078-
.running_nodes
3079-
.btc_regtest_controller
3080-
.get_mining_pubkey()
3081-
.as_deref()
3082-
.map(Secp256k1PublicKey::from_hex)
3083-
.unwrap()
3084-
.unwrap();
3085-
3086-
let get_unconfirmed_commit_data = |btc_controller: &mut BitcoinRegtestController| {
3087-
let unconfirmed_utxo = btc_controller
3088-
.get_all_utxos(&miner_pk)
3089-
.into_iter()
3090-
.find(|utxo| utxo.confirmations == 0)?;
3091-
let unconfirmed_txid = Txid::from_bitcoin_tx_hash(&unconfirmed_utxo.txid);
3092-
let unconfirmed_tx = btc_controller.get_raw_transaction(&unconfirmed_txid);
3093-
let unconfirmed_tx_opreturn_bytes = unconfirmed_tx.output[0].script_pubkey.as_bytes();
3094-
info!(
3095-
"Unconfirmed tx bytes: {}",
3096-
stacks::util::hash::to_hex(unconfirmed_tx_opreturn_bytes)
3097-
);
3098-
let data = LeaderBlockCommitOp::parse_data(
3099-
&unconfirmed_tx_opreturn_bytes[unconfirmed_tx_opreturn_bytes.len() - 77..],
3100-
)
3101-
.unwrap();
3102-
Some(data)
3103-
};
31043074

31053075
signer_test.boot_to_epoch_3();
31063076
info!("------------------------- Reached Epoch 3.0 -------------------------");
@@ -3205,26 +3175,9 @@ fn tx_replay_forking_test() {
32053175
next_block_and_controller(
32063176
&mut signer_test.running_nodes.btc_regtest_controller,
32073177
60,
3208-
|btc_controller| {
3209-
let commits_submitted = submitted_commits
3210-
.load(Ordering::SeqCst);
3211-
if commits_submitted <= commits_count {
3212-
// wait until a commit was submitted
3213-
return Ok(false)
3214-
}
3215-
let Some(payload) = get_unconfirmed_commit_data(btc_controller) else {
3216-
warn!("Commit submitted, but bitcoin doesn't see it in the unconfirmed UTXO set, will try to wait.");
3217-
return Ok(false)
3218-
};
3219-
let burn_parent_modulus = payload.burn_parent_modulus;
3220-
let current_modulus = u8::try_from((current_burn_height + 1) % 5).unwrap();
3221-
info!(
3222-
"Ongoing Commit Operation check";
3223-
"burn_parent_modulus" => burn_parent_modulus,
3224-
"current_modulus" => current_modulus,
3225-
"payload" => ?payload,
3226-
);
3227-
Ok(burn_parent_modulus == current_modulus)
3178+
|_btc_controller| {
3179+
let commits_submitted = submitted_commits.load(Ordering::SeqCst);
3180+
Ok(commits_submitted > commits_count)
32283181
},
32293182
)
32303183
.unwrap();

0 commit comments

Comments
 (0)