From 21a12d182d08ad0b61e18cb493909e24c0302aca Mon Sep 17 00:00:00 2001 From: giuseppere Date: Wed, 18 Dec 2024 14:41:59 +0100 Subject: [PATCH] Fix PR title in prdoc and migrations for old deprecated storage items --- prdoc/pr_6445.prdoc | 9 ++------- substrate/frame/staking/src/migrations.rs | 24 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/prdoc/pr_6445.prdoc b/prdoc/pr_6445.prdoc index 79e3e6b7b034..36bb6d00fac2 100644 --- a/prdoc/pr_6445.prdoc +++ b/prdoc/pr_6445.prdoc @@ -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: |- @@ -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 diff --git a/substrate/frame/staking/src/migrations.rs b/substrate/frame/staking/src/migrations.rs index 35de7b429f30..7c66f629ce5e 100644 --- a/substrate/frame/staking/src/migrations.rs +++ b/substrate/frame/staking/src/migrations.rs @@ -71,6 +71,8 @@ pub mod v17 { let mut migration_errors = false; v16::MaxValidatorsCount::::kill(); + v16::ErasStakers::::kill(); + v16::ErasStakersClipped::::kill(); let old_disabled_validators = v16::DisabledValidators::::get(); // BoundedVec with MaxDisabledValidators limit, this should always work @@ -254,6 +256,28 @@ pub mod v16 { #[frame_support::storage_alias] pub(crate) type MaxValidatorsCount = StorageValue, u32, OptionQuery>; + #[frame_support::storage_alias] + pub(crate) type ErasStakers = StorageDoubleMap< + Pallet, + Twox64Concat, + EraIndex, + Twox64Concat, + ::AccountId, + Exposure<::AccountId, BalanceOf>, + ValueQuery, + >; + + #[frame_support::storage_alias] + pub(crate) type ErasStakersClipped = StorageDoubleMap< + Pallet, + Twox64Concat, + EraIndex, + Twox64Concat, + ::AccountId, + Exposure<::AccountId, BalanceOf>, + ValueQuery, + >; + pub struct VersionUncheckedMigrateV15ToV16(core::marker::PhantomData); impl UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV15ToV16 { #[cfg(feature = "try-runtime")]