From 5d8cdb88c6431fbb3d8b795256399d05cb4c5780 Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Wed, 16 Dec 2020 14:03:04 +0100 Subject: [PATCH] update validator metrics on startup --- beacon_chain/nimbus_beacon_node.nim | 3 +++ beacon_chain/validator_duties.nim | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 8321809d1..d99da5104 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -325,6 +325,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) = diff --git a/beacon_chain/validator_duties.nim b/beacon_chain/validator_duties.nim index 71afe6150..eebc5629d 100644 --- a/beacon_chain/validator_duties.nim +++ b/beacon_chain/validator_duties.nim @@ -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