From 9b1510a0df8b7517376686eb79d470ec287e014a Mon Sep 17 00:00:00 2001 From: viquezclaudio Date: Mon, 28 Oct 2024 16:13:01 -0600 Subject: [PATCH] Improve migration logging --- pow-migration/src/lib.rs | 14 +++++++++----- pow-migration/src/monitor.rs | 18 +++++++++--------- pow-migration/src/state.rs | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/pow-migration/src/lib.rs b/pow-migration/src/lib.rs index 6ca018b6f..e0403b4d8 100644 --- a/pow-migration/src/lib.rs +++ b/pow-migration/src/lib.rs @@ -324,10 +324,10 @@ pub async fn migrate( panic!("We cannot migrate with just 1 active validator"); } - log::debug!("This is the list of stakers:"); + log::trace!("This is the list of stakers:"); for staker in &stakers { - log::debug!( + log::trace!( staker_address = %staker.staker_address, balance = %staker.balance ); @@ -402,15 +402,19 @@ pub async fn migrate( .unwrap_or_else(|error| exit_with_error(error, "Failed to serialize genesis config")); let genesis_config_hash = hasher.finish(); log::info!( - genesis_config_hash = %genesis_config_hash, + genesis_hash = %genesis_config_hash, "PoS Genesis generation is completed" ); loop { let current_height = async_retryer(|| pow_client.block_number()).await.unwrap(); - log::info!(current_height); - let next_candidate = candidate_block + block_windows.readiness_window; + log::info!( + activation_window, + candidate_block, + current_height, + next_candidate + ); if current_height > next_candidate { log::info!( diff --git a/pow-migration/src/monitor.rs b/pow-migration/src/monitor.rs index d46d88a3c..b7b2a0af7 100644 --- a/pow-migration/src/monitor.rs +++ b/pow-migration/src/monitor.rs @@ -1,6 +1,6 @@ use std::ops::Range; -use log::{error, info}; +use log::{debug, error, info, trace}; use nimiq_hash::Blake2bHash; use nimiq_keys::Address; use nimiq_primitives::coin::Coin; @@ -192,7 +192,7 @@ pub async fn check_validators_ready( let mut ready_validators = Vec::new(); let genesis_config_hash_hex = pos_genesis_config_hash.to_hex(); - log::info!("Starting to collect transactions from validators..."); + trace!("Starting to collect transactions from validators..."); // Now we need to collect all the transactions for each validator for validator in validators { @@ -203,7 +203,7 @@ pub async fn check_validators_ready( if let Ok(transactions) = async_retryer(|| pow_client.get_transactions_by_address(&address, 10)).await { - info!( + trace!( num_transactions = transactions.len(), from_address = address, "Transactions found for validator" @@ -215,7 +215,7 @@ pub async fn check_validators_ready( is_valid_ready_txn(txn, &activation_block_window, &genesis_config_hash_hex) }) .collect(); - info!( + trace!( num_transactions = filtered_txns.len(), "Transactions that met the readiness criteria", ); @@ -245,16 +245,16 @@ pub async fn check_validators_ready( let needed_stake = percent.apply_to(u64::from(total_stake)); info!( - needed_stake, - stake_ready = u64::from(ready_stake), - "Stake needed vs ready" + needed = %Coin::from_u64_unchecked(needed_stake), + ready = %ready_stake, + "Stake needed vs Stake ready" ); if u64::from(ready_stake) >= needed_stake { - info!("Enough validators are ready to start the PoS Chain!"); + debug!("Enough validators are ready to start the PoS Chain!"); ValidatorsReadiness::Ready(ready_stake) } else { - info!(needed_stake, "Not enough validators are ready"); + debug!(needed_stake, "Not enough validators are ready"); ValidatorsReadiness::NotReady(ready_stake) } } diff --git a/pow-migration/src/state.rs b/pow-migration/src/state.rs index 5b98431e7..7f659f118 100644 --- a/pow-migration/src/state.rs +++ b/pow-migration/src/state.rs @@ -155,7 +155,7 @@ pub async fn get_accounts( break; } start_prefix = chunk.tail; - log::debug!(size = chunk.nodes.len(), "Processing accounts tree chunk"); + log::trace!(size = chunk.nodes.len(), "Processing accounts tree chunk"); for node in chunk.nodes { match node.account { nimiq_rpc::primitives::Account::Basic(pow_account) => {