mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-11 06:46:10 +00:00
implement metrics to count send/received blocks/attestations, to detect network loss
This commit is contained in:
parent
6d9a44c264
commit
c9d2815480
@ -23,12 +23,20 @@ const
|
|||||||
testnetsBaseUrl = "https://serenity-testnets.status.im"
|
testnetsBaseUrl = "https://serenity-testnets.status.im"
|
||||||
hasPrompt = not defined(withoutPrompt)
|
hasPrompt = not defined(withoutPrompt)
|
||||||
|
|
||||||
|
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#interop-metrics
|
||||||
declareGauge beacon_slot, "Latest slot of the beacon chain state"
|
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"
|
||||||
|
|
||||||
|
# https://github.com/ethereum/eth2.0-metrics/blob/master/metrics.md#additional-metrics
|
||||||
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
|
||||||
|
|
||||||
|
# Metrics for tracking attestation and beacon block loss
|
||||||
|
declareCounter beacon_attestations_sent, "Number of beacon chain attestations sent by this peer"
|
||||||
|
declareCounter beacon_attestations_received, "Number of beacon chain attestations received by this peer"
|
||||||
|
declareCounter beacon_blocks_proposed, "Number of beacon chain blocks sent by this peer"
|
||||||
|
declareCounter beacon_blocks_received, "Number of becon chain blocks received by this peer"
|
||||||
|
|
||||||
logScope: topics = "beacnde"
|
logScope: topics = "beacnde"
|
||||||
|
|
||||||
proc onBeaconBlock*(node: BeaconNode, blck: BeaconBlock) {.gcsafe.}
|
proc onBeaconBlock*(node: BeaconNode, blck: BeaconBlock) {.gcsafe.}
|
||||||
@ -353,6 +361,8 @@ proc sendAttestation(node: BeaconNode,
|
|||||||
indexInCommittee = indexInCommittee,
|
indexInCommittee = indexInCommittee,
|
||||||
cat = "consensus"
|
cat = "consensus"
|
||||||
|
|
||||||
|
beacon_attestations_sent.inc()
|
||||||
|
|
||||||
proc proposeBlock(node: BeaconNode,
|
proc proposeBlock(node: BeaconNode,
|
||||||
validator: AttachedValidator,
|
validator: AttachedValidator,
|
||||||
head: BlockRef,
|
head: BlockRef,
|
||||||
@ -450,6 +460,8 @@ proc proposeBlock(node: BeaconNode,
|
|||||||
|
|
||||||
node.network.broadcast(topicBeaconBlocks, newBlock)
|
node.network.broadcast(topicBeaconBlocks, newBlock)
|
||||||
|
|
||||||
|
beacon_blocks_proposed.inc()
|
||||||
|
|
||||||
return newBlockRef
|
return newBlockRef
|
||||||
|
|
||||||
proc onAttestation(node: BeaconNode, attestation: Attestation) =
|
proc onAttestation(node: BeaconNode, attestation: Attestation) =
|
||||||
@ -463,6 +475,10 @@ proc onAttestation(node: BeaconNode, attestation: Attestation) =
|
|||||||
signature = shortLog(attestation.signature),
|
signature = shortLog(attestation.signature),
|
||||||
cat = "consensus" # Tag "consensus|attestation"?
|
cat = "consensus" # Tag "consensus|attestation"?
|
||||||
|
|
||||||
|
# This is the shared codepath for both topic attestation and beacon block
|
||||||
|
# attestations.
|
||||||
|
beacon_attestations_received.inc()
|
||||||
|
|
||||||
if (let attestedBlock = node.blockPool.getOrResolve(
|
if (let attestedBlock = node.blockPool.getOrResolve(
|
||||||
attestation.data.beacon_block_root); attestedBlock != nil):
|
attestation.data.beacon_block_root); attestedBlock != nil):
|
||||||
let
|
let
|
||||||
@ -499,6 +515,8 @@ proc onBeaconBlock(node: BeaconNode, blck: BeaconBlock) =
|
|||||||
cat = "block_listener",
|
cat = "block_listener",
|
||||||
pcs = "receive_block"
|
pcs = "receive_block"
|
||||||
|
|
||||||
|
beacon_blocks_received.inc()
|
||||||
|
|
||||||
if node.blockPool.add(node.stateCache, blockRoot, blck).isNil:
|
if node.blockPool.add(node.stateCache, blockRoot, blck).isNil:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user