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
+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,
>;
}