more metrics (#1004)

This commit is contained in:
Ștefan Talpalaru 2020-05-11 08:25:49 +02:00 committed by GitHub
parent c498103b2f
commit a7a50824a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 1145 additions and 75 deletions

View File

@ -51,6 +51,9 @@ declareCounter beacon_attestations_received,
declareCounter beacon_blocks_received,
"Number of beacon chain blocks received by this peer"
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]
logScope: topics = "beacnde"
proc onBeaconBlock*(node: BeaconNode, signedBlock: SignedBeaconBlock) {.gcsafe.}
@ -658,6 +661,8 @@ proc run*(node: BeaconNode) =
# Avoid double-counting attestation-topic attestations on shared codepath
# when they're reflected through beacon blocks
beacon_attestations_received.inc()
beacon_attestation_received_seconds_from_slot_start.observe(node.beaconClock.now.int64 - (attestation.data.slot.int64 * SECONDS_PER_SLOT.int64))
node.onAttestation(attestation)
var attestationSubscriptions: seq[Future[void]] = @[]

View File

@ -14,6 +14,8 @@ import
spec/[crypto, datatypes, digest, helpers, validator]
declareCounter beacon_reorgs_total, "Total occurrences of reorganizations of the chain" # On fork choice
declareCounter beacon_state_data_cache_hits, "pool.cachedStates hits"
declareCounter beacon_state_data_cache_misses, "pool.cachedStates misses"
logScope: topics = "blkpool"
@ -729,6 +731,7 @@ proc rewindState(pool: BlockPool, state: var StateData, bs: BlockSlot):
when false:
doAssert state.blck == ancestor.refs
beacon_state_data_cache_hits.inc()
trace "Replaying state transitions via in-memory cache",
stateSlot = shortLog(state.data.data.slot),
ancestorStateRoot = shortLog(ancestor.data.message.state_root),
@ -740,6 +743,7 @@ proc rewindState(pool: BlockPool, state: var StateData, bs: BlockSlot):
return ancestors
beacon_state_data_cache_misses.inc()
if (let tmp = pool.db.getStateRoot(parBs.blck.root, parBs.slot); tmp.isSome()):
if pool.db.containsState(tmp.get):
stateRoot = tmp
@ -795,12 +799,14 @@ proc getStateDataCached(pool: BlockPool, state: var StateData, bs: BlockSlot): b
for poolStateCache in pool.cachedStates:
try:
state = poolStateCache[(a: bs.blck.root, b: bs.slot)]
beacon_state_data_cache_hits.inc()
return true
except KeyError:
discard
# In-memory caches didn't hit. Try main blockpool database. This is slower
# than the caches due to SSZ (de)serializing and disk I/O, so prefer them.
beacon_state_data_cache_misses.inc()
if (let tmp = pool.db.getStateRoot(bs.blck.root, bs.slot); tmp.isSome()):
return pool.getState(pool.db, tmp.get(), bs.blck, state)

View File

@ -61,6 +61,7 @@ declareGauge epoch_transition_times_rewards_and_penalties, "Epoch transition rew
declareGauge epoch_transition_registry_updates, "Epoch transition registry updates time"
declareGauge epoch_transition_slashings, "Epoch transition slashings time"
declareGauge epoch_transition_final_updates, "Epoch transition final updates time"
declareGauge beacon_current_epoch, "Current epoch"
# Spec
# --------------------------------------------------------
@ -424,8 +425,9 @@ func process_final_updates*(state: var BeaconState) {.nbench.}=
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#epoch-processing
proc process_epoch*(state: var BeaconState, updateFlags: UpdateFlags)
{.nbench.} =
let currentEpoch = get_current_epoch(state)
trace "process_epoch",
current_epoch = get_current_epoch(state)
current_epoch = currentEpoch
var per_epoch_cache = get_empty_per_epoch_cache()
@ -433,11 +435,11 @@ proc process_epoch*(state: var BeaconState, updateFlags: UpdateFlags)
process_justification_and_finalization(state, per_epoch_cache, updateFlags)
# state.slot hasn't been incremented yet.
if verifyFinalization in updateFlags and get_current_epoch(state) >= 3:
if verifyFinalization in updateFlags and currentEpoch >= 3:
# Rule 2/3/4 finalization results in the most pessimal case. The other
# three finalization rules finalize more quickly as long as the any of
# the finalization rules triggered.
doAssert state.finalized_checkpoint.epoch + 3 >= get_current_epoch(state)
doAssert state.finalized_checkpoint.epoch + 3 >= currentEpoch
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/beacon-chain.md#rewards-and-penalties-1
process_rewards_and_penalties(state, per_epoch_cache)
@ -457,6 +459,7 @@ proc process_epoch*(state: var BeaconState, updateFlags: UpdateFlags)
process_final_updates(state)
# Once per epoch metrics
beacon_current_epoch.set(currentEpoch.int64)
beacon_finalized_epoch.set(state.finalized_checkpoint.epoch.int64)
beacon_finalized_root.set(state.finalized_checkpoint.root.toGaugeValue)
beacon_current_justified_epoch.set(

View File

@ -128,7 +128,6 @@ fi
NETWORK_NIM_FLAGS=$(scripts/load-testnet-nim-flags.sh ${NETWORK})
$MAKE LOG_LEVEL="${LOG_LEVEL}" NIMFLAGS="-d:insecure -d:testnet_servers_image ${NETWORK_NIM_FLAGS}" beacon_node
rm -rf "${DEPOSITS_DIR}"
./build/beacon_node makeDeposits \
--quickstart-deposits=${QUICKSTART_VALIDATORS} \
--random-deposits=${RANDOM_VALIDATORS} \

File diff suppressed because it is too large Load Diff

2
vendor/nim-metrics vendored

@ -1 +1 @@
Subproject commit b217f1d343dce8c642b24aa8fbb7887dcea0fd4a
Subproject commit f91deb74228ecb14fb82575e4d0f387ad9732b8a