diff --git a/packages/beacon-node/src/chain/chain.ts b/packages/beacon-node/src/chain/chain.ts index 694cb5495958..7050d7462f4e 100644 --- a/packages/beacon-node/src/chain/chain.ts +++ b/packages/beacon-node/src/chain/chain.ts @@ -806,7 +806,7 @@ export class BeaconChain implements IBeaconChain { sleep((1000 * this.config.SECONDS_PER_SLOT) / 2) .then(() => metrics.onceEveryEndOfEpoch(this.getHeadState())) .catch((e) => { - if (!isErrorAborted(e)) this.logger.error("error on validator monitor onceEveryEndOfEpoch", {slot}, e); + if (!isErrorAborted(e)) this.logger.error("Error on validator monitor onceEveryEndOfEpoch", {slot}, e); }); } } diff --git a/packages/beacon-node/src/metrics/validatorMonitor.ts b/packages/beacon-node/src/metrics/validatorMonitor.ts index de350c36ccbe..bc2bc268ed23 100644 --- a/packages/beacon-node/src/metrics/validatorMonitor.ts +++ b/packages/beacon-node/src/metrics/validatorMonitor.ts @@ -15,6 +15,7 @@ import {ChainConfig, ChainForkConfig} from "@lodestar/config"; import {ForkSeq, INTERVALS_PER_SLOT, MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params"; import {Epoch, Slot, ValidatorIndex} from "@lodestar/types"; import {IndexedAttestation, SignedAggregateAndProof} from "@lodestar/types/phase0"; +import {GENESIS_SLOT} from "../constants/constants.js"; import {LodestarMetrics} from "./metrics/lodestar.js"; /** The validator monitor collects per-epoch data about each monitored validator. @@ -607,6 +608,11 @@ export function createValidatorMonitor( // To guard against short re-orgs it will track the status of epoch N at the end of epoch N+1. // This function **SHOULD** be called at the last slot of an epoch to have max possible information. onceEveryEndOfEpoch(headState) { + if (headState.slot <= GENESIS_SLOT) { + // Before genesis, there won't be any validator activity + return; + } + // Prune validators not seen in a while for (const [index, validator] of validators.entries()) { if (Date.now() - validator.lastRegisteredTimeMs > RETAIN_REGISTERED_VALIDATORS_MS) {