mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-01-12 22:43:42 +08:00
signer-messages
This commit is contained in:
@@ -25,7 +25,7 @@ use libsigner::{SignerEntries, SignerEvent, SignerRunLoop};
|
||||
use slog::{slog_debug, slog_error, slog_info, slog_warn};
|
||||
use stacks_common::types::chainstate::StacksAddress;
|
||||
use stacks_common::{debug, error, info, warn};
|
||||
use wsts::state_machine::OperationResult;
|
||||
use wsts::state_machine::{signer, OperationResult};
|
||||
|
||||
use crate::client::{retry_with_exponential_backoff, ClientError, StacksClient};
|
||||
use crate::config::{GlobalConfig, SignerConfig};
|
||||
@@ -371,6 +371,7 @@ impl SignerRunLoop<Vec<OperationResult>, RunLoopCommand> for RunLoop {
|
||||
if let Some(cmd) = cmd {
|
||||
self.commands.push_back(cmd);
|
||||
}
|
||||
|
||||
if self.state == State::Uninitialized {
|
||||
if let Err(e) = self.initialize_runloop() {
|
||||
error!("Failed to initialize signer runloop: {e}.");
|
||||
@@ -390,10 +391,11 @@ impl SignerRunLoop<Vec<OperationResult>, RunLoopCommand> for RunLoop {
|
||||
.as_ref()
|
||||
.expect("FATAL: cannot be an initialized signer with no reward cycle info.")
|
||||
.reward_cycle;
|
||||
|
||||
if self.state == State::NoRegisteredSigners {
|
||||
let next_reward_cycle = current_reward_cycle.saturating_add(1);
|
||||
if let Some(event) = event {
|
||||
info!("Signer is not registered for the current reward cycle ({current_reward_cycle}) or next reward cycle ({next_reward_cycle}). Waiting for confirmed registration...");
|
||||
info!("Signer is not registered for the current reward cycle ({current_reward_cycle}). Reward set of upcoming reward cycle ({next_reward_cycle}) is not yet determined. Waiting for confirmation...");
|
||||
warn!("Ignoring event: {event:?}");
|
||||
}
|
||||
return None;
|
||||
@@ -422,6 +424,27 @@ impl SignerRunLoop<Vec<OperationResult>, RunLoopCommand> for RunLoop {
|
||||
error!("{signer}: failed to refresh DKG: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
// Has been determined and we are still not registered
|
||||
if self.state == State::NoRegisteredSigners {
|
||||
let next_reward_cycle = current_reward_cycle.saturating_add(1);
|
||||
if let Some(event) = event {
|
||||
info!("Signer is not registered for the current reward cycle ({current_reward_cycle}) or the upcoming reward cycle ({next_reward_cycle}). Nothing to do");
|
||||
warn!("Ignoring event: {event:?}");
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
// Has been determined and we are registered
|
||||
if self.state == State::RegisteredSigners {
|
||||
let next_reward_cycle = current_reward_cycle.saturating_add(1);
|
||||
if let Some(event) = event {
|
||||
info!("Signer is (not) registered for the current reward cycle ({current_reward_cycle}) and the signer is registered for the upcoming reward cycle ({next_reward_cycle}). Nothing to do");
|
||||
warn!("Ignoring event: {event:?}");
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
signer.refresh_coordinator();
|
||||
if let Err(e) = signer.process_event(
|
||||
&self.stacks_client,
|
||||
@@ -433,9 +456,12 @@ impl SignerRunLoop<Vec<OperationResult>, RunLoopCommand> for RunLoop {
|
||||
}
|
||||
if let Some(command) = self.commands.pop_front() {
|
||||
let reward_cycle = command.reward_cycle;
|
||||
let next_reward_cycle = current_reward_cycle.saturating_add(1);
|
||||
if signer.reward_cycle != reward_cycle {
|
||||
warn!(
|
||||
"{signer}: not registered for reward cycle {reward_cycle}. Ignoring command: {command:?}"
|
||||
// Not registered for the next reward_cycle
|
||||
// "{signer}: not registered for reward cycle {reward_cycle}. Ignoring command: {command:?}"
|
||||
"Signer is registered for the current reward cycle ({reward_cycle}). Reward set of upcoming reward cycle ({next_reward_cycle}) is not yet determined."
|
||||
);
|
||||
} else {
|
||||
info!(
|
||||
|
||||
Reference in New Issue
Block a user