From 6efcf9bbdd4575f2712efd6fc426d6151f631094 Mon Sep 17 00:00:00 2001 From: Giulio rebuffo Date: Fri, 3 May 2024 08:33:14 +0200 Subject: [PATCH] Unnecessary Logs in sentry removed (#10187) Steps to reproduce: 1) Sync snapshots and no other stage 2) Stop 3) No Head Header so hell break loose. --- p2p/sentry/sentry_multi_client/sentry_multi_client.go | 4 +++- p2p/sentry/status_data_provider.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/p2p/sentry/sentry_multi_client/sentry_multi_client.go b/p2p/sentry/sentry_multi_client/sentry_multi_client.go index 0f32615b949..ef62bfaa84a 100644 --- a/p2p/sentry/sentry_multi_client/sentry_multi_client.go +++ b/p2p/sentry/sentry_multi_client/sentry_multi_client.go @@ -156,7 +156,9 @@ func SentryReconnectAndPumpStreamLoop[TMessage interface{}]( statusData, err := statusDataFactory(ctx) if err != nil { - logger.Error("SentryReconnectAndPumpStreamLoop: statusDataFactory error", "stream", streamName, "err", err) + if !errors.Is(err, sentry.ErrNoHead) { + logger.Error("SentryReconnectAndPumpStreamLoop: statusDataFactory error", "stream", streamName, "err", err) + } time.Sleep(time.Second) continue } diff --git a/p2p/sentry/status_data_provider.go b/p2p/sentry/status_data_provider.go index fffd98d829b..91137e5c321 100644 --- a/p2p/sentry/status_data_provider.go +++ b/p2p/sentry/status_data_provider.go @@ -18,6 +18,8 @@ import ( "github.com/ledgerwatch/erigon/core/types" ) +var ErrNoHead = errors.New("ReadChainHead: ReadCurrentHeader error") + type ChainHead struct { HeadHeight uint64 HeadTime uint64 @@ -77,7 +79,7 @@ func (s *StatusDataProvider) GetStatusData(ctx context.Context) (*proto_sentry.S func ReadChainHeadWithTx(tx kv.Tx) (ChainHead, error) { header := rawdb.ReadCurrentHeaderHavingBody(tx) if header == nil { - return ChainHead{}, errors.New("ReadChainHead: ReadCurrentHeader error") + return ChainHead{}, ErrNoHead } height := header.Number.Uint64()