lighthouse/consensus/types
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
..
benches Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
examples Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
presets Native support for Gnosis Beacon Chain network (#2931) 2022-01-27 22:58:33 +00:00
src Optimize historic committee calculation for the HTTP API (#3272) 2022-07-04 02:56:11 +00:00
Cargo.toml Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
clippy.toml Lint for sum and product in consensus code (#2226) 2021-03-01 00:57:13 +00:00