From 39a2a91003c9200fa9cdc57bf2f767fedd03e8e7 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Mon, 15 Jan 2024 17:48:03 +0100 Subject: [PATCH] only show upcoming fork info if one is scheduled (#5751) This ensures that information about the next scheduled fork is only displayed if one is actually scheduled. Current fork name is no longer shown. --- beacon_chain/conf.nim | 3 +- beacon_chain/nimbus_beacon_node.nim | 51 +++++++++++++++++------------ 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index ed0229b1c..2fe506cdc 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -439,8 +439,7 @@ type desc: "Textual template for the contents of the status bar" defaultValue: "peers: $connected_peers;" & "finalized: $finalized_root:$finalized_epoch;" & - "head: $head_root:$head_epoch:$head_epoch_slot;" & - "fork: $consensus_fork;" & + "head: $head_root:$head_epoch:$head_epoch_slot$next_consensus_fork;" & "time: $epoch:$epoch_slot ($slot);" & "sync: $sync_status|" & "ETH: $attached_validators_balance" diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index e3522eec1..de4fdf353 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -1473,17 +1473,17 @@ proc onSlotEnd(node: BeaconNode, slot: Slot) {.async.} = await node.updateGossipStatus(slot + 1) -func formatForkSchedule(node: BeaconNode): string = +func formatNextConsensusFork(node: BeaconNode): Opt[string] = let consensusFork = node.dag.cfg.consensusForkAtEpoch(node.dag.head.slot.epoch) - var res = $consensusFork - if consensusFork != ConsensusFork.high: - let - nextConsensusFork = consensusFork.succ() - nextForkEpoch = node.dag.cfg.consensusForkEpoch(nextConsensusFork) - if nextForkEpoch != FAR_FUTURE_EPOCH: - res.add " (next: " & $nextConsensusFork & ":" & $nextForkEpoch & ")" - res + if consensusFork == ConsensusFork.high: + return Opt.none(string) + let + nextConsensusFork = consensusFork.succ() + nextForkEpoch = node.dag.cfg.consensusForkEpoch(nextConsensusFork) + if nextForkEpoch == FAR_FUTURE_EPOCH: + return Opt.none(string) + Opt.some($nextConsensusFork & ":" & $nextForkEpoch) func syncStatus(node: BeaconNode, wallSlot: Slot): string = let optimistic_head = not node.dag.head.executionValid @@ -1528,16 +1528,21 @@ proc onSlotStart(node: BeaconNode, wallTime: BeaconTime, node.processingDelay = Opt.some(nanoseconds(delay.nanoseconds)) - info "Slot start", - slot = shortLog(wallSlot), - epoch = shortLog(wallSlot.epoch), - fork = node.formatForkSchedule(), - sync = node.syncStatus(wallSlot), - peers = len(node.network.peerPool), - head = shortLog(node.dag.head), - finalized = shortLog(getStateField( - node.dag.headState, finalized_checkpoint)), - delay = shortLog(delay) + block: + logScope: + slot = shortLog(wallSlot) + epoch = shortLog(wallSlot.epoch) + sync = node.syncStatus(wallSlot) + peers = len(node.network.peerPool) + head = shortLog(node.dag.head) + finalized = shortLog(getStateField( + node.dag.headState, finalized_checkpoint)) + delay = shortLog(delay) + let nextConsensusForkDescription = node.formatNextConsensusFork() + if nextConsensusForkDescription.isNone: + info "Slot start" + else: + info "Slot start", nextFork = nextConsensusForkDescription.get # Check before any re-scheduling of onSlotStart() if checkIfShouldStopAtEpoch(wallSlot, node.config.stopAtEpoch): @@ -1964,8 +1969,12 @@ when not defined(windows): of "attached_validators_balance": formatGwei(node.attachedValidatorBalanceTotal) - of "consensus_fork": - node.formatForkSchedule() + of "next_consensus_fork": + let nextConsensusForkDescription = node.formatNextConsensusFork() + if nextConsensusForkDescription.isNone: + "" + else: + " (scheduled " & nextConsensusForkDescription.get & ")" of "sync_status": node.syncStatus(node.currentSlot)