Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

fix migrations (also companion for #14421) #7454

Merged
merged 17 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
377 changes: 188 additions & 189 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion runtime/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pallet-recovery = { git = "https://github.com/paritytech/substrate", branch = "m
pallet-referenda = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["experimental"] }
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-state-trie-migration = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down
6 changes: 5 additions & 1 deletion runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,11 @@ pub mod migrations {
/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
init_state_migration::InitMigrate,
pallet_society::migrations::MigrateToV2<Runtime, (), past_payouts::PastPayouts>,
pallet_society::migrations::VersionCheckedMigrateToV2<
Runtime,
(),
past_payouts::PastPayouts,
>,
pallet_im_online::migration::v1::Migration<Runtime>,
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
);
Expand Down
2 changes: 1 addition & 1 deletion runtime/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pallet-whitelist = { git = "https://github.com/paritytech/substrate", branch = "
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-election-provider-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false }
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false, features=["experimental"] }

frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ pub mod migrations {
use frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade, StorageVersion};

pub type V0938 = (
pallet_xcm::migration::v1::MigrateToV1<Runtime>,
pallet_xcm::migration::v1::VersionCheckedMigrateToV1<Runtime>,
// The UMP pallet got deleted in <https://github.com/paritytech/polkadot/pull/6271>
// parachains_ump::migration::v1::MigrateToV1<Runtime>,
);
Expand Down
4 changes: 2 additions & 2 deletions runtime/rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "mast
pallet-recovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["experimental"] }
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand All @@ -74,7 +74,7 @@ pallet-tips = { git = "https://github.com/paritytech/substrate", branch = "maste
pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false }
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false, features=["experimental"] }
pallet-xcm-benchmarks = { path = "../../xcm/pallet-xcm-benchmarks", default-features = false, optional = true }

frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
Expand Down
2 changes: 1 addition & 1 deletion runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ pub mod migrations {

/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
pallet_society::migrations::MigrateToV2<Runtime, (), ()>,
pallet_society::migrations::VersionCheckedMigrateToV2<Runtime, (), ()>,
pallet_im_online::migration::v1::Migration<Runtime>,
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
);
Expand Down
2 changes: 1 addition & 1 deletion runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/sub
pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false }
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false, features=["experimental"] }
pallet-xcm-benchmarks = { path = "../../xcm/pallet-xcm-benchmarks", default-features = false, optional = true }

frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
Expand Down
4 changes: 4 additions & 0 deletions xcm/pallet-xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ xcm-builder = { path = "../xcm-builder" }

[features]
default = ["std"]
# Enable `VersionedRuntimeUpgrade` for the migrations that is currently still experimental.
experimental = [
"frame-support/experimental"
]
std = [
"bounded-collections/std",
"codec/std",
Expand Down
22 changes: 20 additions & 2 deletions xcm/pallet-xcm/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@ const DEFAULT_PROOF_SIZE: u64 = 64 * 1024;
pub mod v1 {
use super::*;

pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
/// Named with the 'VersionUnchecked'-prefix because although this implements some version
/// checking, the version checking is not complete as it will begin failing after the upgrade is
/// enacted on-chain.
///
/// Use experimental [`VersionCheckedMigrateToV1`] instead.
pub struct VersionUncheckedMigrateToV1<T>(sp_std::marker::PhantomData<T>);
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
impl<T: Config> OnRuntimeUpgrade for VersionUncheckedMigrateToV1<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, sp_runtime::TryRuntimeError> {
ensure!(StorageVersion::get::<Pallet<T>>() == 0, "must upgrade linearly");
Expand Down Expand Up @@ -58,4 +63,17 @@ pub mod v1 {
}
}
}

/// Version checked migration to v1.
///
/// Wrapped in VersionedRuntimeUpgrade so the pre/post checks don't begin failing after the
/// upgrade is enacted on-chain.
#[cfg(feature = "experimental")]
pub type VersionCheckedMigrateToV1<T> = frame_support::migrations::VersionedRuntimeUpgrade<
0,
1,
VersionUncheckedMigrateToV1<T>,
crate::pallet::Pallet<T>,
<T as frame_system::Config>::DbWeight,
>;
}