Skip to content

Commit

Permalink
Fix PR title in prdoc and migrations for old deprecated storage items
Browse files Browse the repository at this point in the history
  • Loading branch information
re-gius committed Dec 18, 2024
1 parent 17eeef7 commit 21a12d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
9 changes: 2 additions & 7 deletions prdoc/pr_6445.prdoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: Add storage bounds for pallet `staking`
title: Add storage bounds for pallet `staking` and clean up deprecated non paged exposure storages
doc:
- audience: Runtime Dev
description: |-
Expand All @@ -17,18 +17,13 @@ doc:
- Completing the task from #5986
- Use `MaxExposurePageSize` to bound `ErasStakersPaged` mapping to exposure pages: each `ExposurePage.others` Vec is turned into a `WeakBoundedVec` to allow easy and quick changes to this bound
- Add `MaxBondedEras` to bound `BondedEras` Vec -> `BoundedVec`
- Set to `BondingDuration::get() + 1` everywhere to include both time interval endpoints in [`current_era - BondingDuration::get()`, `current_era`]
- Set to `BondingDuration::get() + 1` everywhere to include both time interval endpoints in [`current_era - BondingDuration::get()`, `current_era`]. Notice that this was done manually in every test and runtime.
- Add `MaxRewardPagesPerValidator` to bound `ClaimedRewards` Vec of pages -> `WeakBoundedVec`
- Set to constant 20 in the pallet. The vector of pages is now a `WeakBoundedVec` to allow easy and quick changes to this parameter
- Remove `MaxValidatorsCount` optional storage item to add `MaxValidatorsCount` mandatory config parameter
- Using it to to bound `EraRewardPoints.individual` BTreeMap -> `BoundedBTreeMap`;
- Set to dynamic parameter in runtime westend so that changing it should not require migrations for it

**TO DO**
Slashing storage items will be bounded in another PR.

- `UnappliedSlashes`
- `SlashingSpans`
crates:
- name: pallet-staking
bump: major
Expand Down
24 changes: 24 additions & 0 deletions substrate/frame/staking/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ pub mod v17 {
let mut migration_errors = false;

v16::MaxValidatorsCount::<T>::kill();
v16::ErasStakers::<T>::kill();
v16::ErasStakersClipped::<T>::kill();

let old_disabled_validators = v16::DisabledValidators::<T>::get();
// BoundedVec with MaxDisabledValidators limit, this should always work
Expand Down Expand Up @@ -254,6 +256,28 @@ pub mod v16 {
#[frame_support::storage_alias]
pub(crate) type MaxValidatorsCount<T: Config> = StorageValue<Pallet<T>, u32, OptionQuery>;

#[frame_support::storage_alias]
pub(crate) type ErasStakers<T: Config> = StorageDoubleMap<
Pallet<T>,
Twox64Concat,
EraIndex,
Twox64Concat,
<T as frame_system::Config>::AccountId,
Exposure<<T as frame_system::Config>::AccountId, BalanceOf<T>>,
ValueQuery,
>;

#[frame_support::storage_alias]
pub(crate) type ErasStakersClipped<T: Config> = StorageDoubleMap<
Pallet<T>,
Twox64Concat,
EraIndex,
Twox64Concat,
<T as frame_system::Config>::AccountId,
Exposure<<T as frame_system::Config>::AccountId, BalanceOf<T>>,
ValueQuery,
>;

pub struct VersionUncheckedMigrateV15ToV16<T>(core::marker::PhantomData<T>);
impl<T: Config> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV15ToV16<T> {
#[cfg(feature = "try-runtime")]
Expand Down

0 comments on commit 21a12d1

Please sign in to comment.