Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add REST implementation for ValidatorStatus #11757

Merged
merged 7 commits into from
Dec 14, 2022
Merged

Add REST implementation for ValidatorStatus #11757

merged 7 commits into from
Dec 14, 2022

Conversation

nalepae
Copy link
Contributor

@nalepae nalepae commented Dec 12, 2022

What type of PR is this?

Feature

Related gitHub issue:

#11580

What does this PR do? Why is it needed?

This adds an implementation for the ValidatorStatus validator client method by calling the Beacon Node REST API instead of the gRPC one.

Notes for reviewers:

Eth1DepositBlockNumber & DepositInclusionSlot:

In gRPC implementation, the beacon node returns Eth1DepositBlockNumber & DepositInclusionSlot.
As far as I know, the Beacon API does not offers easy way to retrieve these data.
Unless I'm mistaken, these data are not used in the Validator Client.
I chose to skip them. Please tell me if this decision is not valid.

Ordered validators

I assumed the call to /eth/v1/beacon/states/head/validators returns a sorted (by index) list of validators.
However, I was not able to find such a sort requirement in the specification, even if Prysm, Teku and Lighthouse (did not test Nimbus) seem to respect this sort standard.

The advantage of this assumption is, in order to retrieve the last active validator, we just have to get the last element of the list. (O(1))
Please tell me if such an assumption is not valid.

Position in active queue

I tried to mimic the behaviour of https://github.com/prysmaticlabs/prysm/blob/develop/beacon-chain/rpc/prysm/v1alpha1/validator/status.go#L272.

This implementation assumes that the position in active queue for a given validator is the difference between the index of the validator and the highest index in the set of currently active validators.

If we consider the following case:

validatorIndex | validatorStatus
-------------------------------
1000           | active_ongoing
1001           | active_ongoing
1002           | exited_slashed
1003           | pending_queued
1004           | pending_queued    <--- our validator

Then:

  • the real position in active queue for our validator will be 1004 - 1002 = 2
  • the indicated position in active queue for our validator will be 1004 - 1001 = 3

(But I think it's still a good proxy)

@nalepae nalepae requested a review from a team as a code owner December 12, 2022 23:11
validator/client/beacon-api/status.go Outdated Show resolved Hide resolved
validator/client/beacon-api/status.go Outdated Show resolved Hide resolved
validator/client/beacon-api/status.go Show resolved Hide resolved
@nalepae nalepae requested review from rkapka and removed request for kasey, rauljordan and saolyn December 13, 2022 22:31
@prylabs-bulldozer prylabs-bulldozer bot merged commit 9c21809 into prysmaticlabs:develop Dec 14, 2022
roberto-bayardo pushed a commit to roberto-bayardo/prysm that referenced this pull request Dec 17, 2022
* Add REST implementation for `ValidatorStatus`

* Fix review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants