implement beacon_current_live_validators and beacon_previous_live_validators metrics

This commit is contained in:
Dustin Brody 2019-10-21 10:11:54 +02:00 committed by zah
parent 956843822f
commit 3da4c02bb3
2 changed files with 9 additions and 2 deletions

View File

@ -27,8 +27,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_slot, "Slot of the head block of the beacon chain"
declareGauge beacon_head_root, "Root of the head block of the beacon chain" declareGauge beacon_head_root, "Root of the head block of the beacon chain"
declareGauge beacon_current_live_validators, "Number of active validators that successfully included attestation on chain for current epoch" # On block
declareGauge beacon_previous_live_validators, "Number of active validators that successfully included attestation on chain for previous epoch" # On block
declareGauge beacon_pending_exits, "Number of pending voluntary exits in local operation pool" # On slot declareGauge beacon_pending_exits, "Number of pending voluntary exits in local operation pool" # On slot
declareCounter beacon_reorgs_total, "Total occurrences of reorganizations of the chain" # On fork choice declareCounter beacon_reorgs_total, "Total occurrences of reorganizations of the chain" # On fork choice

View File

@ -39,6 +39,8 @@ import # TODO - cleanup imports
state_transition_helpers state_transition_helpers
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#additional-metrics # https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#additional-metrics
declareGauge beacon_current_live_validators, "Number of active validators that successfully included attestation on chain for current epoch" # On block
declareGauge beacon_previous_live_validators, "Number of active validators that successfully included attestation on chain for previous epoch" # On block
declareGauge beacon_pending_deposits, "Number of pending deposits (state.eth1_data.deposit_count - state.eth1_deposit_index)" # On block declareGauge beacon_pending_deposits, "Number of pending deposits (state.eth1_data.deposit_count - state.eth1_deposit_index)" # On block
declareGauge beacon_processed_deposits_total, "Number of total deposits included on chain" # On block declareGauge beacon_processed_deposits_total, "Number of total deposits included on chain" # On block
@ -474,6 +476,13 @@ proc processBlock*(
state.eth1_data.deposit_count.int64 - state.eth1_deposit_index.int64) state.eth1_data.deposit_count.int64 - state.eth1_deposit_index.int64)
beacon_processed_deposits_total.set(state.eth1_deposit_index.int64) beacon_processed_deposits_total.set(state.eth1_deposit_index.int64)
# Adds nontrivial additional computation, but only does so when metrics
# enabled.
beacon_current_live_validators.set(toSet(
mapIt(state.current_epoch_attestations, it.proposerIndex)).len.int64)
beacon_previous_live_validators.set(toSet(
mapIt(state.previous_epoch_attestations, it.proposerIndex)).len.int64)
if not process_block_header(state, blck, flags, stateCache): if not process_block_header(state, blck, flags, stateCache):
notice "Block header not valid", slot = shortLog(state.slot) notice "Block header not valid", slot = shortLog(state.slot)
return false return false