lighthouse/consensus/state_processing/src
Michael Sproul b82f7843ff Use peeking_take_while in BlockReplayer (#4803)
## Issue Addressed

While reviewing #4801 I noticed that our use of `take_while` in the block replayer means that if a state root iterator _with gaps_ is provided, some additonal state roots will be dropped unnecessarily. In practice the impact is small, because once there's _one_ state root miss, the whole tree hash cache needs to be built anyway, and subsequent misses are less costly. However this was still a little inefficient, so I figured it's better to fix it.

## Proposed Changes

Use [`peeking_take_while`](https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.peeking_take_while) to avoid consuming the next element when checking whether it satisfies the slot predicate.

## Additional Info

There's a gist here that shows the basic dynamics in isolation: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=40b623cc0febf9ed51705d476ab140c5. Changing the `peeking_take_while` to a `take_while` causes the assert to fail. Similarly I've added a new test `block_replayer_peeking_state_roots` which fails if the same change is applied inside `get_state_root`.
2023-10-05 06:03:24 +00:00
..
common Phase 0 attestation rewards via Beacon API (#4474) 2023-07-18 01:48:40 +00:00
per_block_processing Use peeking_take_while in BlockReplayer (#4803) 2023-10-05 06:03:24 +00:00
per_epoch_processing Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
upgrade Cache target attester balances for unrealized FFG progression calculation (#4362) 2023-06-30 01:13:06 +00:00
block_replayer.rs Use peeking_take_while in BlockReplayer (#4803) 2023-10-05 06:03:24 +00:00
consensus_context.rs Merged with unstable 2022-11-30 17:29:10 -06:00
genesis.rs Cache target attester balances for unrealized FFG progression calculation (#4362) 2023-06-30 01:13:06 +00:00
lib.rs Rust 1.71 lints (#4503) 2023-07-17 00:14:19 +00:00
macros.rs Directory Restructure (#1163) 2020-05-18 21:24:23 +10:00
metrics.rs Move dependencies to workspace (#4650) 2023-09-22 04:30:56 +00:00
per_block_processing.rs Cache target attester balances for unrealized FFG progression calculation (#4362) 2023-06-30 01:13:06 +00:00
per_epoch_processing.rs Clean capella (#4019) 2023-03-01 03:19:02 +00:00
per_slot_processing.rs Remove checkpoint alignment requirements and enable historic state pruning (#4610) 2023-08-21 05:02:32 +00:00
state_advance.rs Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
upgrade.rs Clean capella (#4019) 2023-03-01 03:19:02 +00:00
verify_operation.rs Rust 1.71 lints (#4503) 2023-07-17 00:14:19 +00:00