Skip to content

Commit

Permalink
Improve VersionedMigration naming conventions (#2264)
Browse files Browse the repository at this point in the history
As suggested by @ggwpez
(#2142 (comment)),
remove the `VersionChecked` prefix from version checked migrations (but
leave `VersionUnchecked` prefixes)

---------

Co-authored-by: command-bot <>
  • Loading branch information
liamaharon authored Nov 10, 2023
1 parent 3f0383a commit 84ddbaf
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 30 deletions.
10 changes: 5 additions & 5 deletions polkadot/runtime/common/src/assigned_slots/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use sp_std::vec::Vec;
pub mod v1 {

use super::*;
pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
pub struct VersionUncheckedMigrateToV1<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for VersionUncheckedMigrateToV1<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
let onchain_version = Pallet::<T>::on_chain_storage_version();
Expand Down Expand Up @@ -60,13 +60,13 @@ pub mod v1 {
}
}

/// [`MigrateToV1`] wrapped in a
/// [`VersionUncheckedMigrateToV1`] wrapped in a
/// [`VersionedMigration`](frame_support::migrations::VersionedMigration), ensuring the
/// migration is only performed when on-chain version is 0.
pub type VersionCheckedMigrateToV1<T> = frame_support::migrations::VersionedMigration<
pub type MigrateToV1<T> = frame_support::migrations::VersionedMigration<
0,
1,
MigrateToV1<T>,
VersionUncheckedMigrateToV1<T>,
Pallet<T>,
<T as frame_system::Config>::DbWeight,
>;
Expand Down
15 changes: 7 additions & 8 deletions polkadot/runtime/common/src/paras_registrar/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ impl<T: Config, UnlockParaIds: Contains<ParaId>> OnRuntimeUpgrade
}
}

pub type VersionCheckedMigrateToV1<T, UnlockParaIds> =
frame_support::migrations::VersionedMigration<
0,
1,
VersionUncheckedMigrateToV1<T, UnlockParaIds>,
super::Pallet<T>,
<T as frame_system::Config>::DbWeight,
>;
pub type MigrateToV1<T, UnlockParaIds> = frame_support::migrations::VersionedMigration<
0,
1,
VersionUncheckedMigrateToV1<T, UnlockParaIds>,
super::Pallet<T>,
<T as frame_system::Config>::DbWeight,
>;
6 changes: 3 additions & 3 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,14 +1472,14 @@ pub mod migrations {

/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
pallet_society::migrations::VersionCheckedMigrateToV2<Runtime, (), ()>,
pallet_society::migrations::MigrateToV2<Runtime, (), ()>,
pallet_im_online::migration::v1::Migration<Runtime>,
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
assigned_slots::migration::v1::VersionCheckedMigrateToV1<Runtime>,
assigned_slots::migration::v1::MigrateToV1<Runtime>,
parachains_scheduler::migration::v1::MigrateToV1<Runtime>,
parachains_configuration::migration::v8::MigrateToV8<Runtime>,
parachains_configuration::migration::v9::MigrateToV9<Runtime>,
paras_registrar::migration::VersionCheckedMigrateToV1<Runtime, ()>,
paras_registrar::migration::MigrateToV1<Runtime, ()>,
pallet_referenda::migration::v1::MigrateV0ToV1<Runtime, ()>,
pallet_referenda::migration::v1::MigrateV0ToV1<Runtime, pallet_referenda::Instance2>,

Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,12 +1549,12 @@ pub mod migrations {
pallet_im_online::migration::v1::Migration<Runtime>,
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
pallet_staking::migrations::v14::MigrateToV14<Runtime>,
assigned_slots::migration::v1::VersionCheckedMigrateToV1<Runtime>,
assigned_slots::migration::v1::MigrateToV1<Runtime>,
parachains_scheduler::migration::v1::MigrateToV1<Runtime>,
parachains_configuration::migration::v8::MigrateToV8<Runtime>,
UpgradeSessionKeys,
parachains_configuration::migration::v9::MigrateToV9<Runtime>,
paras_registrar::migration::VersionCheckedMigrateToV1<Runtime, ()>,
paras_registrar::migration::MigrateToV1<Runtime, ()>,
pallet_nomination_pools::migration::versioned_migrations::V5toV6<Runtime>,
pallet_referenda::migration::v1::MigrateV0ToV1<Runtime, ()>,
pallet_nomination_pools::migration::versioned_migrations::V6ToV7<Runtime>,
Expand Down
4 changes: 2 additions & 2 deletions polkadot/xcm/pallet-xcm/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub mod v1 {
/// checking, the version checking is not complete as it will begin failing after the upgrade is
/// enacted on-chain.
///
/// Use experimental [`VersionCheckedMigrateToV1`] instead.
/// Use experimental [`MigrateToV1`] instead.
pub struct VersionUncheckedMigrateToV1<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for VersionUncheckedMigrateToV1<T> {
fn on_runtime_upgrade() -> Weight {
Expand Down Expand Up @@ -65,7 +65,7 @@ pub mod v1 {
///
/// Wrapped in [`frame_support::migrations::VersionedMigration`] so the pre/post checks don't
/// begin failing after the upgrade is enacted on-chain.
pub type VersionCheckedMigrateToV1<T> = frame_support::migrations::VersionedMigration<
pub type MigrateToV1<T> = frame_support::migrations::VersionedMigration<
0,
1,
VersionUncheckedMigrateToV1<T>,
Expand Down
15 changes: 7 additions & 8 deletions substrate/frame/society/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,13 @@ impl<

/// [`VersionUncheckedMigrateToV2`] wrapped in a [`frame_support::migrations::VersionedMigration`],
/// ensuring the migration is only performed when on-chain version is 0.
pub type VersionCheckedMigrateToV2<T, I, PastPayouts> =
frame_support::migrations::VersionedMigration<
0,
2,
VersionUncheckedMigrateToV2<T, I, PastPayouts>,
crate::pallet::Pallet<T, I>,
<T as frame_system::Config>::DbWeight,
>;
pub type MigrateToV2<T, I, PastPayouts> = frame_support::migrations::VersionedMigration<
0,
2,
VersionUncheckedMigrateToV2<T, I, PastPayouts>,
crate::pallet::Pallet<T, I>,
<T as frame_system::Config>::DbWeight,
>;

pub(crate) mod old {
use super::*;
Expand Down
4 changes: 2 additions & 2 deletions substrate/frame/support/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use sp_std::marker::PhantomData;
/// // OnRuntimeUpgrade implementation...
/// }
///
/// pub type VersionCheckedMigrateV5ToV6<T, I> =
/// pub type MigrateV5ToV6<T, I> =
/// VersionedMigration<
/// 5,
/// 6,
Expand All @@ -63,7 +63,7 @@ use sp_std::marker::PhantomData;
/// // Migrations tuple to pass to the Executive pallet:
/// pub type Migrations = (
/// // other migrations...
/// VersionCheckedMigrateV5ToV6<T, ()>,
/// MigrateV5ToV6<T, ()>,
/// // other migrations...
/// );
/// ```
Expand Down

0 comments on commit 84ddbaf

Please sign in to comment.