diff --git a/packages/beacon-node/src/node/notifier.ts b/packages/beacon-node/src/node/notifier.ts index 37a59a9c28d4..9952541450d3 100644 --- a/packages/beacon-node/src/node/notifier.ts +++ b/packages/beacon-node/src/node/notifier.ts @@ -1,6 +1,6 @@ import {BeaconConfig} from "@lodestar/config"; -import {ExecutionStatus, ProtoBlock} from "@lodestar/fork-choice"; -import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {ExecutionStatus, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice"; +import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH, isForkPostGloas} from "@lodestar/params"; import { IBeaconStateView, computeEpochAtSlot, @@ -19,6 +19,11 @@ import {TimeSeries} from "../util/timeSeries.js"; /** Create a warning log whenever the peer count is at or below this value */ const WARN_PEER_COUNT = 1; +/** Notifier log point as basis points of the slot: 5000 BPS = half-slot (pre-Gloas). */ +const NOTIFIER_LOG_DUE_BPS = 5000; +/** Notifier log point for Gloas: 8333 BPS ≈ 5/6 of slot — past PTC deadline so the head has transitioned from PENDING to FULL/EMPTY. */ +const NOTIFIER_LOG_DUE_BPS_GLOAS = 8333; + type NodeNotifierModules = { network: INetwork; chain: IBeaconChain; @@ -127,8 +132,9 @@ export async function runNodeNotifier(modules: NodeNotifierModules): Promise msPerHalfSlot ? msToNextSlot - msPerHalfSlot : msToNextSlot + msPerHalfSlot; + // at the 1st time we may miss the log point of the current clock slot + const msToSlotEndFromLogPoint = msPerSlot - msSlotOffset; + return msToNextSlot > msToSlotEndFromLogPoint + ? msToNextSlot - msToSlotEndFromLogPoint + : msToNextSlot + msSlotOffset; } - // after the 1st time always wait until middle of next clock slot - return msToNextSlot + msPerHalfSlot; + // after the 1st time always wait until the log point of the next clock slot + return msToNextSlot + msSlotOffset; } function getHeadExecutionInfo( @@ -167,6 +184,13 @@ function getHeadExecutionInfo( return []; } + const fork = config.getForkName(headInfo.slot); + + // Gloas: show payload status (PENDING/EMPTY/FULL) instead of EL execution status + if (isForkPostGloas(fork)) { + return getGloasExecutionInfo(headInfo); + } + const executionStatusStr = headInfo.executionStatus.toLowerCase(); // Add execution status to notifier only if head is on/post bellatrix @@ -187,3 +211,21 @@ function getHeadExecutionInfo( return []; } + +/** Gloas-specific execution info showing payload status and block details */ +function getGloasExecutionInfo(headInfo: ProtoBlock): string[] { + const payloadStatusStr = + headInfo.payloadStatus === PayloadStatus.FULL + ? "full" + : headInfo.payloadStatus === PayloadStatus.EMPTY + ? "empty" + : "pending"; + + if (headInfo.payloadStatus === PayloadStatus.FULL && headInfo.executionPayloadBlockHash !== null) { + const hashInfo = prettyBytesShort(headInfo.executionPayloadBlockHash); + const numberInfo = headInfo.executionPayloadNumber; + return [`payload: ${payloadStatusStr}(${numberInfo} ${hashInfo})`]; + } + + return [`payload: ${payloadStatusStr}`]; +}