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

feat: improve doppelganger protection logs #5987

Merged
merged 1 commit into from
Sep 23, 2023
Merged
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
13 changes: 9 additions & 4 deletions packages/validator/src/services/doppelgangerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,26 @@ export class DoppelgangerService {
metrics.doppelganger.statusCount.addCollect(() => this.onScrapeMetrics(metrics));
}

this.logger.info("doppelganger protection enabled", {detectionEpochs: DEFAULT_REMAINING_DETECTION_EPOCHS});
this.logger.info("Doppelganger protection enabled", {
currentEpoch: this.clock.currentEpoch,
detectionEpochs: DEFAULT_REMAINING_DETECTION_EPOCHS,
});
}

registerValidator(pubkeyHex: PubkeyHex): void {
const {currentEpoch} = this.clock;
// Disable doppelganger protection when the validator was initialized before genesis.
// There's no activity before genesis, so doppelganger is pointless.
const remainingEpochs = currentEpoch <= 0 ? 0 : DEFAULT_REMAINING_DETECTION_EPOCHS;
const nextEpochToCheck = currentEpoch + 1;

// Log here to alert that validation won't be active until remainingEpochs == 0
if (remainingEpochs > 0) {
this.logger.info("Registered validator for doppelganger", {remainingEpochs, pubkeyHex});
this.logger.info("Registered validator for doppelganger", {remainingEpochs, nextEpochToCheck, pubkeyHex});
}

this.doppelgangerStateByPubkey.set(pubkeyHex, {
nextEpochToCheck: this.clock.currentEpoch + 1,
nextEpochToCheck,
remainingEpochs,
});
}
Expand Down Expand Up @@ -118,11 +122,12 @@ export class DoppelgangerService {
}
}

this.logger.debug("doppelganger pollLiveness", {currentEpoch, indicesCount: indicesToCheckMap.size});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means we won't be logging anything now if there are no indices to check but I don't see how that's useful anyways

if (indicesToCheckMap.size === 0) {
return;
}

this.logger.info("Doppelganger liveness check", {currentEpoch, indicesCount: indicesToCheckMap.size});

// in the current epoch also request for liveness check for past epoch in case a validator index was live
// in the remaining 25% of the last slot of the previous epoch
const indicesToCheck = Array.from(indicesToCheckMap.keys());
Expand Down
Loading