Skip to content

Commit eb86527

Browse files
authored
Merge pull request #5612 from stacks-network/hotfix/reward-cycle-block-proposal
Do not process block validation responses for the wrong reward cycle
2 parents ed839e4 + 1cdabb3 commit eb86527

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

stacks-signer/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1111

1212
## Changed
1313

14+
# [3.1.0.0.2.1]
15+
16+
## Added
17+
18+
## Changed
19+
20+
- Prevent old reward cycle signers from processing block validation response messages that do not apply to blocks from their cycle.
21+
1422
## [3.1.0.0.2.0]
1523

1624
## Added

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)