Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reduce verbosity of gossip block errors #6430

Merged
merged 7 commits into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions packages/beacon-node/src/network/processor/gossipHandlers.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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: {
Expand All @@ -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
Expand All @@ -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();
});
}
Expand Down