diff --git a/beacon_chain/beacon_node.nim b/beacon_chain/beacon_node.nim index f6805751b..5b3b8ec26 100644 --- a/beacon_chain/beacon_node.nim +++ b/beacon_chain/beacon_node.nim @@ -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" diff --git a/beacon_chain/block_pool.nim b/beacon_chain/block_pool.nim index 505556919..97a4a433d 100644 --- a/beacon_chain/block_pool.nim +++ b/beacon_chain/block_pool.nim @@ -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),