Implement POST validators/validator_balances APIs #4872
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Addressed
Some API users want to fetch large chunks of the validator set, and currently do so using the
id
param in the query string. However, query strings are usually subject to length limits on both the client and server side. For Lighthouse, we can't extend the length limit without forking our HTTP server (see #4333 (comment)).Proposed Changes
Bypass the issue of query string limits by adding a POST variant of the
/eth/v1/beacon/states/{state_id}/validators
method. It takes the exact same parameters in a JSON body that looks like this:Update (Dec 2023): this is part of the beacon API spec now.
Additional Info
I would like the RocketPool analytics tools to use this, as they're currently using individual validator queries and large batches in parallel, which frustrate Lighthouse's state load mechanisms. Even with tree-states, large numbers of parallel queries are hard to deal with, because we have to load the entire state, even if only one validator is required. We have caches, but these typically only take effect after one of the requests completes. In practice this is several thousands times slower than if the end-user just loaded the whole validator set once. However users are (rightly) reluctant to do this, because the size of the JSON response is unwieldy. The best of both worlds is to get all the desired validators (and nothing else) in one request: i.e. using a POST request enabled by this PR.