lighthouse-pulse/beacon_node/http_api/src
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
..
attestation_performance.rs Fix attestation performance API InvalidValidatorIndex error (#3503) 2022-09-05 04:50:45 +00:00
attester_duties.rs Indicate that invalid blocks are optimistic (#3383) 2022-07-30 05:08:57 +00:00
block_id.rs Fix lints for Rust 1.63 (#3459) 2022-08-12 00:56:39 +00:00
block_packing_efficiency.rs Separate execution payloads in the DB (#3157) 2022-05-12 00:42:17 +00:00
block_rewards.rs Implement skip_randao_verification and blinded block rewards API (#3540) 2022-09-19 07:58:48 +00:00
database.rs Use async code when interacting with EL (#3244) 2022-07-03 05:36:50 +00:00
lib.rs Optimise HTTP validator lookups (#3559) 2022-10-15 22:25:51 +00:00
metrics.rs Metrics and DEBG log for late gossip blocks (#2533) 2021-08-23 00:59:14 +00:00
proposer_duties.rs Indicate that invalid blocks are optimistic (#3383) 2022-07-30 05:08:57 +00:00
publish_blocks.rs Deduplicate block root computation (#3590) 2022-09-23 03:52:42 +00:00
state_id.rs Optimise HTTP validator lookups (#3559) 2022-10-15 22:25:51 +00:00
sync_committees.rs Don't return errors on HTTP API for already-known messages (#3341) 2022-08-10 07:52:57 +00:00
validator_inclusion.rs Add execution_optimistic flag to HTTP responses (#3070) 2022-07-25 08:23:00 +00:00
version.rs Add execution_optimistic flag to HTTP responses (#3070) 2022-07-25 08:23:00 +00:00