add metric to track finalization delay (#1399)

This commit is contained in:
tersec 2020-07-30 14:27:34 +00:00 committed by GitHub
parent 254a510c0d
commit 55607f107f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -61,6 +61,10 @@ declareCounter beacon_attestations_received,
declareCounter beacon_blocks_received, declareCounter beacon_blocks_received,
"Number of beacon chain blocks received by this peer" "Number of beacon chain blocks received by this peer"
# Finalization tracking
declareGauge finalization_delay,
"Epoch delay between scheduled epoch and finalized epoch"
declareHistogram beacon_attestation_received_seconds_from_slot_start, declareHistogram beacon_attestation_received_seconds_from_slot_start,
"Interval between slot start and attestation receival", buckets = [2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, Inf] "Interval between slot start and attestation receival", buckets = [2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, Inf]
@ -388,6 +392,8 @@ proc onSlotStart(node: BeaconNode, lastSlot, scheduledSlot: Slot) {.gcsafe, asyn
# The slot we should be at, according to the clock # The slot we should be at, according to the clock
beaconTime = node.beaconClock.now() beaconTime = node.beaconClock.now()
wallSlot = beaconTime.toSlot() wallSlot = beaconTime.toSlot()
finalizedEpoch =
node.blockPool.finalizedHead.blck.slot.compute_epoch_at_slot()
info "Slot start", info "Slot start",
lastSlot = shortLog(lastSlot), lastSlot = shortLog(lastSlot),
@ -397,7 +403,7 @@ proc onSlotStart(node: BeaconNode, lastSlot, scheduledSlot: Slot) {.gcsafe, asyn
head = shortLog(node.blockPool.head), head = shortLog(node.blockPool.head),
headEpoch = shortLog(node.blockPool.head.slot.compute_epoch_at_slot()), headEpoch = shortLog(node.blockPool.head.slot.compute_epoch_at_slot()),
finalized = shortLog(node.blockPool.finalizedHead.blck), finalized = shortLog(node.blockPool.finalizedHead.blck),
finalizedEpoch = shortLog(node.blockPool.finalizedHead.blck.slot.compute_epoch_at_slot()) finalizedEpoch = shortLog(finalizedEpoch)
# Check before any re-scheduling of onSlotStart() # Check before any re-scheduling of onSlotStart()
# Offset backwards slightly to allow this epoch's finalization check to occur # Offset backwards slightly to allow this epoch's finalization check to occur
@ -437,6 +443,7 @@ proc onSlotStart(node: BeaconNode, lastSlot, scheduledSlot: Slot) {.gcsafe, asyn
nextSlot = slot + 1 nextSlot = slot + 1
beacon_slot.set slot.int64 beacon_slot.set slot.int64
finalization_delay.set scheduledSlot.epoch.int64 - finalizedEpoch.int64
if node.config.verifyFinalization: if node.config.verifyFinalization:
verifyFinalization(node, scheduledSlot) verifyFinalization(node, scheduledSlot)