Skip to content

Commit

Permalink
Remove gossip validation result log (#3893)
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths authored Apr 8, 2022
1 parent bc9afa7 commit 4311180
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 56 deletions.
12 changes: 1 addition & 11 deletions packages/lodestar/src/network/gossip/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from "../interface";
import {GossipActionError, GossipAction} from "../../../chain/errors";
import {createValidationQueues} from "./queue";
import {getGossipAcceptMetadataByType, GetGossipAcceptMetadataFn} from "./onAccept";

type ValidatorFnModules = {
config: IChainForkConfig;
Expand Down Expand Up @@ -68,8 +67,7 @@ function getGossipValidatorFn<K extends GossipType>(
type: K,
modules: ValidatorFnModules
): GossipValidatorFn {
const {config, logger, metrics} = modules;
const getGossipObjectAcceptMetadata = getGossipAcceptMetadataByType[type] as GetGossipAcceptMetadataFn;
const {logger, metrics} = modules;

return async function gossipValidatorFn(topic, msg, propagationSource, seenTimestampSec) {
// Define in scope above try {} to be used in catch {} if object was parsed
Expand All @@ -86,8 +84,6 @@ function getGossipValidatorFn<K extends GossipType>(

await (gossipHandler as GossipHandlerFn)(gossipObject, topic, propagationSource, seenTimestampSec);

const metadata = getGossipObjectAcceptMetadata(config, gossipObject, topic);
logger.debug(`gossip - ${type} - accept`, metadata);
metrics?.gossipValidationAccept.inc({topic: type});

return MessageAcceptance.Accept;
Expand All @@ -97,22 +93,16 @@ function getGossipValidatorFn<K extends GossipType>(
return MessageAcceptance.Ignore;
}

// If the gossipObject was deserialized include its short metadata with the error data
const metadata = gossipObject && getGossipObjectAcceptMetadata(config, gossipObject, topic);
const errorData = {...metadata, ...e.getMetadata()};

// Metrics on specific error reason
// Note: LodestarError.code are bounded pre-declared error messages, not from arbitrary error.message
metrics?.gossipValidationError.inc({topic: type, error: (e as GossipActionError<{code: string}>).type.code});

switch (e.action) {
case GossipAction.IGNORE:
logger.debug(`gossip - ${type} - ignore`, errorData);
metrics?.gossipValidationIgnore.inc({topic: type});
return MessageAcceptance.Ignore;

case GossipAction.REJECT:
logger.debug(`gossip - ${type} - reject`, errorData);
metrics?.gossipValidationReject.inc({topic: type});
return MessageAcceptance.Reject;
}
Expand Down
45 changes: 0 additions & 45 deletions packages/lodestar/src/network/gossip/validation/onAccept.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {IChainForkConfig} from "@chainsafe/lodestar-config";
import {toHexString} from "@chainsafe/ssz";
import {GossipType, GossipTypeMap, GossipTopicTypeMap} from "../interface";

export type GetGossipAcceptMetadataFn = (
Expand All @@ -14,47 +13,3 @@ export type GetGossipAcceptMetadataFns = {
topic: GossipTopicTypeMap[K]
) => Record<string, string | number>;
};

/**
* Return succint but meaningful data about accepted gossip objects.
* This data is logged at the debug level extremely frequently so it must be short.
*/
export const getGossipAcceptMetadataByType: GetGossipAcceptMetadataFns = {
[GossipType.beacon_block]: (config, signedBlock) => ({
slot: signedBlock.message.slot,
root: toHexString(config.getForkTypes(signedBlock.message.slot).BeaconBlock.hashTreeRoot(signedBlock.message)),
}),
[GossipType.beacon_aggregate_and_proof]: (config, aggregateAndProof) => {
const {data} = aggregateAndProof.message.aggregate;
return {
slot: data.slot,
index: data.index,
};
},
[GossipType.beacon_attestation]: (config, attestation, topic) => ({
slot: attestation.data.slot,
subnet: topic.subnet,
index: attestation.data.index,
}),
[GossipType.voluntary_exit]: (config, voluntaryExit) => ({
validatorIndex: voluntaryExit.message.validatorIndex,
}),
[GossipType.proposer_slashing]: (config, proposerSlashing) => ({
proposerIndex: proposerSlashing.signedHeader1.message.proposerIndex,
}),
[GossipType.attester_slashing]: (config, attesterSlashing) => ({
slot1: attesterSlashing.attestation1.data.slot,
slot2: attesterSlashing.attestation2.data.slot,
}),
[GossipType.sync_committee_contribution_and_proof]: (config, contributionAndProof) => {
const {contribution} = contributionAndProof.message;
return {
slot: contribution.slot,
index: contribution.subcommitteeIndex,
};
},
[GossipType.sync_committee]: (config, syncCommitteeSignature, topic) => ({
slot: syncCommitteeSignature.slot,
subnet: topic.subnet,
}),
};

0 comments on commit 4311180

Please sign in to comment.