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

staking: 🥞 get_validator_info() uses consensus set #4262

Merged
merged 2 commits into from
Apr 29, 2024

Conversation

cratelyn
Copy link
Contributor

@cratelyn cratelyn commented Apr 23, 2024

see #3846.

🔍 changes

NB: this branch performs a refactor away from validator_definitions() and subsequently moves the definition of that method. this is done in distinct commits, which reviewers are encouraged to examine independently.

staking: 🥞 get_validator_info() uses consensus set

The staking component query service provides a ValidatorInfo RPC that returns
the list of registered validators, optionally filtering Inactive validators.

The way this method is implemented is by using an internal
ValidatorDataRead::validator_definitions methods which returns every single
definition ever submitted to the chain. This is problematic because this list
will inevitably grow quite large, turning usage of a benign-looking method
into an onerous source of I/O and expensive rendering.

this refactors the validator_definitions() method to only return validators
included within the consensus set. this will prevent the list returned from
becoming too large over time.

app: 🧙 ValidatorDataReadExt::validator_definitions()

these methods are tremendously useful for tests, because they save us the
trouble of repeatedly hassling with a Stream. to discourage future use of
them in production code however, we can define these in a test-specific
extension.

this commit introduces ValidatorDataReadExt. validator_identity_keys() is
also moved, as it is subject to the same performance considerations.

checklist before requesting a review

  • if this code contains consensus-breaking changes, i have added the "consensus-breaking" label. otherwise, i declare my belief that there are not consensus-breaking changes, for the following reason:

    this only changes the behavior of an RPC endpoint

@cratelyn cratelyn self-assigned this Apr 23, 2024
@cratelyn cratelyn added A-staking Area: Design and implementation of staking and delegation _P-V1 Priority: slated for V1 release _P-high High priority labels Apr 23, 2024
@cratelyn cratelyn added this to the Sprint 5 milestone Apr 23, 2024
@cratelyn
Copy link
Contributor Author

❓ question for reviewers

there is a third to-do item mentioned in #3846, regarding a pcli query validator status command. i'd like to do that in a subsequent PR if possible, to keep this branch focused specifically on the changes to ValidatorDataRead.

is that reasonable, or is the need to inquire about validator state acute enough that i should do that here?

@erwanor erwanor self-requested a review April 23, 2024 21:38
@cratelyn
Copy link
Contributor Author

❓ question for reviewers

there is a third to-do item mentioned in #3846, regarding a pcli query validator status command. i'd like to do that in a subsequent PR if possible, to keep this branch focused specifically on the changes to ValidatorDataRead.

is that reasonable, or is the need to inquire about validator state acute enough that i should do that here?

i've opened #4263. the changes to pcli ended up being a straightforward change. it is still kept distinct from the core changes here to facilitate review.

Copy link
Contributor Author

@cratelyn cratelyn left a comment

Choose a reason for hiding this comment

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

🥖 breadcrumbs for review.

@cratelyn cratelyn marked this pull request as ready for review April 24, 2024 06:17
Copy link
Member

@erwanor erwanor left a comment

Choose a reason for hiding this comment

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

Awesome

see #3846.

> The staking component query service provides a ValidatorInfo RPC that
> returns the list of registered validators, optionally filtering
> Inactive validators.
>
> The way this method is implemented is by using an internal
> ValidatorDataRead::validator_definitions methods which returns every
> single definition ever submitted to the chain. This is problematic
> because this list will inevitably grow quite large, turning usage of a
> benign-looking method into an onerous source of I/O and expensive
> rendering.

this refactors the `validator_definitions` method to only return
validators included within the consensus set. this will prevent the list
returned from becoming too large over time.
these methods are tremendously useful for tests, because they save us
the trouble of repeatedly hassling with a `Stream`. to discourage future
use of them in production code however, we can define these in a
test-specific extension.

this commit introduces `ValidatorDataReadExt`. `validator_identity_keys`
is also moved, as it is subject to the same performance considerations.
@cratelyn cratelyn force-pushed the kate/bounded-validator-info-query branch from 254a78c to 35fca7c Compare April 29, 2024 01:05
@cratelyn
Copy link
Contributor Author

rebased onto main at dc8eff9 ♻️

@cratelyn cratelyn merged commit 098d9cc into main Apr 29, 2024
8 checks passed
@cratelyn cratelyn deleted the kate/bounded-validator-info-query branch April 29, 2024 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-staking Area: Design and implementation of staking and delegation _P-high High priority _P-V1 Priority: slated for V1 release
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants