update validator metrics on startup

This commit is contained in:
Jacek Sieka 2020-12-16 14:03:04 +01:00 committed by zah
parent ca2a09d424
commit de779c7812
2 changed files with 9 additions and 2 deletions

View File

@ -335,6 +335,9 @@ proc init*(T: type BeaconNode,
# This merely configures the BeaconSync
# The traffic will be started when we join the network.
network.initBeaconSync(chainDag, enrForkId.forkDigest)
res.updateValidatorMetrics()
return res
func verifyFinalization(node: BeaconNode, slot: Slot) =

View File

@ -548,7 +548,7 @@ proc getSlotTimingEntropy(): int64 =
rand(range[(slot_timing_entropy_lower_bound + 1) ..
(slot_timing_entropy_upper_bound - 1)])
proc updateMetrics(node: BeaconNode) =
proc updateValidatorMetrics*(node: BeaconNode) =
when defined(metrics):
# Technically, this only needs to be done on epoch transitions and if there's
# a reorg that spans an epoch transition, but it's easier to implement this
@ -599,6 +599,10 @@ proc handleValidatorDuties*(node: BeaconNode, lastSlot, slot: Slot) {.async.} =
if not node.isSynced(head):
notice "Syncing in progress; skipping validator duties for now",
slot, headSlot = head.slot
# Rewards will be growing though, as we sync..
updateValidatorMetrics(node)
return
var curSlot = lastSlot + 1
@ -671,7 +675,7 @@ proc handleValidatorDuties*(node: BeaconNode, lastSlot, slot: Slot) {.async.} =
handleAttestations(node, head, slot)
updateMetrics(node) # the important stuff is done, update the vanity numbers
updateValidatorMetrics(node) # the important stuff is done, update the vanity numbers
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.0/specs/phase0/validator.md#broadcast-aggregate
# If the validator is selected to aggregate (is_aggregator), then they