Skip to content

Commit 06a4279

Browse files
committed
disallow reorg if more than one block has already been signed
1 parent 0dd2966 commit 06a4279

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

stacks-signer/src/chainstate.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,24 @@ impl SortitionsView {
439439
continue;
440440
}
441441

442+
// disallow reorg if more than one block has already been signed
443+
let signed_blocks =
444+
signer_db.get_signed_block_count_in_tenure(&tenure.consensus_hash)?;
445+
if signed_blocks > 1 {
446+
warn!(
447+
"Miner is not building off of most recent tenure, but a tenure they attempted to reorg has already more than one signed block.";
448+
"proposed_block_consensus_hash" => %block.header.consensus_hash,
449+
"proposed_block_signer_sighash" => %block.header.signer_signature_hash(),
450+
"parent_tenure" => %sortition_state.parent_tenure_id,
451+
"last_sortition" => %sortition_state.prior_sortition,
452+
"violating_tenure_id" => %tenure.consensus_hash,
453+
"violating_tenure_first_block_id" => ?tenure.first_block_mined,
454+
"signed_blocks" => signed_blocks,
455+
);
456+
return Ok(false);
457+
}
458+
442459
if tenure.first_block_mined.is_some() {
443-
// TODO: roberto -> get the amount of signed blocks
444460
let Some(local_block_info) =
445461
signer_db.get_first_signed_block_in_tenure(&tenure.consensus_hash)?
446462
else {

0 commit comments

Comments
 (0)