-
Notifications
You must be signed in to change notification settings - Fork 710
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 storage bounds for pallet staking
#6445
base: master
Are you sure you want to change the base?
Conversation
/// Ideally, it should be `BondingDuration::get() + 1` to include all eras in the interval | ||
/// [current_era - BondingDuration::get(), current_era]. | ||
#[pallet::constant] | ||
type MaxBondedEras: Get<u32>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should have an integrity test ensuring MaxBondedEras
>= BondingDuration + 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in tests
assert_eq!(MaxBondedEras::get(), (BondingDuration::get() as u32) + 1);
pub type ErasStakersPaged<T: Config> = StorageNMap< | ||
_, | ||
( | ||
NMapKey<Twox64Concat, EraIndex>, | ||
NMapKey<Twox64Concat, T::AccountId>, | ||
NMapKey<Twox64Concat, Page>, | ||
), | ||
ExposurePage<T::AccountId, BalanceOf<T>>, | ||
ExposurePage<T::AccountId, BalanceOf<T>, T::MaxExposurePageSize>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gpestana should we reduce MaxExposurePageSize
before we do this? What would be the ideal number? 64/128?
To give context, once we make this bounded, reducing it would need (large) migration. Alternatively, we can make it WeaklyBoundedVec
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using WeakBoundedVec
in c066632
_, | ||
Twox64Concat, | ||
EraIndex, | ||
EraRewardPoints<T::AccountId, <T::ElectionProvider as ElectionProviderBase>::MaxWinners>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this is not correct. The storage ValidatorCount
is the right value.
We can potentially turn it into a config item but that has the implication that increasing validator count would always require runtime upgrade and cannot happen via governance. To fix that, you will have to also turn it into a dynamic parameter (see here).
_, | ||
BoundedVec< | ||
(u32, OffenceSeverity), | ||
<T::ElectionProvider as ElectionProviderBase>::MaxWinners, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
Also, consider using WeaklyBoundedVec
since we expect validator numbers to change over time. An increase in the value is not an issue but for some reason if we decrease it, it can lead to decode issues with BoundedVec
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, DisabledValidators
would be a much smaller number than the actual validator set, and it depends on the DisablingStrategy
, which is currenctly 1/3rd of the set. This can also be a new config value.
self.invulnerables.len() as u32 <= T::MaxInvulnerables::get(), | ||
"Too many invulnerable validators at genesis." | ||
); | ||
<Invulnerables<T>>::put(BoundedVec::truncate_from(self.invulnerables.clone())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stakers param in GenesisConfig
itself can be BoundedVec
, right?
All GitHub workflows were cancelled due to failure one of the required jobs. |
This is part of #6289 and necessary for the Asset Hub migration.
Building on the observations and suggestions from #255 .
Changes
MaxInvulnerables
to boundInvulnerables
Vec.westend
).MaxWinners
frompallet-election-provider-support
to boundDisabledValidators
Vec andEraRewardPoints.individual
BTreeMap.ErasStakers
andErasStakersClipped
(see Tracker issue for cleaning up old non-paged exposure logic in staking pallet #433 )MaxExposurePageSize
to boundErasStakersPaged
->ExposurePage.others
VecMaxBondedEras
to boundBondedEras
VecBondingDuration::get() + 1
everywhere to include both time interval endpointsMaxRewardPagesPerValidator
to boundClaimedRewards
Vec of pagesWeakBoundedVec
TO DO
Slashing storage items will be bounded in another PR.
UnappliedSlashes
SlashingSpans