Companion for substrate#9115 (#3265)

* runtime(kusama/polkadot): migrations for collective storage prefix

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* fix

* fix migration

* spelling

* Fix

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Fix

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* update Substrate

* fix unused

Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Qinxuan Chen
2021-09-14 21:01:19 +08:00
committed by GitHub
parent de637b966a
commit 438a45799f
4 changed files with 266 additions and 156 deletions
+153 -153
View File
File diff suppressed because it is too large Load Diff
@@ -31,7 +31,7 @@ use sc_executor::NativeElseWasmExecutor;
use sc_service::{TFullBackend, TFullClient};
use sp_runtime::{app_crypto::sp_core::H256, generic::Era, AccountId32};
use std::{error::Error, future::Future, str::FromStr};
use support::{weights::Weight, StorageValue};
use support::weights::Weight;
use test_runner::{
build_runtime, client_parts, ChainInfo, ConfigOrChainSpec, Node, SignatureVerificationOverride,
};
+56 -1
View File
@@ -1505,11 +1505,66 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
(TechnicalMembershipStoragePrefixMigration, MigrateTipsPalletPrefix),
(
CouncilStoragePrefixMigration,
TechnicalCommitteeStoragePrefixMigration,
TechnicalMembershipStoragePrefixMigration,
MigrateTipsPalletPrefix,
),
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
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::<Runtime, Council, _>(COUNCIL_OLD_PREFIX)
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v4::pre_migrate::<Council, _>(COUNCIL_OLD_PREFIX);
Ok(())
}
#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v4::post_migrate::<Council, _>(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::<Runtime, TechnicalCommittee, _>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
)
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v4::pre_migrate::<TechnicalCommittee, _>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
);
Ok(())
}
#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v4::post_migrate::<TechnicalCommittee, _>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
);
Ok(())
}
}
const TECHNICAL_MEMBERSHIP_OLD_PREFIX: &str = "Instance1Membership";
/// Migrate from `Instance1Membership` to the new pallet prefix `TechnicalMembership`
pub struct TechnicalMembershipStoragePrefixMigration;
+56 -1
View File
@@ -1131,11 +1131,66 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
(TechnicalMembershipStoragePrefixMigration, MigrateTipsPalletPrefix),
(
CouncilStoragePrefixMigration,
TechnicalCommitteeStoragePrefixMigration,
TechnicalMembershipStoragePrefixMigration,
MigrateTipsPalletPrefix,
),
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
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::<Runtime, Council, _>(COUNCIL_OLD_PREFIX)
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v4::pre_migrate::<Council, _>(COUNCIL_OLD_PREFIX);
Ok(())
}
#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v4::post_migrate::<Council, _>(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::<Runtime, TechnicalCommittee, _>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
)
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v4::pre_migrate::<TechnicalCommittee, _>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
);
Ok(())
}
#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v4::post_migrate::<TechnicalCommittee, _>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
);
Ok(())
}
}
const TECHNICAL_MEMBERSHIP_OLD_PREFIX: &str = "Instance1Membership";
/// Migrate from `Instance1Membership` to the new pallet prefix `TechnicalMembership`
pub struct TechnicalMembershipStoragePrefixMigration;