Skip to content

Commit

Permalink
feat: include more details in validator attestation logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Aug 27, 2024
1 parent 6d01593 commit a62c5a7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/validator/src/services/attestation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {toHexString} from "@chainsafe/ssz";
import {BLSSignature, phase0, Slot, ssz} from "@lodestar/types";
import {computeEpochAtSlot, isAggregatorFromCommitteeLength} from "@lodestar/state-transition";
import {sleep} from "@lodestar/utils";
import {prettyBytes, sleep} from "@lodestar/utils";
import {ApiClient, routes} from "@lodestar/api";
import {IClock, LoggerVc} from "../util/index.js";
import {PubkeyHex} from "../types.js";
Expand Down Expand Up @@ -233,7 +233,11 @@ export class AttestationService {
};
try {
(await this.api.beacon.submitPoolAttestations({signedAttestations})).assertOk();
this.logger.info("Published attestations", {...logCtx, count: signedAttestations.length});
this.logger.info("Published attestations", {
...logCtx,
head: prettyBytes(headRootHex),
count: signedAttestations.length,
});
this.metrics?.publishedAttestations.inc(signedAttestations.length);
} catch (e) {
// Note: metric counts only 1 since we don't know how many signedAttestations are invalid
Expand Down Expand Up @@ -269,7 +273,8 @@ export class AttestationService {
slot: attestation.slot,
});
const aggregate = res.value();
this.metrics?.numParticipantsInAggregate.observe(aggregate.aggregationBits.getTrueBitIndexes().length);
const participants = aggregate.aggregationBits.getTrueBitIndexes().length;
this.metrics?.numParticipantsInAggregate.observe(participants);

const signedAggregateAndProofs: phase0.SignedAggregateAndProof[] = [];

Expand All @@ -295,7 +300,11 @@ export class AttestationService {
if (signedAggregateAndProofs.length > 0) {
try {
(await this.api.validator.publishAggregateAndProofs({signedAggregateAndProofs})).assertOk();
this.logger.info("Published aggregateAndProofs", {...logCtx, count: signedAggregateAndProofs.length});
this.logger.info("Published aggregateAndProofs", {
...logCtx,
participants,
count: signedAggregateAndProofs.length,
});
this.metrics?.publishedAggregates.inc(signedAggregateAndProofs.length);
} catch (e) {
this.logger.error("Error publishing aggregateAndProofs", logCtx, e as Error);
Expand Down

0 comments on commit a62c5a7

Please sign in to comment.