lighthouse/consensus
Michael Sproul 61ed5f0ec6 Optimize historic committee calculation for the HTTP API (#3272)
## Issue Addressed

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

## Proposed Changes

Optimize the calculation of historic beacon committees in the HTTP API.

This is achieved by allowing committee caches to be constructed for historic epochs, and constructing these committee caches on the fly in the API. This is much faster than reconstructing the state at the requested epoch, which usually takes upwards of 20s, and sometimes minutes with SPRP=8192. The depth of the `randao_mixes` array allows us to look back 64K epochs/0.8 years from a single state, which is pretty awesome!

We always use the `state_id` provided by the caller, but will return a nice 400 error if the epoch requested is out of range for the state requested, e.g.

```bash
# Prater
curl "http://localhost:5052/eth/v1/beacon/states/3170304/committees?epoch=33538"
```

```json
{"code":400,"message":"BAD_REQUEST: epoch out of bounds, try state at slot 1081344","stacktraces":[]}
```

Queries will be fastest when aligned to `slot % SPRP == 0`, so the hint suggests a slot that is 0 mod 8192.
2022-07-04 02:56:11 +00:00
..
cached_tree_hash Update and consolidate dependencies (#3136) 2022-04-04 00:26:16 +00:00
fork_choice Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
int_to_bytes Update to Rust 1.59 and 2021 edition (#3038) 2022-02-25 00:10:17 +00:00
merkle_proof Update and consolidate dependencies (#3136) 2022-04-04 00:26:16 +00:00
proto_array Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
safe_arith Inline safe_arith methods (#3229) 2022-05-31 06:09:12 +00:00
serde_utils Update to Rust 1.59 and 2021 edition (#3038) 2022-02-25 00:10:17 +00:00
ssz Update to Rust 1.59 and 2021 edition (#3038) 2022-02-25 00:10:17 +00:00
ssz_derive Update to Rust 1.59 and 2021 edition (#3038) 2022-02-25 00:10:17 +00:00
ssz_types Update to Rust 1.59 and 2021 edition (#3038) 2022-02-25 00:10:17 +00:00
state_processing Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
swap_or_not_shuffle Update and consolidate dependencies (#3136) 2022-04-04 00:26:16 +00:00
tree_hash Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
tree_hash_derive Update to Rust 1.59 and 2021 edition (#3038) 2022-02-25 00:10:17 +00:00
types Optimize historic committee calculation for the HTTP API (#3272) 2022-07-04 02:56:11 +00:00