From 5ebf36f54d882b271350168b2b4e241c179912db Mon Sep 17 00:00:00 2001 From: tersec Date: Fri, 12 Mar 2021 09:46:26 +0000 Subject: [PATCH] add metric for nextActionWait (#2399) * add metric for nextActionWait * use toFloatSeconds --- beacon_chain/gossip_processing/consensus_manager.nim | 2 +- beacon_chain/gossip_processing/eth2_processor.nim | 2 +- beacon_chain/nimbus_beacon_node.nim | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/beacon_chain/gossip_processing/consensus_manager.nim b/beacon_chain/gossip_processing/consensus_manager.nim index 6a26ab0f2..c2051f03e 100644 --- a/beacon_chain/gossip_processing/consensus_manager.nim +++ b/beacon_chain/gossip_processing/consensus_manager.nim @@ -9,7 +9,7 @@ import chronicles, chronos, - ../spec/[crypto, datatypes, digest], + ../spec/[crypto, datatypes], ../consensus_object_pools/[blockchain_dag, attestation_pool] # TODO: Move to "consensus_object_pools" folder diff --git a/beacon_chain/gossip_processing/eth2_processor.nim b/beacon_chain/gossip_processing/eth2_processor.nim index 477b5fb86..b06a12544 100644 --- a/beacon_chain/gossip_processing/eth2_processor.nim +++ b/beacon_chain/gossip_processing/eth2_processor.nim @@ -8,7 +8,7 @@ {.push raises: [Defect].} import - std/[math, tables], + std/tables, stew/results, chronicles, chronos, metrics, ../spec/[crypto, datatypes, digest], diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 6dc22a15b..ab797685d 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -67,6 +67,9 @@ declareGauge finalization_delay, declareGauge ticks_delay, "How long does to take to run the onSecond loop" +declareGauge next_action_wait, + "Seconds until the next attestation will be sent" + logScope: topics = "beacnde" func enrForkIdFromState(state: BeaconState): ENRForkID = @@ -928,7 +931,8 @@ proc onSlotEnd(node: BeaconNode, slot: Slot) {.async.} = horizonSlot = compute_start_slot_at_epoch( node.attestationSubnets.lastCalculatedAttestationEpoch + 1) - 1 nextAttestationSlot = node.getNextAttestation(slot) - nextActionWait = saturate(fromNow(node.beaconClock, nextAttestationSlot)) + nextActionWaitTime = + saturate(fromNow(node.beaconClock, nextAttestationSlot)) horizonDistance = saturate(fromNow(node.beaconClock, horizonSlot)) info "Slot end", @@ -944,9 +948,12 @@ proc onSlotEnd(node: BeaconNode, slot: Slot) {.async.} = if nextAttestationSlot == FAR_FUTURE_SLOT: "n/a" else: - shortLog(nextActionWait), + shortLog(nextActionWaitTime), lookaheadTime = shortLog(horizonDistance) + if nextAttestationSlot != FAR_FUTURE_SLOT: + next_action_wait.set(nextActionWaitTime.toFloatSeconds) + node.updateGossipStatus(slot) proc onSlotStart(