Skip to content

Commit

Permalink
fix: skip validator monitoring pre-genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Sep 26, 2023
1 parent 2177d63 commit 5c9d365
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
Expand Down
6 changes: 6 additions & 0 deletions packages/beacon-node/src/metrics/validatorMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 5c9d365

Please sign in to comment.