From 48871ebfffaccf686fe68b7936acbd9dd393e239 Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Thu, 15 Feb 2024 16:15:15 +0100 Subject: [PATCH] fix: reduce verbosity of gossip block errors (#6430) * Log gossip block errors as warnings * Only log to debug if blobs are unavailable * Always prune cache and track error in metrics * Adapt log level (verbosity) based on error * Do not initialize log level to ensure each case is handled explicitly * Update comments * Update comment --- .../src/network/processor/gossipHandlers.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/beacon-node/src/network/processor/gossipHandlers.ts b/packages/beacon-node/src/network/processor/gossipHandlers.ts index bdd5f1917dc5..2bf9178a0567 100644 --- a/packages/beacon-node/src/network/processor/gossipHandlers.ts +++ b/packages/beacon-node/src/network/processor/gossipHandlers.ts @@ -1,6 +1,6 @@ import {toHexString} from "@chainsafe/ssz"; import {BeaconConfig} from "@lodestar/config"; -import {Logger, prettyBytes} from "@lodestar/utils"; +import {LogLevel, Logger, prettyBytes} from "@lodestar/utils"; import {Root, Slot, ssz, allForks, deneb} from "@lodestar/types"; import {ForkName, ForkSeq} from "@lodestar/params"; import {routes} from "@lodestar/api"; @@ -255,6 +255,9 @@ function getDefaultHandlers(modules: ValidatorFnsModules, options: GossipHandler chain.seenGossipBlockInput.prune(); }) .catch((e) => { + // Adjust verbosity based on error type + let logLevel: LogLevel; + if (e instanceof BlockError) { switch (e.type.code) { case BlockErrorCode.DATA_UNAVAILABLE: { @@ -264,6 +267,9 @@ function getDefaultHandlers(modules: ValidatorFnsModules, options: GossipHandler const rootHex = toHexString(forkTypes.BeaconBlock.hashTreeRoot(signedBlock.message)); events.emit(NetworkEvent.unknownBlock, {rootHex, peer: peerIdStr}); + + // Error is quite frequent and not critical + logLevel = LogLevel.debug; break; } // ALREADY_KNOWN should not happen with ignoreIfKnown=true above @@ -272,14 +278,21 @@ function getDefaultHandlers(modules: ValidatorFnsModules, options: GossipHandler case BlockErrorCode.PARENT_UNKNOWN: case BlockErrorCode.PRESTATE_MISSING: case BlockErrorCode.EXECUTION_ENGINE_ERROR: + // Errors might indicate an issue with our node or the connected EL client + logLevel = LogLevel.error; break; default: // TODO: Should it use PeerId or string? core.reportPeer(peerIdStr, PeerAction.LowToleranceError, "BadGossipBlock"); + // Misbehaving peer, but could highlight an issue in another client + logLevel = LogLevel.warn; } + } else { + // Any unexpected error + logLevel = LogLevel.error; } metrics?.gossipBlock.processBlockErrors.inc({error: e instanceof BlockError ? e.type.code : "NOT_BLOCK_ERROR"}); - logger.error("Error receiving block", {slot: signedBlock.message.slot, peer: peerIdStr}, e as Error); + logger[logLevel]("Error receiving block", {slot: signedBlock.message.slot, peer: peerIdStr}, e as Error); chain.seenGossipBlockInput.prune(); }); }