substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Add a migration helper for reducing HistoryDepth config value in staking pallet

Open Ank4n opened this issue 2 years ago • 0 comments

PR https://github.com/paritytech/substrate/pull/12230 introduced HistoryDepth as a config value in staking pallet which bounds several storage item in the pallet. In order to lower this value for a runtime once it has been already set, we need to handle migration of the storage items affected.

Following storage items are affected by History Depth ErasStakers, ErasStakersClipped, ErasValidatorPrefs, ErasValidatorReward, ErasRewardPoints, ErasTotalStake, ErasStartSessionIndex, StakingLedger.claimed_rewards

We should add a generic migration function fn migrate_history_depth(from: u32, to: u32) -> Weight and put it in staking::migrations that can be used by a future migrations to reduce the HistoryDepth gracefully.

We should also look into reducing the current HistoryDepth = 84 on Polkadot and Kusama once we have this.

cc: @kianenigma

Ank4n avatar Sep 21 '22 15:09 Ank4n