From c17d78d76328295e534b6f355fe0f870206fa04b Mon Sep 17 00:00:00 2001 From: pablomendezroyo <41727368+pablomendezroyo@users.noreply.github.com> Date: Mon, 7 Oct 2024 09:21:36 +0200 Subject: [PATCH] Comment cron validators performance (#389) * comment cron validators performance * fix build --- .../calls/fetchValidatorsPerformanceData.ts | 5 ++- packages/brain/src/index.ts | 42 +++++++++---------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/packages/brain/src/calls/fetchValidatorsPerformanceData.ts b/packages/brain/src/calls/fetchValidatorsPerformanceData.ts index 4726bdd0..67d39d0a 100644 --- a/packages/brain/src/calls/fetchValidatorsPerformanceData.ts +++ b/packages/brain/src/calls/fetchValidatorsPerformanceData.ts @@ -1,16 +1,19 @@ import { fetchAndProcessValidatorsData } from "../modules/validatorsDataIngest/index.js"; -import { minGenesisTime, postgresClient, secondsPerSlot } from "../index.js"; +import { minGenesisTime, secondsPerSlot } from "../index.js"; import type { ValidatorsDataProcessed, Granularity, NumberOfDaysToQuery } from "../modules/validatorsDataIngest/types.js"; +import { PostgresClient } from "../modules/apiClients/index.js"; export async function fetchValidatorsPerformanceData({ + postgresClient, validatorIndexes, numberOfDaysToQuery, granularity }: { + postgresClient: PostgresClient; validatorIndexes: string[]; numberOfDaysToQuery?: NumberOfDaysToQuery; granularity?: Granularity; diff --git a/packages/brain/src/index.ts b/packages/brain/src/index.ts index 3968d9db..24e84b50 100644 --- a/packages/brain/src/index.ts +++ b/packages/brain/src/index.ts @@ -16,10 +16,10 @@ import { params } from "./params.js"; import { CronJob, reloadValidators, - trackValidatorsPerformanceCron, + // trackValidatorsPerformanceCron, sendProofsOfValidation } from "./modules/cron/index.js"; -import { PostgresClient } from "./modules/apiClients/index.js"; +// import { PostgresClient } from "./modules/apiClients/index.js"; import { brainConfig } from "./modules/config/index.js"; logger.info(`Starting brain...`); @@ -84,8 +84,8 @@ export const brainDb = new BrainDataBase( ); // Create postgres client -export const postgresClient = new PostgresClient(postgresUrl); -await postgresClient.initialize().catch((err) => logger.error(`Error initializing table in postgres db`, err)); // TODO: handle error. Consider attempting to initialize on every cron iteration +// export const postgresClient = new PostgresClient(postgresUrl); +// await postgresClient.initialize().catch((err) => logger.error(`Error initializing table in postgres db`, err)); // TODO: handle error. Consider attempting to initialize on every cron iteration // Start server APIs const uiServer = startUiServer(path.resolve(__dirname, params.uiBuildDirName), network); @@ -105,30 +105,30 @@ const proofOfValidationCron = new CronJob(shareCronInterval, () => proofOfValidationCron.start(); // execute the performance cron task every 1/4 of an epoch -export const trackValidatorsPerformanceCronTask = new CronJob( - ((slotsPerEpoch * secondsPerSlot) / 4) * 1000, - async () => { - await trackValidatorsPerformanceCron({ - brainDb, - postgresClient, - beaconchainApi, - executionClient, - consensusClient, - dappmanagerApi, - sendNotification: true - }); - } -); -trackValidatorsPerformanceCronTask.start(); +// export const trackValidatorsPerformanceCronTask = new CronJob( +// ((slotsPerEpoch * secondsPerSlot) / 4) * 1000, +// async () => { +// await trackValidatorsPerformanceCron({ +// brainDb, +// postgresClient, +// beaconchainApi, +// executionClient, +// consensusClient, +// dappmanagerApi, +// sendNotification: true +// }); +// } +// ); +// trackValidatorsPerformanceCronTask.start(); // Graceful shutdown function handle(signal: string): void { logger.info(`${signal} received. Shutting down...`); reloadValidatorsCron.stop(); proofOfValidationCron.stop(); - trackValidatorsPerformanceCronTask.stop(); + // trackValidatorsPerformanceCronTask.stop(); brainDb.close(); - postgresClient.close().catch((err) => logger.error(`Error closing postgres client`, err)); // postgresClient db connection is the only external resource that needs to be closed + // postgresClient.close().catch((err) => logger.error(`Error closing postgres client`, err)); // postgresClient db connection is the only external resource that needs to be closed uiServer.close(); launchpadServer.close(); logger.debug(`Stopped all cron jobs and closed all connections.`);