Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip validator monitoring pre-genesis #6001

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading