From 2d0b214b579cde145e0b40b0f6f1f808d9df89ba Mon Sep 17 00:00:00 2001 From: Age Manning Date: Tue, 18 Aug 2020 08:11:39 +0000 Subject: [PATCH] Clean up logs (#1541) ## Description This PR improves some logging for the end-user. It downgrades some warning logs and removes the slots per second sync speed if we are syncing and the speed is 0. This is likely because we are syncing from a finalised checkpoint and the head doesn't change. --- beacon_node/client/src/notifier.rs | 61 +++++++++++++++---- .../src/beacon_processor/chain_segment.rs | 2 +- .../network/src/beacon_processor/mod.rs | 7 +++ 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/beacon_node/client/src/notifier.rs b/beacon_node/client/src/notifier.rs index 208bd389a..f82c9971d 100644 --- a/beacon_node/client/src/notifier.rs +++ b/beacon_node/client/src/notifier.rs @@ -122,14 +122,28 @@ pub fn spawn_notifier( head_distance.as_u64(), slot_distance_pretty(head_distance, slot_duration) ); - info!( - log, - "Syncing"; - "peers" => peer_count_pretty(connected_peer_count), - "distance" => distance, - "speed" => sync_speed_pretty(speedo.slots_per_second()), - "est_time" => estimated_time_pretty(speedo.estimated_time_till_slot(current_slot)), - ); + + let speed = speedo.slots_per_second(); + let display_speed = speed.map_or(false, |speed| speed != 0.0); + + if display_speed { + info!( + log, + "Syncing"; + "peers" => peer_count_pretty(connected_peer_count), + "distance" => distance, + "speed" => sync_speed_pretty(speed), + "est_time" => estimated_time_pretty(speedo.estimated_time_till_slot(current_slot)), + ); + } else { + info!( + log, + "Syncing"; + "peers" => peer_count_pretty(connected_peer_count), + "distance" => distance, + "est_time" => estimated_time_pretty(speedo.estimated_time_till_slot(current_slot)), + ); + } } else if sync_state.is_synced() { let block_info = if current_slot > head_slot { " … empty".to_string() @@ -220,14 +234,37 @@ fn seconds_pretty(secs: f64) -> String { let hours = d.whole_hours(); let minutes = d.whole_minutes(); + let week_string = if weeks == 1 { "week" } else { "weeks" }; + let day_string = if days == 1 { "day" } else { "days" }; + let hour_string = if hours == 1 { "hr" } else { "hrs" }; + let min_string = if minutes == 1 { "min" } else { "mins" }; + if weeks > 0 { - format!("{:.0} weeks {:.0} days", weeks, days % DAYS_PER_WEEK) + format!( + "{:.0} {} {:.0} {}", + weeks, + week_string, + days % DAYS_PER_WEEK, + day_string + ) } else if days > 0 { - format!("{:.0} days {:.0} hrs", days, hours % HOURS_PER_DAY) + format!( + "{:.0} {} {:.0} {}", + days, + day_string, + hours % HOURS_PER_DAY, + hour_string + ) } else if hours > 0 { - format!("{:.0} hrs {:.0} mins", hours, minutes % MINUTES_PER_HOUR) + format!( + "{:.0} {} {:.0} {}", + hours, + hour_string, + minutes % MINUTES_PER_HOUR, + min_string + ) } else { - format!("{:.0} mins", minutes) + format!("{:.0} {}", minutes, min_string) } } diff --git a/beacon_node/network/src/beacon_processor/chain_segment.rs b/beacon_node/network/src/beacon_processor/chain_segment.rs index a327565e7..94c7893f0 100644 --- a/beacon_node/network/src/beacon_processor/chain_segment.rs +++ b/beacon_node/network/src/beacon_processor/chain_segment.rs @@ -81,7 +81,7 @@ pub fn handle_chain_segment( // reverse match process_blocks(chain, downloaded_blocks.iter().rev(), &log) { (_, Err(e)) => { - warn!(log, "Parent lookup failed"; "last_peer_id" => format!("{}", peer_id), "error" => e); + debug!(log, "Parent lookup failed"; "last_peer_id" => format!("{}", peer_id), "error" => e); sync_send .send(SyncMessage::ParentLookupFailed{peer_id, chain_head}) .unwrap_or_else(|_| { diff --git a/beacon_node/network/src/beacon_processor/mod.rs b/beacon_node/network/src/beacon_processor/mod.rs index 6cce8a28a..ba8243cb3 100644 --- a/beacon_node/network/src/beacon_processor/mod.rs +++ b/beacon_node/network/src/beacon_processor/mod.rs @@ -774,6 +774,13 @@ impl BeaconProcessor { ); return; } + Err(BlockError::BlockIsAlreadyKnown) => { + debug!( + log, + "Gossip block is already known"; + ); + return; + } Err(e) => { warn!( log,