lighthouse/beacon_node
Jimmy Chen 75aea7054c Enshrine head state shuffling in the shuffling_cache (#4296)
## Issue Addressed

#4281 

## Proposed Changes

- Change `ShufflingCache` implementation from using `LruCache` to a custom cache that removes entry with lowest epoch instead of oldest insertion time.
- Protect the "enshrined" head shufflings when inserting new committee cache entries. The shuffling ids matching the head's previous, current, and future epochs will never be ejected from the cache during `Self::insert_cache_item`.

## Additional Info

There is a bonus point on shuffling preferences in the issue description that hasn't been implemented yet, as I haven't figured out a good way to do this:

> However I'm not convinced since there are some complexities around tie-breaking when two entries have the same epoch. Perhaps preferring entries in the canonical chain is best? 

We should be able to check if a block is on the canonical chain by:

```rust
canonical_head
        .fork_choice_read_lock()
        .contains_block(root)
```

However we need to interleave the shuffling and fork choice locks, which may cause deadlocks if we're not careful (mentioned by @paulhauner). Alternatively, we could use the `state.block_roots` field of the `chain.canonical_head.snapshot.beacon_state`, which avoids deadlock but requires more work.

I'd like to get some feedback on review & testing before I dig deeper into the preferences stuff, as having the canonical head preference may already be quite useful in preventing the issue raised.


Co-authored-by: Jimmy Chen <jimmy@sigmaprime.io>
2023-05-19 05:13:05 +00:00
..
beacon_chain Enshrine head state shuffling in the shuffling_cache (#4296) 2023-05-19 05:13:05 +00:00
builder_client Set user agent on requests to builder (#4199) 2023-04-18 02:47:36 +00:00
client Backfill blocks only to the WSP by default (#4082) 2023-05-05 03:49:23 +00:00
eth1 Replace ganache-cli with anvil (#3555) 2023-05-15 07:22:02 +00:00
execution_layer Implement el_offline and use it in the VC (#4295) 2023-05-17 05:51:56 +00:00
genesis Replace ganache-cli with anvil (#3555) 2023-05-15 07:22:02 +00:00
http_api Implement el_offline and use it in the VC (#4295) 2023-05-17 05:51:56 +00:00
http_metrics Add content-type header to metrics server response (#3970) 2023-02-28 02:20:50 +00:00
lighthouse_network Remove redundant gossipsub tests (#4294) 2023-05-16 01:10:47 +00:00
network Don't requeue already-known RPC blocks (#4214) 2023-05-15 07:22:04 +00:00
operation_pool Split common crates out into their own repos (#3890) 2023-04-28 01:15:40 +00:00
src Add a flag for storing invalid blocks (#4194) 2023-05-15 07:22:03 +00:00
store DB migration for fork choice cleanup (#4265) 2023-05-15 02:10:42 +00:00
tests Appease Clippy 1.68 and refactor http_api (#4068) 2023-03-13 01:40:03 +00:00
timer Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
Cargo.toml Release v4.1.0 (#4191) 2023-04-20 00:51:38 +00:00