Skip to content

Commit 801b1f4

Browse files
authored
feat: log agent, version and peerid for batched gossip errors (#8604)
**Motivation** Logs client meta for batch processed gossip errors
1 parent 782dc5e commit 801b1f4

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

packages/beacon-node/src/network/processor/gossipValidatorFn.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,19 @@ export function getGossipValidatorBatchFn(
4646
}))
4747
);
4848

49-
return results.map((e) => {
49+
return results.map((e, i) => {
5050
if (e == null) {
5151
return TopicValidatorResult.Accept;
5252
}
5353

54+
const {clientAgent, clientVersion, propagationSource} = messageInfos[i];
55+
5456
if (!(e instanceof AttestationError)) {
55-
logger.debug(`Gossip batch validation ${type} threw a non-AttestationError`, {}, e as Error);
57+
logger.debug(
58+
`Gossip batch validation ${type} threw a non-AttestationError`,
59+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
60+
e as Error
61+
);
5662
metrics?.networkProcessor.gossipValidationIgnore.inc({topic: type});
5763
return TopicValidatorResult.Ignore;
5864
}
@@ -67,7 +73,11 @@ export function getGossipValidatorBatchFn(
6773
metrics?.networkProcessor.gossipValidationReject.inc({topic: type});
6874
// only beacon_attestation topic is validated in batch
6975
metrics?.networkProcessor.gossipAttestationRejectByReason.inc({reason: e.type.code});
70-
logger.debug(`Gossip validation ${type} rejected`, {}, e);
76+
logger.debug(
77+
`Gossip validation ${type} rejected`,
78+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
79+
e
80+
);
7181
return TopicValidatorResult.Reject;
7282
}
7383
});
@@ -125,7 +135,11 @@ export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: Va
125135
} catch (e) {
126136
if (!(e instanceof GossipActionError)) {
127137
// not deserve to log error here, it looks too dangerous to users
128-
logger.debug(`Gossip validation ${type} threw a non-GossipActionError`, {}, e as Error);
138+
logger.debug(
139+
`Gossip validation ${type} threw a non-GossipActionError`,
140+
{peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
141+
e as Error
142+
);
129143
return TopicValidatorResult.Ignore;
130144
}
131145

0 commit comments

Comments
 (0)