Skip to content

Commit 2a4371f

Browse files
committed
Merge branch 'develop' of https://github.com/stacks-network/stacks-core into feat/signer-subscribe-to-block-events
2 parents ef7cb90 + b3b7117 commit 2a4371f

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

stacks-signer/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
1212
- Introduced the `block_proposal_max_age_secs` configuration option for signers, enabling them to automatically ignore block proposals that exceed the specified age in seconds.
1313

1414
## Changed
15+
- Improvements to the stale signer cleanup logic: deletes the prior signer if it has no remaining unprocessed blocks in its database
1516
- Signers now listen to new block events from the stacks node to determine whether a block has been successfully appended to the chain tip
1617

1718
## [3.1.0.0.1.0]

stacks-signer/src/runloop.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -424,23 +424,15 @@ impl<Signer: SignerTrait<T>, T: StacksMessageCodec + Clone + Send + Debug> RunLo
424424
let mut to_delete = Vec::new();
425425
for (idx, signer) in &mut self.stacks_signers {
426426
let reward_cycle = signer.reward_cycle();
427-
let next_reward_cycle = reward_cycle.wrapping_add(1);
428-
let stale = match next_reward_cycle.cmp(&current_reward_cycle) {
429-
std::cmp::Ordering::Less => true, // We are more than one reward cycle behind, so we are stale
430-
std::cmp::Ordering::Equal => {
431-
// We are the next reward cycle, so check if we were registered and have any pending blocks to process
432-
match signer {
433-
ConfiguredSigner::RegisteredSigner(signer) => {
434-
!signer.has_unprocessed_blocks()
435-
}
436-
_ => true,
437-
}
427+
if reward_cycle >= current_reward_cycle {
428+
// We are either the current or a future reward cycle, so we are not stale.
429+
continue;
430+
}
431+
if let ConfiguredSigner::RegisteredSigner(signer) = signer {
432+
if !signer.has_unprocessed_blocks() {
433+
debug!("{signer}: Signer's tenure has completed.");
434+
to_delete.push(*idx);
438435
}
439-
std::cmp::Ordering::Greater => false, // We are the current reward cycle, so we are not stale
440-
};
441-
if stale {
442-
debug!("{signer}: Signer's tenure has completed.");
443-
to_delete.push(*idx);
444436
}
445437
}
446438
for idx in to_delete {

0 commit comments

Comments
 (0)