Skip to content

Commit

Permalink
update signer logging to include reward cycle to differentiate curren…
Browse files Browse the repository at this point in the history
…t and next signers

Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
  • Loading branch information
jferrant committed Mar 7, 2024
1 parent cab1a11 commit de9494b
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 112 deletions.
23 changes: 13 additions & 10 deletions stacks-signer/src/runloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl RunLoop {
let old_reward_cycle = signer.reward_cycle;
if old_reward_cycle == reward_cycle {
//If the signer is already registered for the reward cycle, we don't need to do anything further here
debug!("Signer is configured for reward cycle {reward_cycle}.")
debug!("Signer is already configured for reward cycle {reward_cycle}.")
} else {
needs_refresh = true;
}
Expand All @@ -251,7 +251,7 @@ impl RunLoop {
if let Some(signer) = self.stacks_signers.get_mut(&prior_reward_set) {
if signer.reward_cycle == prior_reward_cycle {
// The signers have been calculated for the next reward cycle. Update the current one
debug!("Signer #{}: Next reward cycle ({reward_cycle}) signer set calculated. Updating current reward cycle ({prior_reward_cycle}) signer.", signer.signer_id);
debug!("Reward cycle #{} Signer #{}: Next reward cycle ({reward_cycle}) signer set calculated. Reconfiguring signer.", signer.reward_cycle, signer.signer_id);
signer.next_signer_addresses = new_signer_config
.signer_entries
.signer_ids
Expand All @@ -263,7 +263,7 @@ impl RunLoop {
}
self.stacks_signers
.insert(reward_index, Signer::from(new_signer_config));
debug!("Signer #{signer_id} for reward cycle {reward_cycle} initialized. Initialized {} signers", self.stacks_signers.len());
debug!("Reward cycle #{reward_cycle} Signer #{signer_id} initialized.");
} else {
warn!("Signer is not registered for reward cycle {reward_cycle}. Waiting for confirmed registration...");
}
Expand All @@ -285,7 +285,7 @@ impl RunLoop {
.refresh_coordinator(&pox_consensus_hash);
if old_coordinator_id != updated_coordinator_id {
debug!(
"Signer #{}: Coordinator updated. Resetting state to Idle.", signer.signer_id;
"Reward cycle #{} Signer #{}: Coordinator updated. Resetting state to Idle.", signer.reward_cycle, signer.signer_id;
"old_coordinator_id" => {old_coordinator_id},
"updated_coordinator_id" => {updated_coordinator_id},
"pox_consensus_hash" => %pox_consensus_hash
Expand All @@ -302,12 +302,14 @@ impl RunLoop {
}
}
if self.stacks_signers.is_empty() {
info!("Signer is not registered for the current {current_reward_cycle} or next {next_reward_cycle} reward cycles. Waiting for confirmed registration...");
info!("Signer is not registered for the current reward cycle ({current_reward_cycle}) or next reward cycle ({next_reward_cycle}). Waiting for confirmed registration...");
self.state = State::Uninitialized;
return Err(ClientError::NotRegistered);
}
if self.state != State::Initialized {
info!("Signer runloop successfully initialized!");
}
self.state = State::Initialized;
info!("Runloop successfully initialized!");
Ok(())
}
}
Expand Down Expand Up @@ -361,19 +363,20 @@ impl SignerRunLoop<Vec<OperationResult>, RunLoopCommand> for RunLoop {
current_reward_cycle,
) {
error!(
"Signer #{} for reward cycle {} errored processing event: {e}",
signer.signer_id, signer.reward_cycle
"Reward cycle #{} Signer #{} errored processing event: {e}",
signer.reward_cycle, signer.signer_id,
);
}
if let Some(command) = self.commands.pop_front() {
let reward_cycle = command.reward_cycle;
if signer.reward_cycle != reward_cycle {
warn!(
"Signer #{}: not registered for reward cycle {reward_cycle}. Ignoring command: {command:?}", signer.signer_id
"Reward cycle #{} Signer #{}: not registered for reward cycle {reward_cycle}. Ignoring command: {command:?}", signer.reward_cycle, signer.signer_id
);
} else {
info!(
"Signer #{}: Queuing an external runloop command ({:?}): {command:?}",
"Reward cycle #{} Signer #{}: Queuing an external runloop command ({:?}): {command:?}",
signer.reward_cycle,
signer.signer_id,
signer
.signing_round
Expand Down

0 comments on commit de9494b

Please sign in to comment.