From 468cf823bb85eb161cd692f3984c71418fe4ce8f Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Wed, 23 Jul 2025 14:48:31 +0800 Subject: [PATCH] eth/protocols/snap: fix metrics --- eth/protocols/snap/sync.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/eth/protocols/snap/sync.go b/eth/protocols/snap/sync.go index 4730d2317b..1ef4e00fbc 100644 --- a/eth/protocols/snap/sync.go +++ b/eth/protocols/snap/sync.go @@ -689,11 +689,12 @@ func (s *Syncer) Sync(root common.Hash, cancel chan struct{}) error { if len(s.tasks) == 0 && s.healer.scheduler.Pending() == 0 { // State healing phase completed, record the elapsed time in metrics. // Note: healing may be rerun in subsequent cycles to fill gaps between - // pivot states (e.g., if chain sync takes longer). The initial healing - // phase is more important for us. - stateHealTimeResettingTimer.Update(time.Since(s.healStartTime)) - log.Info("State healing phase is completed", "elapsed", common.PrettyDuration(time.Since(s.healStartTime))) - s.healStartTime = time.Time{} // zero the start time + // pivot states (e.g., if chain sync takes longer). + if !s.healStartTime.IsZero() { + stateHealTimeResettingTimer.Update(time.Since(s.healStartTime)) + log.Info("State healing phase is completed", "elapsed", common.PrettyDuration(time.Since(s.healStartTime))) + s.healStartTime = time.Time{} + } return nil } // Assign all the data retrieval tasks to any free peers