Skip to content

Commit

Permalink
Do not process block validation responses for the wrong reward cycle
Browse files Browse the repository at this point in the history
Signed-off-by: Jacinta Ferrant <[email protected]>
  • Loading branch information
jferrant committed Dec 23, 2024
1 parent ed839e4 commit cd45fcb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions stacks-signer/src/v0/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,14 @@ impl Signer {
// For mutability reasons, we need to take the block_info out of the map and add it back after processing
let mut block_info = match self.signer_db.block_lookup(&signer_signature_hash) {
Ok(Some(block_info)) => {
if block_info.reward_cycle != self.reward_cycle {
// We are not signing for this reward cycle. Ignore the block.
debug!(
"{self}: Received a block validation response for a different reward cycle. Ignore it.";
"requested_reward_cycle" => block_info.reward_cycle,
);
return None;
}
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;
Expand Down Expand Up @@ -635,6 +643,14 @@ impl Signer {
}
let mut block_info = match self.signer_db.block_lookup(&signer_signature_hash) {
Ok(Some(block_info)) => {
if block_info.reward_cycle != self.reward_cycle {
// We are not signing for this reward cycle. Ignore the block.
debug!(
"{self}: Received a block validation response for a different reward cycle. Ignore it.";
"requested_reward_cycle" => block_info.reward_cycle,
);
return None;
}
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;
Expand Down

0 comments on commit cd45fcb

Please sign in to comment.