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

Commit 9361e82

Browse files
authored
fix migrations (also companion for #14421) (#7454)
* fix migrations * use society versioned runtime upgrade * simplify usage of versionedruntimeupgrade * use society experimental feature * improve usage of experimental flag * doc comment * Merge branch 'master' of github.com:paritytech/polkadot into liam-fix-migrations * Revert "Merge branch 'master' of github.com:paritytech/polkadot into liam-fix-migrations" This reverts commit 41ab062. * doc comment * westend experimental feature * Revert "westend experimental feature" This reverts commit 42f4f1b. * feature gate experimental xcm migration * update lockfile for {"substrate"} --------- Co-authored-by: parity-processbot <>
1 parent 32edc76 commit 9361e82

File tree

10 files changed

+224
-199
lines changed

10 files changed

+224
-199
lines changed

Cargo.lock

Lines changed: 188 additions & 189 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime/kusama/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pallet-recovery = { git = "https://github.com/paritytech/substrate", branch = "m
7070
pallet-referenda = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
7171
pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
7272
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
73-
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
73+
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["experimental"] }
7474
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
7575
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
7676
pallet-state-trie-migration = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }

runtime/kusama/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,11 @@ pub mod migrations {
15601560
/// Unreleased migrations. Add new ones here:
15611561
pub type Unreleased = (
15621562
init_state_migration::InitMigrate,
1563-
pallet_society::migrations::MigrateToV2<Runtime, (), past_payouts::PastPayouts>,
1563+
pallet_society::migrations::VersionCheckedMigrateToV2<
1564+
Runtime,
1565+
(),
1566+
past_payouts::PastPayouts,
1567+
>,
15641568
pallet_im_online::migration::v1::Migration<Runtime>,
15651569
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
15661570
);

runtime/polkadot/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pallet-whitelist = { git = "https://github.com/paritytech/substrate", branch = "
8080
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
8181
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
8282
frame-election-provider-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
83-
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false }
83+
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false, features=["experimental"] }
8484

8585
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
8686
frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }

runtime/polkadot/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ pub mod migrations {
14991499
use frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade, StorageVersion};
15001500

15011501
pub type V0938 = (
1502-
pallet_xcm::migration::v1::MigrateToV1<Runtime>,
1502+
pallet_xcm::migration::v1::VersionCheckedMigrateToV1<Runtime>,
15031503
// The UMP pallet got deleted in <https://github.com/paritytech/polkadot/pull/6271>
15041504
// parachains_ump::migration::v1::MigrateToV1<Runtime>,
15051505
);

runtime/rococo/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pallet-proxy = { git = "https://github.com/paritytech/substrate", branch = "mast
6363
pallet-recovery = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
6464
pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
6565
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
66-
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
66+
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["experimental"] }
6767
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
6868
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
6969
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -74,7 +74,7 @@ pallet-tips = { git = "https://github.com/paritytech/substrate", branch = "maste
7474
pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
7575
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
7676
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
77-
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false }
77+
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false, features=["experimental"] }
7878
pallet-xcm-benchmarks = { path = "../../xcm/pallet-xcm-benchmarks", default-features = false, optional = true }
7979

8080
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }

runtime/rococo/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ pub mod migrations {
16251625

16261626
/// Unreleased migrations. Add new ones here:
16271627
pub type Unreleased = (
1628-
pallet_society::migrations::MigrateToV2<Runtime, (), ()>,
1628+
pallet_society::migrations::VersionCheckedMigrateToV2<Runtime, (), ()>,
16291629
pallet_im_online::migration::v1::Migration<Runtime>,
16301630
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
16311631
);

runtime/westend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pallet-nomination-pools-runtime-api = { git = "https://github.com/paritytech/sub
7676
pallet-treasury = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
7777
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
7878
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
79-
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false }
79+
pallet-xcm = { path = "../../xcm/pallet-xcm", default-features = false, features=["experimental"] }
8080
pallet-xcm-benchmarks = { path = "../../xcm/pallet-xcm-benchmarks", default-features = false, optional = true }
8181

8282
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }

xcm/pallet-xcm/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ xcm-builder = { path = "../xcm-builder" }
3131

3232
[features]
3333
default = ["std"]
34+
# Enable `VersionedRuntimeUpgrade` for the migrations that is currently still experimental.
35+
experimental = [
36+
"frame-support/experimental"
37+
]
3438
std = [
3539
"bounded-collections/std",
3640
"codec/std",

xcm/pallet-xcm/src/migration.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ const DEFAULT_PROOF_SIZE: u64 = 64 * 1024;
2626
pub mod v1 {
2727
use super::*;
2828

29-
pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>);
30-
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
29+
/// Named with the 'VersionUnchecked'-prefix because although this implements some version
30+
/// checking, the version checking is not complete as it will begin failing after the upgrade is
31+
/// enacted on-chain.
32+
///
33+
/// Use experimental [`VersionCheckedMigrateToV1`] instead.
34+
pub struct VersionUncheckedMigrateToV1<T>(sp_std::marker::PhantomData<T>);
35+
impl<T: Config> OnRuntimeUpgrade for VersionUncheckedMigrateToV1<T> {
3136
#[cfg(feature = "try-runtime")]
3237
fn pre_upgrade() -> Result<sp_std::vec::Vec<u8>, sp_runtime::TryRuntimeError> {
3338
ensure!(StorageVersion::get::<Pallet<T>>() == 0, "must upgrade linearly");
@@ -58,4 +63,17 @@ pub mod v1 {
5863
}
5964
}
6065
}
66+
67+
/// Version checked migration to v1.
68+
///
69+
/// Wrapped in VersionedRuntimeUpgrade so the pre/post checks don't begin failing after the
70+
/// upgrade is enacted on-chain.
71+
#[cfg(feature = "experimental")]
72+
pub type VersionCheckedMigrateToV1<T> = frame_support::migrations::VersionedRuntimeUpgrade<
73+
0,
74+
1,
75+
VersionUncheckedMigrateToV1<T>,
76+
crate::pallet::Pallet<T>,
77+
<T as frame_system::Config>::DbWeight,
78+
>;
6179
}

0 commit comments

Comments
 (0)