lighthouse/beacon_node/beacon_chain/src
Michael Sproul 3be41006a6 Add --light-client-server flag and state cache utils (#3714)
## Issue Addressed

Part of https://github.com/sigp/lighthouse/issues/3651.

## Proposed Changes

Add a flag for enabling the light client server, which should be checked before gossip/RPC traffic is processed (e.g. https://github.com/sigp/lighthouse/pull/3693, https://github.com/sigp/lighthouse/pull/3711). The flag is available at runtime from `beacon_chain.config.enable_light_client_server`.

Additionally, a new method `BeaconChain::with_mutable_state_for_block` is added which I envisage being used for computing light client updates. Unfortunately its performance will be quite poor on average because it will only run quickly with access to the tree hash cache. Each slot the tree hash cache is only available for a brief window of time between the head block being processed and the state advance at 9s in the slot. When the state advance happens the cache is moved and mutated to get ready for the next slot, which makes it no longer useful for merkle proofs related to the head block. Rather than spend more time trying to optimise this I think we should continue prototyping with this code, and I'll make sure `tree-states` is ready to ship before we enable the light client server in prod (cf. https://github.com/sigp/lighthouse/pull/3206).

## Additional Info

I also fixed a bug in the implementation of `BeaconState::compute_merkle_proof` whereby the tree hash cache was moved with `.take()` but never put back with `.restore()`.
2022-11-11 11:03:18 +00:00
..
attestation_verification Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
schema_change Deposit Cache Finalization & Fast WS Sync (#2915) 2022-10-30 04:04:24 +00:00
attestation_verification.rs Refactor op pool for speed and correctness (#3312) 2022-08-29 09:10:26 +00:00
attester_cache.rs Add early attester cache (#2872) 2022-01-11 01:35:55 +00:00
beacon_chain.rs Add --light-client-server flag and state cache utils (#3714) 2022-11-11 11:03:18 +00:00
beacon_fork_choice_store.rs Remove equivocating validators from fork choice (#3371) 2022-07-28 09:43:41 +00:00
beacon_proposer_cache.rs Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
beacon_snapshot.rs Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
block_reward.rs Refactor op pool for speed and correctness (#3312) 2022-08-29 09:10:26 +00:00
block_times_cache.rs Add BlockTimesCache to allow additional block delay metrics (#2546) 2021-09-30 04:31:41 +00:00
block_verification.rs Deposit Cache Finalization & Fast WS Sync (#2915) 2022-10-30 04:04:24 +00:00
builder.rs Deposit Cache Finalization & Fast WS Sync (#2915) 2022-10-30 04:04:24 +00:00
canonical_head.rs Revert "Optimise HTTP validator lookups" (#3658) 2022-10-26 06:50:04 +00:00
chain_config.rs Add --light-client-server flag and state cache utils (#3714) 2022-11-11 11:03:18 +00:00
early_attester_cache.rs Fix some typos (#3376) 2022-07-27 00:51:06 +00:00
errors.rs Impl oneshot_broadcast for committee promises (#3595) 2022-09-21 01:01:50 +00:00
eth1_chain.rs Deposit Cache Finalization & Fast WS Sync (#2915) 2022-10-30 04:04:24 +00:00
eth1_finalization_cache.rs Deposit Cache Finalization & Fast WS Sync (#2915) 2022-10-30 04:04:24 +00:00
events.rs Implement API for block rewards (#2628) 2022-01-27 01:06:02 +00:00
execution_payload.rs Add more logging for invalid payloads (#3515) 2022-08-29 14:34:42 +00:00
fork_choice_signal.rs Run fork choice before block proposal (#3168) 2022-05-20 05:02:11 +00:00
fork_revert.rs Consensus context with proposer index caching (#3604) 2022-10-15 22:25:54 +00:00
head_tracker.rs Fix rust 1.65 lints (#3682) 2022-11-04 07:43:43 +00:00
historical_blocks.rs Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
lib.rs Deposit Cache Finalization & Fast WS Sync (#2915) 2022-10-30 04:04:24 +00:00
merge_readiness.rs Increase merge-readiness lookhead (#3463) 2022-08-15 01:30:59 +00:00
metrics.rs Avoid duplicate committee cache loads (#3574) 2022-09-16 08:54:03 +00:00
migrate.rs Fix rust 1.65 lints (#3682) 2022-11-04 07:43:43 +00:00
naive_aggregation_pool.rs Update to Rust 1.59 and 2021 edition (#3038) 2022-02-25 00:10:17 +00:00
observed_aggregates.rs v2.2.0 (#3139) 2022-04-05 02:53:09 +00:00
observed_attesters.rs Ensure doppelganger detects attestations in blocks (#2495) 2021-08-09 02:43:03 +00:00
observed_block_producers.rs Doppelganger detection (#2230) 2021-07-31 03:50:52 +00:00
observed_operations.rs Refactor op pool for speed and correctness (#3312) 2022-08-29 09:10:26 +00:00
otb_verification_service.rs Initial Commit of Retrospective OTB Verification (#3372) 2022-07-30 00:22:38 +00:00
persisted_beacon_chain.rs Fix head tracker concurrency bugs (#1771) 2020-10-19 05:58:39 +00:00
persisted_fork_choice.rs Remove equivocating validators from fork choice (#3371) 2022-07-28 09:43:41 +00:00
pre_finalization_cache.rs Separate execution payloads in the DB (#3157) 2022-05-12 00:42:17 +00:00
proposer_prep_service.rs Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
schema_change.rs Fix rust 1.65 lints (#3682) 2022-11-04 07:43:43 +00:00
shuffling_cache.rs Impl oneshot_broadcast for committee promises (#3595) 2022-09-21 01:01:50 +00:00
snapshot_cache.rs Add --light-client-server flag and state cache utils (#3714) 2022-11-11 11:03:18 +00:00
state_advance_timer.rs Avoid duplicate committee cache loads (#3574) 2022-09-16 08:54:03 +00:00
sync_committee_verification.rs New rust lints for rustc 1.64.0 (#3602) 2022-09-23 03:52:46 +00:00
test_utils.rs Fix rust 1.65 lints (#3682) 2022-11-04 07:43:43 +00:00
timeout_rw_lock.rs Add flag to disable lock timeouts (#2714) 2021-10-19 00:30:40 +00:00
validator_monitor.rs Register blocks in validator monitor (#3635) 2022-11-09 05:37:09 +00:00
validator_pubkey_cache.rs Add support for beaconAPI in lcli functions (#3252) 2022-08-09 06:05:13 +00:00