implement beacon_finalized_epoch, beacon_current_justified_epoch, and beacon_previous_justified_epoch (#476)

This commit is contained in:
Dustin Brody 2019-10-03 10:36:31 +00:00 committed by GitHub
parent 2b7b7b1471
commit 2122bb44c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 9 deletions

View File

@ -21,14 +21,6 @@ declareGauge beacon_slot, "Latest slot of the beacon chain state"
declareGauge beacon_head_slot, "Slot of the head block of the beacon chain"
declareGauge beacon_head_root, "Root of the head block of the beacon chain"
# TODO Implement these additional metrics (some of the them should be moved to different modules):
declareGauge beacon_finalized_epoch, "Current finalized epoch" # On epoch transition
declareGauge beacon_finalized_root, "Current finalized root" # On epoch transition
declareGauge beacon_current_justified_epoch, "Current justified epoch" # On epoch transition
declareGauge beacon_current_justified_root, "Current justified root" # On epoch transition
declareGauge beacon_previous_justified_epoch, "Current previously justified epoch" # On epoch transition
declareGauge beacon_previous_justified_root, "Current previously justified root" # On epoch transition
declareGauge beacon_current_validators, """Number of status="pending|active|exited|withdrawable" validators in current epoch""" # On epoch transition
declareGauge beacon_previous_validators, """Number of status="pending|active|exited|withdrawable" validators in previous epoch""" # On epoch transition
declareGauge beacon_current_live_validators, "Number of active validators that successfully included attestation on chain for current epoch" # On block

View File

@ -35,7 +35,7 @@
import # TODO - cleanup imports
algorithm, math, options, sequtils, tables,
stew/[bitseqs, bitops2], chronicles, json_serialization/std/sets,
../extras, ../ssz, ../beacon_node_types,
metrics, ../extras, ../ssz, ../beacon_node_types,
beaconstate, crypto, datatypes, digest, helpers, validator,
state_transition_helpers
@ -44,6 +44,15 @@ import # TODO - cleanup imports
logScope: topics = "consens"
# TODO Implement the _root metrics
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md
declareGauge beacon_finalized_epoch, "Current finalized epoch" # On epoch transition
declareGauge beacon_finalized_root, "Current finalized root" # On epoch transition
declareGauge beacon_current_justified_epoch, "Current justified epoch" # On epoch transition
declareGauge beacon_current_justified_root, "Current justified root" # On epoch transition
declareGauge beacon_previous_justified_epoch, "Current previously justified epoch" # On epoch transition
declareGauge beacon_previous_justified_root, "Current previously justified root" # On epoch transition
# Spec
# --------------------------------------------------------
@ -600,3 +609,10 @@ proc process_epoch*(state: var BeaconState) =
process_final_updates(state)
# @after_process_final_updates
# Once per epoch metrics
beacon_finalized_epoch.set(state.finalized_checkpoint.epoch.int64)
beacon_current_justified_epoch.set(
state.current_justified_checkpoint.epoch.int64)
beacon_previous_justified_epoch.set(
state.previous_justified_checkpoint.epoch.int64)