lighthouse/beacon_node
Paul Hauner 02e2fd2fb8 Add early attester cache (#2872)
## Issue Addressed

NA

## Proposed Changes

Introduces a cache to attestation to produce atop blocks which will become the head, but are not fully imported (e.g., not inserted into the database).

Whilst attesting to a block before it's imported is rather easy, if we're going to produce that attestation then we also need to be able to:

1. Verify that attestation.
1. Respond to RPC requests for the `beacon_block_root`.

Attestation verification (1) is *partially* covered. Since we prime the shuffling cache before we insert the block into the early attester cache, we should be fine for all typical use-cases. However, it is possible that the cache is washed out before we've managed to insert the state into the database and then attestation verification will fail with a "missing beacon state"-type error.

Providing the block via RPC (2) is also partially covered, since we'll check the database *and* the early attester cache when responding a blocks-by-root request. However, we'll still omit the block from blocks-by-range requests (until the block lands in the DB). I *think* this is fine, since there's no guarantee that we return all blocks for those responses.

Another important consideration is whether or not the *parent* of the early attester block is available in the databse. If it were not, we might fail to respond to blocks-by-root request that are iterating backwards to collect a chain of blocks. I argue that *we will always have the parent of the early attester block in the database.* This is because we are holding the fork-choice write-lock when inserting the block into the early attester cache and we do not drop that until the block is in the database.
2022-01-11 01:35:55 +00:00
..
beacon_chain Add early attester cache (#2872) 2022-01-11 01:35:55 +00:00
client Additional networking metrics (#2549) 2021-12-22 06:17:14 +00:00
eth1 Bump crate versions (#2829) 2021-12-02 14:29:57 +11:00
execution_layer Additional networking metrics (#2549) 2021-12-22 06:17:14 +00:00
genesis Bump crate versions (#2829) 2021-12-02 14:29:57 +11:00
http_api Additional networking metrics (#2549) 2021-12-22 06:17:14 +00:00
http_metrics Additional networking metrics (#2549) 2021-12-22 06:17:14 +00:00
lighthouse_network Update to superstruct v0.4.1 (#2886) 2022-01-06 03:14:58 +00:00
network Add early attester cache (#2872) 2022-01-11 01:35:55 +00:00
operation_pool Bump crate versions (#2829) 2021-12-02 14:29:57 +11:00
src Allow value for beacon_node fee-recipient argument (#2884) 2022-01-07 01:21:42 +00:00
store Additional networking metrics (#2549) 2021-12-22 06:17:14 +00:00
tests Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
timer Update Lighthouse Dependencies (#2818) 2021-11-18 05:08:42 +00:00
Cargo.toml Rename eth2_libp2p to lighthouse_network (#2702) 2021-10-19 00:30:39 +00:00