lighthouse/common
Paul Hauner 6e3ca48cb9 Cache participating indices for Altair epoch processing (#2416)
## Issue Addressed

NA

## Proposed Changes

This PR addresses two things:

1. Allows the `ValidatorMonitor` to work with Altair states.
1. Optimizes `altair::process_epoch` (see [code](https://github.com/paulhauner/lighthouse/blob/participation-cache/consensus/state_processing/src/per_epoch_processing/altair/participation_cache.rs) for description)

## Breaking Changes

The breaking changes in this PR revolve around one premise:

*After the Altair fork, it's not longer possible (given only a `BeaconState`) to identify if a validator had *any* attestation included during some epoch. The best we can do is see if that validator made the "timely" source/target/head flags.*

Whilst this seems annoying, it's not actually too bad. Finalization is based upon "timely target" attestations, so that's really the most important thing. Although there's *some* value in knowing if a validator had *any* attestation included, it's far more important to know about "timely target" participation, since this is what affects finality and justification.

For simplicity and consistency, I've also removed the ability to determine if *any* attestation was included from metrics and API endpoints. Now, all Altair and non-Altair states will simply report on the head/target attestations.

The following section details where we've removed fields and provides replacement values.

### Breaking Changes: Prometheus Metrics

Some participation metrics have been removed and replaced. Some were removed since they are no longer relevant to Altair (e.g., total attesting balance) and others replaced with gwei values instead of pre-computed values. This provides more flexibility at display-time (e.g., Grafana).

The following metrics were added as replacements:

- `beacon_participation_prev_epoch_head_attesting_gwei_total`
- `beacon_participation_prev_epoch_target_attesting_gwei_total`
- `beacon_participation_prev_epoch_source_attesting_gwei_total`
- `beacon_participation_prev_epoch_active_gwei_total`

The following metrics were removed:

- `beacon_participation_prev_epoch_attester`
   - instead use `beacon_participation_prev_epoch_source_attesting_gwei_total / beacon_participation_prev_epoch_active_gwei_total`.
- `beacon_participation_prev_epoch_target_attester`
   - instead use `beacon_participation_prev_epoch_target_attesting_gwei_total / beacon_participation_prev_epoch_active_gwei_total`.
- `beacon_participation_prev_epoch_head_attester`
   - instead use `beacon_participation_prev_epoch_head_attesting_gwei_total / beacon_participation_prev_epoch_active_gwei_total`.

The `beacon_participation_prev_epoch_attester` endpoint has been removed. Users should instead use the pre-existing `beacon_participation_prev_epoch_target_attester`. 

### Breaking Changes: HTTP API

The `/lighthouse/validator_inclusion/{epoch}/{validator_id}` endpoint loses the following fields:

- `current_epoch_attesting_gwei` (use `current_epoch_target_attesting_gwei` instead)
- `previous_epoch_attesting_gwei` (use `previous_epoch_target_attesting_gwei` instead)

The `/lighthouse/validator_inclusion/{epoch}/{validator_id}` endpoint lose the following fields:

- `is_current_epoch_attester` (use `is_current_epoch_target_attester` instead)
- `is_previous_epoch_attester` (use `is_previous_epoch_target_attester` instead)
- `is_active_in_current_epoch` becomes `is_active_unslashed_in_current_epoch`.
- `is_active_in_previous_epoch` becomes `is_active_unslashed_in_previous_epoch`.

## Additional Info

NA

## TODO

- [x] Deal with total balances
- [x] Update validator_inclusion API
- [ ] Ensure `beacon_participation_prev_epoch_target_attester` and `beacon_participation_prev_epoch_head_attester` work before Altair

Co-authored-by: realbigsean <seananderson33@gmail.com>
2021-07-27 07:01:01 +00:00
..
account_utils Enable Compatibility with Windows (#2333) 2021-05-19 23:05:16 +00:00
clap_utils Tune GNU malloc (#2299) 2021-05-28 05:59:45 +00:00
compare_fields Check for unused deps in CI (#1262) 2020-06-14 10:59:50 +10:00
compare_fields_derive Update external deps (#1711) 2020-10-05 08:22:19 +00:00
deposit_contract Allow specifying alternative url for deposit_contract (#2295) 2021-04-16 06:47:34 +00:00
directory fix default network handling (#2029) 2020-12-08 05:41:10 +00:00
eth2 Cache participating indices for Altair epoch processing (#2416) 2021-07-27 07:01:01 +00:00
eth2_config Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
eth2_interop_keypairs Fix new clippy lints (#2036) 2020-12-03 01:10:26 +00:00
eth2_network_config Network upgrades (#2345) 2021-07-15 16:43:10 +10:00
eth2_wallet_manager Use OS file locks in validator client (#1958) 2020-11-26 11:25:46 +00:00
fallback Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
filesystem Enable Compatibility with Windows (#2333) 2021-05-19 23:05:16 +00:00
hashset_delay Bleeding edge discovery (#2435) 2021-07-15 16:43:17 +10:00
lighthouse_metrics [Altair] Sync committee pools (#2321) 2021-07-15 00:52:02 +00:00
lighthouse_version v1.4.0 (#2402) 2021-06-10 01:44:49 +00:00
lockfile Enable Compatibility with Windows (#2333) 2021-05-19 23:05:16 +00:00
logging Update external deps (#1711) 2020-10-05 08:22:19 +00:00
lru_cache Keep track of failed head chains and prevent re-lookups (#1534) 2020-08-18 03:54:09 +00:00
malloc_utils Modify Malloc Tuning (#2398) 2021-06-09 02:30:06 +00:00
monitoring_api Bleeding edge discovery (#2435) 2021-07-15 16:43:17 +10:00
remote_signer_consumer Bleeding edge discovery (#2435) 2021-07-15 16:43:17 +10:00
rest_types Update to tokio 1.1 (#2172) 2021-02-10 23:29:49 +00:00
sensitive_url Add SensitiveUrl to redact user secrets from endpoints (#2326) 2021-05-04 01:59:51 +00:00
slot_clock Add specific log and metric for delayed blocks (#2308) 2021-04-13 02:16:59 +00:00
target_check Improve compilation error on 32-bit (#2424) 2021-06-30 04:56:22 +00:00
task_executor Bleeding edge discovery (#2435) 2021-07-15 16:43:17 +10:00
test_random_derive Update external deps (#1711) 2020-10-05 08:22:19 +00:00
validator_dir rust 1.53.0 updates (#2411) 2021-06-18 05:58:01 +00:00
warp_utils Bleeding edge discovery (#2435) 2021-07-15 16:43:17 +10:00
README.md Directory Restructure (#1163) 2020-05-18 21:24:23 +10:00

eth2

Common crates containing eth2-specific logic.