From 4ad66039c8154114d21cc678f461a9632eb80575 Mon Sep 17 00:00:00 2001 From: Nico Flaig Date: Sun, 24 Sep 2023 19:47:19 +0200 Subject: [PATCH] fix: only check doppelganger liveness for relevant epochs --- .../validator/src/services/doppelgangerService.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/validator/src/services/doppelgangerService.ts b/packages/validator/src/services/doppelgangerService.ts index f4c9192e8112..4b891eb1b4b9 100644 --- a/packages/validator/src/services/doppelgangerService.ts +++ b/packages/validator/src/services/doppelgangerService.ts @@ -51,10 +51,7 @@ export class DoppelgangerService { metrics.doppelganger.statusCount.addCollect(() => this.onScrapeMetrics(metrics)); } - this.logger.info("Doppelganger protection enabled", { - currentEpoch: this.clock.currentEpoch, - detectionEpochs: DEFAULT_REMAINING_DETECTION_EPOCHS, - }); + this.logger.info("Doppelganger protection enabled", {detectionEpochs: DEFAULT_REMAINING_DETECTION_EPOCHS}); } registerValidator(pubkeyHex: PubkeyHex): void { @@ -103,7 +100,7 @@ export class DoppelgangerService { const indicesToCheckMap = new Map(); for (const [pubkeyHex, state] of this.doppelgangerStateByPubkey.entries()) { - if (state.remainingEpochs > 0) { + if (state.remainingEpochs > 0 && state.nextEpochToCheck <= currentEpoch) { const index = this.indicesService.pubkey2index.get(pubkeyHex); if (index !== undefined) { indicesToCheckMap.set(index, pubkeyHex); @@ -226,11 +223,11 @@ export class DoppelgangerService { state.nextEpochToCheck = currentEpoch; this.metrics?.doppelganger.epochsChecked.inc(1); - const {remainingEpochs} = state; + const {remainingEpochs, nextEpochToCheck} = state; if (remainingEpochs <= 0) { this.logger.info("Doppelganger detection complete", {index: response.index}); } else { - this.logger.info("Found no doppelganger", {remainingEpochs, index: response.index}); + this.logger.info("Found no doppelganger", {remainingEpochs, nextEpochToCheck, index: response.index}); } } }