Skip to content

Commit

Permalink
style(signer): standardize logs based on aggregator rules
Browse files Browse the repository at this point in the history
* Capitalize first letter of functionnal logs
* Make function enter logs start with a `>>` followed by the function
name.
* Add a little more data on runner function entries logs
  • Loading branch information
Alenar committed Oct 15, 2024
1 parent 0dd19f9 commit 2f5652f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 31 deletions.
23 changes: 13 additions & 10 deletions mithril-signer/src/runtime/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl SignerRunner {
#[async_trait]
impl Runner for SignerRunner {
async fn get_epoch_settings(&self) -> StdResult<Option<SignerEpochSettings>> {
debug!(self.logger, "get_epoch_settings");
debug!(self.logger, ">> get_epoch_settings");

self.services
.certificate_handler
Expand All @@ -114,13 +114,13 @@ impl Runner for SignerRunner {
}

async fn get_beacon_to_sign(&self) -> StdResult<Option<BeaconToSign>> {
debug!(self.logger, "get_beacon_to_sign");
debug!(self.logger, ">> get_beacon_to_sign");

self.services.certifier.get_beacon_to_sign().await
}

async fn get_current_time_point(&self) -> StdResult<TimePoint> {
debug!(self.logger, "get_current_time_point");
debug!(self.logger, ">> get_current_time_point");

self.services
.ticker_service
Expand All @@ -130,7 +130,7 @@ impl Runner for SignerRunner {
}

async fn register_signer_to_aggregator(&self) -> StdResult<()> {
debug!(self.logger, "register_signer_to_aggregator");
debug!(self.logger, ">> register_signer_to_aggregator");

let (epoch, protocol_parameters) = {
let epoch_service = self.services.epoch_service.read().await;
Expand Down Expand Up @@ -206,7 +206,7 @@ impl Runner for SignerRunner {
}

async fn update_stake_distribution(&self, epoch: Epoch) -> StdResult<()> {
debug!(self.logger, "update_stake_distribution");
debug!(self.logger, ">> update_stake_distribution(epoch: {epoch})");

let exists_stake_distribution = !self
.services
Expand Down Expand Up @@ -239,7 +239,10 @@ impl Runner for SignerRunner {
}

async fn inform_epoch_settings(&self, epoch_settings: SignerEpochSettings) -> StdResult<()> {
debug!(self.logger, "register_epoch");
debug!(
self.logger,
">> inform_epoch_settings(epoch:{})", epoch_settings.epoch
);
let aggregator_features = self
.services
.certificate_handler
Expand All @@ -261,7 +264,7 @@ impl Runner for SignerRunner {
&self,
signed_entity_type: &SignedEntityType,
) -> StdResult<ProtocolMessage> {
debug!(self.logger, "compute_message");
debug!(self.logger, ">> compute_message({signed_entity_type:?})");

let protocol_message = self
.services
Expand All @@ -278,15 +281,15 @@ impl Runner for SignerRunner {
beacon_to_sign: &BeaconToSign,
message: &ProtocolMessage,
) -> StdResult<()> {
debug!(self.logger, "compute_publish_single_signature");
debug!(self.logger, ">> compute_publish_single_signature"; "beacon_to_sign" => ?beacon_to_sign);
self.services
.certifier
.compute_publish_single_signature(beacon_to_sign, message)
.await
}

async fn update_era_checker(&self, epoch: Epoch) -> StdResult<()> {
debug!(self.logger, "update_era_checker");
debug!(self.logger, ">> update_era_checker(epoch:{epoch})");

let era_token = self
.services
Expand Down Expand Up @@ -314,7 +317,7 @@ impl Runner for SignerRunner {
}

async fn upkeep(&self, current_epoch: Epoch) -> StdResult<()> {
debug!(self.logger, "upkeep");
debug!(self.logger, ">> upkeep(current_epoch:{current_epoch})");
self.services.upkeep_service.run(current_epoch).await?;
Ok(())
}
Expand Down
21 changes: 9 additions & 12 deletions mithril-signer/src/runtime/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl StateMachine {

/// Launch the state machine until an error occurs or it is interrupted.
pub async fn run(&self) -> Result<(), RuntimeError> {
info!(self.logger, "launching");
info!(self.logger, "Launching State Machine");

loop {
if let Err(e) = self.cycle().await {
Expand All @@ -135,7 +135,7 @@ impl StateMachine {
self.logger,
"================================================================================"
);
info!(self.logger, "new cycle: {}", *state);
info!(self.logger, "New cycle: {}", *state);

self.metrics_service
.runtime_cycle_total_since_startup_counter_increment();
Expand Down Expand Up @@ -164,17 +164,16 @@ impl StateMachine {
{
info!(self.logger, "→ Epoch settings found");
if epoch_settings.epoch >= *epoch {
info!(self.logger, "new Epoch found");
info!(self.logger, " ⋅ transiting to Registered");
info!(self.logger, "New Epoch found");
info!(self.logger, " ⋅ Transiting to Registered");
*state = self
.transition_from_unregistered_to_one_of_registered_states(
epoch_settings,
)
.await?;
} else {
info!(
self.logger,
" ⋅ Epoch settings found, but its epoch is behind the known epoch, waiting…";
self.logger, " ⋅ Epoch settings found, but its epoch is behind the known epoch, waiting…";
"epoch_settings" => ?epoch_settings,
"known_epoch" => ?epoch,
);
Expand All @@ -187,7 +186,7 @@ impl StateMachine {
if let Some(new_epoch) = self.has_epoch_changed(*epoch).await? {
info!(
self.logger,
" → new Epoch detected, transiting to Unregistered"
" → New Epoch detected, transiting to Unregistered"
);
*state = self
.transition_from_registered_not_able_to_sign_to_unregistered(new_epoch)
Expand Down Expand Up @@ -218,16 +217,15 @@ impl StateMachine {
match beacon_to_sign {
Some(beacon) => {
info!(
self.logger,
"→ Epoch has NOT changed we can sign this beacon, transiting to ReadyToSign";
self.logger, "→ Epoch has NOT changed we can sign this beacon, transiting to ReadyToSign";
"beacon_to_sign" => ?beacon,
);
*state = self
.transition_from_ready_to_sign_to_ready_to_sign(*epoch, beacon)
.await?;
}
None => {
info!(self.logger, " ⋅ no beacon to sign, waiting…");
info!(self.logger, " ⋅ No beacon to sign, waiting…");
}
}
}
Expand Down Expand Up @@ -373,8 +371,7 @@ impl StateMachine {
);

debug!(
self.logger,
" > transition_from_ready_to_sign_to_ready_to_sign";
self.logger, ">> transition_from_ready_to_sign_to_ready_to_sign";
"current_epoch" => ?current_epoch,
"retrieval_epoch" => ?retrieval_epoch,
"next_retrieval_epoch" => ?next_retrieval_epoch,
Expand Down
4 changes: 2 additions & 2 deletions mithril-signer/src/services/certifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl CertifierService for SignerCertifierService {
.compute_single_signatures(protocol_message)
.await?
{
debug!(self.logger, " > there is a single signature to send");
debug!(self.logger, " > There is a single signature to send");
self.signature_publisher
.publish(
&beacon_to_sign.signed_entity_type,
Expand All @@ -163,7 +163,7 @@ impl CertifierService for SignerCertifierService {
debug!(self.logger, " > NO single signature to send");
}

debug!(self.logger, " > marking beacon as signed"; "beacon" => ?beacon_to_sign);
debug!(self.logger, " > Marking beacon as signed"; "beacon" => ?beacon_to_sign);
self.signed_beacon_store
.mark_beacon_as_signed(beacon_to_sign)
.await?;
Expand Down
11 changes: 7 additions & 4 deletions mithril-signer/src/services/epoch_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ impl MithrilEpochService {
epoch: Epoch,
signers: &[Signer],
) -> StdResult<Vec<SignerWithStake>> {
debug!(self.logger, "associate_signers_with_stake");
debug!(
self.logger,
">> associate_signers_with_stake(epoch:{epoch})"
);

let stakes = self
.stake_storer
Expand All @@ -143,7 +146,7 @@ impl MithrilEpochService {
));
trace!(
self.logger,
" > associating signer_id {} with stake {}",
" > Associating signer_id {} with stake {}",
signer.party_id,
*stake
);
Expand Down Expand Up @@ -177,7 +180,7 @@ impl EpochService for MithrilEpochService {
epoch_settings: SignerEpochSettings,
allowed_discriminants: BTreeSet<SignedEntityTypeDiscriminants>,
) -> StdResult<()> {
debug!(self.logger, "register_epoch_settings"; "epoch_settings" => ?epoch_settings);
debug!(self.logger, ">> inform_epoch_settings"; "epoch_settings" => ?epoch_settings);

let epoch = epoch_settings.epoch;
let protocol_initializer = self
Expand Down Expand Up @@ -259,7 +262,7 @@ impl EpochService for MithrilEpochService {
if let Some(protocol_initializer) = self.protocol_initializer()? {
debug!(
self.logger,
" > got protocol initializer for this epoch ({epoch})"
" > Got protocol initializer for this epoch ({epoch})"
);
if self
.is_signer_included_in_current_stake_distribution(party_id, protocol_initializer)?
Expand Down
2 changes: 1 addition & 1 deletion mithril-signer/src/services/single_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl SingleSigner for MithrilSingleSigner {
None => {
warn!(
self.logger,
"no signature computed, all lotteries were lost"
"No signature computed, all lotteries were lost"
);
}
};
Expand Down
4 changes: 2 additions & 2 deletions mithril-signer/src/services/upkeep_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl SignerUpkeepService {
#[async_trait]
impl UpkeepService for SignerUpkeepService {
async fn run(&self, current_epoch: Epoch) -> StdResult<()> {
info!(self.logger, "start upkeep of the application");
info!(self.logger, "Start upkeep of the application");

self.execute_pruning_tasks(current_epoch)
.await
Expand All @@ -133,7 +133,7 @@ impl UpkeepService for SignerUpkeepService {
.await
.with_context(|| "Database upkeep failed")?;

info!(self.logger, "upkeep finished");
info!(self.logger, "Upkeep finished");
Ok(())
}
}
Expand Down

0 comments on commit 2f5652f

Please sign in to comment.