Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not process block validation responses for the wrong reward cycle #5612

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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