lighthouse/common
realbigsean b22ac95d7f v1.1.6 Fork Choice changes (#2822)
## Issue Addressed

Resolves: https://github.com/sigp/lighthouse/issues/2741
Includes: https://github.com/sigp/lighthouse/pull/2853 so that we can get ssz static tests passing here on v1.1.6. If we want to merge that first, we can make this diff slightly smaller

## Proposed Changes

- Changes the `justified_epoch` and `finalized_epoch` in the `ProtoArrayNode` each to an `Option<Checkpoint>`. The `Option` is necessary only for the migration, so not ideal. But does allow us to add a default logic to `None` on these fields during the database migration.
- Adds a database migration from a legacy fork choice struct to the new one, search for all necessary block roots in fork choice by iterating through blocks in the db.
- updates related to https://github.com/ethereum/consensus-specs/pull/2727
  -  We will have to update the persisted forkchoice to make sure the justified checkpoint stored is correct according to the updated fork choice logic. This boils down to setting the forkchoice store's justified checkpoint to the justified checkpoint of the block that advanced the finalized checkpoint to the current one. 
  - AFAICT there's no migration steps necessary for the update to allow applying attestations from prior blocks, but would appreciate confirmation on that
- I updated the consensus spec tests to v1.1.6 here, but they will fail until we also implement the proposer score boost updates. I confirmed that the previously failing scenario `new_finalized_slot_is_justified_checkpoint_ancestor` will now pass after the boost updates, but haven't confirmed _all_ tests will pass because I just quickly stubbed out the proposer boost test scenario formatting.
- This PR now also includes proposer boosting https://github.com/ethereum/consensus-specs/pull/2730

## Additional Info
I realized checking justified and finalized roots in fork choice makes it more likely that we trigger this bug: https://github.com/ethereum/consensus-specs/pull/2727

It's possible the combination of justified checkpoint and finalized checkpoint in the forkchoice store is different from in any block in fork choice. So when trying to startup our store's justified checkpoint seems invalid to the rest of fork choice (but it should be valid). When this happens we get an `InvalidBestNode` error and fail to start up. So I'm including that bugfix in this branch.

Todo:

- [x] Fix fork choice tests
- [x] Self review
- [x] Add fix for https://github.com/ethereum/consensus-specs/pull/2727
- [x] Rebase onto Kintusgi 
- [x] Fix `num_active_validators` calculation as @michaelsproul pointed out
- [x] Clean up db migrations

Co-authored-by: realbigsean <seananderson33@gmail.com>
2021-12-13 20:43:22 +00:00
..
account_utils Update zeroize_derive (#2625) 2021-09-25 05:58:37 +00:00
clap_utils Bump crate versions (#2829) 2021-12-02 14:29:57 +11: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 Bump crate versions (#2829) 2021-12-02 14:29:57 +11:00
directory Add background file logging (#2762) 2021-11-30 03:25:32 +00:00
eth2 1.57.0 lints (#2850) 2021-12-03 04:44:30 +00:00
eth2_config Remove unused deps (#2592) 2021-09-30 04:31:42 +00:00
eth2_interop_keypairs Fix nightly bump num bigint (#2591) 2021-09-12 23:55:20 +00:00
eth2_network_config v1.1.6 Fork Choice changes (#2822) 2021-12-13 20:43:22 +00:00
eth2_wallet_manager Remove unused deps (#2592) 2021-09-30 04:31:42 +00:00
fallback Improve eth1 fallback logging (#2490) 2021-08-30 00:51:26 +00:00
filesystem Fix linting error on Windows (#2759) 2021-11-01 07:44:42 +00:00
hashset_delay Update Lighthouse Dependencies (#2818) 2021-11-18 05:08:42 +00:00
lighthouse_metrics Update prometheus to v0.13.0 (#2757) 2021-11-01 05:52:30 +00:00
lighthouse_version Release v2.0.1 (#2726) 2021-10-18 03:08:32 +00:00
lockfile 1.57.0 lints (#2850) 2021-12-03 04:44:30 +00:00
logging 1.57.0 lints (#2850) 2021-12-03 04:44:30 +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 Avoid negative values in malloc_utils metrics (#2692) 2021-10-11 00:10:34 +00:00
monitoring_api 1.57.0 lints (#2850) 2021-12-03 04:44:30 +00:00
sensitive_url Add SensitiveUrl to redact user secrets from endpoints (#2326) 2021-05-04 01:59:51 +00:00
slot_clock v1.1.6 Fork Choice changes (#2822) 2021-12-13 20:43:22 +00:00
target_check Improve compilation error on 32-bit (#2424) 2021-06-30 04:56:22 +00:00
task_executor [Merge] Implement execution_layer (#2635) 2021-12-02 14:26:51 +11:00
test_random_derive Update external deps (#1711) 2020-10-05 08:22:19 +00:00
validator_dir 1.57.0 lints (#2850) 2021-12-03 04:44:30 +00:00
warp_utils Update Lighthouse Dependencies (#2818) 2021-11-18 05:08:42 +00:00
README.md Directory Restructure (#1163) 2020-05-18 21:24:23 +10:00

eth2

Common crates containing eth2-specific logic.