diff --git a/polkadot/runtime/kusama/src/lib.rs b/polkadot/runtime/kusama/src/lib.rs index f16c1da145..45e8ba1fe2 100644 --- a/polkadot/runtime/kusama/src/lib.rs +++ b/polkadot/runtime/kusama/src/lib.rs @@ -81,7 +81,7 @@ use sp_core::OpaqueMetadata; use sp_staking::SessionIndex; use frame_support::{ parameter_types, construct_runtime, RuntimeDebug, PalletId, - traits::{KeyOwnerProofSystem, LockIdentifier, Filter, InstanceFilter, All}, + traits::{KeyOwnerProofSystem, LockIdentifier, Filter, InstanceFilter, All, OnRuntimeUpgrade}, weights::Weight, }; use frame_system::{EnsureRoot, EnsureOneOf}; @@ -1525,11 +1525,22 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - RemoveCollectiveFlip, + (RemoveCollectiveFlip, MigratePalletVersionToStorageVersion), >; /// The payload being signed in the transactions. pub type SignedPayload = generic::SignedPayload; +/// Migrate from `PalletVersion` to the new `StorageVersion` +pub struct MigratePalletVersionToStorageVersion; + +impl OnRuntimeUpgrade for MigratePalletVersionToStorageVersion { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + frame_support::migrations::migrate_from_pallet_version_to_storage_version::( + &RocksDbWeight::get() + ) + } +} + pub struct RemoveCollectiveFlip; impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip { fn on_runtime_upgrade() -> Weight { diff --git a/polkadot/runtime/polkadot/src/lib.rs b/polkadot/runtime/polkadot/src/lib.rs index 213e54c806..22773c5d36 100644 --- a/polkadot/runtime/polkadot/src/lib.rs +++ b/polkadot/runtime/polkadot/src/lib.rs @@ -56,7 +56,7 @@ use sp_core::OpaqueMetadata; use sp_staking::SessionIndex; use frame_support::{ parameter_types, construct_runtime, RuntimeDebug, PalletId, - traits::{KeyOwnerProofSystem, LockIdentifier, Filter}, + traits::{KeyOwnerProofSystem, LockIdentifier, Filter, OnRuntimeUpgrade}, weights::Weight, }; use frame_system::{EnsureRoot, EnsureOneOf}; @@ -1088,11 +1088,22 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - RemoveCollectiveFlip, + (RemoveCollectiveFlip, MigratePalletVersionToStorageVersion), >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; +/// Migrate from `PalletVersion` to the new `StorageVersion` +pub struct MigratePalletVersionToStorageVersion; + +impl OnRuntimeUpgrade for MigratePalletVersionToStorageVersion { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + frame_support::migrations::migrate_from_pallet_version_to_storage_version::( + &RocksDbWeight::get() + ) + } +} + pub struct RemoveCollectiveFlip; impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip { fn on_runtime_upgrade() -> Weight { diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 9f9f601bd1..16cabf4d73 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -39,10 +39,9 @@ use runtime_parachains::{ runtime_api_impl::v1 as runtime_api_impl, }; use frame_support::{ - construct_runtime, parameter_types, - traits::{Filter, KeyOwnerProofSystem, Randomness, All, IsInVec}, + PalletId, construct_runtime, parameter_types, + traits::{All, Filter, IsInVec, KeyOwnerProofSystem, OnRuntimeUpgrade, Randomness}, weights::Weight, - PalletId }; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, @@ -159,6 +158,17 @@ pub type SignedExtra = ( pallet_transaction_payment::ChargeTransactionPayment, ); +/// Migrate from `PalletVersion` to the new `StorageVersion` +pub struct MigratePalletVersionToStorageVersion; + +impl OnRuntimeUpgrade for MigratePalletVersionToStorageVersion { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + frame_support::migrations::migrate_from_pallet_version_to_storage_version::( + &RocksDbWeight::get() + ) + } +} + /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. @@ -168,7 +178,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - GrandpaStoragePrefixMigration, + MigratePalletVersionToStorageVersion, >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; @@ -267,31 +277,6 @@ construct_runtime! { } } -pub struct GrandpaStoragePrefixMigration; -impl frame_support::traits::OnRuntimeUpgrade for GrandpaStoragePrefixMigration { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("grandpa is part of pallets in construct_runtime, so it has a name; qed"); - pallet_grandpa::migrations::v3_1::migrate::(name) - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - use frame_support::traits::PalletInfo; - let name = ::PalletInfo::name::() - .expect("grandpa is part of pallets in construct_runtime, so it has a name; qed"); - pallet_grandpa::migrations::v3_1::pre_migration::(name); - Ok(()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - pallet_grandpa::migrations::v3_1::post_migration::(); - Ok(()) - } -} - pub struct BaseFilter; impl Filter for BaseFilter { fn filter(_call: &Call) -> bool { diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 6ef324e59f..1cd5f6c5cf 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -80,7 +80,7 @@ use sp_core::OpaqueMetadata; use sp_staking::SessionIndex; use frame_support::{ parameter_types, construct_runtime, RuntimeDebug, PalletId, - traits::{KeyOwnerProofSystem, Filter, InstanceFilter, All}, + traits::{KeyOwnerProofSystem, Filter, InstanceFilter, All, OnRuntimeUpgrade}, weights::Weight, }; use pallet_im_online::sr25519::AuthorityId as ImOnlineId; @@ -1116,11 +1116,22 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPallets, - RemoveCollectiveFlip, + (RemoveCollectiveFlip, MigratePalletVersionToStorageVersion), >; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; +/// Migrate from `PalletVersion` to the new `StorageVersion` +pub struct MigratePalletVersionToStorageVersion; + +impl OnRuntimeUpgrade for MigratePalletVersionToStorageVersion { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + frame_support::migrations::migrate_from_pallet_version_to_storage_version::( + &RocksDbWeight::get() + ) + } +} + pub struct RemoveCollectiveFlip; impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip { fn on_runtime_upgrade() -> Weight {