Skip to content

Commit

Permalink
fix: don't re-broadcast locally finalized blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
hstove committed Nov 19, 2024
1 parent 76dea22 commit 014e3fd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 8 additions & 0 deletions stacks-signer/src/signerdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@ impl BlockInfo {
BlockState::GloballyAccepted | BlockState::GloballyRejected
)
}

/// Check if the block is locally accepted or rejected
pub fn is_locally_finalized(&self) -> bool {
matches!(
self.state,
BlockState::LocallyAccepted | BlockState::LocallyRejected
)
}
}

/// This struct manages a SQLite database connection
Expand Down
16 changes: 14 additions & 2 deletions stacks-signer/src/v0/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,13 @@ impl Signer {
.signer_db
.block_lookup(self.reward_cycle, &signer_signature_hash)
{
Ok(Some(block_info)) => block_info,
Ok(Some(block_info)) => {
if block_info.is_locally_finalized() {
debug!("{self}: Received block validation for a block that is already marked as {}. Ignoring...", block_info.state);
return None;
}
block_info
}
Ok(None) => {
// We have not seen this block before. Why are we getting a response for it?
debug!("{self}: Received a block validate response for a block we have not seen before. Ignoring...");
Expand Down Expand Up @@ -591,7 +597,13 @@ impl Signer {
.signer_db
.block_lookup(self.reward_cycle, &signer_signature_hash)
{
Ok(Some(block_info)) => block_info,
Ok(Some(block_info)) => {
if block_info.is_locally_finalized() {
debug!("{self}: Received block validation for a block that is already marked as {}. Ignoring...", block_info.state);
return None;
}
block_info
}
Ok(None) => {
// We have not seen this block before. Why are we getting a response for it?
debug!("{self}: Received a block validate response for a block we have not seen before. Ignoring...");
Expand Down

0 comments on commit 014e3fd

Please sign in to comment.