Skip to content

Commit c6ca6b9

Browse files
committed
fix: dont rely on node burn block to be processed
1 parent d4d3917 commit c6ca6b9

File tree

2 files changed

+12
-45
lines changed

2 files changed

+12
-45
lines changed

stacks-signer/src/v0/signer_state.rs

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,16 @@ impl LocalStateMachine {
580580
}
581581
};
582582

583-
let peer_info = client.get_peer_info()?;
584-
let next_burn_block_height = peer_info.burn_block_height;
585-
let next_burn_block_hash = peer_info.pox_consensus;
583+
let (next_burn_block_height, next_burn_block_hash) = match expected_burn_block.clone() {
584+
Some(expected_burn_block) => (
585+
expected_burn_block.burn_block_height,
586+
expected_burn_block.consensus_hash,
587+
),
588+
None => {
589+
let peer_info = client.get_peer_info()?;
590+
(peer_info.burn_block_height, peer_info.pox_consensus)
591+
}
592+
};
586593
let mut tx_replay_set = prior_state_machine.tx_replay_set.clone();
587594

588595
if let Some(expected_burn_block) = expected_burn_block {
@@ -997,41 +1004,8 @@ impl LocalStateMachine {
9971004
replay_state: &ReplayState,
9981005
) -> Result<Option<ReplayState>, SignerChainstateError> {
9991006
if expected_burn_block.burn_block_height > prior_state_machine.burn_block_height {
1000-
// prevent too large of a loop
1001-
if expected_burn_block
1002-
.burn_block_height
1003-
.saturating_sub(prior_state_machine.burn_block_height)
1004-
> 10
1005-
{
1006-
return Ok(None);
1007-
}
1008-
// are we building on top of this prior tip?
1009-
let mut parent_burn_block_info =
1010-
db.get_burn_block_by_ch(&expected_burn_block.consensus_hash)?;
1011-
1012-
while parent_burn_block_info.block_height > prior_state_machine.burn_block_height {
1013-
let Ok(parent_info) =
1014-
db.get_burn_block_by_hash(&parent_burn_block_info.parent_burn_block_hash)
1015-
else {
1016-
warn!(
1017-
"Failed to get parent burn block info for {}",
1018-
parent_burn_block_info.parent_burn_block_hash
1019-
);
1020-
return Ok(None);
1021-
};
1022-
parent_burn_block_info = parent_info;
1023-
}
1024-
if parent_burn_block_info.consensus_hash == prior_state_machine.burn_block {
1025-
// no bitcoin fork, because we're building on the parent
1026-
return Ok(None);
1027-
} else {
1028-
info!("Detected bitcoin fork - prior tip is not parent of new tip.";
1029-
"new_tip.burn_block_height" => expected_burn_block.burn_block_height,
1030-
"new_tip.consensus_hash" => %expected_burn_block.consensus_hash,
1031-
"prior_tip.burn_block_height" => prior_state_machine.burn_block_height,
1032-
"prior_tip.consensus_hash" => %prior_state_machine.burn_block,
1033-
);
1034-
}
1007+
// no bitcoin fork, because we're higher than the previous tip
1008+
return Ok(None);
10351009
}
10361010
if expected_burn_block.consensus_hash == prior_state_machine.burn_block {
10371011
// no bitcoin fork, because we're at the same burn block hash as before

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3982,13 +3982,6 @@ fn tx_replay_simple() {
39823982
let _http_origin = format!("http://{}", &conf.node.rpc_bind);
39833983
let btc_controller = &signer_test.running_nodes.btc_regtest_controller;
39843984

3985-
let miner_pk = btc_controller
3986-
.get_mining_pubkey()
3987-
.as_deref()
3988-
.map(Secp256k1PublicKey::from_hex)
3989-
.unwrap()
3990-
.unwrap();
3991-
39923985
if signer_test.bootstrap_snapshot() {
39933986
signer_test.shutdown_and_snapshot();
39943987
return;

0 commit comments

Comments
 (0)