Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display current fork (+ next fork if applicable) in slot start / status #5731

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions beacon_chain/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ type
defaultValue: "peers: $connected_peers;" &
"finalized: $finalized_root:$finalized_epoch;" &
"head: $head_root:$head_epoch:$head_epoch_slot;" &
"fork: $consensus_fork;" &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally we'd display it only when there's an upcoming fork though - that's the only time it's interesting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's in line with synced which also shows when no user action is needed.
without upcoming fork it is just showing Capella (single word), no extras

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's play with this for now; if we have a better idea to display it more conditionally, we can still update.
for now, we are at a period where it's interesting to have around, on all networks.

"time: $epoch:$epoch_slot ($slot);" &
"sync: $sync_status|" &
"ETH: $attached_validators_balance"
Expand Down
18 changes: 17 additions & 1 deletion beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ func forkDigests(node: BeaconNode): auto =
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#attestation-subnet-subscription
proc updateAttestationSubnetHandlers(node: BeaconNode, slot: Slot) =
if node.gossipState.card == 0:
# When disconnected, updateGossipState is responsible for all things
# When disconnected, updateBlocksGossipStatus is responsible for all things
# subnets - in particular, it will remove subscriptions on the edge where
# we enter the disconnected state.
return
Expand Down Expand Up @@ -1507,6 +1507,18 @@ proc onSlotEnd(node: BeaconNode, slot: Slot) {.async.} =

await node.updateGossipStatus(slot + 1)

func formatForkSchedule(node: BeaconNode): 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

func syncStatus(node: BeaconNode, wallSlot: Slot): string =
let optimistic_head = not node.dag.head.executionValid
if node.syncManager.inProgress:
Expand Down Expand Up @@ -1550,6 +1562,7 @@ proc onSlotStart(node: BeaconNode, wallTime: BeaconTime,
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),
Expand Down Expand Up @@ -1982,6 +1995,9 @@ when not defined(windows):
of "attached_validators_balance":
formatGwei(node.attachedValidatorBalanceTotal)

of "consensus_fork":
node.formatForkSchedule()

of "sync_status":
node.syncStatus(node.currentSlot)
else:
Expand Down
14 changes: 14 additions & 0 deletions beacon_chain/spec/forks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,20 @@ func setStateRoot*(x: var ForkedHashedBeaconState, root: Eth2Digest) =
withState(x): forkyState.root = root
{.pop.}

func consensusForkEpoch*(
cfg: RuntimeConfig, consensusFork: ConsensusFork): Epoch =
case consensusFork
of ConsensusFork.Deneb:
cfg.DENEB_FORK_EPOCH
of ConsensusFork.Capella:
cfg.CAPELLA_FORK_EPOCH
of ConsensusFork.Bellatrix:
cfg.BELLATRIX_FORK_EPOCH
of ConsensusFork.Altair:
cfg.ALTAIR_FORK_EPOCH
of ConsensusFork.Phase0:
GENESIS_EPOCH

func consensusForkAtEpoch*(cfg: RuntimeConfig, epoch: Epoch): ConsensusFork =
## Return the current fork for the given epoch.
static:
Expand Down
Loading