2021-07-15 00:52:02 +00:00
|
|
|
use crate::observed_attesters::SlotSubcommitteeIndex;
|
|
|
|
use crate::types::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT;
|
2021-04-07 01:02:56 +00:00
|
|
|
use crate::{BeaconChain, BeaconChainError, BeaconChainTypes};
|
2020-10-19 05:58:39 +00:00
|
|
|
use lazy_static::lazy_static;
|
2019-08-19 11:02:34 +00:00
|
|
|
pub use lighthouse_metrics::*;
|
2020-05-17 11:16:48 +00:00
|
|
|
use slot_clock::SlotClock;
|
2022-01-14 07:20:55 +00:00
|
|
|
use std::time::Duration;
|
2020-05-17 11:16:48 +00:00
|
|
|
use types::{BeaconState, Epoch, EthSpec, Hash256, Slot};
|
2019-05-28 07:30:09 +00:00
|
|
|
|
2022-01-14 07:20:55 +00:00
|
|
|
/// The maximum time to wait for the snapshot cache lock during a metrics scrape.
|
|
|
|
const SNAPSHOT_CACHE_TIMEOUT: Duration = Duration::from_millis(100);
|
|
|
|
|
2019-08-19 11:02:34 +00:00
|
|
|
lazy_static! {
|
|
|
|
/*
|
|
|
|
* Block Processing
|
|
|
|
*/
|
|
|
|
pub static ref BLOCK_PROCESSING_REQUESTS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_block_processing_requests_total",
|
|
|
|
"Count of blocks submitted for processing"
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PROCESSING_SUCCESSES: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_block_processing_successes_total",
|
|
|
|
"Count of blocks processed without error"
|
|
|
|
);
|
2022-01-14 07:20:55 +00:00
|
|
|
pub static ref BLOCK_PROCESSING_SNAPSHOT_CACHE_SIZE: Result<IntGauge> = try_create_int_gauge(
|
|
|
|
"beacon_block_processing_snapshot_cache_size",
|
|
|
|
"Count snapshots in the snapshot cache"
|
|
|
|
);
|
2021-12-06 03:41:31 +00:00
|
|
|
pub static ref BLOCK_PROCESSING_SNAPSHOT_CACHE_MISSES: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_block_processing_snapshot_cache_misses",
|
|
|
|
"Count of snapshot cache misses"
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PROCESSING_SNAPSHOT_CACHE_CLONES: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_block_processing_snapshot_cache_clones",
|
|
|
|
"Count of snapshot cache clones"
|
|
|
|
);
|
2019-08-19 11:02:34 +00:00
|
|
|
pub static ref BLOCK_PROCESSING_TIMES: Result<Histogram> =
|
|
|
|
try_create_histogram("beacon_block_processing_seconds", "Full runtime of block processing");
|
|
|
|
pub static ref BLOCK_PROCESSING_BLOCK_ROOT: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_processing_block_root_seconds",
|
|
|
|
"Time spent calculating the block root when processing a block."
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PROCESSING_DB_READ: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_processing_db_read_seconds",
|
|
|
|
"Time spent loading block and state from DB for block processing"
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PROCESSING_CATCHUP_STATE: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_processing_catch_up_state_seconds",
|
|
|
|
"Time spent skipping slots on a state before processing a block."
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PROCESSING_COMMITTEE: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_processing_committee_building_seconds",
|
|
|
|
"Time spent building/obtaining committees for block processing."
|
|
|
|
);
|
2020-04-06 04:13:19 +00:00
|
|
|
pub static ref BLOCK_PROCESSING_SIGNATURE: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_processing_signature_seconds",
|
|
|
|
"Time spent doing signature verification for a block."
|
|
|
|
);
|
2019-08-19 11:02:34 +00:00
|
|
|
pub static ref BLOCK_PROCESSING_CORE: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_processing_core_seconds",
|
|
|
|
"Time spent doing the core per_block_processing state processing."
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PROCESSING_STATE_ROOT: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_processing_state_root_seconds",
|
|
|
|
"Time spent calculating the state root when processing a block."
|
|
|
|
);
|
2022-11-30 05:22:58 +00:00
|
|
|
pub static ref BLOCK_PROCESSING_POST_EXEC_PROCESSING: Result<Histogram> = try_create_histogram_with_buckets(
|
|
|
|
"beacon_block_processing_post_exec_pre_attestable_seconds",
|
|
|
|
"Time between finishing execution processing and the block becoming attestable",
|
|
|
|
linear_buckets(5e-3, 5e-3, 10)
|
|
|
|
);
|
2019-08-19 11:02:34 +00:00
|
|
|
pub static ref BLOCK_PROCESSING_DB_WRITE: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_processing_db_write_seconds",
|
|
|
|
"Time spent writing a newly processed block and state to DB"
|
|
|
|
);
|
2020-05-06 11:42:56 +00:00
|
|
|
pub static ref BLOCK_PROCESSING_ATTESTATION_OBSERVATION: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_processing_attestation_observation_seconds",
|
|
|
|
"Time spent hashing and remembering all the attestations in the block"
|
|
|
|
);
|
2022-12-13 09:57:26 +00:00
|
|
|
pub static ref BLOCK_PROCESSING_FORK_CHOICE: Result<Histogram> = try_create_histogram_with_buckets(
|
|
|
|
"beacon_block_processing_fork_choice_seconds",
|
|
|
|
"Time spent running fork choice's `get_head` during block import",
|
|
|
|
exponential_buckets(1e-3, 2.0, 8)
|
|
|
|
);
|
2021-07-13 02:22:55 +00:00
|
|
|
pub static ref BLOCK_SYNC_AGGREGATE_SET_BITS: Result<IntGauge> = try_create_int_gauge(
|
|
|
|
"block_sync_aggregate_set_bits",
|
|
|
|
"The number of true bits in the last sync aggregate in a block"
|
|
|
|
);
|
2019-08-19 11:02:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Block Production
|
|
|
|
*/
|
|
|
|
pub static ref BLOCK_PRODUCTION_REQUESTS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_block_production_requests_total",
|
|
|
|
"Count of all block production requests"
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PRODUCTION_SUCCESSES: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_block_production_successes_total",
|
|
|
|
"Count of blocks successfully produced."
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PRODUCTION_TIMES: Result<Histogram> =
|
|
|
|
try_create_histogram("beacon_block_production_seconds", "Full runtime of block production");
|
Run fork choice before block proposal (#3168)
## Issue Addressed
Upcoming spec change https://github.com/ethereum/consensus-specs/pull/2878
## Proposed Changes
1. Run fork choice at the start of every slot, and wait for this run to complete before proposing a block.
2. As an optimisation, also run fork choice 3/4 of the way through the slot (at 9s), _dequeueing attestations for the next slot_.
3. Remove the fork choice run from the state advance timer that occurred before advancing the state.
## Additional Info
### Block Proposal Accuracy
This change makes us more likely to propose on top of the correct head in the presence of re-orgs with proposer boost in play. The main scenario that this change is designed to address is described in the linked spec issue.
### Attestation Accuracy
This change _also_ makes us more likely to attest to the correct head. Currently in the case of a skipped slot at `slot` we only run fork choice 9s into `slot - 1`. This means the attestations from `slot - 1` aren't taken into consideration, and any boost applied to the block from `slot - 1` is not removed (it should be). In the language of the linked spec issue, this means we are liable to attest to C, even when the majority voting weight has already caused a re-org to B.
### Why remove the call before the state advance?
If we've run fork choice at the start of the slot then it has already dequeued all the attestations from the previous slot, which are the only ones eligible to influence the head in the current slot. Running fork choice again is unnecessary (unless we run it for the next slot and try to pre-empt a re-org, but I don't currently think this is a great idea).
### Performance
Based on Prater testing this adds about 5-25ms of runtime to block proposal times, which are 500-1000ms on average (and spike to 5s+ sometimes due to state handling issues :cry: ). I believe this is a small enough penalty to enable it by default, with the option to disable it via the new flag `--fork-choice-before-proposal-timeout 0`. Upcoming work on block packing and state representation will also reduce block production times in general, while removing the spikes.
### Implementation
Fork choice gets invoked at the start of the slot via the `per_slot_task` function called from the slot timer. It then uses a condition variable to signal to block production that fork choice has been updated. This is a bit funky, but it seems to work. One downside of the timer-based approach is that it doesn't happen automatically in most of the tests. The test added by this PR has to trigger the run manually.
2022-05-20 05:02:11 +00:00
|
|
|
pub static ref BLOCK_PRODUCTION_FORK_CHOICE_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_production_fork_choice_seconds",
|
|
|
|
"Time taken to run fork choice before block production"
|
|
|
|
);
|
2022-12-13 09:57:26 +00:00
|
|
|
pub static ref BLOCK_PRODUCTION_GET_PROPOSER_HEAD_TIMES: Result<Histogram> = try_create_histogram_with_buckets(
|
|
|
|
"beacon_block_production_get_proposer_head_times",
|
|
|
|
"Time taken for fork choice to compute the proposer head before block production",
|
|
|
|
exponential_buckets(1e-3, 2.0, 8)
|
|
|
|
);
|
Optimise tree hash caching for block production (#2106)
## Proposed Changes
`@potuz` on the Eth R&D Discord observed that Lighthouse blocks on Pyrmont were always arriving at other nodes after at least 1 second. Part of this could be due to processing and slow propagation, but metrics also revealed that the Lighthouse nodes were usually taking 400-600ms to even just produce a block before broadcasting it.
I tracked the slowness down to the lack of a pre-built tree hash cache (THC) on the states being used for block production. This was due to using the head state for block production, which lacks a THC in order to keep fork choice fast (cloning a THC takes at least 30ms for 100k validators). This PR modifies block production to clone a state from the snapshot cache rather than the head, which speeds things up by 200-400ms by avoiding the tree hash cache rebuild. In practice this seems to have cut block production time down to 300ms or less. Ideally we could _remove_ the snapshot from the cache (and save the 30ms), but it is required for when we re-process the block after signing it with the validator client.
## Alternatives
I experimented with 2 alternatives to this approach, before deciding on it:
* Alternative 1: ensure the `head` has a tree hash cache. This is too slow, as it imposes a +30ms hit on fork choice, which currently takes ~5ms (with occasional spikes).
* Alternative 2: use `Arc<BeaconSnapshot>` in the snapshot cache and share snapshots between the cache and the `head`. This made fork choice blazing fast (1ms), and block production the same as in this PR, but had a negative impact on block processing which I don't think is worth it. It ended up being necessary to clone the full state from the snapshot cache during block production, imposing the +30ms penalty there _as well_ as in block production.
In contract, the approach in this PR should only impact block production, and it improves it! Yay for pareto improvements :tada:
## Additional Info
This commit (ac59dfa) is currently running on all the Lighthouse Pyrmont nodes, and I've added a dashboard to the Pyrmont grafana instance with the metrics.
In future work we should optimise the attestation packing, which consumes around 30-60ms and is now a substantial contributor to the total.
2020-12-21 06:29:39 +00:00
|
|
|
pub static ref BLOCK_PRODUCTION_STATE_LOAD_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_production_state_load_seconds",
|
|
|
|
"Time taken to load the base state for block production"
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PRODUCTION_SLOT_PROCESS_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_production_slot_process_seconds",
|
|
|
|
"Time taken to advance the state to the block production slot"
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PRODUCTION_UNAGGREGATED_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_production_unaggregated_seconds",
|
|
|
|
"Time taken to import the naive aggregation pool for block production"
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PRODUCTION_ATTESTATION_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_production_attestation_seconds",
|
|
|
|
"Time taken to pack attestations into a block"
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PRODUCTION_PROCESS_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_production_process_seconds",
|
|
|
|
"Time taken to process the block produced"
|
|
|
|
);
|
|
|
|
pub static ref BLOCK_PRODUCTION_STATE_ROOT_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_block_production_state_root_seconds",
|
|
|
|
"Time taken to calculate the block's state root"
|
|
|
|
);
|
2019-08-19 11:02:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Block Statistics
|
|
|
|
*/
|
2022-09-13 01:57:44 +00:00
|
|
|
pub static ref OPERATIONS_PER_BLOCK_ATTESTATION: Result<Histogram> = try_create_histogram_with_buckets(
|
2019-08-19 11:02:34 +00:00
|
|
|
"beacon_operations_per_block_attestation_total",
|
2022-09-13 01:57:44 +00:00
|
|
|
"Number of attestations in a block",
|
|
|
|
// Full block is 128.
|
|
|
|
Ok(vec![0_f64, 1_f64, 3_f64, 15_f64, 31_f64, 63_f64, 127_f64, 255_f64])
|
2019-08-19 11:02:34 +00:00
|
|
|
);
|
|
|
|
|
2022-09-13 01:57:44 +00:00
|
|
|
pub static ref BLOCK_SIZE: Result<Histogram> = try_create_histogram_with_buckets(
|
2021-11-09 16:42:02 +00:00
|
|
|
"beacon_block_total_size",
|
2022-09-13 01:57:44 +00:00
|
|
|
"Size of a signed beacon block",
|
|
|
|
linear_buckets(5120_f64,5120_f64,10)
|
2021-11-09 16:42:02 +00:00
|
|
|
);
|
|
|
|
|
2019-08-19 11:02:34 +00:00
|
|
|
/*
|
2020-05-17 11:16:48 +00:00
|
|
|
* Unaggregated Attestation Verification
|
2019-08-19 11:02:34 +00:00
|
|
|
*/
|
2020-05-17 11:16:48 +00:00
|
|
|
pub static ref UNAGGREGATED_ATTESTATION_PROCESSING_REQUESTS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_unaggregated_attestation_processing_requests_total",
|
|
|
|
"Count of all unaggregated attestations submitted for processing"
|
|
|
|
);
|
|
|
|
pub static ref UNAGGREGATED_ATTESTATION_PROCESSING_SUCCESSES: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_unaggregated_attestation_processing_successes_total",
|
|
|
|
"Number of unaggregated attestations verified for gossip"
|
|
|
|
);
|
|
|
|
pub static ref UNAGGREGATED_ATTESTATION_GOSSIP_VERIFICATION_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_unaggregated_attestation_gossip_verification_seconds",
|
|
|
|
"Full runtime of aggregated attestation gossip verification"
|
2019-08-19 11:02:34 +00:00
|
|
|
);
|
2020-05-17 11:16:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Aggregated Attestation Verification
|
|
|
|
*/
|
|
|
|
pub static ref AGGREGATED_ATTESTATION_PROCESSING_REQUESTS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_aggregated_attestation_processing_requests_total",
|
|
|
|
"Count of all aggregated attestations submitted for processing"
|
2019-08-19 11:02:34 +00:00
|
|
|
);
|
2020-05-17 11:16:48 +00:00
|
|
|
pub static ref AGGREGATED_ATTESTATION_PROCESSING_SUCCESSES: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_aggregated_attestation_processing_successes_total",
|
|
|
|
"Number of aggregated attestations verified for gossip"
|
|
|
|
);
|
|
|
|
pub static ref AGGREGATED_ATTESTATION_GOSSIP_VERIFICATION_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_aggregated_attestation_gossip_verification_seconds",
|
|
|
|
"Full runtime of aggregated attestation gossip verification"
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* General Attestation Processing
|
|
|
|
*/
|
|
|
|
pub static ref ATTESTATION_PROCESSING_APPLY_TO_AGG_POOL: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_apply_to_agg_pool",
|
|
|
|
"Time spent applying an attestation to the naive aggregation pool"
|
2020-03-05 06:19:35 +00:00
|
|
|
);
|
2020-05-17 11:16:48 +00:00
|
|
|
pub static ref ATTESTATION_PROCESSING_AGG_POOL_PRUNE: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_agg_pool_prune",
|
|
|
|
"Time spent for the agg pool to prune"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_AGG_POOL_INSERT: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_agg_pool_insert",
|
|
|
|
"Time spent for the outer pool.insert() function of agg pool"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_AGG_POOL_CORE_INSERT: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_agg_pool_core_insert",
|
|
|
|
"Time spent for the core map.insert() function of agg pool"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_AGG_POOL_AGGREGATION: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_agg_pool_aggregation",
|
|
|
|
"Time spent doing signature aggregation when adding to the agg poll"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_AGG_POOL_CREATE_MAP: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_agg_pool_create_map",
|
|
|
|
"Time spent for creating a map for a new slot"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_APPLY_TO_OP_POOL: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_apply_to_op_pool",
|
|
|
|
"Time spent applying an attestation to the block inclusion pool"
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attestation Processing
|
|
|
|
*/
|
2020-03-05 06:19:35 +00:00
|
|
|
pub static ref ATTESTATION_PROCESSING_SHUFFLING_CACHE_WAIT_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_shuffling_cache_wait_seconds",
|
|
|
|
"Time spent on waiting for the shuffling cache lock during attestation processing"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_COMMITTEE_BUILDING_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_committee_building_seconds",
|
|
|
|
"Time spent on building committees during attestation processing"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_STATE_READ_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_state_read_seconds",
|
|
|
|
"Time spent on reading the state during attestation processing"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_STATE_SKIP_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_state_skip_seconds",
|
|
|
|
"Time spent on reading the state during attestation processing"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_SIGNATURE_SETUP_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_signature_setup_seconds",
|
|
|
|
"Time spent on setting up for the signature verification of attestation processing"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_SIGNATURE_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_signature_seconds",
|
|
|
|
"Time spent on the signature verification of attestation processing"
|
2019-08-19 11:02:34 +00:00
|
|
|
);
|
|
|
|
|
Batch BLS verification for attestations (#2399)
## Issue Addressed
NA
## Proposed Changes
Adds the ability to verify batches of aggregated/unaggregated attestations from the network.
When the `BeaconProcessor` finds there are messages in the aggregated or unaggregated attestation queues, it will first check the length of the queue:
- `== 1` verify the attestation individually.
- `>= 2` take up to 64 of those attestations and verify them in a batch.
Notably, we only perform batch verification if the queue has a backlog. We don't apply any artificial delays to attestations to try and force them into batches.
### Batching Details
To assist with implementing batches we modify `beacon_chain::attestation_verification` to have two distinct categories for attestations:
- *Indexed* attestations: those which have passed initial validation and were valid enough for us to derive an `IndexedAttestation`.
- *Verified* attestations: those attestations which were indexed *and also* passed signature verification. These are well-formed, interesting messages which were signed by validators.
The batching functions accept `n` attestations and then return `n` attestation verification `Result`s, where those `Result`s can be any combination of `Ok` or `Err`. In other words, we attempt to verify as many attestations as possible and return specific per-attestation results so peer scores can be updated, if required.
When we batch verify attestations, we first try to map all those attestations to *indexed* attestations. If any of those attestations were able to be indexed, we then perform batch BLS verification on those indexed attestations. If the batch verification succeeds, we convert them into *verified* attestations, disabling individual signature checking. If the batch fails, we convert to verified attestations with individual signature checking enabled.
Ultimately, we optimistically try to do a batch verification of attestation signatures and fall-back to individual verification if it fails. This opens an attach vector for "poisoning" the attestations and causing us to waste a batch verification. I argue that peer scoring should do a good-enough job of defending against this and the typical-case gains massively outweigh the worst-case losses.
## Additional Info
Before this PR, attestation verification took the attestations by value (instead of by reference). It turns out that this was unnecessary and, in my opinion, resulted in some undesirable ergonomics (e.g., we had to pass the attestation back in the `Err` variant to avoid clones). In this PR I've modified attestation verification so that it now takes a reference.
I refactored the `beacon_chain/tests/attestation_verification.rs` tests so they use a builder-esque "tester" struct instead of a weird macro. It made it easier for me to test individual/batch with the same set of tests and I think it was a nice tidy-up. Notably, I did this last to try and make sure my new refactors to *actual* production code would pass under the existing test suite.
2021-09-22 08:49:41 +00:00
|
|
|
/*
|
|
|
|
* Batch Attestation Processing
|
|
|
|
*/
|
|
|
|
pub static ref ATTESTATION_PROCESSING_BATCH_AGG_SIGNATURE_SETUP_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_batch_agg_signature_setup_times",
|
|
|
|
"Time spent on setting up for the signature verification of batch aggregate processing"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_BATCH_AGG_SIGNATURE_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_batch_agg_signature_times",
|
|
|
|
"Time spent on the signature verification of batch aggregate attestation processing"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_BATCH_UNAGG_SIGNATURE_SETUP_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_batch_unagg_signature_setup_times",
|
|
|
|
"Time spent on setting up for the signature verification of batch unaggregate processing"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PROCESSING_BATCH_UNAGG_SIGNATURE_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_attestation_processing_batch_unagg_signature_times",
|
|
|
|
"Time spent on the signature verification of batch unaggregate attestation processing"
|
|
|
|
);
|
|
|
|
|
2020-03-05 06:19:35 +00:00
|
|
|
/*
|
|
|
|
* Shuffling cache
|
|
|
|
*/
|
|
|
|
pub static ref SHUFFLING_CACHE_HITS: Result<IntCounter> =
|
|
|
|
try_create_int_counter("beacon_shuffling_cache_hits_total", "Count of times shuffling cache fulfils request");
|
|
|
|
pub static ref SHUFFLING_CACHE_MISSES: Result<IntCounter> =
|
|
|
|
try_create_int_counter("beacon_shuffling_cache_misses_total", "Count of times shuffling cache fulfils request");
|
Avoid duplicate committee cache loads (#3574)
## Issue Addressed
NA
## Proposed Changes
I have observed scenarios on Goerli where Lighthouse was receiving attestations which reference the same, un-cached shuffling on multiple threads at the same time. Lighthouse was then loading the same state from database and determining the shuffling on multiple threads at the same time. This is unnecessary load on the disk and RAM.
This PR modifies the shuffling cache so that each entry can be either:
- A committee
- A promise for a committee (i.e., a `crossbeam_channel::Receiver`)
Now, in the scenario where we have thread A and thread B simultaneously requesting the same un-cached shuffling, we will have the following:
1. Thread A will take the write-lock on the shuffling cache, find that there's no cached committee and then create a "promise" (a `crossbeam_channel::Sender`) for a committee before dropping the write-lock.
1. Thread B will then be allowed to take the write-lock for the shuffling cache and find the promise created by thread A. It will block the current thread waiting for thread A to fulfill that promise.
1. Thread A will load the state from disk, obtain the shuffling, send it down the channel, insert the entry into the cache and then continue to verify the attestation.
1. Thread B will then receive the shuffling from the receiver, be un-blocked and then continue to verify the attestation.
In the case where thread A fails to generate the shuffling and drops the sender, the next time that specific shuffling is requested we will detect that the channel is disconnected and return a `None` entry for that shuffling. This will cause the shuffling to be re-calculated.
## Additional Info
NA
2022-09-16 08:54:03 +00:00
|
|
|
pub static ref SHUFFLING_CACHE_PROMISE_HITS: Result<IntCounter> =
|
|
|
|
try_create_int_counter("beacon_shuffling_cache_promise_hits_total", "Count of times shuffling cache returns a promise to future shuffling");
|
|
|
|
pub static ref SHUFFLING_CACHE_PROMISE_FAILS: Result<IntCounter> =
|
|
|
|
try_create_int_counter("beacon_shuffling_cache_promise_fails_total", "Count of times shuffling cache detects a failed promise");
|
2020-03-05 06:19:35 +00:00
|
|
|
|
2022-01-11 01:35:55 +00:00
|
|
|
/*
|
|
|
|
* Early attester cache
|
|
|
|
*/
|
|
|
|
pub static ref BEACON_EARLY_ATTESTER_CACHE_HITS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_early_attester_cache_hits",
|
|
|
|
"Count of times the early attester cache returns an attestation"
|
|
|
|
);
|
|
|
|
|
2019-08-19 11:02:34 +00:00
|
|
|
/*
|
|
|
|
* Attestation Production
|
|
|
|
*/
|
2021-07-29 04:38:26 +00:00
|
|
|
pub static ref ATTESTATION_PRODUCTION_SECONDS: Result<Histogram> = try_create_histogram(
|
2019-08-19 11:02:34 +00:00
|
|
|
"beacon_attestation_production_seconds",
|
|
|
|
"Full runtime of attestation production"
|
|
|
|
);
|
2021-07-29 04:38:26 +00:00
|
|
|
pub static ref ATTESTATION_PRODUCTION_HEAD_SCRAPE_SECONDS: Result<Histogram> = try_create_histogram(
|
|
|
|
"attestation_production_head_scrape_seconds",
|
|
|
|
"Time taken to read the head state"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PRODUCTION_CACHE_INTERACTION_SECONDS: Result<Histogram> = try_create_histogram(
|
|
|
|
"attestation_production_cache_interaction_seconds",
|
|
|
|
"Time spent interacting with the attester cache"
|
|
|
|
);
|
|
|
|
pub static ref ATTESTATION_PRODUCTION_CACHE_PRIME_SECONDS: Result<Histogram> = try_create_histogram(
|
|
|
|
"attestation_production_cache_prime_seconds",
|
|
|
|
"Time spent loading a new state from the disk due to a cache miss"
|
|
|
|
);
|
2020-03-05 06:19:35 +00:00
|
|
|
}
|
2019-08-19 11:02:34 +00:00
|
|
|
|
2020-03-05 06:19:35 +00:00
|
|
|
// Second lazy-static block is used to account for macro recursion limit.
|
|
|
|
lazy_static! {
|
2019-08-19 11:02:34 +00:00
|
|
|
/*
|
|
|
|
* Fork Choice
|
|
|
|
*/
|
|
|
|
pub static ref FORK_CHOICE_REQUESTS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_fork_choice_requests_total",
|
|
|
|
"Count of occasions where fork choice has tried to find a head"
|
|
|
|
);
|
|
|
|
pub static ref FORK_CHOICE_ERRORS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_fork_choice_errors_total",
|
|
|
|
"Count of occasions where fork choice has returned an error when trying to find a head"
|
|
|
|
);
|
|
|
|
pub static ref FORK_CHOICE_CHANGED_HEAD: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_fork_choice_changed_head_total",
|
|
|
|
"Count of occasions fork choice has found a new head"
|
|
|
|
);
|
|
|
|
pub static ref FORK_CHOICE_REORG_COUNT: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_fork_choice_reorg_total",
|
|
|
|
"Count of occasions fork choice has switched to a different chain"
|
|
|
|
);
|
2022-09-13 17:19:27 +00:00
|
|
|
pub static ref FORK_CHOICE_REORG_DISTANCE: Result<IntGauge> = try_create_int_gauge(
|
|
|
|
"beacon_fork_choice_reorg_distance",
|
|
|
|
"The distance of each re-org of the fork choice algorithm"
|
|
|
|
);
|
2021-09-29 23:44:24 +00:00
|
|
|
pub static ref FORK_CHOICE_REORG_COUNT_INTEROP: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_reorgs_total",
|
|
|
|
"Count of occasions fork choice has switched to a different chain"
|
|
|
|
);
|
2022-12-13 09:57:26 +00:00
|
|
|
pub static ref FORK_CHOICE_TIMES: Result<Histogram> = try_create_histogram_with_buckets(
|
|
|
|
"beacon_fork_choice_seconds",
|
|
|
|
"Full runtime of fork choice",
|
|
|
|
linear_buckets(10e-3, 20e-3, 10)
|
|
|
|
);
|
|
|
|
pub static ref FORK_CHOICE_OVERRIDE_FCU_TIMES: Result<Histogram> = try_create_histogram_with_buckets(
|
|
|
|
"beacon_fork_choice_override_fcu_seconds",
|
|
|
|
"Time taken to compute the optional forkchoiceUpdated override",
|
|
|
|
exponential_buckets(1e-3, 2.0, 8)
|
|
|
|
);
|
|
|
|
pub static ref FORK_CHOICE_AFTER_NEW_HEAD_TIMES: Result<Histogram> = try_create_histogram_with_buckets(
|
|
|
|
"beacon_fork_choice_after_new_head_seconds",
|
|
|
|
"Time taken to run `after_new_head`",
|
|
|
|
exponential_buckets(1e-3, 2.0, 10)
|
|
|
|
);
|
|
|
|
pub static ref FORK_CHOICE_AFTER_FINALIZATION_TIMES: Result<Histogram> = try_create_histogram_with_buckets(
|
|
|
|
"beacon_fork_choice_after_finalization_seconds",
|
|
|
|
"Time taken to run `after_finalization`",
|
|
|
|
exponential_buckets(1e-3, 2.0, 10)
|
|
|
|
);
|
2019-08-19 11:02:34 +00:00
|
|
|
pub static ref FORK_CHOICE_PROCESS_BLOCK_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_fork_choice_process_block_seconds",
|
|
|
|
"Time taken to add a block and all attestations to fork choice"
|
|
|
|
);
|
|
|
|
pub static ref FORK_CHOICE_PROCESS_ATTESTATION_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_fork_choice_process_attestation_seconds",
|
|
|
|
"Time taken to add an attestation to fork choice"
|
|
|
|
);
|
Persist to DB after setting canonical head (#2547)
## Issue Addressed
NA
## Proposed Changes
Missed head votes on attestations is a well-known issue. The primary cause is a block getting set as the head *after* the attestation deadline.
This PR aims to shorten the overall time between "block received" and "block set as head" by:
1. Persisting the head and fork choice *after* setting the canonical head
- Informal measurements show this takes ~200ms
1. Pruning the op pool *after* setting the canonical head.
1. No longer persisting the op pool to disk during `BeaconChain::fork_choice`
- Informal measurements show this can take up to 1.2s.
I also add some metrics to help measure the effect of these changes.
Persistence changes like this run the risk of breaking assumptions downstream. However, I have considered these risks and I think we're fine here. I will describe my reasoning for each change.
## Reasoning
### Change 1: Persisting the head and fork choice *after* setting the canonical head
For (1), although the function is called `persist_head_and_fork_choice`, it only persists:
- Fork choice
- Head tracker
- Genesis block root
Since `BeaconChain::fork_choice_internal` does not modify these values between the original time we were persisting it and the current time, I assert that the change I've made is non-substantial in terms of what ends up on-disk. There's the possibility that some *other* thread has modified fork choice in the extra time we've given it, but that's totally fine.
Since the only time we *read* those values from disk is during startup, I assert that this has no impact during runtime.
### Change 2: Pruning the op pool after setting the canonical head
Similar to the argument above, we don't modify the op pool during `BeaconChain::fork_choice_internal` so it shouldn't matter when we prune. This change should be non-substantial.
### Change 3: No longer persisting the op pool to disk during `BeaconChain::fork_choice`
This change *is* substantial. With the proposed changes, we'll only be persisting the op pool to disk when we shut down cleanly (i.e., the `BeaconChain` gets dropped). This means we'll save disk IO and time during usual operation, but a `kill -9` or similar "crash" will probably result in an out-of-date op pool when we reboot. An out-of-date op pool can only have an impact when producing blocks or aggregate attestations/sync committees.
I think it's pretty reasonable that a crash might result in an out-of-date op pool, since:
- Crashes are fairly rare. Practically the only time I see LH suffer a full crash is when the OOM killer shows up, and that's a very serious event.
- It's generally quite rare to produce a block/aggregate immediately after a reboot. Just a few slots of runtime is probably enough to have a decent-enough op pool again.
## Additional Info
Credits to @macladson for the timings referenced here.
2021-08-31 04:48:21 +00:00
|
|
|
pub static ref FORK_CHOICE_SET_HEAD_LAG_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_fork_choice_set_head_lag_times",
|
|
|
|
"Time taken between finding the head and setting the canonical head value"
|
|
|
|
);
|
2020-01-29 04:05:00 +00:00
|
|
|
pub static ref BALANCES_CACHE_HITS: Result<IntCounter> =
|
|
|
|
try_create_int_counter("beacon_balances_cache_hits_total", "Count of times balances cache fulfils request");
|
|
|
|
pub static ref BALANCES_CACHE_MISSES: Result<IntCounter> =
|
2022-09-10 01:35:10 +00:00
|
|
|
try_create_int_counter("beacon_balances_cache_misses_total", "Count of times balances cache misses request");
|
2019-08-19 11:02:34 +00:00
|
|
|
|
|
|
|
/*
|
2020-03-06 05:09:41 +00:00
|
|
|
* Persisting BeaconChain components to disk
|
2019-08-19 11:02:34 +00:00
|
|
|
*/
|
2020-03-06 05:09:41 +00:00
|
|
|
pub static ref PERSIST_HEAD: Result<Histogram> =
|
|
|
|
try_create_histogram("beacon_persist_head", "Time taken to persist the canonical head");
|
|
|
|
pub static ref PERSIST_OP_POOL: Result<Histogram> =
|
|
|
|
try_create_histogram("beacon_persist_op_pool", "Time taken to persist the operations pool");
|
|
|
|
pub static ref PERSIST_ETH1_CACHE: Result<Histogram> =
|
|
|
|
try_create_histogram("beacon_persist_eth1_cache", "Time taken to persist the eth1 caches");
|
|
|
|
pub static ref PERSIST_FORK_CHOICE: Result<Histogram> =
|
|
|
|
try_create_histogram("beacon_persist_fork_choice", "Time taken to persist the fork choice struct");
|
2019-08-19 11:02:34 +00:00
|
|
|
|
2019-12-16 23:20:27 +00:00
|
|
|
/*
|
|
|
|
* Eth1
|
|
|
|
*/
|
2020-02-10 23:19:36 +00:00
|
|
|
pub static ref DEFAULT_ETH1_VOTES: Result<IntCounter> =
|
|
|
|
try_create_int_counter("beacon_eth1_default_votes", "Count of times we have voted default value for eth1 data");
|
2019-12-16 23:20:27 +00:00
|
|
|
|
2019-08-19 11:02:34 +00:00
|
|
|
/*
|
|
|
|
* Chain Head
|
|
|
|
*/
|
|
|
|
pub static ref UPDATE_HEAD_TIMES: Result<Histogram> =
|
|
|
|
try_create_histogram("beacon_update_head_seconds", "Time taken to update the canonical head");
|
|
|
|
pub static ref HEAD_STATE_SLOT: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_slot", "Slot of the block at the head of the chain");
|
2021-09-29 23:44:24 +00:00
|
|
|
pub static ref HEAD_STATE_SLOT_INTEROP: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_slot", "Slot of the block at the head of the chain");
|
2019-08-19 11:02:34 +00:00
|
|
|
pub static ref HEAD_STATE_ROOT: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_root", "Root of the block at the head of the chain");
|
|
|
|
pub static ref HEAD_STATE_LATEST_BLOCK_SLOT: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_latest_block_slot", "Latest block slot at the head of the chain");
|
|
|
|
pub static ref HEAD_STATE_CURRENT_JUSTIFIED_ROOT: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_current_justified_root", "Current justified root at the head of the chain");
|
|
|
|
pub static ref HEAD_STATE_CURRENT_JUSTIFIED_EPOCH: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_current_justified_epoch", "Current justified epoch at the head of the chain");
|
2021-09-29 23:44:24 +00:00
|
|
|
pub static ref HEAD_STATE_CURRENT_JUSTIFIED_EPOCH_INTEROP: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_current_justified_epoch", "Current justified epoch at the head of the chain");
|
2019-08-19 11:02:34 +00:00
|
|
|
pub static ref HEAD_STATE_PREVIOUS_JUSTIFIED_ROOT: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_previous_justified_root", "Previous justified root at the head of the chain");
|
|
|
|
pub static ref HEAD_STATE_PREVIOUS_JUSTIFIED_EPOCH: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_previous_justified_epoch", "Previous justified epoch at the head of the chain");
|
2021-09-29 23:44:24 +00:00
|
|
|
pub static ref HEAD_STATE_PREVIOUS_JUSTIFIED_EPOCH_INTEROP: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_previous_justified_epoch", "Previous justified epoch at the head of the chain");
|
2019-08-19 11:02:34 +00:00
|
|
|
pub static ref HEAD_STATE_FINALIZED_ROOT: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_finalized_root", "Finalized root at the head of the chain");
|
|
|
|
pub static ref HEAD_STATE_FINALIZED_EPOCH: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_finalized_epoch", "Finalized epoch at the head of the chain");
|
2021-09-29 23:44:24 +00:00
|
|
|
pub static ref HEAD_STATE_FINALIZED_EPOCH_INTEROP: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_finalized_epoch", "Finalized epoch at the head of the chain");
|
2019-08-19 11:02:34 +00:00
|
|
|
pub static ref HEAD_STATE_TOTAL_VALIDATORS: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_total_validators_total", "Count of validators at the head of the chain");
|
|
|
|
pub static ref HEAD_STATE_ACTIVE_VALIDATORS: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_active_validators_total", "Count of active validators at the head of the chain");
|
2021-09-29 23:44:24 +00:00
|
|
|
pub static ref HEAD_STATE_ACTIVE_VALIDATORS_INTEROP: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_current_active_validators", "Count of active validators at the head of the chain");
|
2019-08-19 11:02:34 +00:00
|
|
|
pub static ref HEAD_STATE_VALIDATOR_BALANCES: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_validator_balances_total", "Sum of all validator balances at the head of the chain");
|
|
|
|
pub static ref HEAD_STATE_SLASHED_VALIDATORS: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_slashed_validators_total", "Count of all slashed validators at the head of the chain");
|
|
|
|
pub static ref HEAD_STATE_WITHDRAWN_VALIDATORS: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_withdrawn_validators_total", "Sum of all validator balances at the head of the chain");
|
|
|
|
pub static ref HEAD_STATE_ETH1_DEPOSIT_INDEX: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_head_state_eth1_deposit_index", "Eth1 deposit index at the head of the chain");
|
2021-09-29 23:44:24 +00:00
|
|
|
pub static ref HEAD_STATE_ETH1_DEPOSITS_INTEROP: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_processed_deposits_total", "Total Eth1 deposits at the head of the chain");
|
2020-02-04 01:43:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Operation Pool
|
|
|
|
*/
|
|
|
|
pub static ref OP_POOL_NUM_ATTESTATIONS: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_op_pool_attestations_total", "Count of attestations in the op pool");
|
2021-11-01 05:52:31 +00:00
|
|
|
pub static ref OP_POOL_NUM_ATTESTATION_DATA: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_op_pool_attestation_data_total", "Count of attestation data in the op pool");
|
|
|
|
pub static ref OP_POOL_MAX_AGGREGATES_PER_DATA: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_op_pool_max_aggregates_per_data", "Max aggregates per AttestationData");
|
2020-02-04 01:43:04 +00:00
|
|
|
pub static ref OP_POOL_NUM_ATTESTER_SLASHINGS: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_op_pool_attester_slashings_total", "Count of attester slashings in the op pool");
|
|
|
|
pub static ref OP_POOL_NUM_PROPOSER_SLASHINGS: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_op_pool_proposer_slashings_total", "Count of proposer slashings in the op pool");
|
|
|
|
pub static ref OP_POOL_NUM_VOLUNTARY_EXITS: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_op_pool_voluntary_exits_total", "Count of voluntary exits in the op pool");
|
2021-07-15 00:52:02 +00:00
|
|
|
pub static ref OP_POOL_NUM_SYNC_CONTRIBUTIONS: Result<IntGauge> =
|
|
|
|
try_create_int_gauge("beacon_op_pool_sync_contributions_total", "Count of sync contributions in the op pool");
|
2020-05-17 11:16:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attestation Observation Metrics
|
|
|
|
*/
|
|
|
|
pub static ref ATTN_OBSERVATION_PREV_EPOCH_ATTESTERS: Result<IntGauge> = try_create_int_gauge(
|
|
|
|
"beacon_attn_observation_epoch_attesters",
|
|
|
|
"Count of attesters that have been seen by the beacon chain in the previous epoch"
|
|
|
|
);
|
|
|
|
pub static ref ATTN_OBSERVATION_PREV_EPOCH_AGGREGATORS: Result<IntGauge> = try_create_int_gauge(
|
|
|
|
"beacon_attn_observation_epoch_aggregators",
|
|
|
|
"Count of aggregators that have been seen by the beacon chain in the previous epoch"
|
|
|
|
);
|
2021-07-15 00:52:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sync Committee Observation Metrics
|
|
|
|
*/
|
|
|
|
pub static ref SYNC_COMM_OBSERVATION_PREV_SLOT_SIGNERS: Result<IntGauge> = try_create_int_gauge(
|
|
|
|
"beacon_sync_comm_observation_slot_signers",
|
|
|
|
"Count of sync committee contributors that have been seen by the beacon chain in the previous slot"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_COMM_OBSERVATION_PREV_SLOT_AGGREGATORS: Result<IntGauge> = try_create_int_gauge(
|
|
|
|
"beacon_sync_comm_observation_slot_aggregators",
|
|
|
|
"Count of sync committee aggregators that have been seen by the beacon chain in the previous slot"
|
|
|
|
);
|
2019-05-28 07:30:09 +00:00
|
|
|
}
|
|
|
|
|
2021-01-20 19:19:38 +00:00
|
|
|
// Third lazy-static block is used to account for macro recursion limit.
|
|
|
|
lazy_static! {
|
|
|
|
/*
|
|
|
|
* Validator Monitor Metrics (balances, etc)
|
|
|
|
*/
|
|
|
|
pub static ref VALIDATOR_MONITOR_BALANCE_GWEI: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_balance_gwei",
|
|
|
|
"The validator's balance in gwei.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_EFFECTIVE_BALANCE_GWEI: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_effective_balance_gwei",
|
|
|
|
"The validator's effective balance in gwei.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_SLASHED: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_slashed",
|
|
|
|
"Set to 1 if the validator is slashed.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_ACTIVE: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_active",
|
|
|
|
"Set to 1 if the validator is active.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_EXITED: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_exited",
|
|
|
|
"Set to 1 if the validator is exited.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_WITHDRAWABLE: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_withdrawable",
|
|
|
|
"Set to 1 if the validator is withdrawable.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_ACTIVATION_ELIGIBILITY_EPOCH: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_activation_eligibility_epoch",
|
|
|
|
"Set to the epoch where the validator will be eligible for activation.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_ACTIVATION_EPOCH: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_activation_epoch",
|
|
|
|
"Set to the epoch where the validator will activate.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_EXIT_EPOCH: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_exit_epoch",
|
|
|
|
"Set to the epoch where the validator will exit.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_WITHDRAWABLE_EPOCH: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_withdrawable_epoch",
|
|
|
|
"Set to the epoch where the validator will be withdrawable.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Validator Monitor Metrics (per-epoch summaries)
|
|
|
|
*/
|
2021-02-15 07:17:52 +00:00
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ON_CHAIN_ATTESTER_HIT: Result<IntCounterVec> =
|
|
|
|
try_create_int_counter_vec(
|
|
|
|
"validator_monitor_prev_epoch_on_chain_attester_hit",
|
|
|
|
"Incremented if the validator is flagged as a previous epoch attester \
|
|
|
|
during per epoch processing",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ON_CHAIN_ATTESTER_MISS: Result<IntCounterVec> =
|
|
|
|
try_create_int_counter_vec(
|
|
|
|
"validator_monitor_prev_epoch_on_chain_attester_miss",
|
|
|
|
"Incremented if the validator is not flagged as a previous epoch attester \
|
|
|
|
during per epoch processing",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ON_CHAIN_HEAD_ATTESTER_HIT: Result<IntCounterVec> =
|
|
|
|
try_create_int_counter_vec(
|
|
|
|
"validator_monitor_prev_epoch_on_chain_head_attester_hit",
|
|
|
|
"Incremented if the validator is flagged as a previous epoch head attester \
|
|
|
|
during per epoch processing",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ON_CHAIN_HEAD_ATTESTER_MISS: Result<IntCounterVec> =
|
|
|
|
try_create_int_counter_vec(
|
|
|
|
"validator_monitor_prev_epoch_on_chain_head_attester_miss",
|
|
|
|
"Incremented if the validator is not flagged as a previous epoch head attester \
|
|
|
|
during per epoch processing",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ON_CHAIN_TARGET_ATTESTER_HIT: Result<IntCounterVec> =
|
|
|
|
try_create_int_counter_vec(
|
|
|
|
"validator_monitor_prev_epoch_on_chain_target_attester_hit",
|
|
|
|
"Incremented if the validator is flagged as a previous epoch target attester \
|
|
|
|
during per epoch processing",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ON_CHAIN_TARGET_ATTESTER_MISS: Result<IntCounterVec> =
|
|
|
|
try_create_int_counter_vec(
|
|
|
|
"validator_monitor_prev_epoch_on_chain_target_attester_miss",
|
|
|
|
"Incremented if the validator is not flagged as a previous epoch target attester \
|
|
|
|
during per epoch processing",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ON_CHAIN_INCLUSION_DISTANCE: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_on_chain_inclusion_distance",
|
|
|
|
"The attestation inclusion distance calculated during per epoch processing",
|
|
|
|
&["validator"]
|
|
|
|
);
|
2021-01-20 19:19:38 +00:00
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATIONS_TOTAL: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_attestations_total",
|
|
|
|
"The number of unagg. attestations seen in the previous epoch.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATIONS_MIN_DELAY_SECONDS: Result<HistogramVec> =
|
|
|
|
try_create_histogram_vec(
|
|
|
|
"validator_monitor_prev_epoch_attestations_min_delay_seconds",
|
|
|
|
"The min delay between when the validator should send the attestation and when it was received.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_AGGREGATE_INCLUSIONS: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_attestation_aggregate_inclusions",
|
|
|
|
"The count of times an attestation was seen inside an aggregate.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_BLOCK_INCLUSIONS: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_attestation_block_inclusions",
|
|
|
|
"The count of times an attestation was seen inside a block.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_BLOCK_MIN_INCLUSION_DISTANCE: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_attestation_block_min_inclusion_distance",
|
|
|
|
"The minimum inclusion distance observed for the inclusion of an attestation in a block.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_BEACON_BLOCKS_TOTAL: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_beacon_blocks_total",
|
|
|
|
"The number of beacon_blocks seen in the previous epoch.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_BEACON_BLOCKS_MIN_DELAY_SECONDS: Result<HistogramVec> =
|
|
|
|
try_create_histogram_vec(
|
|
|
|
"validator_monitor_prev_epoch_beacon_blocks_min_delay_seconds",
|
|
|
|
"The min delay between when the validator should send the block and when it was received.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_AGGREGATES_TOTAL: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_aggregates_total",
|
|
|
|
"The number of aggregates seen in the previous epoch.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_AGGREGATES_MIN_DELAY_SECONDS: Result<HistogramVec> =
|
|
|
|
try_create_histogram_vec(
|
|
|
|
"validator_monitor_prev_epoch_aggregates_min_delay_seconds",
|
|
|
|
"The min delay between when the validator should send the aggregate and when it was received.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_EXITS_TOTAL: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_exits_total",
|
|
|
|
"The number of exits seen in the previous epoch.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_PROPOSER_SLASHINGS_TOTAL: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_proposer_slashings_total",
|
|
|
|
"The number of proposer slashings seen in the previous epoch.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_ATTESTER_SLASHINGS_TOTAL: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_attester_slashings_total",
|
|
|
|
"The number of attester slashings seen in the previous epoch.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
2021-08-31 23:31:36 +00:00
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_COMMITTEE_MESSAGES_TOTAL: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_sync_committee_messages_total",
|
|
|
|
"The number of sync committee messages seen in the previous epoch.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_COMMITTEE_MESSAGES_MIN_DELAY_SECONDS: Result<HistogramVec> =
|
|
|
|
try_create_histogram_vec(
|
|
|
|
"validator_monitor_prev_epoch_sync_committee_messages_min_delay_seconds",
|
|
|
|
"The min delay between when the validator should send the sync committee message and when it was received.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_CONTRIBUTION_INCLUSIONS: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_sync_contribution_inclusions",
|
|
|
|
"The count of times a sync signature was seen inside a sync contribution.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_SIGNATURE_BLOCK_INCLUSIONS: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_sync_signature_block_inclusions",
|
|
|
|
"The count of times a sync signature was seen inside a block.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_CONTRIBUTIONS_TOTAL: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_prev_epoch_sync_contributions_total",
|
|
|
|
"The number of sync contributions seen in the previous epoch.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_CONTRIBUTION_MIN_DELAY_SECONDS: Result<HistogramVec> =
|
|
|
|
try_create_histogram_vec(
|
|
|
|
"validator_monitor_prev_epoch_sync_contribution_min_delay_seconds",
|
|
|
|
"The min delay between when the validator should send the sync contribution and when it was received.",
|
|
|
|
&["validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_VALIDATOR_IN_CURRENT_SYNC_COMMITTEE: Result<IntGaugeVec> =
|
|
|
|
try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_validator_in_current_sync_committee",
|
|
|
|
"Is the validator in the current sync committee (1 for true and 0 for false)",
|
|
|
|
&["validator"]
|
|
|
|
);
|
2021-01-20 19:19:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Validator Monitor Metrics (real-time)
|
|
|
|
*/
|
|
|
|
pub static ref VALIDATOR_MONITOR_VALIDATORS_TOTAL: Result<IntGauge> = try_create_int_gauge(
|
|
|
|
"validator_monitor_validators_total",
|
|
|
|
"Count of validators that are specifically monitored by this beacon node"
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_UNAGGREGATED_ATTESTATION_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_unaggregated_attestation_total",
|
|
|
|
"Number of unaggregated attestations seen",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_UNAGGREGATED_ATTESTATION_DELAY_SECONDS: Result<HistogramVec> = try_create_histogram_vec(
|
|
|
|
"validator_monitor_unaggregated_attestation_delay_seconds",
|
|
|
|
"The delay between when the validator should send the attestation and when it was received.",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
2021-08-31 23:31:36 +00:00
|
|
|
pub static ref VALIDATOR_MONITOR_SYNC_COMMITTEE_MESSAGES_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_sync_committee_messages_total",
|
|
|
|
"Number of sync committee messages seen",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_SYNC_COMMITTEE_MESSAGES_DELAY_SECONDS: Result<HistogramVec> = try_create_histogram_vec(
|
|
|
|
"validator_monitor_sync_committee_messages_delay_seconds",
|
|
|
|
"The delay between when the validator should send the sync committee message and when it was received.",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_SYNC_CONTRIBUTIONS_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_sync_contributions_total",
|
|
|
|
"Number of sync contributions seen",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
2021-09-30 01:22:43 +00:00
|
|
|
pub static ref VALIDATOR_MONITOR_SYNC_CONTRIBUTIONS_DELAY_SECONDS: Result<HistogramVec> = try_create_histogram_vec(
|
|
|
|
"validator_monitor_sync_contributions_delay_seconds",
|
2021-08-31 23:31:36 +00:00
|
|
|
"The delay between when the aggregator should send the sync contribution and when it was received.",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
2021-01-20 19:19:38 +00:00
|
|
|
pub static ref VALIDATOR_MONITOR_AGGREGATED_ATTESTATION_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_aggregated_attestation_total",
|
|
|
|
"Number of aggregated attestations seen",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_AGGREGATED_ATTESTATION_DELAY_SECONDS: Result<HistogramVec> = try_create_histogram_vec(
|
|
|
|
"validator_monitor_aggregated_attestation_delay_seconds",
|
|
|
|
"The delay between then the validator should send the aggregate and when it was received.",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_ATTESTATION_IN_AGGREGATE_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_attestation_in_aggregate_total",
|
|
|
|
"Number of times an attestation has been seen in an aggregate",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
2021-08-31 23:31:36 +00:00
|
|
|
pub static ref VALIDATOR_MONITOR_SYNC_COMMITTEE_MESSAGE_IN_CONTRIBUTION_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_sync_committee_message_in_contribution_total",
|
|
|
|
"Number of times a sync committee message has been seen in a sync contribution",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
2021-01-20 19:19:38 +00:00
|
|
|
pub static ref VALIDATOR_MONITOR_ATTESTATION_IN_AGGREGATE_DELAY_SECONDS: Result<HistogramVec> = try_create_histogram_vec(
|
|
|
|
"validator_monitor_attestation_in_aggregate_delay_seconds",
|
|
|
|
"The delay between when the validator should send the aggregate and when it was received.",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_ATTESTATION_IN_BLOCK_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_attestation_in_block_total",
|
|
|
|
"Number of times an attestation has been seen in a block",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
2021-08-31 23:31:36 +00:00
|
|
|
pub static ref VALIDATOR_MONITOR_SYNC_COMMITTEE_MESSAGE_IN_BLOCK_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_sync_committee_message_in_block_total",
|
|
|
|
"Number of times a validator's sync committee message has been seen in a sync aggregate",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
2021-01-20 19:19:38 +00:00
|
|
|
pub static ref VALIDATOR_MONITOR_ATTESTATION_IN_BLOCK_DELAY_SLOTS: Result<IntGaugeVec> = try_create_int_gauge_vec(
|
|
|
|
"validator_monitor_attestation_in_block_delay_slots",
|
|
|
|
"The excess slots (beyond the minimum delay) between the attestation slot and the block slot.",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_BEACON_BLOCK_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_beacon_block_total",
|
|
|
|
"Number of beacon blocks seen",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_BEACON_BLOCK_DELAY_SECONDS: Result<HistogramVec> = try_create_histogram_vec(
|
|
|
|
"validator_monitor_beacon_block_delay_seconds",
|
|
|
|
"The delay between when the validator should send the block and when it was received.",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_EXIT_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_exit_total",
|
|
|
|
"Number of beacon exits seen",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_PROPOSER_SLASHING_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_proposer_slashing_total",
|
|
|
|
"Number of proposer slashings seen",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
pub static ref VALIDATOR_MONITOR_ATTESTER_SLASHING_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
|
|
|
|
"validator_monitor_attester_slashing_total",
|
|
|
|
"Number of attester slashings seen",
|
|
|
|
&["src", "validator"]
|
|
|
|
);
|
|
|
|
|
2021-02-04 05:33:56 +00:00
|
|
|
/*
|
|
|
|
* Block Delay Metrics
|
|
|
|
*/
|
2022-09-13 01:57:44 +00:00
|
|
|
pub static ref BEACON_BLOCK_OBSERVED_SLOT_START_DELAY_TIME: Result<Histogram> = try_create_histogram_with_buckets(
|
2021-09-30 04:31:41 +00:00
|
|
|
"beacon_block_observed_slot_start_delay_time",
|
|
|
|
"Duration between the start of the block's slot and the time the block was observed.",
|
2022-09-13 01:57:44 +00:00
|
|
|
// [0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50]
|
|
|
|
decimal_buckets(-1,2)
|
2021-09-30 04:31:41 +00:00
|
|
|
);
|
2022-09-13 01:57:44 +00:00
|
|
|
pub static ref BEACON_BLOCK_IMPORTED_OBSERVED_DELAY_TIME: Result<Histogram> = try_create_histogram_with_buckets(
|
2021-09-30 04:31:41 +00:00
|
|
|
"beacon_block_imported_observed_delay_time",
|
|
|
|
"Duration between the time the block was observed and the time when it was imported.",
|
2022-09-13 01:57:44 +00:00
|
|
|
// [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5]
|
|
|
|
decimal_buckets(-2,0)
|
2021-09-30 04:31:41 +00:00
|
|
|
);
|
2022-09-13 01:57:44 +00:00
|
|
|
pub static ref BEACON_BLOCK_HEAD_IMPORTED_DELAY_TIME: Result<Histogram> = try_create_histogram_with_buckets(
|
2021-09-30 04:31:41 +00:00
|
|
|
"beacon_block_head_imported_delay_time",
|
|
|
|
"Duration between the time the block was imported and the time when it was set as head.",
|
2022-09-13 01:57:44 +00:00
|
|
|
// [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5]
|
|
|
|
decimal_buckets(-2,-1)
|
|
|
|
);
|
|
|
|
pub static ref BEACON_BLOCK_HEAD_SLOT_START_DELAY_TIME: Result<Histogram> = try_create_histogram_with_buckets(
|
2021-02-15 07:17:52 +00:00
|
|
|
"beacon_block_head_slot_start_delay_time",
|
2021-09-30 04:31:41 +00:00
|
|
|
"Duration between the start of the block's slot and the time when it was set as head.",
|
2022-09-13 01:57:44 +00:00
|
|
|
// [0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50]
|
|
|
|
decimal_buckets(-1,2)
|
2021-02-15 07:17:52 +00:00
|
|
|
);
|
2021-04-13 02:16:59 +00:00
|
|
|
pub static ref BEACON_BLOCK_HEAD_SLOT_START_DELAY_EXCEEDED_TOTAL: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_block_head_slot_start_delay_exceeded_total",
|
2021-09-30 04:31:41 +00:00
|
|
|
"Triggered when the duration between the start of the block's slot and the current time \
|
2021-04-13 02:16:59 +00:00
|
|
|
will result in failed attestations.",
|
|
|
|
);
|
2021-02-15 07:17:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* General block metrics
|
|
|
|
*/
|
|
|
|
pub static ref GOSSIP_BEACON_BLOCK_SKIPPED_SLOTS: Result<IntGauge> =
|
|
|
|
try_create_int_gauge(
|
|
|
|
"gossip_beacon_block_skipped_slots",
|
|
|
|
"For each gossip blocks, the number of skip slots between it and its parent"
|
|
|
|
);
|
2021-01-20 19:19:38 +00:00
|
|
|
}
|
|
|
|
|
2021-07-15 00:52:02 +00:00
|
|
|
// Fourth lazy-static block is used to account for macro recursion limit.
|
|
|
|
lazy_static! {
|
|
|
|
/*
|
|
|
|
* Sync Committee Message Verification
|
|
|
|
*/
|
|
|
|
pub static ref SYNC_MESSAGE_PROCESSING_REQUESTS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_sync_committee_message_processing_requests_total",
|
|
|
|
"Count of all sync messages submitted for processing"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_MESSAGE_PROCESSING_SUCCESSES: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_sync_committee_message_processing_successes_total",
|
|
|
|
"Number of sync messages verified for gossip"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_MESSAGE_GOSSIP_VERIFICATION_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_committee_message_gossip_verification_seconds",
|
|
|
|
"Full runtime of sync contribution gossip verification"
|
|
|
|
);
|
2023-05-19 05:13:07 +00:00
|
|
|
pub static ref SYNC_MESSAGE_EQUIVOCATIONS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"sync_message_equivocations_total",
|
|
|
|
"Number of sync messages with the same validator index for different blocks"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_MESSAGE_EQUIVOCATIONS_TO_HEAD: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"sync_message_equivocations_to_head_total",
|
|
|
|
"Number of sync message which conflict with a previous message but elect the head"
|
|
|
|
);
|
2021-07-15 00:52:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sync Committee Contribution Verification
|
|
|
|
*/
|
|
|
|
pub static ref SYNC_CONTRIBUTION_PROCESSING_REQUESTS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_sync_contribution_processing_requests_total",
|
|
|
|
"Count of all sync contributions submitted for processing"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_CONTRIBUTION_PROCESSING_SUCCESSES: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_sync_contribution_processing_successes_total",
|
|
|
|
"Number of sync contributions verified for gossip"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_CONTRIBUTION_GOSSIP_VERIFICATION_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_contribution_gossip_verification_seconds",
|
|
|
|
"Full runtime of sync contribution gossip verification"
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* General Sync Committee Contribution Processing
|
|
|
|
*/
|
|
|
|
pub static ref SYNC_CONTRIBUTION_PROCESSING_APPLY_TO_AGG_POOL: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_contribution_processing_apply_to_agg_pool",
|
|
|
|
"Time spent applying a sync contribution to the naive aggregation pool"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_CONTRIBUTION_PROCESSING_AGG_POOL_PRUNE: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_contribution_processing_agg_pool_prune",
|
|
|
|
"Time spent for the agg pool to prune"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_CONTRIBUTION_PROCESSING_AGG_POOL_INSERT: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_contribution_processing_agg_pool_insert",
|
|
|
|
"Time spent for the outer pool.insert() function of agg pool"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_CONTRIBUTION_PROCESSING_AGG_POOL_CORE_INSERT: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_contribution_processing_agg_pool_core_insert",
|
|
|
|
"Time spent for the core map.insert() function of agg pool"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_CONTRIBUTION_PROCESSING_AGG_POOL_AGGREGATION: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_contribution_processing_agg_pool_aggregation",
|
|
|
|
"Time spent doing signature aggregation when adding to the agg poll"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_CONTRIBUTION_PROCESSING_AGG_POOL_CREATE_MAP: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_contribution_processing_agg_pool_create_map",
|
|
|
|
"Time spent for creating a map for a new slot"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_CONTRIBUTION_PROCESSING_APPLY_TO_OP_POOL: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_contribution_processing_apply_to_op_pool",
|
|
|
|
"Time spent applying a sync contribution to the block inclusion pool"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_CONTRIBUTION_PROCESSING_SIGNATURE_SETUP_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_contribution_processing_signature_setup_seconds",
|
|
|
|
"Time spent on setting up for the signature verification of sync contribution processing"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_CONTRIBUTION_PROCESSING_SIGNATURE_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_contribution_processing_signature_seconds",
|
|
|
|
"Time spent on the signature verification of sync contribution processing"
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* General Sync Committee Contribution Processing
|
|
|
|
*/
|
|
|
|
pub static ref SYNC_MESSAGE_PROCESSING_SIGNATURE_SETUP_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_committee_message_processing_signature_setup_seconds",
|
|
|
|
"Time spent on setting up for the signature verification of sync message processing"
|
|
|
|
);
|
|
|
|
pub static ref SYNC_MESSAGE_PROCESSING_SIGNATURE_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_sync_committee_message_processing_signature_seconds",
|
|
|
|
"Time spent on the signature verification of sync message processing"
|
|
|
|
);
|
2021-10-15 03:28:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Checkpoint sync & backfill
|
|
|
|
*/
|
|
|
|
pub static ref BACKFILL_SIGNATURE_SETUP_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_backfill_signature_setup_seconds",
|
|
|
|
"Time spent constructing the signature set during backfill sync"
|
|
|
|
);
|
|
|
|
pub static ref BACKFILL_SIGNATURE_VERIFY_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_backfill_signature_verify_seconds",
|
|
|
|
"Time spent verifying the signature set during backfill sync"
|
|
|
|
);
|
|
|
|
pub static ref BACKFILL_SIGNATURE_TOTAL_TIMES: Result<Histogram> = try_create_histogram(
|
|
|
|
"beacon_backfill_signature_total_seconds",
|
|
|
|
"Time spent verifying the signature set during backfill sync, including setup"
|
|
|
|
);
|
2022-01-27 22:58:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Pre-finalization block cache.
|
|
|
|
*/
|
|
|
|
pub static ref PRE_FINALIZATION_BLOCK_CACHE_SIZE: Result<IntGauge> =
|
|
|
|
try_create_int_gauge(
|
|
|
|
"beacon_pre_finalization_block_cache_size",
|
|
|
|
"Number of pre-finalization block roots cached for quick rejection"
|
|
|
|
);
|
|
|
|
pub static ref PRE_FINALIZATION_BLOCK_LOOKUP_COUNT: Result<IntGauge> =
|
|
|
|
try_create_int_gauge(
|
|
|
|
"beacon_pre_finalization_block_lookup_count",
|
|
|
|
"Number of block roots subject to single block lookups"
|
|
|
|
);
|
2021-07-15 00:52:02 +00:00
|
|
|
}
|
|
|
|
|
2022-12-13 06:24:51 +00:00
|
|
|
// Fifth lazy-static block is used to account for macro recursion limit.
|
|
|
|
lazy_static! {
|
|
|
|
/*
|
|
|
|
* Light server message verification
|
|
|
|
*/
|
|
|
|
pub static ref FINALITY_UPDATE_PROCESSING_SUCCESSES: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"light_client_finality_update_verification_success_total",
|
|
|
|
"Number of light client finality updates verified for gossip"
|
|
|
|
);
|
|
|
|
/*
|
|
|
|
* Light server message verification
|
|
|
|
*/
|
|
|
|
pub static ref OPTIMISTIC_UPDATE_PROCESSING_SUCCESSES: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"light_client_optimistic_update_verification_success_total",
|
|
|
|
"Number of light client optimistic updates verified for gossip"
|
|
|
|
);
|
2023-06-27 01:06:49 +00:00
|
|
|
/*
|
|
|
|
* Aggregate subset metrics
|
|
|
|
*/
|
|
|
|
pub static ref SYNC_CONTRIBUTION_SUBSETS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_sync_contribution_subsets_total",
|
|
|
|
"Count of new sync contributions that are subsets of already known aggregates"
|
|
|
|
);
|
|
|
|
pub static ref AGGREGATED_ATTESTATION_SUBSETS: Result<IntCounter> = try_create_int_counter(
|
|
|
|
"beacon_aggregated_attestation_subsets_total",
|
|
|
|
"Count of new aggregated attestations that are subsets of already known aggregates"
|
|
|
|
);
|
2022-12-13 06:24:51 +00:00
|
|
|
}
|
|
|
|
|
2019-08-19 11:02:34 +00:00
|
|
|
/// Scrape the `beacon_chain` for metrics that are not constantly updated (e.g., the present slot,
|
|
|
|
/// head state info, etc) and update the Prometheus `DEFAULT_REGISTRY`.
|
|
|
|
pub fn scrape_for_metrics<T: BeaconChainTypes>(beacon_chain: &BeaconChain<T>) {
|
2021-04-07 01:02:56 +00:00
|
|
|
let _ = beacon_chain.with_head(|head| {
|
|
|
|
scrape_head_state(&head.beacon_state, head.beacon_state_root());
|
|
|
|
Ok::<_, BeaconChainError>(())
|
|
|
|
});
|
2020-02-04 01:43:04 +00:00
|
|
|
|
2020-05-17 11:16:48 +00:00
|
|
|
if let Some(slot) = beacon_chain.slot_clock.now() {
|
|
|
|
scrape_attestation_observation(slot, beacon_chain);
|
2021-07-15 00:52:02 +00:00
|
|
|
scrape_sync_committee_observation(slot, beacon_chain);
|
2020-05-17 11:16:48 +00:00
|
|
|
}
|
|
|
|
|
2021-11-01 05:52:31 +00:00
|
|
|
let attestation_stats = beacon_chain.op_pool.attestation_stats();
|
|
|
|
|
2022-01-14 07:20:55 +00:00
|
|
|
if let Some(snapshot_cache) = beacon_chain
|
|
|
|
.snapshot_cache
|
|
|
|
.try_write_for(SNAPSHOT_CACHE_TIMEOUT)
|
|
|
|
{
|
|
|
|
set_gauge(
|
|
|
|
&BLOCK_PROCESSING_SNAPSHOT_CACHE_SIZE,
|
|
|
|
snapshot_cache.len() as i64,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-01-27 22:58:32 +00:00
|
|
|
if let Some((size, num_lookups)) = beacon_chain.pre_finalization_block_cache.metrics() {
|
|
|
|
set_gauge_by_usize(&PRE_FINALIZATION_BLOCK_CACHE_SIZE, size);
|
|
|
|
set_gauge_by_usize(&PRE_FINALIZATION_BLOCK_LOOKUP_COUNT, num_lookups);
|
|
|
|
}
|
|
|
|
|
2020-02-04 01:43:04 +00:00
|
|
|
set_gauge_by_usize(
|
|
|
|
&OP_POOL_NUM_ATTESTATIONS,
|
2021-11-01 05:52:31 +00:00
|
|
|
attestation_stats.num_attestations,
|
|
|
|
);
|
|
|
|
set_gauge_by_usize(
|
|
|
|
&OP_POOL_NUM_ATTESTATION_DATA,
|
|
|
|
attestation_stats.num_attestation_data,
|
|
|
|
);
|
|
|
|
set_gauge_by_usize(
|
|
|
|
&OP_POOL_MAX_AGGREGATES_PER_DATA,
|
|
|
|
attestation_stats.max_aggregates_per_data,
|
2020-02-04 01:43:04 +00:00
|
|
|
);
|
|
|
|
set_gauge_by_usize(
|
|
|
|
&OP_POOL_NUM_ATTESTER_SLASHINGS,
|
|
|
|
beacon_chain.op_pool.num_attester_slashings(),
|
|
|
|
);
|
|
|
|
set_gauge_by_usize(
|
|
|
|
&OP_POOL_NUM_PROPOSER_SLASHINGS,
|
|
|
|
beacon_chain.op_pool.num_proposer_slashings(),
|
|
|
|
);
|
|
|
|
set_gauge_by_usize(
|
|
|
|
&OP_POOL_NUM_VOLUNTARY_EXITS,
|
|
|
|
beacon_chain.op_pool.num_voluntary_exits(),
|
|
|
|
);
|
2021-07-15 00:52:02 +00:00
|
|
|
set_gauge_by_usize(
|
|
|
|
&OP_POOL_NUM_SYNC_CONTRIBUTIONS,
|
|
|
|
beacon_chain.op_pool.num_sync_contributions(),
|
|
|
|
);
|
2021-01-20 19:19:38 +00:00
|
|
|
|
|
|
|
beacon_chain
|
|
|
|
.validator_monitor
|
|
|
|
.read()
|
|
|
|
.scrape_metrics(&beacon_chain.slot_clock, &beacon_chain.spec);
|
2019-08-19 11:02:34 +00:00
|
|
|
}
|
2019-05-28 07:30:09 +00:00
|
|
|
|
2019-08-19 11:02:34 +00:00
|
|
|
/// Scrape the given `state` assuming it's the head state, updating the `DEFAULT_REGISTRY`.
|
2021-04-07 01:02:56 +00:00
|
|
|
fn scrape_head_state<T: EthSpec>(state: &BeaconState<T>, state_root: Hash256) {
|
2021-07-09 06:15:32 +00:00
|
|
|
set_gauge_by_slot(&HEAD_STATE_SLOT, state.slot());
|
2021-09-29 23:44:24 +00:00
|
|
|
set_gauge_by_slot(&HEAD_STATE_SLOT_INTEROP, state.slot());
|
2019-08-19 11:02:34 +00:00
|
|
|
set_gauge_by_hash(&HEAD_STATE_ROOT, state_root);
|
|
|
|
set_gauge_by_slot(
|
|
|
|
&HEAD_STATE_LATEST_BLOCK_SLOT,
|
2021-07-09 06:15:32 +00:00
|
|
|
state.latest_block_header().slot,
|
2019-08-19 11:02:34 +00:00
|
|
|
);
|
|
|
|
set_gauge_by_hash(
|
|
|
|
&HEAD_STATE_CURRENT_JUSTIFIED_ROOT,
|
2021-07-09 06:15:32 +00:00
|
|
|
state.current_justified_checkpoint().root,
|
2019-08-19 11:02:34 +00:00
|
|
|
);
|
|
|
|
set_gauge_by_epoch(
|
|
|
|
&HEAD_STATE_CURRENT_JUSTIFIED_EPOCH,
|
2021-07-09 06:15:32 +00:00
|
|
|
state.current_justified_checkpoint().epoch,
|
2019-08-19 11:02:34 +00:00
|
|
|
);
|
2021-09-29 23:44:24 +00:00
|
|
|
set_gauge_by_epoch(
|
|
|
|
&HEAD_STATE_CURRENT_JUSTIFIED_EPOCH_INTEROP,
|
|
|
|
state.current_justified_checkpoint().epoch,
|
|
|
|
);
|
2019-08-19 11:02:34 +00:00
|
|
|
set_gauge_by_hash(
|
|
|
|
&HEAD_STATE_PREVIOUS_JUSTIFIED_ROOT,
|
2021-07-09 06:15:32 +00:00
|
|
|
state.previous_justified_checkpoint().root,
|
2019-08-19 11:02:34 +00:00
|
|
|
);
|
|
|
|
set_gauge_by_epoch(
|
|
|
|
&HEAD_STATE_PREVIOUS_JUSTIFIED_EPOCH,
|
2021-07-09 06:15:32 +00:00
|
|
|
state.previous_justified_checkpoint().epoch,
|
|
|
|
);
|
2021-09-29 23:44:24 +00:00
|
|
|
set_gauge_by_epoch(
|
|
|
|
&HEAD_STATE_PREVIOUS_JUSTIFIED_EPOCH_INTEROP,
|
|
|
|
state.previous_justified_checkpoint().epoch,
|
|
|
|
);
|
2021-07-09 06:15:32 +00:00
|
|
|
set_gauge_by_hash(
|
|
|
|
&HEAD_STATE_FINALIZED_ROOT,
|
|
|
|
state.finalized_checkpoint().root,
|
2019-08-19 11:02:34 +00:00
|
|
|
);
|
|
|
|
set_gauge_by_epoch(
|
|
|
|
&HEAD_STATE_FINALIZED_EPOCH,
|
2021-07-09 06:15:32 +00:00
|
|
|
state.finalized_checkpoint().epoch,
|
|
|
|
);
|
2021-09-29 23:44:24 +00:00
|
|
|
set_gauge_by_epoch(
|
|
|
|
&HEAD_STATE_FINALIZED_EPOCH_INTEROP,
|
|
|
|
state.finalized_checkpoint().epoch,
|
|
|
|
);
|
2021-07-09 06:15:32 +00:00
|
|
|
set_gauge_by_usize(&HEAD_STATE_TOTAL_VALIDATORS, state.validators().len());
|
|
|
|
set_gauge_by_u64(
|
|
|
|
&HEAD_STATE_VALIDATOR_BALANCES,
|
|
|
|
state.balances().iter().sum(),
|
|
|
|
);
|
|
|
|
set_gauge_by_u64(&HEAD_STATE_ETH1_DEPOSIT_INDEX, state.eth1_deposit_index());
|
2021-09-29 23:44:24 +00:00
|
|
|
set_gauge_by_u64(
|
|
|
|
&HEAD_STATE_ETH1_DEPOSITS_INTEROP,
|
|
|
|
state.eth1_data().deposit_count,
|
|
|
|
);
|
2021-07-09 06:15:32 +00:00
|
|
|
set_gauge_by_usize(&HEAD_STATE_TOTAL_VALIDATORS, state.validators().len());
|
|
|
|
set_gauge_by_u64(
|
|
|
|
&HEAD_STATE_VALIDATOR_BALANCES,
|
|
|
|
state.balances().iter().sum(),
|
2019-08-19 11:02:34 +00:00
|
|
|
);
|
2021-04-07 01:02:56 +00:00
|
|
|
|
|
|
|
let mut num_active: usize = 0;
|
|
|
|
let mut num_slashed: usize = 0;
|
|
|
|
let mut num_withdrawn: usize = 0;
|
|
|
|
|
2021-07-09 06:15:32 +00:00
|
|
|
for v in state.validators() {
|
2021-04-07 01:02:56 +00:00
|
|
|
if v.is_active_at(state.current_epoch()) {
|
|
|
|
num_active += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if v.slashed {
|
|
|
|
num_slashed += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if v.is_withdrawable_at(state.current_epoch()) {
|
|
|
|
num_withdrawn += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set_gauge_by_usize(&HEAD_STATE_ACTIVE_VALIDATORS, num_active);
|
2021-09-29 23:44:24 +00:00
|
|
|
set_gauge_by_usize(&HEAD_STATE_ACTIVE_VALIDATORS_INTEROP, num_active);
|
2021-04-07 01:02:56 +00:00
|
|
|
set_gauge_by_usize(&HEAD_STATE_SLASHED_VALIDATORS, num_slashed);
|
|
|
|
set_gauge_by_usize(&HEAD_STATE_WITHDRAWN_VALIDATORS, num_withdrawn);
|
2019-08-19 11:02:34 +00:00
|
|
|
}
|
|
|
|
|
2020-05-17 11:16:48 +00:00
|
|
|
fn scrape_attestation_observation<T: BeaconChainTypes>(slot_now: Slot, chain: &BeaconChain<T>) {
|
|
|
|
let prev_epoch = slot_now.epoch(T::EthSpec::slots_per_epoch()) - 1;
|
|
|
|
|
|
|
|
if let Some(count) = chain
|
2021-08-09 02:43:03 +00:00
|
|
|
.observed_gossip_attesters
|
2020-11-22 23:02:51 +00:00
|
|
|
.read()
|
2020-05-17 11:16:48 +00:00
|
|
|
.observed_validator_count(prev_epoch)
|
|
|
|
{
|
|
|
|
set_gauge_by_usize(&ATTN_OBSERVATION_PREV_EPOCH_ATTESTERS, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Some(count) = chain
|
|
|
|
.observed_aggregators
|
2020-11-22 23:02:51 +00:00
|
|
|
.read()
|
2020-05-17 11:16:48 +00:00
|
|
|
.observed_validator_count(prev_epoch)
|
|
|
|
{
|
|
|
|
set_gauge_by_usize(&ATTN_OBSERVATION_PREV_EPOCH_AGGREGATORS, count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-15 00:52:02 +00:00
|
|
|
fn scrape_sync_committee_observation<T: BeaconChainTypes>(slot_now: Slot, chain: &BeaconChain<T>) {
|
|
|
|
let prev_slot = slot_now - 1;
|
|
|
|
|
|
|
|
let contributors = chain.observed_sync_contributors.read();
|
|
|
|
let mut contributor_sum = 0;
|
|
|
|
for i in 0..SYNC_COMMITTEE_SUBNET_COUNT {
|
|
|
|
if let Some(count) =
|
|
|
|
contributors.observed_validator_count(SlotSubcommitteeIndex::new(prev_slot, i))
|
|
|
|
{
|
|
|
|
contributor_sum += count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drop(contributors);
|
|
|
|
set_gauge_by_usize(&SYNC_COMM_OBSERVATION_PREV_SLOT_SIGNERS, contributor_sum);
|
|
|
|
|
|
|
|
let sync_aggregators = chain.observed_sync_aggregators.read();
|
|
|
|
let mut aggregator_sum = 0;
|
|
|
|
for i in 0..SYNC_COMMITTEE_SUBNET_COUNT {
|
|
|
|
if let Some(count) =
|
|
|
|
sync_aggregators.observed_validator_count(SlotSubcommitteeIndex::new(prev_slot, i))
|
|
|
|
{
|
|
|
|
aggregator_sum += count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drop(sync_aggregators);
|
|
|
|
set_gauge_by_usize(&SYNC_COMM_OBSERVATION_PREV_SLOT_AGGREGATORS, aggregator_sum);
|
|
|
|
}
|
|
|
|
|
2019-08-19 11:02:34 +00:00
|
|
|
fn set_gauge_by_slot(gauge: &Result<IntGauge>, value: Slot) {
|
|
|
|
set_gauge(gauge, value.as_u64() as i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_gauge_by_epoch(gauge: &Result<IntGauge>, value: Epoch) {
|
|
|
|
set_gauge(gauge, value.as_u64() as i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_gauge_by_hash(gauge: &Result<IntGauge>, value: Hash256) {
|
|
|
|
set_gauge(gauge, value.to_low_u64_le() as i64);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_gauge_by_usize(gauge: &Result<IntGauge>, value: usize) {
|
|
|
|
set_gauge(gauge, value as i64);
|
|
|
|
}
|
2019-05-28 07:30:09 +00:00
|
|
|
|
2019-08-19 11:02:34 +00:00
|
|
|
fn set_gauge_by_u64(gauge: &Result<IntGauge>, value: u64) {
|
|
|
|
set_gauge(gauge, value as i64);
|
2019-05-28 07:30:09 +00:00
|
|
|
}
|