From 195772c5d4a747a29ca7179f08933341cbed5140 Mon Sep 17 00:00:00 2001 From: Ashley <ashley.ruglys@gmail.com> Date: Mon, 12 Apr 2021 13:29:52 +0200 Subject: [PATCH] Remove already triggered migrations (#2764) * Remove BabeEpochConfigMigrations * Remove remaining migrations * Remove unused migration definitions --- polkadot/runtime/kusama/src/lib.rs | 27 +------------ polkadot/runtime/polkadot/src/lib.rs | 59 +--------------------------- polkadot/runtime/westend/src/lib.rs | 11 +----- 3 files changed, 3 insertions(+), 94 deletions(-) diff --git a/polkadot/runtime/kusama/src/lib.rs b/polkadot/runtime/kusama/src/lib.rs index 1e4a1088d38..a31683d81d4 100644 --- a/polkadot/runtime/kusama/src/lib.rs +++ b/polkadot/runtime/kusama/src/lib.rs @@ -1036,18 +1036,6 @@ impl pallet_babe::migrations::BabePalletPrefix for Runtime { } } -pub struct BabeEpochConfigMigrations; -impl frame_support::traits::OnRuntimeUpgrade for BabeEpochConfigMigrations { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_babe::migrations::add_epoch_configuration::<Runtime>( - babe_primitives::BabeEpochConfiguration { - allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryPlainSlots, - ..BABE_GENESIS_EPOCH_CONFIG - } - ) - } -} - /// The address format for describing accounts. pub type Address = sp_runtime::MultiAddress<AccountId, ()>; /// Block header type as expected by this runtime. @@ -1079,24 +1067,11 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext<Runtime>, Runtime, AllPallets, - (BabeEpochConfigMigrations, KillOffchainPhragmenStorageTest), + (), >; /// The payload being signed in the transactions. pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>; -/// This is only for testing. The main migration is inside staking's `on_runtime_upgrade`. -pub struct KillOffchainPhragmenStorageTest; -impl frame_support::traits::OnRuntimeUpgrade for KillOffchainPhragmenStorageTest { - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - pallet_staking::migrations::v6::pre_migrate::<Runtime>() - } - - fn on_runtime_upgrade() -> frame_support::weights::Weight { - 0 - } -} - #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core<Block> for Runtime { diff --git a/polkadot/runtime/polkadot/src/lib.rs b/polkadot/runtime/polkadot/src/lib.rs index f32fba2a0da..e2967b77898 100644 --- a/polkadot/runtime/polkadot/src/lib.rs +++ b/polkadot/runtime/polkadot/src/lib.rs @@ -1030,15 +1030,6 @@ impl pallet_babe::migrations::BabePalletPrefix for Runtime { } } -pub struct BabeEpochConfigMigrations; -impl frame_support::traits::OnRuntimeUpgrade for BabeEpochConfigMigrations { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_babe::migrations::add_epoch_configuration::<Runtime>( - BABE_GENESIS_EPOCH_CONFIG, - ) - } -} - /// The address format for describing accounts. pub type Address = sp_runtime::MultiAddress<AccountId, ()>; /// Block header type as expected by this runtime. @@ -1071,59 +1062,11 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext<Runtime>, Runtime, AllPallets, - (BabeEpochConfigMigrations, FixPolkadotCouncilVotersDeposit), + (), >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>; -pub struct FixPolkadotCouncilVotersDeposit; -impl frame_support::traits::OnRuntimeUpgrade for FixPolkadotCouncilVotersDeposit { - fn on_runtime_upgrade() -> Weight { - use pallet_elections_phragmen::Voter; - use frame_support::IterableStorageMap; - let mut updated = 0; - let mut skipped = 0; - let mut correct = 0; - pallet_elections_phragmen::Voting::<Runtime>::translate::<Voter<AccountId, Balance>, _>( - |_who, mut vote| { - if vote.deposit == 5 * CENTS { - // If their deposit is what we set by mistake - vote.deposit = 5 * DOLLARS; - updated += 1; - } else if vote.deposit == 5 * DOLLARS { - correct += 1; - } else { - skipped += 1; - } - Some(vote) - }, - ); - - log::info!( - target: "runtime::polkadot", - "updated {} (updated) + {} (correct) + {} (skipped) voter's deposit.", - updated, - correct, - skipped, - ); - BlockWeights::get().max_block - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - use frame_support::IterableStorageMap; - log::info!("Checking FixPolkadotCouncilVotersDeposit post migration"); - // no further vote with the wrong 5 CENT deposit shall exist. - assert!( - pallet_elections_phragmen::Voting::<Runtime>::iter().all( - |(_, vote)| vote.deposit != 5 * CENTS - ) - ); - - Ok(()) - } -} - #[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core<Block> for Runtime { diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index c6b4edb02e3..a272abe0508 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -809,15 +809,6 @@ impl pallet_babe::migrations::BabePalletPrefix for Runtime { } } -pub struct BabeEpochConfigMigrations; -impl frame_support::traits::OnRuntimeUpgrade for BabeEpochConfigMigrations { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_babe::migrations::add_epoch_configuration::<Runtime>( - BABE_GENESIS_EPOCH_CONFIG, - ) - } -} - /// The address format for describing accounts. pub type Address = sp_runtime::MultiAddress<AccountId, ()>; /// Block header type as expected by this runtime. @@ -849,7 +840,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext<Runtime>, Runtime, AllPallets, - (BabeEpochConfigMigrations, UpgradeSessionKeys), + (), >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>; -- GitLab