diff --git a/runtime/common/src/crowdloan/migration.rs b/runtime/common/src/crowdloan/migration.rs index 2d80ff878c4a..468c2a572b51 100644 --- a/runtime/common/src/crowdloan/migration.rs +++ b/runtime/common/src/crowdloan/migration.rs @@ -16,24 +16,27 @@ use super::*; use frame_support::{ - dispatch::GetStorageVersion, storage_alias, traits::OnRuntimeUpgrade, Twox64Concat, + dispatch::GetStorageVersion, + storage_alias, + traits::{OnRuntimeUpgrade, StorageVersion}, + Twox64Concat, }; pub struct MigrateToTrackInactive(sp_std::marker::PhantomData); impl OnRuntimeUpgrade for MigrateToTrackInactive { fn on_runtime_upgrade() -> Weight { - let current_version = Pallet::::current_storage_version(); let onchain_version = Pallet::::on_chain_storage_version(); - if onchain_version == 0 && current_version == 1 { + if onchain_version == 0 { let mut translated = 0u64; for index in Funds::::iter_keys() { let b = CurrencyOf::::total_balance(&Pallet::::fund_account_id(index.into())); CurrencyOf::::deactivate(b); translated.saturating_inc(); } - current_version.put::>(); - log::info!(target: "runtime::crowdloan", "Summed {} funds, storage to version {:?}", translated, current_version); + + StorageVersion::new(1).put::>(); + log::info!(target: "runtime::crowdloan", "Summed {} funds, storage to version 1", translated); T::DbWeight::get().reads_writes(translated * 2 + 1, translated * 2 + 1) } else { log::info!(target: "runtime::crowdloan", "Migration did not execute. This probably should be removed"); diff --git a/runtime/common/src/crowdloan/mod.rs b/runtime/common/src/crowdloan/mod.rs index cedcb464775c..224f06c0d6e4 100644 --- a/runtime/common/src/crowdloan/mod.rs +++ b/runtime/common/src/crowdloan/mod.rs @@ -184,9 +184,13 @@ pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::{ensure_root, ensure_signed, pallet_prelude::*}; + /// The current storage version. + const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] #[pallet::without_storage_info] + #[pallet::storage_version(STORAGE_VERSION)] pub struct Pallet(_); #[pallet::config]