Skip to content

Commit 014e3fd

Browse files
committed
fix: don't re-broadcast locally finalized blocks
1 parent 76dea22 commit 014e3fd

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

stacks-signer/src/signerdb.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ impl BlockInfo {
266266
BlockState::GloballyAccepted | BlockState::GloballyRejected
267267
)
268268
}
269+
270+
/// Check if the block is locally accepted or rejected
271+
pub fn is_locally_finalized(&self) -> bool {
272+
matches!(
273+
self.state,
274+
BlockState::LocallyAccepted | BlockState::LocallyRejected
275+
)
276+
}
269277
}
270278

271279
/// This struct manages a SQLite database connection

stacks-signer/src/v0/signer.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,13 @@ impl Signer {
538538
.signer_db
539539
.block_lookup(self.reward_cycle, &signer_signature_hash)
540540
{
541-
Ok(Some(block_info)) => block_info,
541+
Ok(Some(block_info)) => {
542+
if block_info.is_locally_finalized() {
543+
debug!("{self}: Received block validation for a block that is already marked as {}. Ignoring...", block_info.state);
544+
return None;
545+
}
546+
block_info
547+
}
542548
Ok(None) => {
543549
// We have not seen this block before. Why are we getting a response for it?
544550
debug!("{self}: Received a block validate response for a block we have not seen before. Ignoring...");
@@ -591,7 +597,13 @@ impl Signer {
591597
.signer_db
592598
.block_lookup(self.reward_cycle, &signer_signature_hash)
593599
{
594-
Ok(Some(block_info)) => block_info,
600+
Ok(Some(block_info)) => {
601+
if block_info.is_locally_finalized() {
602+
debug!("{self}: Received block validation for a block that is already marked as {}. Ignoring...", block_info.state);
603+
return None;
604+
}
605+
block_info
606+
}
595607
Ok(None) => {
596608
// We have not seen this block before. Why are we getting a response for it?
597609
debug!("{self}: Received a block validate response for a block we have not seen before. Ignoring...");

0 commit comments

Comments
 (0)