From 7931766c849b979782a5c4a60e4f9f59a3f48327 Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 27 Aug 2020 19:16:56 +1000 Subject: [PATCH] fix: Improve checkpoint diagnostics Improve metrics and logging when the checkpoint verifier is waiting for more blocks. --- zebra-consensus/src/checkpoint.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/zebra-consensus/src/checkpoint.rs b/zebra-consensus/src/checkpoint.rs index e06af4a9..59b12390 100644 --- a/zebra-consensus/src/checkpoint.rs +++ b/zebra-consensus/src/checkpoint.rs @@ -267,6 +267,13 @@ impl CheckpointVerifier { if height == block::Height(pending_height.0 + 1) { pending_height = height; } else { + let gap = height.0 - pending_height.0; + // Try to log a useful message when checkpointing has issues + tracing::trace!(contiguous_height = ?pending_height, + next_height = ?height, + ?gap, + "Waiting for more checkpoint blocks"); + metrics::gauge!("checkpoint.contiguous.height", pending_height.0 as i64); break; } } @@ -331,7 +338,10 @@ impl CheckpointVerifier { InitialTip(previous_height) | PreviousCheckpoint(previous_height) if (height <= previous_height) => { - Err(format!("Block has already been verified. {:?}", height))? + Err(format!( + "Block height has already been verified. {:?}", + height + ))? } InitialTip(_) | PreviousCheckpoint(_) => {} // We're finished, so no checkpoint height is valid