From d559cd031bb4ad4f09eaf214bd7a6b99e130b7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Thu, 27 Apr 2023 23:37:02 +0200 Subject: [PATCH 1/2] level-monitor: Use prroper log target --- client/consensus/common/src/level_monitor.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/client/consensus/common/src/level_monitor.rs b/client/consensus/common/src/level_monitor.rs index 4f344b505a7..137480f1abc 100644 --- a/client/consensus/common/src/level_monitor.rs +++ b/client/consensus/common/src/level_monitor.rs @@ -22,6 +22,8 @@ use std::{ sync::Arc, }; +const LOG_TARGET: &'static str = "level-monitor"; + /// Value good enough to be used with parachains using the current backend implementation /// that ships with Substrate. This value may change in the future. pub const MAX_LEAVES_PER_LEVEL_SENSIBLE_DEFAULT: usize = 32; @@ -100,7 +102,7 @@ where let info = self.backend.blockchain().info(); log::debug!( - target: "parachain", + target: LOG_TARGET, "Restoring chain level monitor from last finalized block: {} {}", info.finalized_number, info.finalized_hash ); @@ -124,7 +126,7 @@ where } } - log::debug!(target: "parachain", "Restored chain level monitor up to height {}", self.import_counter); + log::debug!(target: LOG_TARGET, "Restored chain level monitor up to height {}", self.import_counter); } /// Check and enforce the limit bound at the given height. @@ -161,7 +163,7 @@ where let remove_count = level_len - self.level_limit + 1; log::debug!( - target: "parachain", + target: LOG_TARGET, "Detected leaves overflow at height {number}, removing {remove_count} obsolete blocks", ); @@ -224,7 +226,7 @@ where }), Err(err) => { log::warn!( - target: "parachain", + target: LOG_TARGET, "(Lookup) Unable getting route from {:?} to {:?}: {}", blk_hash, leaf_hash, err, ); @@ -243,7 +245,7 @@ where None => { // This should never happen log::error!( - target: "parachain", + target: LOG_TARGET, "Unable getting route to any leaf from {:?} (this is a bug)", blk_hash, ); @@ -294,9 +296,9 @@ where invalidated_leaves: &mut HashSet, ) { let mut remove_leaf = |number, hash| { - log::debug!(target: "parachain", "Removing block (@{}) {:?}", number, hash); + log::debug!(target: LOG_TARGET, "Removing block (@{}) {:?}", number, hash); if let Err(err) = self.backend.remove_leaf_block(hash) { - log::debug!(target: "parachain", "Remove not possible for {}: {}", hash, err); + log::debug!(target: LOG_TARGET, "Remove not possible for {}: {}", hash, err); return false } self.levels.get_mut(&number).map(|level| level.remove(&hash)); @@ -337,7 +339,7 @@ where }, Err(err) => { log::warn!( - target: "parachain", + target: LOG_TARGET, "(Removal) unable getting route from {:?} to {:?}: {}", target_hash, leaf_hash, err, ); From 5a000b43449df6bba99444902a2bbd2f35b4bbde Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Fri, 28 Apr 2023 07:21:07 +0000 Subject: [PATCH 2/2] ".git/.scripts/commands/fmt/fmt.sh" --- client/consensus/common/src/level_monitor.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/client/consensus/common/src/level_monitor.rs b/client/consensus/common/src/level_monitor.rs index 137480f1abc..3576ced1858 100644 --- a/client/consensus/common/src/level_monitor.rs +++ b/client/consensus/common/src/level_monitor.rs @@ -104,7 +104,8 @@ where log::debug!( target: LOG_TARGET, "Restoring chain level monitor from last finalized block: {} {}", - info.finalized_number, info.finalized_hash + info.finalized_number, + info.finalized_hash ); self.lowest_level = info.finalized_number; @@ -126,7 +127,11 @@ where } } - log::debug!(target: LOG_TARGET, "Restored chain level monitor up to height {}", self.import_counter); + log::debug!( + target: LOG_TARGET, + "Restored chain level monitor up to height {}", + self.import_counter + ); } /// Check and enforce the limit bound at the given height. @@ -228,7 +233,9 @@ where log::warn!( target: LOG_TARGET, "(Lookup) Unable getting route from {:?} to {:?}: {}", - blk_hash, leaf_hash, err, + blk_hash, + leaf_hash, + err, ); None }, @@ -341,7 +348,9 @@ where log::warn!( target: LOG_TARGET, "(Removal) unable getting route from {:?} to {:?}: {}", - target_hash, leaf_hash, err, + target_hash, + leaf_hash, + err, ); }, _ => (),