diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index de0ec1a5489a8..7ba9e288f63dc 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -50,7 +50,7 @@ sp-io = { version = "23.0.0", default-features = false, path = "../../../primiti frame-executive = { version = "4.0.0-dev", default-features = false, path = "../../../frame/executive" } frame-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/benchmarking" } frame-benchmarking-pallet-pov = { version = "4.0.0-dev", default-features = false, path = "../../../frame/benchmarking/pov" } -frame-support = { version = "4.0.0-dev", default-features = false, path = "../../../frame/support", features = ["tuples-96"] } +frame-support = { version = "4.0.0-dev", default-features = false, path = "../../../frame/support", features = ["tuples-96", "experimental"] } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../frame/system" } frame-system-benchmarking = { version = "4.0.0-dev", default-features = false, path = "../../../frame/system/benchmarking", optional = true } frame-election-provider-support = { version = "4.0.0-dev", default-features = false, path = "../../../frame/election-provider-support" } diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 4e1b6d4e8bec0..65ff0bb970c49 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -48,6 +48,7 @@ use frame_support::{ ConstantMultiplier, IdentityFee, Weight, }, BoundedVec, PalletId, RuntimeDebug, + migrations::VersionedRuntimeUpgrade }; use frame_system::{ limits::{BlockLength, BlockWeights}, @@ -1995,12 +1996,19 @@ pub type Executive = frame_executive::Executive< Migrations, >; +pub type VersionCheckedMigrateV1ToV2 = + VersionedRuntimeUpgrade< + 1, + 2, + pallet_nomination_pools::migration::v2::VersionUncheckedMigrateV1ToV2, + pallet_nomination_pools::Pallet, + ::DbWeight + >; + // All migrations executed on runtime upgrade as a nested tuple of types implementing // `OnRuntimeUpgrade`. type Migrations = ( - pallet_nomination_pools::migration::v2::MigrateToV2, - pallet_alliance::migration::Migration, - pallet_contracts::Migration, + VersionCheckedMigrateV1ToV2, ); type EventRecord = frame_system::EventRecord< diff --git a/frame/nomination-pools/src/migration.rs b/frame/nomination-pools/src/migration.rs index 2ae4cd1b86857..c411b59ee0962 100644 --- a/frame/nomination-pools/src/migration.rs +++ b/frame/nomination-pools/src/migration.rs @@ -194,8 +194,8 @@ pub mod v2 { /// Migrate the pool reward scheme to the new version, as per /// . - pub struct MigrateToV2(sp_std::marker::PhantomData); - impl MigrateToV2 { + pub struct VersionUncheckedMigrateV1ToV2(sp_std::marker::PhantomData); + impl VersionUncheckedMigrateV1ToV2 { fn run(current: StorageVersion) -> Weight { let mut reward_pools_translated = 0u64; let mut members_translated = 0u64; @@ -337,24 +337,10 @@ pub mod v2 { } } - impl OnRuntimeUpgrade for MigrateToV2 { + impl OnRuntimeUpgrade for VersionUncheckedMigrateV1ToV2 { fn on_runtime_upgrade() -> Weight { let current = Pallet::::current_storage_version(); - let onchain = Pallet::::on_chain_storage_version(); - - log!( - info, - "Running migration with current storage version {:?} / onchain {:?}", - current, - onchain - ); - - if current == 2 && onchain == 1 { - Self::run(current) - } else { - log!(info, "MigrateToV2 did not executed. This probably should be removed"); - T::DbWeight::get().reads(1) - } + Self::run(current) } #[cfg(feature = "try-runtime")] @@ -400,7 +386,7 @@ pub mod v2 { Ok(()) })?; - log!(info, "post upgrade hook for MigrateToV2 executed."); + log!(info, "post upgrade hook for VersionUncheckedMigrateV1ToV2 executed."); Ok(()) } }