implement beacon_reorgs_total metric (#491)

This commit is contained in:
Dustin Brody 2019-10-22 11:57:34 +00:00 committed by Jacek Sieka
parent 3da4c02bb3
commit 43f353e665
2 changed files with 8 additions and 2 deletions

View File

@ -28,7 +28,6 @@ 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_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
logScope: topics = "beacnde"

View File

@ -1,9 +1,11 @@
import
bitops, chronicles, options, sequtils, tables,
ssz, beacon_chain_db, state_transition, extras,
beacon_node_types,
beacon_node_types, metrics,
spec/[crypto, datatypes, digest, helpers]
declareCounter beacon_reorgs_total, "Total occurrences of reorganizations of the chain" # On fork choice
logScope: topics = "blkpool"
proc parent*(bs: BlockSlot): BlockSlot =
@ -618,6 +620,11 @@ proc updateHead*(pool: BlockPool, state: var StateData, blck: BlockRef) =
justifiedEpoch = shortLog(state.data.data.current_justified_checkpoint.epoch),
finalizedEpoch = shortLog(state.data.data.finalized_checkpoint.epoch),
cat = "fork_choice"
# A reasonable criterion for "reorganizations of the chain"
# TODO if multiple heads have gotten skipped, could fire at
# spurious times
beacon_reorgs_total.inc()
else:
info "Updated No head block",
stateRoot = shortLog(state.data.root),