lighthouse/beacon_node
Michael Sproul 22115049ee Prioritise important parts of block processing (#3696)
## Issue Addressed

Closes https://github.com/sigp/lighthouse/issues/2327

## Proposed Changes

This is an extension of some ideas I implemented while working on `tree-states`:

- Cache the indexed attestations from blocks in the `ConsensusContext`. Previously we were re-computing them 3-4 times over.
- Clean up `import_block` by splitting each part into `import_block_XXX`.
- Move some stuff off hot paths, specifically:
  - Relocate non-essential tasks that were running between receiving the payload verification status and priming the early attester cache. These tasks are moved after the cache priming:
    - Attestation observation
    - Validator monitor updates
    - Slasher updates
    - Updating the shuffling cache
  - Fork choice attestation observation now happens at the end of block verification in parallel with payload verification (this seems to save 5-10ms).
  - Payload verification now happens _before_ advancing the pre-state and writing it to disk! States were previously being written eagerly and adding ~20-30ms in front of verifying the execution payload. State catchup also sometimes takes ~500ms if we get a cache miss and need to rebuild the tree hash cache.

The remaining task that's taking substantial time (~20ms) is importing the block to fork choice. I _think_ this is because of pull-tips, and we should be able to optimise it out with a clever total active balance cache in the state (which would be computed in parallel with payload verification). I've decided to leave that for future work though. For now it can be observed via the new `beacon_block_processing_post_exec_pre_attestable_seconds` metric.


Co-authored-by: Michael Sproul <micsproul@gmail.com>
2022-11-30 05:22:58 +00:00
..
beacon_chain Prioritise important parts of block processing (#3696) 2022-11-30 05:22:58 +00:00
builder_client Builder Specs v0.2.0 (#3134) 2022-07-30 00:22:37 +00:00
client Health Endpoints for UI (#3668) 2022-11-15 05:21:26 +00:00
eth1 Lower deposit finalization error to warning (#3739) 2022-11-21 06:29:03 +00:00
execution_layer Improve debugging experience for builder proposals (#3725) 2022-11-29 05:51:42 +00:00
genesis Super small improvement: Remove unnecessary mut (#3736) 2022-11-21 03:15:54 +00:00
http_api Optimize finalized chain sync by skipping newPayload messages (#3738) 2022-11-29 08:19:27 +00:00
http_metrics Support IPv6 in BN and VC HTTP APIs (#3104) 2022-03-24 00:04:49 +00:00
lighthouse_network Optimize finalized chain sync by skipping newPayload messages (#3738) 2022-11-29 08:19:27 +00:00
network Optimize finalized chain sync by skipping newPayload messages (#3738) 2022-11-29 08:19:27 +00:00
operation_pool Fix rust 1.65 lints (#3682) 2022-11-04 07:43:43 +00:00
src Ipv6 bootnodes (#3752) 2022-11-30 03:21:35 +00:00
store Deposit Cache Finalization & Fast WS Sync (#2915) 2022-10-30 04:04:24 +00:00
tests Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
timer Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
Cargo.toml v3.3.0 (#3741) 2022-11-23 23:38:32 +00:00