From 3702795f13e815afb22aa63bc5ee691dcf381983 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Tue, 19 Oct 2021 16:49:34 +0200 Subject: [PATCH 1/3] remove stale migrations --- runtime/kusama/src/lib.rs | 177 +----------------------------------- runtime/polkadot/src/lib.rs | 137 +--------------------------- runtime/westend/src/lib.rs | 21 +---- 3 files changed, 3 insertions(+), 332 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index d596769dd2e6..3611e00a5576 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -1557,186 +1557,11 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - ( - CouncilStoragePrefixMigration, - TechnicalCommitteeStoragePrefixMigration, - TechnicalMembershipStoragePrefixMigration, - MigrateTipsPalletPrefix, - BountiesPrefixMigration, - StakingBagsListMigrationV8, - ), + (), >; /// The payload being signed in the transactions. pub type SignedPayload = generic::SignedPayload; -const BOUNTIES_OLD_PREFIX: &str = "Treasury"; - -/// Migrate from 'Treasury' to the new prefix 'Bounties' -pub struct BountiesPrefixMigration; - -impl OnRuntimeUpgrade for BountiesPrefixMigration { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("Bounties is part of runtime, so it has a name; qed"); - pallet_bounties::migrations::v4::migrate::(BOUNTIES_OLD_PREFIX, name) - } - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("Bounties is part of runtime, so it has a name; qed"); - pallet_bounties::migrations::v4::pre_migration::( - BOUNTIES_OLD_PREFIX, - name, - ); - Ok(()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("Bounties is part of runtime, so it has a name; qed"); - pallet_bounties::migrations::v4::post_migration::( - BOUNTIES_OLD_PREFIX, - name, - ); - Ok(()) - } -} - -const COUNCIL_OLD_PREFIX: &str = "Instance1Collective"; -/// Migrate from `Instance1Collective` to the new pallet prefix `Council` -pub struct CouncilStoragePrefixMigration; - -impl OnRuntimeUpgrade for CouncilStoragePrefixMigration { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_collective::migrations::v4::migrate::(COUNCIL_OLD_PREFIX) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - pallet_collective::migrations::v4::pre_migrate::(COUNCIL_OLD_PREFIX); - Ok(()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - pallet_collective::migrations::v4::post_migrate::(COUNCIL_OLD_PREFIX); - Ok(()) - } -} - -const TECHNICAL_COMMITTEE_OLD_PREFIX: &str = "Instance2Collective"; -/// Migrate from `Instance2Collective` to the new pallet prefix `TechnicalCommittee` -pub struct TechnicalCommitteeStoragePrefixMigration; - -impl OnRuntimeUpgrade for TechnicalCommitteeStoragePrefixMigration { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_collective::migrations::v4::migrate::( - TECHNICAL_COMMITTEE_OLD_PREFIX, - ) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - pallet_collective::migrations::v4::pre_migrate::( - TECHNICAL_COMMITTEE_OLD_PREFIX, - ); - Ok(()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - pallet_collective::migrations::v4::post_migrate::( - TECHNICAL_COMMITTEE_OLD_PREFIX, - ); - Ok(()) - } -} - -const TECHNICAL_MEMBERSHIP_OLD_PREFIX: &str = "Instance1Membership"; -/// Migrate from `Instance1Membership` to the new pallet prefix `TechnicalMembership` -pub struct TechnicalMembershipStoragePrefixMigration; - -impl OnRuntimeUpgrade for TechnicalMembershipStoragePrefixMigration { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("TechnicalMembership is part of runtime, so it has a name; qed"); - pallet_membership::migrations::v4::migrate::( - TECHNICAL_MEMBERSHIP_OLD_PREFIX, - name, - ) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("TechnicalMembership is part of runtime, so it has a name; qed"); - pallet_membership::migrations::v4::pre_migrate::( - TECHNICAL_MEMBERSHIP_OLD_PREFIX, - name, - ); - Ok(()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("TechnicalMembership is part of runtime, so it has a name; qed"); - pallet_membership::migrations::v4::post_migrate::( - TECHNICAL_MEMBERSHIP_OLD_PREFIX, - name, - ); - Ok(()) - } -} - -const TIPS_OLD_PREFIX: &str = "Treasury"; -/// Migrate pallet-tips from `Treasury` to the new pallet prefix `Tips` -pub struct MigrateTipsPalletPrefix; - -impl OnRuntimeUpgrade for MigrateTipsPalletPrefix { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_tips::migrations::v4::migrate::(TIPS_OLD_PREFIX) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - pallet_tips::migrations::v4::pre_migrate::(TIPS_OLD_PREFIX); - Ok(()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - pallet_tips::migrations::v4::post_migrate::(TIPS_OLD_PREFIX); - Ok(()) - } -} - -// Migration to generate pallet staking's `SortedListProvider` from pre-existing nominators. -pub struct StakingBagsListMigrationV8; - -impl OnRuntimeUpgrade for StakingBagsListMigrationV8 { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_staking::migrations::v8::migrate::() - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - pallet_staking::migrations::v8::pre_migrate::() - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - pallet_staking::migrations::v8::post_migrate::() - } -} - #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index c43fbcb85393..60e12bc8ad78 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -1349,146 +1349,11 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - ( - SetInitialHostConfiguration, - BountiesPrefixMigration, - CouncilStoragePrefixMigration, - TechnicalCommitteeStoragePrefixMigration, - TechnicalMembershipStoragePrefixMigration, - MigrateTipsPalletPrefix, - ), + (), >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; -const BOUNTIES_OLD_PREFIX: &str = "Treasury"; - -/// Migrate from 'Treasury' to the new prefix 'Bounties' -pub struct BountiesPrefixMigration; - -impl OnRuntimeUpgrade for BountiesPrefixMigration { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("Bounties is part of runtime, so it has a name; qed"); - pallet_bounties::migrations::v4::migrate::(BOUNTIES_OLD_PREFIX, name) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("Bounties is part of runtime, so it has a name; qed"); - pallet_bounties::migrations::v4::pre_migration::( - BOUNTIES_OLD_PREFIX, - name, - ); - Ok(()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("Bounties is part of runtime, so it has a name; qed"); - pallet_bounties::migrations::v4::post_migration::( - BOUNTIES_OLD_PREFIX, - name, - ); - Ok(()) - } -} - -const COUNCIL_OLD_PREFIX: &str = "Instance1Collective"; -/// Migrate from `Instance1Collective` to the new pallet prefix `Council` -pub struct CouncilStoragePrefixMigration; - -impl OnRuntimeUpgrade for CouncilStoragePrefixMigration { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_collective::migrations::v4::migrate::(COUNCIL_OLD_PREFIX) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - pallet_collective::migrations::v4::pre_migrate::(COUNCIL_OLD_PREFIX); - Ok(()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - pallet_collective::migrations::v4::post_migrate::(COUNCIL_OLD_PREFIX); - Ok(()) - } -} - -const TECHNICAL_COMMITTEE_OLD_PREFIX: &str = "Instance2Collective"; -/// Migrate from `Instance2Collective` to the new pallet prefix `TechnicalCommittee` -pub struct TechnicalCommitteeStoragePrefixMigration; - -impl OnRuntimeUpgrade for TechnicalCommitteeStoragePrefixMigration { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_collective::migrations::v4::migrate::( - TECHNICAL_COMMITTEE_OLD_PREFIX, - ) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - pallet_collective::migrations::v4::pre_migrate::( - TECHNICAL_COMMITTEE_OLD_PREFIX, - ); - Ok(()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - pallet_collective::migrations::v4::post_migrate::( - TECHNICAL_COMMITTEE_OLD_PREFIX, - ); - Ok(()) - } -} - -const TECHNICAL_MEMBERSHIP_OLD_PREFIX: &str = "Instance1Membership"; -/// Migrate from `Instance1Membership` to the new pallet prefix `TechnicalMembership` -pub struct TechnicalMembershipStoragePrefixMigration; - -impl OnRuntimeUpgrade for TechnicalMembershipStoragePrefixMigration { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("TechnialMembership is part of runtime, so it has a name; qed"); - pallet_membership::migrations::v4::migrate::( - TECHNICAL_MEMBERSHIP_OLD_PREFIX, - name, - ) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("TechnicalMembership is part of runtime, so it has a name; qed"); - pallet_membership::migrations::v4::pre_migrate::( - TECHNICAL_MEMBERSHIP_OLD_PREFIX, - name, - ); - Ok(()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("TechnicalMembership is part of runtime, so it has a name; qed"); - pallet_membership::migrations::v4::post_migrate::( - TECHNICAL_MEMBERSHIP_OLD_PREFIX, - name, - ); - Ok(()) - } -} - /// Set the initial host configuration for Polkadot. pub struct SetInitialHostConfiguration; impl OnRuntimeUpgrade for SetInitialHostConfiguration { diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 55ef0c129c2a..51c3af69687a 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1135,30 +1135,11 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - (StakingBagsListMigrationV8,), + (), >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; -// Migration to generate pallet staking's `SortedListProvider` from pre-existing nominators. -pub struct StakingBagsListMigrationV8; - -impl OnRuntimeUpgrade for StakingBagsListMigrationV8 { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_staking::migrations::v8::migrate::() - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - pallet_staking::migrations::v8::pre_migrate::() - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - pallet_staking::migrations::v8::post_migrate::() - } -} - #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { From d34aab8cf140fed519b690ae6bc627a5b8c104f3 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Tue, 19 Oct 2021 16:54:17 +0200 Subject: [PATCH 2/3] fix warnings --- runtime/kusama/src/lib.rs | 1 - runtime/westend/src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 3611e00a5576..a33e35f591d9 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -51,7 +51,6 @@ use frame_support::{ construct_runtime, parameter_types, traits::{ Contains, Everything, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, Nothing, - OnRuntimeUpgrade, }, weights::Weight, PalletId, RuntimeDebug, diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 51c3af69687a..b5e1a8c5e5bf 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -20,7 +20,7 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] -use frame_support::traits::OnRuntimeUpgrade; +//use frame_support::traits::OnRuntimeUpgrade; use pallet_transaction_payment::CurrencyAdapter; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::v1::{ From 617e02d4e2c1331e129a57c416af1179c4d05a3d Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Wed, 20 Oct 2021 05:01:26 +0200 Subject: [PATCH 3/3] Update runtime/westend/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- runtime/westend/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index b5e1a8c5e5bf..c19d16030539 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -20,7 +20,6 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] -//use frame_support::traits::OnRuntimeUpgrade; use pallet_transaction_payment::CurrencyAdapter; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use primitives::v1::{