-
Notifications
You must be signed in to change notification settings - Fork 814
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
Bound some storage items for pallet staking
and clean up deprecated exposures
#7483
Bound some storage items for pallet staking
and clean up deprecated exposures
#7483
Conversation
staking
and clean up deprecated exposuresstaking
and clean up deprecated exposures
/cmd prdoc --audience runtime_dev --bump patch |
Deferring |
@@ -842,7 +802,11 @@ pub mod pallet { | |||
fn build(&self) { | |||
ValidatorCount::<T>::put(self.validator_count); | |||
MinimumValidatorCount::<T>::put(self.minimum_validator_count); | |||
Invulnerables::<T>::put(&self.invulnerables); | |||
assert!( | |||
self.invulnerables.len() as u32 <= T::MaxInvulnerables::get(), |
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.
self.invulnerables
is already bounded, we don't need this check.
let disabled_validators_maybe = BoundedVec::try_from(old_disabled_validators); | ||
match disabled_validators_maybe { | ||
Ok(disabled_validators) => { | ||
y = y.saturating_add(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.
You have read the storage already no matter if the match is Ok or Err.
match disabled_validators_maybe { | ||
Ok(disabled_validators) => { | ||
y = y.saturating_add(1); | ||
DisabledValidators::<T>::set(disabled_validators); |
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 main point that might be missed here is that the encoding of a Vec<_>
and BoundedVec<_>
is exactly the same. So no data actually needs to be migrated.
What the migration would have to do is to check if the data won't fit into BoundedVec<_>
, and in this case truncate it.
If hypothetically DisabledValidators
is too large, your migration will not touch it, which means the runtime will still fail to decode it upon next access.
log!(warn, "v17 failed to bound some storage items."); | ||
} | ||
|
||
T::DbWeight::get().reads_writes(x.into(), y.into()) |
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.
In any case I will temp remove this migration as we will start from a fresh state and migrate the data. So any failed bounding will be detected in the migration testing.
<Pallet<T>>::deposit_event(super::Event::<T>::ValidatorDisabled { | ||
stash: params.stash.clone(), | ||
}); | ||
if disabled.try_insert(index, (offender_idx, new_severity)).is_ok() { |
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.
For this you can use .defensive
, worth reading up on it.
All GitHub workflows were cancelled due to failure one of the required jobs. |
Building from #6445 on top of #7282
Changes
Invulnerables
, vector of validators invulnerable to slashing.MaxInvulnerables
to boundInvulnerables
Vec ->BoundedVec
.westend
).Disabled Validators
, vector of validators that have offended in a given era and have been disabled.MaxDisabledValidators
to boundDisabledValidators
Vec ->BoundedVec
.MaxValidatorsCount
according to the current disabling strategy).ErasStakers
andErasStakersClipped
(see Tracker issue for cleaning up old non-paged exposure logic in staking pallet #433 ), non-paged validators exposures.Migrating pallet
staking
storage to v17 to apply all changes.TO DO (in a follow-up PR)
ErasStakersPaged
ExposurePage.others
vectorBondedEras
vectorClaimedRewards
pages vectorErasRewardPoints
EraRewardPoints.individual
BTreeMapUnappliedSlashes
SlashingSpans
SlashingSpans.prior
vector