Skip to content

Commit 0279bc0

Browse files
jferrantwileyj
authored andcommitted
Do not process block validation responses for the wrong reward cycle
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent c251141 commit 0279bc0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

stacks-signer/src/v0/signer.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,14 @@ impl Signer {
584584
// For mutability reasons, we need to take the block_info out of the map and add it back after processing
585585
let mut block_info = match self.signer_db.block_lookup(&signer_signature_hash) {
586586
Ok(Some(block_info)) => {
587+
if block_info.reward_cycle != self.reward_cycle {
588+
// We are not signing for this reward cycle. Ignore the block.
589+
debug!(
590+
"{self}: Received a block validation response for a different reward cycle. Ignore it.";
591+
"requested_reward_cycle" => block_info.reward_cycle,
592+
);
593+
return None;
594+
}
587595
if block_info.is_locally_finalized() {
588596
debug!("{self}: Received block validation for a block that is already marked as {}. Ignoring...", block_info.state);
589597
return None;
@@ -655,6 +663,14 @@ impl Signer {
655663
}
656664
let mut block_info = match self.signer_db.block_lookup(&signer_signature_hash) {
657665
Ok(Some(block_info)) => {
666+
if block_info.reward_cycle != self.reward_cycle {
667+
// We are not signing for this reward cycle. Ignore the block.
668+
debug!(
669+
"{self}: Received a block validation response for a different reward cycle. Ignore it.";
670+
"requested_reward_cycle" => block_info.reward_cycle,
671+
);
672+
return None;
673+
}
658674
if block_info.is_locally_finalized() {
659675
debug!("{self}: Received block validation for a block that is already marked as {}. Ignoring...", block_info.state);
660676
return None;

0 commit comments

Comments
 (0)