lighthouse/consensus
Michael Sproul ca9dc8e094 Optimise HTTP validator lookups (#3559)
## Issue Addressed

While digging around in some logs I noticed that queries for validators by pubkey were taking 10ms+, which seemed too long. This was due to a loop through the entire validator registry for each lookup.

## Proposed Changes

Rather than using a loop through the register, this PR utilises the pubkey cache which is usually initialised at the head*. In case the cache isn't built, we fall back to the previous loop logic. In the vast majority of cases I expect the cache will be built, as the validator client queries at the `head` where all caches should be built.

## Additional Info

*I had to modify the cache build that runs after fork choice to build the pubkey cache. I think it had been optimised out, perhaps accidentally. I think it's preferable to have the exit cache and the pubkey cache built on the head state, as they are required for verifying deposits and exits respectively, and we may as well build them off the hot path of block processing. Previously they'd get built the first time a deposit or exit needed to be verified.

I've deleted the unused `map_state` function which was obsoleted by `map_state_and_execution_optimistic`.
2022-10-15 22:25:51 +00:00
..
cached_tree_hash Update and consolidate dependencies (#3136) 2022-04-04 00:26:16 +00:00
fork_choice Strict count unrealized (#3522) 2022-09-05 04:50:47 +00:00
int_to_bytes Update to Rust 1.59 and 2021 edition (#3038) 2022-02-25 00:10:17 +00:00
merkle_proof New rust lints for rustc 1.64.0 (#3602) 2022-09-23 03:52:46 +00:00
proto_array Strict count unrealized (#3522) 2022-09-05 04:50:47 +00:00
safe_arith Inline safe_arith methods (#3229) 2022-05-31 06:09:12 +00:00
serde_utils Add a u256_hex_be module to encode/decode U256 types (#3321) 2022-07-15 07:31:21 +00:00
ssz Pre-allocate vectors in SSZ decoding (#3417) 2022-09-16 11:54:17 +00:00
ssz_derive Update to Rust 1.59 and 2021 edition (#3038) 2022-02-25 00:10:17 +00:00
ssz_types New rust lints for rustc 1.64.0 (#3602) 2022-09-23 03:52:46 +00:00
state_processing Optimise HTTP validator lookups (#3559) 2022-10-15 22:25:51 +00:00
swap_or_not_shuffle Update and consolidate dependencies (#3136) 2022-04-04 00:26:16 +00:00
tree_hash Use SmallVec for TreeHash packed encoding (#3581) 2022-09-16 08:54:06 +00:00
tree_hash_derive Use SmallVec for TreeHash packed encoding (#3581) 2022-09-16 08:54:06 +00:00
types Optimise HTTP validator lookups (#3559) 2022-10-15 22:25:51 +00:00