From 3f6bd9eb680f4e2c7b616723f1a35134cf492811 Mon Sep 17 00:00:00 2001 From: vgorkavenko Date: Thu, 20 Jul 2023 12:30:08 +0400 Subject: [PATCH] fix: undefined operators for metrics --- src/inspector/inspector.service.ts | 8 +++++++- src/validators-registry/registry.service.ts | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/inspector/inspector.service.ts b/src/inspector/inspector.service.ts index 8c3d829e..aad77462 100644 --- a/src/inspector/inspector.service.ts +++ b/src/inspector/inspector.service.ts @@ -11,6 +11,7 @@ import { PrometheusService, TrackTask } from 'common/prometheus'; import { DutyMetrics, DutyService } from 'duty'; import { ClickhouseService } from 'storage'; import { EpochProcessingState } from 'storage/clickhouse'; +import { RegistryService } from 'validators-registry'; @Injectable() export class InspectorService implements OnModuleInit { @@ -22,6 +23,7 @@ export class InspectorService implements OnModuleInit { protected readonly prometheus: PrometheusService, protected readonly criticalAlerts: CriticalAlertsService, protected readonly blockCacheService: BlockCacheService, + protected readonly registryService: RegistryService, protected readonly dutyService: DutyService, protected readonly dutyMetrics: DutyMetrics, @@ -42,7 +44,7 @@ export class InspectorService implements OnModuleInit { try { const toProcess = await this.getEpochDataToProcess(); if (toProcess) { - if (this.config.get('WORKING_MODE') === WorkingMode.Head) { + if (this.config.get('WORKING_MODE') == WorkingMode.Head) { this.logger.warn(`Working in HEAD mode. This can cause calculation errors and inaccurate data!`); } const { epoch, slot, is_stored, is_calculated } = toProcess; @@ -51,6 +53,10 @@ export class InspectorService implements OnModuleInit { possibleHighRewardValidators = await this.dutyService.checkAndWrite({ epoch: epoch, stateSlot: slot }); } if (!is_calculated) { + if (!this.registryService.isFilled()) { + const slotTime = await this.clClient.getSlotTime(epoch * this.config.get('FETCH_INTERVAL_SLOTS')); + await this.registryService.updateKeysRegistry(slotTime); + } await this.dutyMetrics.calculate(epoch, possibleHighRewardValidators); } await this.criticalAlerts.send(epoch); diff --git a/src/validators-registry/registry.service.ts b/src/validators-registry/registry.service.ts index 7e6382d3..3c959fd4 100644 --- a/src/validators-registry/registry.service.ts +++ b/src/validators-registry/registry.service.ts @@ -29,6 +29,7 @@ export class RegistryService { @TrackTask('update-validators') public async updateKeysRegistry(timestamp: number): Promise { + this.logger.log('Updating validators registry data'); const tasks = await Promise.all([ this.source.update(), this.config.get('VALIDATOR_USE_STUCK_KEYS_FILE') ? this.readStuckKeysFile() : (() => [])(), @@ -57,6 +58,10 @@ export class RegistryService { return this.stuckKeys; } + public isFilled() { + return this.lastTimestamp > 0; + } + /** * Returns keys of validators that are stuck and will not be monitored * */