diff --git a/packages/brain/src/modules/cron/trackValidatorsPerformance/trackValidatorsPerformance.ts b/packages/brain/src/modules/cron/trackValidatorsPerformance/trackValidatorsPerformance.ts index 4021900b..4ff7f5ce 100644 --- a/packages/brain/src/modules/cron/trackValidatorsPerformance/trackValidatorsPerformance.ts +++ b/packages/brain/src/modules/cron/trackValidatorsPerformance/trackValidatorsPerformance.ts @@ -31,7 +31,15 @@ export async function trackValidatorsPerformanceCron({ consensusClient: ConsensusClient; }): Promise { try { - const currentEpoch = await beaconchainApi.getEpochHeader({ blockId: "finalized" }); + // Get finalized epoch from finality endpoint instead of from header endpoint. + // The header endpoint might jump two epochs in one call (due to missed block proposals), which would cause the cron to skip an epoch. + const currentEpoch = parseInt( + ( + await beaconchainApi.getStateFinalityCheckpoints({ + stateId: "finalized" + }) + ).data.finalized.epoch + ); // If the current epoch is different from the last processed epoch, or epoch is the same but the last epoch was processed with an error // then fetch and insert the performance data @@ -88,13 +96,13 @@ export async function fetchAndInsertPerformanceCron({ if (is_syncing) throw new NodeSyncingError("Node is syncing"); if (el_offline) throw new ExecutionOfflineError("Execution layer is offline"); - validatorsAttestationsTotalRewards = await getAttestationsTotalRewards({ + validatorBlockStatusMap = await getBlockProposalStatusMap({ beaconchainApi, epoch: currentEpoch.toString(), activeValidatorsIndexes }); - validatorBlockStatusMap = await getBlockProposalStatusMap({ + validatorsAttestationsTotalRewards = await getAttestationsTotalRewards({ beaconchainApi, epoch: currentEpoch.toString(), activeValidatorsIndexes