update validator metrics on startup

This commit is contained in:
Jacek Sieka 2020-12-16 14:03:04 +01:00 committed by Zahary Karadjov
parent 974f0b7d5e
commit 5d8cdb88c6
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
2 changed files with 9 additions and 2 deletions

View File

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

View File

@ -548,7 +548,7 @@ proc getSlotTimingEntropy(): int64 =
rand(range[(slot_timing_entropy_lower_bound + 1) .. rand(range[(slot_timing_entropy_lower_bound + 1) ..
(slot_timing_entropy_upper_bound - 1)]) (slot_timing_entropy_upper_bound - 1)])
proc updateMetrics(node: BeaconNode) = proc updateValidatorMetrics*(node: BeaconNode) =
when defined(metrics): when defined(metrics):
# Technically, this only needs to be done on epoch transitions and if there's # 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 # 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): if not node.isSynced(head):
notice "Syncing in progress; skipping validator duties for now", notice "Syncing in progress; skipping validator duties for now",
slot, headSlot = head.slot slot, headSlot = head.slot
# Rewards will be growing though, as we sync..
updateValidatorMetrics(node)
return return
var curSlot = lastSlot + 1 var curSlot = lastSlot + 1
@ -671,7 +675,7 @@ proc handleValidatorDuties*(node: BeaconNode, lastSlot, slot: Slot) {.async.} =
handleAttestations(node, head, slot) 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 # 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 # If the validator is selected to aggregate (is_aggregator), then they