Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

session, staking: introduce static limit on the number of validators #9724

Closed
andresilva opened this issue Sep 7, 2021 · 7 comments
Closed
Labels
J0-enhancement An additional feature request. U2-some_time_soon Issue is worth doing soon. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder

Comments

@andresilva
Copy link
Contributor

andresilva commented Sep 7, 2021

We need to introduce a static value for the maximum number of validators allowed in staking and session, we can then use this limit to replace a couple of storage entries with length-bounded data structures, e.g. DisabledValidators, Invulnerables, OffendingValidators can use BoundedVec.

See: #9448 (comment)

@andresilva andresilva added J0-enhancement An additional feature request. U2-some_time_soon Issue is worth doing soon. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder labels Sep 7, 2021
@andresilva andresilva changed the title staking: introduce static limit on the number of validators session, staking: introduce static limit on the number of validators Sep 7, 2021
@ShubhamPalriwala
Copy link

Hey, so we can have the DisabledValidators, Invulnerables, and OffendingValidators use the BoundedVec.
Apart from that. how are we having an upper limit, is it static or dynamic?
And how do we want to validate it?

@burdges
Copy link

burdges commented Jun 25, 2022

I'm confused by "static" here. You want a global limit no chain ever exceeds? Or you want some more authoritative governance controlled limit?

We believe no substrate chain will ever exceed 3072 validators because we believe the OmniLedger sharding approach kicks in before 1500 validators, possibly before 768, and someone might require a factor of two so the set could be split. We envision doing this with the polkado relay chain eventually. We might require better randomness for this, but that's preferable to running gossip on more than 3072 validators.

@andresilva
Copy link
Contributor Author

andresilva commented Jun 27, 2022

We want a static limit that can only be changed by a runtime upgrade, similar to what exists here: https://github.com/paritytech/substrate/blob/master/frame/babe/src/lib.rs#L176-L178, so that we can use this limit to use size-bounded collections like here: https://github.com/paritytech/substrate/blob/master/frame/babe/src/lib.rs#L198-L205.

For example this vector in session pallet can currently grow indefinitely: https://github.com/paritytech/substrate/blob/master/frame/session/src/lib.rs#L523-L530

cc @kianenigma ?

@burdges
Copy link

burdges commented Jun 28, 2022

How do the size-bounded collections help? It's weight computations?

I suppose 3072 fits nicely if you do not matter a factor of 2x or 3x but likely going that high requires other runtime upgrades, so it could be set lower if required.

@Doordashcon
Copy link
Contributor

Doordashcon commented Aug 2, 2022

The static limit can be set by entities adding staking and session pallets to their runtimes, for the node I believe 3072 is acceptable?

Then add this bound to relevant storage items.

Might be an over simplification on my part.

@kianenigma
Copy link
Contributor

I've made a draft of the proper way to do this in https://github.com/paritytech/substrate/tree/kiz-properly-bound-staking-validators

@Doordashcon this is how you should go about doing #12125. Nonetheless, as noted in #11967 (review), this might be a little bit of an involved issue since it touches multiple pallets and perhaps you should work with someone from our team to do this.

I will try and create a new tracking issue for bounding the staking pallet, and devise a plan there. Hopefully we can come up with some better small steps for you to contribute through.

@kianenigma
Copy link
Contributor

Replaced with paritytech/polkadot-sdk#255

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J0-enhancement An additional feature request. U2-some_time_soon Issue is worth doing soon. Z1-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants