From 0c9c8356d8b13985671d8b83c1ea436f5d4e5a2d Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Wed, 14 Aug 2024 08:52:00 +0300 Subject: [PATCH] all runtimes: remove already applied migrations (#420) Remove migrations already **applied on-chain**. - [x] Does not require a CHANGELOG entry --------- Signed-off-by: Adrian Catangiu Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- Cargo.lock | 21 --- Cargo.toml | 1 - .../asset-hubs/asset-hub-kusama/Cargo.toml | 4 - .../asset-hubs/asset-hub-kusama/src/lib.rs | 7 +- .../asset-hubs/asset-hub-polkadot/src/lib.rs | 9 +- .../bridge-hubs/bridge-hub-kusama/Cargo.toml | 4 - .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 7 +- .../bridge-hub-polkadot/src/lib.rs | 15 +- .../collectives-polkadot/src/lib.rs | 9 +- .../coretime/coretime-kusama/src/lib.rs | 5 +- system-parachains/encointer/src/lib.rs | 8 +- .../encointer/src/migrations_fix.rs | 171 ------------------ .../people/people-kusama/src/lib.rs | 10 +- .../people/people-polkadot/src/lib.rs | 1 + 14 files changed, 11 insertions(+), 261 deletions(-) delete mode 100644 system-parachains/encointer/src/migrations_fix.rs diff --git a/Cargo.lock b/Cargo.lock index caa004cff0..957509ac98 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -628,7 +628,6 @@ dependencies = [ "bp-bridge-hub-kusama", "bp-bridge-hub-polkadot", "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", "cumulus-pallet-session-benchmarking", "cumulus-pallet-xcm", @@ -1746,7 +1745,6 @@ dependencies = [ "bridge-hub-test-utils", "bridge-runtime-common", "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", "cumulus-pallet-session-benchmarking", "cumulus-pallet-xcm", @@ -3090,25 +3088,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "cumulus-pallet-dmp-queue" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7926abe4b165565b8c86a3525ac98e3a962761d05c201c53012460b237ad5887" -dependencies = [ - "cumulus-primitives-core", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-io 37.0.0", - "sp-runtime 38.0.0", - "sp-std", - "staging-xcm", -] - [[package]] name = "cumulus-pallet-parachain-system" version = "0.15.0" diff --git a/Cargo.toml b/Cargo.toml index 7939bfd8c1..ac26a8686d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,6 @@ coretime-kusama-runtime = { path = "system-parachains/coretime/coretime-kusama" coretime-polkadot-emulated-chain = { path = "integration-tests/emulated/chains/parachains/coretime/coretime-polkadot" } coretime-polkadot-runtime = { path = "system-parachains/coretime/coretime-polkadot" } cumulus-pallet-aura-ext = { version = "0.15.0", default-features = false } -cumulus-pallet-dmp-queue = { version = "0.15.0", default-features = false } cumulus-pallet-parachain-system = { version = "0.15.0", default-features = false } cumulus-pallet-session-benchmarking = { version = "17.0.0", default-features = false } cumulus-pallet-xcm = { version = "0.15.0", default-features = false } diff --git a/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml b/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml index 510662d905..637720d361 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml +++ b/system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml @@ -86,7 +86,6 @@ xcm-runtime-apis = { workspace = true } # Cumulus cumulus-pallet-aura-ext = { workspace = true } -cumulus-pallet-dmp-queue = { workspace = true } cumulus-pallet-parachain-system = { workspace = true } cumulus-pallet-session-benchmarking = { workspace = true } cumulus-pallet-xcm = { workspace = true } @@ -124,7 +123,6 @@ default = ["std"] state-trie-version-1 = ["pallet-state-trie-migration"] runtime-benchmarks = [ "assets-common/runtime-benchmarks", - "cumulus-pallet-dmp-queue/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", @@ -162,7 +160,6 @@ runtime-benchmarks = [ ] try-runtime = [ "cumulus-pallet-aura-ext/try-runtime", - "cumulus-pallet-dmp-queue/try-runtime", "cumulus-pallet-parachain-system/try-runtime", "cumulus-pallet-xcm/try-runtime", "cumulus-pallet-xcmp-queue/try-runtime", @@ -203,7 +200,6 @@ std = [ "bp-bridge-hub-polkadot/std", "codec/std", "cumulus-pallet-aura-ext/std", - "cumulus-pallet-dmp-queue/std", "cumulus-pallet-parachain-system/std", "cumulus-pallet-session-benchmarking/std", "cumulus-pallet-xcm/std", diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs index 48ee7c5d85..43aa145858 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs @@ -1049,14 +1049,9 @@ pub type SignedExtra = ( pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -parameter_types! { - pub DmpQueueName: &'static str = "DmpQueue"; -} - /// Migrations to apply on runtime upgrade. pub type Migrations = ( - frame_support::migrations::RemovePallet, - pallet_collator_selection::migration::v2::MigrationToV2, + // unreleased and/or un-applied cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, pallet_assets::migration::next_asset_id::SetNextAssetId< ConstU32<50_000_000>, diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs index cc54fa8be0..73fb67cd59 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs @@ -1029,16 +1029,9 @@ pub type SignedExtra = ( pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -parameter_types! { - pub DmpQueueName: &'static str = "DmpQueue"; -} - /// Migrations to apply on runtime upgrade. pub type Migrations = ( - // unreleased - frame_support::migrations::RemovePallet, - cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, - pallet_collator_selection::migration::v2::MigrationToV2, + // unreleased and/or un-applied cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, pallet_assets::migration::next_asset_id::SetNextAssetId< ConstU32<50_000_000>, diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml b/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml index c5fd0a09e2..d4140280da 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml @@ -75,7 +75,6 @@ xcm-runtime-apis = { workspace = true } # Cumulus cumulus-pallet-aura-ext = { workspace = true } -cumulus-pallet-dmp-queue = { workspace = true } cumulus-pallet-parachain-system = { workspace = true } cumulus-pallet-session-benchmarking = { workspace = true } cumulus-pallet-xcm = { workspace = true } @@ -146,7 +145,6 @@ std = [ "bridge-runtime-common/std", "codec/std", "cumulus-pallet-aura-ext/std", - "cumulus-pallet-dmp-queue/std", "cumulus-pallet-parachain-system/std", "cumulus-pallet-session-benchmarking/std", "cumulus-pallet-xcm/std", @@ -227,7 +225,6 @@ std = [ runtime-benchmarks = [ "bridge-hub-common/runtime-benchmarks", "bridge-runtime-common/runtime-benchmarks", - "cumulus-pallet-dmp-queue/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-session-benchmarking/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", @@ -269,7 +266,6 @@ runtime-benchmarks = [ try-runtime = [ "cumulus-pallet-aura-ext/try-runtime", - "cumulus-pallet-dmp-queue/try-runtime", "cumulus-pallet-parachain-system/try-runtime", "cumulus-pallet-xcm/try-runtime", "cumulus-pallet-xcmp-queue/try-runtime", diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs index 77370cf3c5..b486b8541a 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -139,14 +139,9 @@ bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! { pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -parameter_types! { - pub DmpQueueName: &'static str = "DmpQueue"; -} - /// Migrations to apply on runtime upgrade. pub type Migrations = ( - frame_support::migrations::RemovePallet, - pallet_collator_selection::migration::v2::MigrationToV2, + // unreleased and/or un-applied cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, // permanent pallet_xcm::migration::MigrateToLatestXcmVersion, diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 8117d564a2..6ebb56f5a5 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -81,7 +81,6 @@ pub use sp_runtime::BuildStorage; // Polkadot imports use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; -use polkadot_runtime_constants::system_parachain::{ASSET_HUB_ID, BRIDGE_HUB_ID}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; @@ -141,21 +140,9 @@ bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! { pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -parameter_types! { - pub DmpQueueName: &'static str = "DmpQueue"; -} - /// Migrations to apply on runtime upgrade. pub type Migrations = ( - // unreleased - frame_support::migrations::RemovePallet, - cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, - snowbridge_pallet_system::migration::v0::InitializeOnUpgrade< - Runtime, - ConstU32, - ConstU32, - >, - pallet_collator_selection::migration::v2::MigrationToV2, + // unreleased and/or un-applied cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, // permanent pallet_xcm::migration::MigrateToLatestXcmVersion, diff --git a/system-parachains/collectives/collectives-polkadot/src/lib.rs b/system-parachains/collectives/collectives-polkadot/src/lib.rs index 66325dea50..8df3f396c0 100644 --- a/system-parachains/collectives/collectives-polkadot/src/lib.rs +++ b/system-parachains/collectives/collectives-polkadot/src/lib.rs @@ -749,17 +749,10 @@ pub type SignedExtra = ( pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -parameter_types! { - pub DmpQueueName: &'static str = "DmpQueue"; -} - /// All migrations executed on runtime upgrade as a nested tuple of types implementing /// `OnRuntimeUpgrade`. Included migrations must be idempotent. type Migrations = ( - // unreleased - frame_support::migrations::RemovePallet, - cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, - pallet_collator_selection::migration::v2::MigrationToV2, + // unreleased and/or un-applied cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, pallet_core_fellowship::migration::MigrateV0ToV1, pallet_core_fellowship::migration::MigrateV0ToV1, diff --git a/system-parachains/coretime/coretime-kusama/src/lib.rs b/system-parachains/coretime/coretime-kusama/src/lib.rs index 95324c4ce3..4b6a296024 100644 --- a/system-parachains/coretime/coretime-kusama/src/lib.rs +++ b/system-parachains/coretime/coretime-kusama/src/lib.rs @@ -115,12 +115,13 @@ pub type UncheckedExtrinsic = /// Migrations to apply on runtime upgrade. pub type Migrations = ( - pallet_xcm::migration::MigrateToLatestXcmVersion, - pallet_collator_selection::migration::v2::MigrationToV2, + // unreleased and/or un-applied cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, pallet_broker::migration::MigrateV0ToV1, pallet_broker::migration::MigrateV1ToV2, pallet_broker::migration::MigrateV2ToV3, + // permanent + pallet_xcm::migration::MigrateToLatestXcmVersion, ); /// Executive: handles dispatch to the various modules. diff --git a/system-parachains/encointer/src/lib.rs b/system-parachains/encointer/src/lib.rs index f660ffe6cc..e4827dddae 100644 --- a/system-parachains/encointer/src/lib.rs +++ b/system-parachains/encointer/src/lib.rs @@ -33,7 +33,6 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); // Genesis preset configurations. pub mod genesis_config_presets; -mod migrations_fix; mod weights; pub mod xcm_config; @@ -754,14 +753,9 @@ pub type UncheckedExtrinsic = /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; -parameter_types! { - pub DmpQueueName: &'static str = "DmpQueue"; -} - /// Migrations to apply on runtime upgrade. pub type Migrations = ( - frame_support::migrations::RemovePallet, - migrations_fix::collator_selection_init::v0::InitInvulnerables, + // unreleased and/or un-applied cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, // permanent pallet_xcm::migration::MigrateToLatestXcmVersion, diff --git a/system-parachains/encointer/src/migrations_fix.rs b/system-parachains/encointer/src/migrations_fix.rs deleted file mode 100644 index 472fbd5852..0000000000 --- a/system-parachains/encointer/src/migrations_fix.rs +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) 2023 Encointer Association -// This file is part of Encointer -// -// Encointer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Encointer is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Encointer. If not, see . - -// the following are temporary local migration fixes to solve inconsistencies caused by not -// migrating Storage at the time of migrating runtime code - -pub mod collator_selection_init { - use frame_support::traits::OnRuntimeUpgrade; - #[cfg(feature = "try-runtime")] - use sp_runtime::TryRuntimeError; - - /// The log target. - const TARGET: &str = "runtime::fix::collator_selection_init"; - pub mod v0 { - use super::*; - use crate::SessionKeys; - use codec::EncodeLike; - use frame_support::{pallet_prelude::*, traits::Currency}; - use hex_literal::hex; - use log::info; - use parachains_common::impls::BalanceOf; - use sp_core::{crypto::key_types::AURA, sr25519}; - use sp_std::{vec, vec::Vec}; - - const INVULNERABLE_AURA_A: [u8; 32] = - hex!("5e962096da68302d5c47fce0178d72fab503c4f00a3f1df64856748f0d9dd51e"); - const INVULNERABLE_AURA_B: [u8; 32] = - hex!("0cecb8d1c2c744ca4c5cea57f5d6c40238f4dad17afa213672b8b7d43b80a659"); - const INVULNERABLE_AURA_C: [u8; 32] = - hex!("ca1951a3c4e100fb5a899e7bae3ea124491930a72000c5e4b2775fea27ecf05d"); - const INVULNERABLE_AURA_D: [u8; 32] = - hex!("484b443bd95068b860c92b0f66487b78f58234eca0f88e2adbe80bae4807b809"); - const INVULNERABLE_AURA_E: [u8; 32] = - hex!("6c642fb4b571a5685a869cd291fafd575be47a918b231ba28165e5c0cd0cfa15"); - - const INVULNERABLE_ACCOUNT_A: [u8; 32] = - hex!("920534bf448645557bae98bc7f681bd3ebed13d39bee28e10b193d4073357572"); - const INVULNERABLE_ACCOUNT_B: [u8; 32] = - hex!("76bff5abc7a4fce647fab172c9f016af8f5b5f8c3da56a92b619bbc02989fb71"); - const INVULNERABLE_ACCOUNT_C: [u8; 32] = - hex!("c0e021ab805fa956f29661c4380377e5296c5fa5fc16be26ffd516675a66bf6d"); - const INVULNERABLE_ACCOUNT_D: [u8; 32] = - hex!("9c17e9b360d9ca3cf8e42ce015ab649281d42484e7240020a12f5b16acc0d718"); - const INVULNERABLE_ACCOUNT_E: [u8; 32] = - hex!("2c3b7e77d0a8db2e3389669c4bc8112c34d5d1619cf20edc79c12c57a75f8c19"); - - pub struct InitInvulnerables(sp_std::marker::PhantomData); - impl OnRuntimeUpgrade for InitInvulnerables - where - T: frame_system::Config - + pallet_collator_selection::Config - + pallet_session::Config - + pallet_balances::Config, - ::AccountId: From<[u8; 32]>, - ::ValidatorId: From<[u8; 32]>, - ::Keys: From, - ::Balance: From, - ::Balance: EncodeLike< - <::Currency as Currency< - ::AccountId, - >>::Balance, - >, - { - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, TryRuntimeError> { - let invulnerables_len = pallet_collator_selection::Invulnerables::::get().len(); - Ok((invulnerables_len as u32).encode()) - } - - fn on_runtime_upgrade() -> Weight { - let invulnerables_len = pallet_collator_selection::Invulnerables::::get().len(); - if invulnerables_len > 0 { - info!(target: TARGET, "no need to initialize invulnerables"); - return T::DbWeight::get().reads_writes(1, 0) - } - info!(target: TARGET, "initializing the set of invulnerables"); - - let raw_aura_keys: Vec<[u8; 32]> = vec![ - INVULNERABLE_AURA_A, - INVULNERABLE_AURA_B, - INVULNERABLE_AURA_C, - INVULNERABLE_AURA_D, - INVULNERABLE_AURA_E, - ]; - let raw_account_keys: Vec<[u8; 32]> = vec![ - INVULNERABLE_ACCOUNT_A, - INVULNERABLE_ACCOUNT_B, - INVULNERABLE_ACCOUNT_C, - INVULNERABLE_ACCOUNT_D, - INVULNERABLE_ACCOUNT_E, - ]; - - let validatorids: Vec<::ValidatorId> = - raw_account_keys.iter().map(|&pk| pk.into()).collect(); - - pallet_session::Validators::::put(validatorids); - - let queued_keys: Vec<( - ::ValidatorId, - ::Keys, - )> = raw_account_keys - .iter() - .zip(raw_aura_keys.iter()) - .map(|(&account, &aura)| { - ( - account.into(), - SessionKeys { aura: sr25519::Public::from_raw(aura).into() }.into(), - ) - }) - .collect(); - - pallet_session::QueuedKeys::::put(queued_keys); - - for (&account, &aura) in raw_account_keys.iter().zip(raw_aura_keys.iter()) { - pallet_session::NextKeys::::insert::< - ::ValidatorId, - ::Keys, - >( - account.into(), - SessionKeys { aura: sr25519::Public::from_raw(aura).into() }.into(), - ); - pallet_session::KeyOwner::::insert::< - _, - ::ValidatorId, - >((AURA, aura.encode()), account.into()); - } - - let mut invulnerables: Vec<::AccountId> = - raw_account_keys.iter().map(|&pk| pk.into()).collect(); - invulnerables.sort(); - let invulnerables: BoundedVec<_, T::MaxInvulnerables> = - invulnerables.try_into().unwrap(); - pallet_collator_selection::Invulnerables::::put(invulnerables); - - pallet_collator_selection::CandidacyBond::::put::>( - 5_000_000_000_000u128.into(), - ); - - T::DbWeight::get().reads_writes(0, 4 + 5 * 2) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(state: sp_std::vec::Vec) -> Result<(), TryRuntimeError> { - let invulnerables_len = - pallet_collator_selection::Invulnerables::::get().len() as u32; - let apriori_invulnerables_len: u32 = Decode::decode(&mut state.as_slice()).expect( - "the state parameter should be something that was generated by pre_upgrade", - ); - ensure!( - invulnerables_len > 0, - "invulnerables are empty after initialization. that should not happen" - ); - info!(target: TARGET, "apriori invulnerables: {}, aposteriori: {}", apriori_invulnerables_len, invulnerables_len); - Ok(()) - } - } - } -} diff --git a/system-parachains/people/people-kusama/src/lib.rs b/system-parachains/people/people-kusama/src/lib.rs index f0b9bf90f3..7d2503f615 100644 --- a/system-parachains/people/people-kusama/src/lib.rs +++ b/system-parachains/people/people-kusama/src/lib.rs @@ -150,17 +150,9 @@ pub type SignedExtra = ( pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -parameter_types! { - pub const IdentityMigratorPalletName: &'static str = "IdentityMigrator"; -} /// Migrations to apply on runtime upgrade. pub type Migrations = ( - pallet_collator_selection::migration::v2::MigrationToV2, - // remove `identity-migrator` - frame_support::migrations::RemovePallet< - IdentityMigratorPalletName, - ::DbWeight, - >, + // unreleased and/or un-applied cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, // permanent pallet_xcm::migration::MigrateToLatestXcmVersion, diff --git a/system-parachains/people/people-polkadot/src/lib.rs b/system-parachains/people/people-polkadot/src/lib.rs index ba4ebecc70..5aaac6a0ed 100644 --- a/system-parachains/people/people-polkadot/src/lib.rs +++ b/system-parachains/people/people-polkadot/src/lib.rs @@ -116,6 +116,7 @@ parameter_types! { /// Migrations to apply on runtime upgrade. pub type Migrations = ( + // unreleased and/or un-applied cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, frame_support::migrations::RemovePallet< IdentityMigratorPalletName,