Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/master' into migrate-pallet-co…
…llective
  • Loading branch information
koushiro committed Jul 21, 2021
commit 6a898e81361d09aab5ed0fc8e126d6fb66f93eb8
100 changes: 50 additions & 50 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1503,14 +1503,58 @@ construct_runtime! {
}
}

/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// A Block signed with a Justification
pub type SignedBlock = generic::SignedBlock<Block>;
/// `BlockId` type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;
/// The `SignedExtension` to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckMortality<Runtime>,
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
(RemoveCollectiveFlip, CouncilStoragePrefixMigration, TechnicalCommitteeStoragePrefixMigration),
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;

pub struct RemoveCollectiveFlip;
impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip {
fn on_runtime_upgrade() -> Weight {
use frame_support::storage::migration;
// Remove the storage value `RandomMaterial` from removed pallet `RandomnessCollectiveFlip`
migration::remove_storage_prefix(b"RandomnessCollectiveFlip", b"RandomMaterial", b"");
<Runtime as frame_system::Config>::DbWeight::get().writes(1)
}
}

const COUNCIL_OLD_PREFIX: &str = "Instance1Collective";
pub struct CouncilStoragePrefixMigration;
impl frame_support::traits::OnRuntimeUpgrade for CouncilStoragePrefixMigration {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Council>()
.expect("council is part of pallets in construct_runtime, so it has a name; qed");
pallet_collective::migrations::v3_1::migrate::<Runtime, Council, _>(
pallet_collective::migrations::v4::migrate::<Runtime, Council, _>(
COUNCIL_OLD_PREFIX,
name,
)
Expand All @@ -1521,7 +1565,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CouncilStoragePrefixMigration {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Council>()
.expect("council is part of pallets in construct_runtime, so it has a name; qed");
pallet_collective::migrations::v3_1::pre_migration::<Runtime, Council, _>(
pallet_collective::migrations::v4::pre_migration::<Runtime, Council, _>(
COUNCIL_OLD_PREFIX,
name,
);
Expand All @@ -1530,7 +1574,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CouncilStoragePrefixMigration {

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v3_1::post_migration::<Council>(COUNCIL_OLD_PREFIX);
pallet_collective::migrations::v4::post_migration::<Council>(COUNCIL_OLD_PREFIX);
Ok(())
}
}
Expand All @@ -1542,7 +1586,7 @@ impl frame_support::traits::OnRuntimeUpgrade for TechnicalCommitteeStoragePrefix
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<TechnicalCommittee>()
.expect("technical committee is part of pallets in construct_runtime, so it has a name; qed");
pallet_collective::migrations::v3_1::migrate::<Runtime, TechnicalCommittee, _>(
pallet_collective::migrations::v4::migrate::<Runtime, TechnicalCommittee, _>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
name,
)
Expand All @@ -1553,7 +1597,7 @@ impl frame_support::traits::OnRuntimeUpgrade for TechnicalCommitteeStoragePrefix
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<TechnicalCommittee>()
.expect("technical committee is part of pallets in construct_runtime, so it has a name; qed");
pallet_collective::migrations::v3_1::pre_migration::<Runtime, TechnicalCommittee, _>(
pallet_collective::migrations::v4::pre_migration::<Runtime, TechnicalCommittee, _>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
name,
);
Expand All @@ -1562,57 +1606,13 @@ impl frame_support::traits::OnRuntimeUpgrade for TechnicalCommitteeStoragePrefix

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v3_1::post_migration::<TechnicalCommittee>(
pallet_collective::migrations::v4::post_migration::<TechnicalCommittee>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
);
Ok(())
}
}

/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// A Block signed with a Justification
pub type SignedBlock = generic::SignedBlock<Block>;
/// `BlockId` type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;
/// The `SignedExtension` to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckMortality<Runtime>,
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
(CouncilStoragePrefixMigration, TechnicalCommitteeStoragePrefixMigration),
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;

pub struct RemoveCollectiveFlip;
impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip {
fn on_runtime_upgrade() -> Weight {
use frame_support::storage::migration;
// Remove the storage value `RandomMaterial` from removed pallet `RandomnessCollectiveFlip`
migration::remove_storage_prefix(b"RandomnessCollectiveFlip", b"RandomMaterial", b"");
<Runtime as frame_system::Config>::DbWeight::get().writes(1)
}
}

#[cfg(not(feature = "disable-runtime-api"))]
sp_api::impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
Expand Down
119 changes: 47 additions & 72 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1066,28 +1066,48 @@ 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 = <Runtime as frame_system::Config>::PalletInfo::name::<Grandpa>()
.expect("grandpa is part of pallets in construct_runtime, so it has a name; qed");
pallet_grandpa::migrations::v3_1::migrate::<Runtime, Grandpa, _>(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::<Grandpa>()
.expect("grandpa is part of pallets in construct_runtime, so it has a name; qed");
pallet_grandpa::migrations::v3_1::pre_migration::<Runtime, Grandpa, _>(name);
Ok(())
}
/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// A Block signed with a Justification
pub type SignedBlock = generic::SignedBlock<Block>;
/// `BlockId` type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;
/// The `SignedExtension` to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckMortality<Runtime>,
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
claims::PrevalidateAttests<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
(RemoveCollectiveFlip, CouncilStoragePrefixMigration, TechnicalCommitteeStoragePrefixMigration),
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
pallet_grandpa::migrations::v3_1::post_migration::<Grandpa>();
Ok(())
pub struct RemoveCollectiveFlip;
impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip {
fn on_runtime_upgrade() -> Weight {
use frame_support::storage::migration;
// Remove the storage value `RandomMaterial` from removed pallet `RandomnessCollectiveFlip`
migration::remove_storage_prefix(b"RandomnessCollectiveFlip", b"RandomMaterial", b"");
<Runtime as frame_system::Config>::DbWeight::get().writes(1)
}
}

Expand All @@ -1098,7 +1118,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CouncilStoragePrefixMigration {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Council>()
.expect("council is part of pallets in construct_runtime, so it has a name; qed");
pallet_collective::migrations::v3_1::migrate::<Runtime, Council, _>(
pallet_collective::migrations::v4::migrate::<Runtime, Council, _>(
COUNCIL_OLD_PREFIX,
name,
)
Expand All @@ -1109,7 +1129,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CouncilStoragePrefixMigration {
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<Council>()
.expect("council is part of pallets in construct_runtime, so it has a name; qed");
pallet_collective::migrations::v3_1::pre_migration::<Runtime, Council, _>(
pallet_collective::migrations::v4::pre_migration::<Runtime, Council, _>(
COUNCIL_OLD_PREFIX,
name,
);
Expand All @@ -1118,7 +1138,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CouncilStoragePrefixMigration {

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v3_1::post_migration::<Council>(COUNCIL_OLD_PREFIX);
pallet_collective::migrations::v4::post_migration::<Council>(COUNCIL_OLD_PREFIX);
Ok(())
}
}
Expand All @@ -1130,7 +1150,7 @@ impl frame_support::traits::OnRuntimeUpgrade for TechnicalCommitteeStoragePrefix
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<TechnicalCommittee>()
.expect("technical committee is part of pallets in construct_runtime, so it has a name; qed");
pallet_collective::migrations::v3_1::migrate::<Runtime, TechnicalCommittee, _>(
pallet_collective::migrations::v4::migrate::<Runtime, TechnicalCommittee, _>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
name,
)
Expand All @@ -1141,7 +1161,7 @@ impl frame_support::traits::OnRuntimeUpgrade for TechnicalCommitteeStoragePrefix
use frame_support::traits::PalletInfo;
let name = <Runtime as frame_system::Config>::PalletInfo::name::<TechnicalCommittee>()
.expect("technical committee is part of pallets in construct_runtime, so it has a name; qed");
pallet_collective::migrations::v3_1::pre_migration::<Runtime, TechnicalCommittee, _>(
pallet_collective::migrations::v4::pre_migration::<Runtime, TechnicalCommittee, _>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
name,
);
Expand All @@ -1150,58 +1170,13 @@ impl frame_support::traits::OnRuntimeUpgrade for TechnicalCommitteeStoragePrefix

#[cfg(feature = "try-runtime")]
fn post_upgrade() -> Result<(), &'static str> {
pallet_collective::migrations::v3_1::post_migration::<TechnicalCommittee>(
pallet_collective::migrations::v4::post_migration::<TechnicalCommittee>(
TECHNICAL_COMMITTEE_OLD_PREFIX,
);
Ok(())
}
}

/// The address format for describing accounts.
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// A Block signed with a Justification
pub type SignedBlock = generic::SignedBlock<Block>;
/// `BlockId` type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;
/// The `SignedExtension` to the basic transaction logic.
pub type SignedExtra = (
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckMortality<Runtime>,
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
claims::PrevalidateAttests<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPallets,
(GrandpaStoragePrefixMigration, CouncilStoragePrefixMigration, TechnicalCommitteeStoragePrefixMigration),
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;

pub struct RemoveCollectiveFlip;
impl frame_support::traits::OnRuntimeUpgrade for RemoveCollectiveFlip {
fn on_runtime_upgrade() -> Weight {
use frame_support::storage::migration;
// Remove the storage value `RandomMaterial` from removed pallet `RandomnessCollectiveFlip`
migration::remove_storage_prefix(b"RandomnessCollectiveFlip", b"RandomMaterial", b"");
<Runtime as frame_system::Config>::DbWeight::get().writes(1)
}
}

#[cfg(not(feature = "disable-runtime-api"))]
sp_api::impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.