Unverified Commit be11414c authored by Qinxuan Chen's avatar Qinxuan Chen Committed by GitHub
Browse files

Companion for substrate#9080 (#3263)



* runtime(kusama/polkadot): migrations for membership storage prefix
Signed-off-by: default avatarkoushiro <koushiro.cqx@gmail.com>

* Fix
Signed-off-by: default avatarkoushiro <koushiro.cqx@gmail.com>

* make correct custom migration

* some fix

* Update
Signed-off-by: default avatarkoushiro <koushiro.cqx@gmail.com>

* Fix format
Signed-off-by: default avatarkoushiro <koushiro.cqx@gmail.com>

* import traits

* update Substrate
Co-authored-by: thiolliere's avatarthiolliere <gui.thiolliere@gmail.com>
Co-authored-by: parity-processbot <>
parent e8f89b30
Pipeline #155942 passed with stages
in 43 minutes and 10 seconds
This diff is collapsed.
......@@ -49,7 +49,10 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_support::{
construct_runtime, parameter_types,
traits::{Contains, Everything, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, Nothing},
traits::{
Contains, Everything, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, Nothing,
OnRuntimeUpgrade,
},
weights::Weight,
PalletId, RuntimeDebug,
};
......@@ -1501,11 +1504,51 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
(),
TechnicalMembershipStoragePrefixMigration,
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
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 = <Runtime as frame_system::Config>::PalletInfo::name::<TechnicalMembership>()
.expect("TechnicalMembership is part of runtime, so it has a name; qed");
pallet_membership::migrations::v4::migrate::<Runtime, TechnicalMembership, _>(
TECHNICAL_MEMBERSHIP_OLD_PREFIX,
name,
)
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<TechnicalMembership>()
.expect("TechnicalMembership is part of runtime, so it has a name; qed");
pallet_membership::migrations::v4::pre_migrate::<TechnicalMembership, _>(
TECHNICAL_MEMBERSHIP_OLD_PREFIX,
name,
);
Ok(())
}
#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<TechnicalMembership>()
.expect("TechnicalMembership is part of runtime, so it has a name; qed");
pallet_membership::migrations::v4::post_migrate::<TechnicalMembership, _>(
TECHNICAL_MEMBERSHIP_OLD_PREFIX,
name,
);
Ok(())
}
}
#[cfg(not(feature = "disable-runtime-api"))]
sp_api::impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
......
......@@ -31,7 +31,7 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_support::{
construct_runtime, parameter_types,
traits::{Contains, KeyOwnerProofSystem, LockIdentifier},
traits::{Contains, KeyOwnerProofSystem, LockIdentifier, OnRuntimeUpgrade},
weights::Weight,
PalletId, RuntimeDebug,
};
......@@ -1130,11 +1130,51 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
(),
TechnicalMembershipStoragePrefixMigration,
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
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 = <Runtime as frame_system::Config>::PalletInfo::name::<TechnicalMembership>()
.expect("TechnialMembership is part of runtime, so it has a name; qed");
pallet_membership::migrations::v4::migrate::<Runtime, TechnicalMembership, _>(
TECHNICAL_MEMBERSHIP_OLD_PREFIX,
name,
)
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<TechnicalMembership>()
.expect("TechnicalMembership is part of runtime, so it has a name; qed");
pallet_membership::migrations::v4::pre_migrate::<TechnicalMembership, _>(
TECHNICAL_MEMBERSHIP_OLD_PREFIX,
name,
);
Ok(())
}
#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<TechnicalMembership>()
.expect("TechnicalMembership is part of runtime, so it has a name; qed");
pallet_membership::migrations::v4::post_migrate::<TechnicalMembership, _>(
TECHNICAL_MEMBERSHIP_OLD_PREFIX,
name,
);
Ok(())
}
}
#[cfg(not(feature = "disable-runtime-api"))]
sp_api::impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment