substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Stop using deprecated `remove_prefix` to clear era information in Staking Pallet

Open Ank4n opened this issue 2 years ago • 1 comments

We currently clear state for eras older than HistoryDepth by using the fn map.remove_prefix which is deprecated. Use map.clear_prefix that can be paged.

This is how we clear old era information today

/// Clear all era information for given era.
	pub(crate) fn clear_era_information(era_index: EraIndex) {
		#[allow(deprecated)]
		<ErasStakers<T>>::remove_prefix(era_index, None);
		#[allow(deprecated)]
		<ErasStakersClipped<T>>::remove_prefix(era_index, None);
		#[allow(deprecated)]
		<ErasValidatorPrefs<T>>::remove_prefix(era_index, None);
		#[allow(deprecated)]
		<ClaimedRewards<T>>::remove_prefix(era_index, None);
		#[allow(deprecated)]
		<ErasStakersPaged<T>>::remove_prefix((era_index,), None);
		#[allow(deprecated)]
		<ErasStakersOverview<T>>::remove_prefix(era_index, None);

		<ErasValidatorReward<T>>::remove(era_index);
		<ErasRewardPoints<T>>::remove(era_index);
		<ErasTotalStake<T>>::remove(era_index);
		ErasStartSessionIndex::<T>::remove(era_index);
	}
	

Ank4n avatar Feb 22 '23 15:02 Ank4n

Can I handle this task?

gflow33 avatar Mar 07 '23 21:03 gflow33