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

feat: add /pallets/staking/validators endpoint #1045

Merged
merged 12 commits into from
Jan 24, 2023
Merged

Conversation

Imod7
Copy link
Contributor

@Imod7 Imod7 commented Sep 5, 2022

Relates to this Issue #1005

Description

Adds /pallets/staking/validators endpoint which returns a list of all validators addresses and their corresponding status which can be either active or waiting.

  • Active means that the validator is part of the active set
  • Waiting means that the validator did not get into the active set this era

Sample Response

Sample request :
/pallets/staking/validators

Sample response :

{
  "validators": [
    {
      "address": "HYxzaXwkydDNAy3R8UnCvfprNm74TwwSELpyXSRoqmy9AQY",
      "status": "waiting"
    },
    {
      "address": "DfishveZoxSRNRb8FtyS7ignbw6cr32eCY2w6ctLDRM1NQz",
      "status": "active"
    },
    {
      "address": "HmsTAS1bCtZc9FSq9nqJzZCEkhhSygtXj9TDxNgEWTHnpyQ",
      "status": "active"
    },
    {
      "address": "Efishjj6mrTWVjwFoxtMmHH3mX6tRNnPKsSfQeCLZSv3jAE",
      "status": "waiting"
    },
    {
      "address": "Hn8ELsyUL9UgDZpPX6bE464o4sbi7gqgYEKjntK7xuVzGXH",
      "status": "active"
    },
...

Todos

  • Update Docs
  • Add Tests

- Controller, service, response type
- Returns all validators addresses and their corresponding status (active / waiting)
@Imod7 Imod7 requested a review from a team as a code owner September 5, 2022 06:40
@TarikGul
Copy link
Member

closes: #301

- Added the `at` query param
- Modified the Service accordingly
- Changed the data structure used to save the validators in the active set from an `array` to a `Set` (based on James suggestion)
- Changed also the used functions accordingly.
- Merged in one loop the check of which validator is in the active set and the population of the returned array.
@Imod7 Imod7 requested a review from a team as a code owner January 17, 2023 14:21
- yarn lint
- Added validators endpoint to the docs
- Corrected other parts of the docs mentioned by the swagger as errors.
Copy link
Member

@TarikGul TarikGul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great so far, just some nits, and code changes.

@Imod7
Copy link
Contributor Author

Imod7 commented Jan 20, 2023

@TarikGul @IkerAlus If validators can change status (go from active to waiting for example) per era then I have to add as param in the endpoint also the era right ? Right now I only have the block height.
From Polkadot Support

An era is a period of time during which there is a specific set of active validators. Each era has 6 epochs (or sessions). During the last epoch, the active set of the next era is elected.

@IkerAlus
Copy link
Contributor

IkerAlus commented Jan 20, 2023

@Imod7 Either you add blockHeight or era as input parameter but not both. There is an unequivocally relationship between a block and an era.

If the question is what is more useful as input parameter, block heights or eras, I am not sure, I see reasons for both:

  • block height is used everywhere in the endpoints and it is easy to find
  • The concept of era is more related to this endpoint

Copy link
Member

@TarikGul TarikGul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nit. Great Job! lgtm

Copy link
Collaborator

@marshacb marshacb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great to me! once merge conflicts and any remaining nits are addressed its good to go!

Imod7 and others added 3 commits January 24, 2023 13:32
@Imod7 Imod7 merged commit 70e0a36 into master Jan 24, 2023
@Imod7 Imod7 deleted the domi-validators-endpoint branch January 24, 2023 14:09
This pull request was closed.
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.

5 participants