Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
howardwu committed Feb 11, 2024
1 parent cdbc65f commit f779241
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cli/src/commands/start.rs
Expand Up @@ -248,7 +248,7 @@ impl Start {
let _ = PrivateKey::<N>::new(&mut rng)?;
}
let private_key = PrivateKey::<N>::new(&mut rng)?;
println!("🔑 Your development private key for node {dev} is {}\n", private_key.to_string().bold());
println!("🔑 Your development private key for node {dev} is {}.\n", private_key.to_string().bold());
private_key
})
}
Expand Down Expand Up @@ -411,7 +411,7 @@ impl Start {
// If the display is not enabled, render the welcome message.
if self.nodisplay {
// Print the Aleo address.
println!("🪪 Your Aleo address is {}.\n", account.address().to_string().bold());
println!("👛 Your Aleo address is {}.\n", account.address().to_string().bold());
// Print the node type and network.
println!(
"🧭 Starting {} on {} at {}.\n",
Expand Down
8 changes: 4 additions & 4 deletions cli/src/helpers/mod.rs
Expand Up @@ -41,8 +41,8 @@ pub fn check_open_files_limit(minimum: u64) {
// Warn about too low limit.
let warning = [
format!("⚠️ The open files limit ({soft_limit}) for this process is lower than recommended."),
format!("⚠️ To ensure correct behavior of the node, please raise it to at least {minimum}."),
"⚠️ See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(),
format!(" To ensure correct behavior of the node, please raise it to at least {minimum}."),
" See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(),
]
.join("\n")
.yellow()
Expand All @@ -54,8 +54,8 @@ pub fn check_open_files_limit(minimum: u64) {
// Warn about unknown limit.
let warning = [
format!("⚠️ Unable to check the open files limit for this process due to {err}."),
format!("⚠️ To ensure correct behavior of the node, please ensure it is at least {minimum}."),
"⚠️ See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(),
format!(" To ensure correct behavior of the node, please ensure it is at least {minimum}."),
" See the `ulimit` command and `/etc/security/limits.conf` for more details.".to_owned(),
]
.join("\n")
.yellow()
Expand Down
2 changes: 1 addition & 1 deletion node/bft/src/bft.rs
Expand Up @@ -483,7 +483,7 @@ impl<N: Network> BFT<N> {
}

/* Proceeding to commit the leader. */
info!("Proceeding to commit round {commit_round} with leader {leader}...");
info!("Proceeding to commit round {commit_round} with leader '{}'", fmt_id(leader));

// Commit the leader certificate, and all previous leader certificates since the last committed round.
self.commit_leader_certificate::<ALLOW_LEDGER_ACCESS, false>(leader_certificate).await
Expand Down
11 changes: 8 additions & 3 deletions node/bft/src/primary.rs
Expand Up @@ -554,7 +554,11 @@ impl<N: Network> Primary<N> {
// Ensure the batch is for the current round.
// This method must be called after fetching previous certificates (above),
// and prior to checking the batch header (below).
self.ensure_is_signing_round(batch_round)?;
if let Err(e) = self.ensure_is_signing_round(batch_round) {
// If the primary is not signing for the peer's round, then return early.
trace!("Skipped signing a batch for round {batch_round} from '{peer_ip}' - {e}");
return Ok(());
}

// Ensure the batch header from the peer is valid.
let (storage, header) = (self.storage.clone(), batch_header.clone());
Expand Down Expand Up @@ -1266,9 +1270,10 @@ impl<N: Network> Primary<N> {
return Ok(Default::default());
}

// Ensure this batch ID is new.
// Ensure this batch ID is new, otherwise return early.
if self.storage.contains_batch(batch_header.batch_id()) {
bail!("Batch for round {} from peer has already been processed", batch_header.round())
trace!("Batch for round {} from peer has already been processed", batch_header.round());
return Ok(Default::default());
}

// Retrieve the workers.
Expand Down
6 changes: 3 additions & 3 deletions node/bft/src/sync/mod.rs
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use crate::{
helpers::{BFTSender, Pending, Storage, SyncReceiver},
helpers::{fmt_id, BFTSender, Pending, Storage, SyncReceiver},
Gateway,
Transport,
MAX_FETCH_TIMEOUT_IN_MS,
Expand Down Expand Up @@ -358,7 +358,7 @@ impl<N: Network> Sync<N> {
if self.pending.insert(certificate_id, peer_ip, Some(callback_sender)) {
// Send the certificate request to the peer.
if self.gateway.send(peer_ip, Event::CertificateRequest(certificate_id.into())).await.is_none() {
bail!("Unable to fetch batch certificate {certificate_id} - failed to send request")
bail!("Unable to fetch certificate {} - failed to send request", fmt_id(certificate_id))
}
}
// Wait for the certificate to be fetched.
Expand All @@ -367,7 +367,7 @@ impl<N: Network> Sync<N> {
// If the certificate was fetched, return it.
Ok(result) => Ok(result?),
// If the certificate was not fetched, return an error.
Err(e) => bail!("Unable to fetch batch certificate {certificate_id} - (timeout) {e}"),
Err(e) => bail!("Unable to fetch certificate {} - (timeout) {e}", fmt_id(certificate_id)),
}
}

Expand Down

0 comments on commit f779241

Please sign in to comment.