Skip to content

Commit cd45fcb

Browse files
committed
Do not process block validation responses for the wrong reward cycle
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent ed839e4 commit cd45fcb

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
@@ -564,6 +564,14 @@ impl Signer {
564564
// For mutability reasons, we need to take the block_info out of the map and add it back after processing
565565
let mut block_info = match self.signer_db.block_lookup(&signer_signature_hash) {
566566
Ok(Some(block_info)) => {
567+
if block_info.reward_cycle != self.reward_cycle {
568+
// We are not signing for this reward cycle. Ignore the block.
569+
debug!(
570+
"{self}: Received a block validation response for a different reward cycle. Ignore it.";
571+
"requested_reward_cycle" => block_info.reward_cycle,
572+
);
573+
return None;
574+
}
567575
if block_info.is_locally_finalized() {
568576
debug!("{self}: Received block validation for a block that is already marked as {}. Ignoring...", block_info.state);
569577
return None;
@@ -635,6 +643,14 @@ impl Signer {
635643
}
636644
let mut block_info = match self.signer_db.block_lookup(&signer_signature_hash) {
637645
Ok(Some(block_info)) => {
646+
if block_info.reward_cycle != self.reward_cycle {
647+
// We are not signing for this reward cycle. Ignore the block.
648+
debug!(
649+
"{self}: Received a block validation response for a different reward cycle. Ignore it.";
650+
"requested_reward_cycle" => block_info.reward_cycle,
651+
);
652+
return None;
653+
}
638654
if block_info.is_locally_finalized() {
639655
debug!("{self}: Received block validation for a block that is already marked as {}. Ignoring...", block_info.state);
640656
return None;

0 commit comments

Comments
 (0)