From 1ae671e09a1385a468f1a18fbcb10c3efcc41091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 8 May 2023 16:42:17 +0200 Subject: [PATCH] sc-informant: Do not show `Block history` if doing major sync (#14094) After warp syncing a node it still downloads the block history. If the node is stopped and then started later while downloading the block history, the node first needs to do a major sync to sync to the tip of the chain. Before informant was showing `Block history` as sync state, while we actually were doing a major sync. This pr is fixing this. --- substrate/client/informant/src/display.rs | 29 ++++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/substrate/client/informant/src/display.rs b/substrate/client/informant/src/display.rs index 2f10130722..722cf56d77 100644 --- a/substrate/client/informant/src/display.rs +++ b/substrate/client/informant/src/display.rs @@ -98,25 +98,36 @@ impl InformantDisplay { let (level, status, target) = match (sync_status.state, sync_status.state_sync, sync_status.warp_sync) { + // Do not set status to "Block history" when we are doing a major sync. + // + // A node could for example have been warp synced to the tip of the chain and + // shutdown. At the next start we still need to download the block history, but + // first will sync to the tip of the chain. ( - _, + sync_status, _, Some(WarpSyncProgress { phase: WarpSyncPhase::DownloadingBlocks(n), .. }), - ) => ("⏩", "Block history".into(), format!(", #{}", n)), + ) if !sync_status.is_major_syncing() => ("⏩", "Block history".into(), format!(", #{}", n)), ( _, _, Some(WarpSyncProgress { phase: WarpSyncPhase::AwaitingTargetBlock, .. }), ) => ("⏩", "Waiting for pending target block".into(), "".into()), - (_, _, Some(warp)) => ( - "⏩", - "Warping".into(), - format!( - ", {}, {:.2} Mib", + // Handle all phases besides the two phases we already handle above. + (_, _, Some(warp)) + if !matches!( warp.phase, - (warp.total_bytes as f32) / (1024f32 * 1024f32) + WarpSyncPhase::AwaitingTargetBlock | WarpSyncPhase::DownloadingBlocks(_) + ) => + ( + "⏩", + "Warping".into(), + format!( + ", {}, {:.2} Mib", + warp.phase, + (warp.total_bytes as f32) / (1024f32 * 1024f32) + ), ), - ), (_, Some(state), _) => ( "⚙️ ", "Downloading state".into(),