🌳
pt0/deployF/ethF/mkValidatorCheckAI.mts
4import { DateTime } from 'luxon'
7const formatFailedSources = (failedSources: string[] | undefined, source: string | undefined) =>
8 failedSources?.length ? ` ${chalkYellow(`(${failedSources.join(', ')} unreachable, fell back to ${source})`)}` : ''
10export const mkValidatorCheck = ({ethValidatorNum}: {ethValidatorNum: number}) => async ({ethStatusCfgs}: {ethStatusCfgs?: any[]} = {}) => {
11 const v: any = await lastValidatedAt({ethValidatorNum, beaconFallbackCfgs: ethStatusCfgs})
12 const srcWarn = formatFailedSources(v.failedSources, v.source)
13 const prefix = `\n${chalkCyan('Validator')} ${v.ethValidatorNum}`
14 if (v.error) {
15 console.log(`${prefix}: ${chalkYellow(v.error)}${srcWarn ? '\n' + srcWarn : ''}`)
16 } else {
17 const ago = durHumanAbs(luxNow().diff(DateTime.fromISO(v.iso))) || ''
18 console.log(`${prefix}: last attested ${chalkGreen(ago)} ago (slot ${v.slot}) via ${v.source}${srcWarn ? '\n' + srcWarn : ''}`)
19 }