Skip to content

Commit

Permalink
Merge pull request #5612 from stacks-network/hotfix/reward-cycle-bloc…
Browse files Browse the repository at this point in the history
…k-proposal

Do not process block validation responses for the wrong reward cycle
  • Loading branch information
wileyj authored Dec 23, 2024
2 parents ed839e4 + 1cdabb3 commit eb86527
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stacks-signer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE

## Changed

# [3.1.0.0.2.1]

## Added

## Changed

- Prevent old reward cycle signers from processing block validation response messages that do not apply to blocks from their cycle.

## [3.1.0.0.2.0]

## Added
Expand Down
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 eb86527

Please sign in to comment.