diff --git a/substrate/frame/assets/src/migration/v1.rs b/substrate/frame/assets/src/migration/v1.rs index e32e3787b5360..7b8cc83b54cf5 100644 --- a/substrate/frame/assets/src/migration/v1.rs +++ b/substrate/frame/assets/src/migration/v1.rs @@ -101,9 +101,8 @@ pub(crate) struct AssetDetails { pub struct MigrateToV1(sp_std::marker::PhantomData<(T, I)>); impl, I: 'static> OnRuntimeUpgrade for MigrateToV1 { 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; Asset::::translate::< old::AssetDetails>, @@ -112,14 +111,15 @@ impl, I: 'static> OnRuntimeUpgrade for MigrateToV1 { translated.saturating_inc(); Some(old_value.migrate_to_v1()) }); - current_version.put::>(); + StorageVersion::new(1).put::>(); log::info!( target: LOG_TARGET, - "Upgraded {} pools, storage to version {:?}", + "Upgraded {} pools, storage to version 1", translated, - current_version ); - T::DbWeight::get().reads_writes(translated + 1, translated + 1) + translated.saturating_inc(); + + T::DbWeight::get().reads_writes(translated, translated) } else { log::info!( target: LOG_TARGET, @@ -149,13 +149,11 @@ impl, I: 'static> OnRuntimeUpgrade for MigrateToV1 { "the asset count before and after the migration should be the same" ); - let current_version = Pallet::::current_storage_version(); let onchain_version = Pallet::::on_chain_storage_version(); - frame_support::ensure!(current_version == 1, "must_upgrade"); - ensure!( - current_version == onchain_version, - "after migration, the current_version and onchain_version should be the same" + frame_support::ensure!( + onchain_version == 1, + "on chain storage version for assets should be 1 after migration" ); Asset::::iter().try_for_each(|(_id, asset)| -> Result<(), TryRuntimeError> {