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 41ab0621811ead11b0a7f91338b0895208feef77.

* doc comment

* westend experimental feature

* Revert "westend experimental feature"

This reverts commit 42f4f1b76655ef509a92c324d18d635a1b913dcb.

* feature gate experimental xcm migration

* update lockfile for {"substrate"}

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Liam Aharon
2023-07-13 20:39:01 +10:00
committed by GitHub
parent 95ba849ee6
commit bfaec080cc
10 changed files with 224 additions and 199 deletions
+188 -189
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -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"] }
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 }
+5 -1
View File
@@ -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>,
);
+1 -1
View File
@@ -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 }
+1 -1
View File
@@ -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>,
);
+2 -2
View File
@@ -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 }
@@ -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 }
+1 -1
View File
@@ -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>,
);
+1 -1
View File
@@ -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 }
+4
View File
@@ -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",
+20 -2
View File
@@ -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>);
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");
@@ -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,
>;
}