Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

migration: unlock/unreserve Gov v1 balances, remove Gov V1 pallets from polkadot runtime, and remove Gov V1 pallet key/values from storage #7314

Merged
merged 39 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d1cf215
restore old gov configs
liamaharon May 31, 2023
639ab0a
migrate old gov v1 storage
liamaharon May 31, 2023
3066df0
exclude the Call enum for gov v1 pallets
liamaharon May 31, 2023
d099689
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jun 2, 2023
964ac34
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jun 5, 2023
fc9e0a2
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jun 13, 2023
670f199
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jun 13, 2023
abf4d90
update substrate
liamaharon Jun 13, 2023
357328c
update tips pallet
liamaharon Jun 13, 2023
e2a8ff2
update chain_spec
liamaharon Jun 13, 2023
a85c346
fix migrations tuple
liamaharon Jun 14, 2023
49174b9
oliver comments
liamaharon Jun 14, 2023
b090f34
format comment
liamaharon Jun 14, 2023
187bda0
".git/.scripts/commands/fmt/fmt.sh"
Jun 14, 2023
c94588a
comments
liamaharon Jun 14, 2023
b3cbdde
Merge branch 'liam-kusama-gov-v1-storage-migration' of github.com:par…
liamaharon Jun 14, 2023
b64b92b
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jul 2, 2023
271666a
polkadot migrations
liamaharon Jul 2, 2023
4ec49ff
fix cargo.lock
liamaharon Jul 2, 2023
ca208cf
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jul 24, 2023
5dd4daa
fix compilation
liamaharon Jul 24, 2023
bff4590
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Jul 28, 2023
4005aee
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Aug 4, 2023
45ba24f
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Aug 16, 2023
5e440c1
use democracy standalone migration
liamaharon Aug 16, 2023
1f3f785
re-remove gov v1 pallets from kusama
liamaharon Aug 16, 2023
6cd663b
remove unnecessary feature
liamaharon Aug 16, 2023
8fef227
fix unlock configs
liamaharon Aug 17, 2023
82d4de9
use substrate master
liamaharon Aug 17, 2023
1991ecb
Merge remote-tracking branch 'origin' into liam-kusama-gov-v1-storage…
liamaharon Aug 17, 2023
e6048d9
reset cargo.lock
liamaharon Aug 17, 2023
7473d8e
cargo update -p sp-io
liamaharon Aug 17, 2023
3a47d7a
remove from chainspec
liamaharon Aug 17, 2023
3eb21c0
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Aug 17, 2023
2779a6e
Merge branch 'master' of github.com:paritytech/polkadot into liam-kus…
liamaharon Aug 18, 2023
25e81d4
remove polkadot gov v1 pallets
liamaharon Aug 18, 2023
8ef96a0
clean up chain spec
liamaharon Aug 18, 2023
6bf0aec
cargo fmt
liamaharon Aug 18, 2023
6baa262
remove old gov import
liamaharon Aug 18, 2023
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
24 changes: 24 additions & 0 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,18 @@ fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::RuntimeG
xcm_pallet: Default::default(),
nomination_pools: Default::default(),
nis_counterpart_balances: Default::default(),

// Old gov v1 pallets that should be removed once the migration unlocking funds is confirmed
// successful, probably in release 1.1.
// See https://github.com/paritytech/polkadot/issues/6749
phragmen_election: Default::default(),
democracy: Default::default(),
council: kusama::CouncilConfig { members: vec![], phantom: Default::default() },
technical_committee: kusama::TechnicalCommitteeConfig {
members: vec![],
phantom: Default::default(),
},
technical_membership: Default::default(),
}
}

Expand Down Expand Up @@ -1397,6 +1409,18 @@ pub fn kusama_testnet_genesis(
xcm_pallet: Default::default(),
nomination_pools: Default::default(),
nis_counterpart_balances: Default::default(),

// Old gov v1 pallets that should be removed once the migration unlocking funds is confirmed
// successful, probably in release 1.1.
// See https://github.com/paritytech/polkadot/issues/6749
phragmen_election: Default::default(),
democracy: kusama::DemocracyConfig::default(),
council: kusama::CouncilConfig { members: vec![], phantom: Default::default() },
technical_committee: kusama::TechnicalCommitteeConfig {
members: vec![],
phantom: Default::default(),
},
technical_membership: Default::default(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pallet-referenda = { git = "https://github.com/paritytech/substrate", branch = "
pallet-scheduler = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["experimental"] }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, features = ["tuples-96"] }
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-state-trie-migration = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down
3 changes: 3 additions & 0 deletions runtime/kusama/src/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ use frame_support::{
};
use frame_system::EnsureRootWithSuccess;

// Old governance configurations.
pub mod old;

mod origins;
pub use origins::{
pallet_custom_origins, AuctionAdmin, Fellows, FellowshipAdmin, FellowshipExperts,
Expand Down
189 changes: 189 additions & 0 deletions runtime/kusama/src/governance/old.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
// Copyright 2022 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

//! Old governance configurations for the Kusama runtime.
//!
//! Here purely so locked funds can be released before we purge the storage. It should be removed
//! from the runtime once the migration was confirmed successful, probably in 1.1.
//! See https://github.com/paritytech/polkadot/issues/6749

use crate::*;
use frame_support::{
parameter_types,
traits::{EitherOfDiverse, LockIdentifier},
};
use frame_system::EnsureNever;
use static_assertions::const_assert;

parameter_types! {
pub LaunchPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1, "KSM_LAUNCH_PERIOD");
pub VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES, "KSM_VOTING_PERIOD");
pub FastTrackVotingPeriod: BlockNumber = prod_or_fast!(3 * HOURS, 1 * MINUTES, "KSM_FAST_TRACK_VOTING_PERIOD");
pub const MinimumDeposit: Balance = 100 * CENTS;
pub EnactmentPeriod: BlockNumber = prod_or_fast!(8 * DAYS, 1, "KSM_ENACTMENT_PERIOD");
pub CooloffPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES, "KSM_COOLOFF_PERIOD");
pub const InstantAllowed: bool = true;
pub const MaxVotes: u32 = 100;
pub const MaxProposals: u32 = 100;
pub MaxProposalWeight: Weight = Perbill::from_percent(50) * BlockWeights::get().max_block;
}

impl pallet_democracy::Config for Runtime {
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type EnactmentPeriod = EnactmentPeriod;
type VoteLockingPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
type MinimumDeposit = MinimumDeposit;
type SubmitOrigin = frame_system::EnsureSigned<AccountId>;
/// A straight majority of the council can decide what their next motion is.
type ExternalOrigin =
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>;
/// A majority can have the next scheduled referendum be a straight majority-carries vote.
type ExternalMajorityOrigin =
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>;
/// A unanimous council can have the next scheduled referendum be a straight default-carries
/// (NTB) vote.
type ExternalDefaultOrigin =
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>;
/// Two thirds of the technical committee can have an `ExternalMajority/ExternalDefault` vote
/// be tabled immediately and with a shorter voting/enactment period.
type FastTrackOrigin =
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 2, 3>;
type InstantOrigin =
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>;
type InstantAllowed = InstantAllowed;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
// To cancel a proposal which has been passed, 2/3 of the council must agree to it.
type CancellationOrigin = EitherOfDiverse<
EnsureNever<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>,
>;
type BlacklistOrigin = EnsureNever<AccountId>;
// To cancel a proposal before it has been passed, the technical committee must be unanimous or
// Root must agree.
type CancelProposalOrigin = EitherOfDiverse<
EnsureNever<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>,
>;
// Any single technical committee member may veto a coming council proposal, however they can
// only do it once and it lasts only for the cooloff period.
type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
type CooloffPeriod = CooloffPeriod;
type Slash = Treasury;
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
type WeightInfo = weights::pallet_democracy::WeightInfo<Runtime>;
type MaxProposals = MaxProposals;
type Preimages = Preimage;
type MaxDeposits = ConstU32<100>;
type MaxBlacklisted = ConstU32<100>;
}

parameter_types! {
pub CouncilMotionDuration: BlockNumber = prod_or_fast!(3 * DAYS, 2 * MINUTES, "KSM_MOTION_DURATION");
pub const CouncilMaxProposals: u32 = 100;
pub const CouncilMaxMembers: u32 = 100;
}

pub type CouncilCollective = pallet_collective::Instance1;
impl pallet_collective::Config<CouncilCollective> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = CouncilMotionDuration;
type MaxProposals = CouncilMaxProposals;
type MaxMembers = CouncilMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type SetMembersOrigin = EnsureNever<AccountId>;
type WeightInfo = weights::pallet_collective_council::WeightInfo<Runtime>;
type MaxProposalWeight = MaxProposalWeight;
}

parameter_types! {
pub const CandidacyBond: Balance = 100 * CENTS;
// 1 storage item created, key size is 32 bytes, value size is 16+16.
pub const VotingBondBase: Balance = deposit(1, 64);
// additional data per vote is 32 bytes (account id).
pub const VotingBondFactor: Balance = deposit(0, 32);
/// Daily council elections
pub TermDuration: BlockNumber = prod_or_fast!(24 * HOURS, 2 * MINUTES, "KSM_TERM_DURATION");
pub const DesiredMembers: u32 = 19;
pub const DesiredRunnersUp: u32 = 19;
pub const MaxVotesPerVoter: u32 = 16;
pub const MaxVoters: u32 = 10 * 1000;
pub const MaxCandidates: u32 = 1000;
pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect";
}

// Make sure that there are no more than `MaxMembers` members elected via Phragmen.
const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get());

impl pallet_elections_phragmen::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type ChangeMembers = Council;
type InitializeMembers = Council;
type CurrencyToVote = runtime_common::CurrencyToVote;
type CandidacyBond = CandidacyBond;
type VotingBondBase = VotingBondBase;
type VotingBondFactor = VotingBondFactor;
type LoserCandidate = Treasury;
type KickedMember = Treasury;
type DesiredMembers = DesiredMembers;
type DesiredRunnersUp = DesiredRunnersUp;
type TermDuration = TermDuration;
type MaxVoters = MaxVoters;
type MaxCandidates = MaxCandidates;
type MaxVotesPerVoter = MaxVotesPerVoter;
type PalletId = PhragmenElectionPalletId;
type WeightInfo = weights::pallet_elections_phragmen::WeightInfo<Runtime>;
}

parameter_types! {
pub TechnicalMotionDuration: BlockNumber = prod_or_fast!(3 * DAYS, 2 * MINUTES, "KSM_MOTION_DURATION");
pub const TechnicalMaxProposals: u32 = 100;
pub const TechnicalMaxMembers: u32 = 100;
}

pub type TechnicalCollective = pallet_collective::Instance2;
impl pallet_collective::Config<TechnicalCollective> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = TechnicalMotionDuration;
type MaxProposals = TechnicalMaxProposals;
type MaxMembers = TechnicalMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type SetMembersOrigin = EnsureNever<AccountId>;
type WeightInfo = weights::pallet_collective_technical_committee::WeightInfo<Runtime>;
type MaxProposalWeight = MaxProposalWeight;
}

impl pallet_membership::Config<pallet_membership::Instance1> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = EnsureNever<AccountId>;
type RemoveOrigin = EnsureNever<AccountId>;
type SwapOrigin = EnsureNever<AccountId>;
type ResetOrigin = EnsureNever<AccountId>;
type PrimeOrigin = EnsureNever<AccountId>;
type MembershipInitialized = TechnicalCommittee;
type MembershipChanged = TechnicalCommittee;
type MaxMembers = TechnicalMaxMembers;
type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>;
}
52 changes: 52 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,20 @@ impl pallet_offences::Config for Runtime {
type OnOffenceHandler = Staking;
}

// Tips are here purely so locked funds can be released before we purge the storage. It should be
// removed from the runtime once the migration was confirmed successful, probably in 1.1.
// See https://github.com/paritytech/polkadot/issues/6749
impl pallet_tips::Config for Runtime {
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
type MaximumReasonLength = MaximumReasonLength;
type DataDepositPerByte = DataDepositPerByte;
type Tippers = PhragmenElection;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_tips::WeightInfo<Runtime>;
}

impl pallet_authority_discovery::Config for Runtime {
type MaxAuthorities = MaxAuthorities;
}
Expand Down Expand Up @@ -1390,6 +1404,15 @@ construct_runtime! {
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>} = 11,
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config<T>} = 12,

// Old, deprecated governance pallets. Here purely so storage can be migrated.
// See https://github.com/paritytech/polkadot/issues/6749
Democracy: pallet_democracy exclude_parts {Call} = 13,
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
Council: pallet_collective::<Instance1> exclude_parts {Call} = 14,
TechnicalCommittee: pallet_collective::<Instance2> exclude_parts {Call} = 15,
PhragmenElection: pallet_elections_phragmen exclude_parts {Call} = 16,
TechnicalMembership: pallet_membership::<Instance1> exclude_parts {Call} = 17,
Tips: pallet_tips exclude_parts {Call} = 36,

// Governance stuff.
Treasury: pallet_treasury::{Pallet, Call, Storage, Config<T>, Event<T>} = 18,
ConvictionVoting: pallet_conviction_voting::{Pallet, Call, Storage, Event<T>} = 20,
Expand Down Expand Up @@ -1517,6 +1540,17 @@ impl Get<Perbill> for NominationPoolsMigrationV4OldPallet {
}
}

// Gov V1 pallets pending storage removal using the frame_support RemovePallet migration.
// See https://github.com/paritytech/polkadot/issues/6749
parameter_types! {
pub const DemocracyStr: &'static str = "Democracy";
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
pub const CouncilStr: &'static str = "Council";
pub const TechnicalCommitteeStr: &'static str = "TechnicalCommittee";
pub const PhragmenElectionStr: &'static str = "PhragmenElection";
pub const TechnicalMembershipStr: &'static str = "TechnicalMembership";
pub const TipsStr: &'static str = "Tips";
}

/// All migrations that will run on the next runtime upgrade.
///
/// This contains the combined migrations of the last 10 releases. It allows to skip runtime
Expand All @@ -1538,6 +1572,24 @@ pub mod migrations {
>,
pallet_im_online::migration::v1::Migration<Runtime>,
parachains_configuration::migration::v7::MigrateToV7<Runtime>,

liamaharon marked this conversation as resolved.
Show resolved Hide resolved
// Gov v1 storage migrations
// https://github.com/paritytech/polkadot/issues/6749
pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<Runtime>,
pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<Runtime>,
pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<Runtime, ()>,

// RemovePallets only after they have been removed from the runtime. Otherwise, the on-chain
// storage version is removed for active pallets causing try-runtime to fail. The below code
// should be uncommented to fully remove the storage at the same time as the pallets are
// removed from the runtime, probably in 1.1.
// See https://github.com/paritytech/polkadot/issues/6749
// frame_support::migrations::RemovePallet<DemocracyStr, RocksDbWeight>,
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
// frame_support::migrations::RemovePallet<CouncilStr, RocksDbWeight>,
// frame_support::migrations::RemovePallet<TechnicalCommitteeStr, RocksDbWeight>,
// frame_support::migrations::RemovePallet<PhragmenElectionStr, RocksDbWeight>,
// frame_support::migrations::RemovePallet<TechnicalMembershipStr, RocksDbWeight>,
// frame_support::migrations::RemovePallet<TipsStr, RocksDbWeight>,
);
}

Expand Down
18 changes: 18 additions & 0 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,24 @@ pub mod migrations {
pub type Unreleased = (
pallet_im_online::migration::v1::Migration<Runtime>,
parachains_configuration::migration::v7::MigrateToV7<Runtime>,

// Gov v1 storage migrations
// https://github.com/paritytech/polkadot/issues/6749
pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<Runtime>,
pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<Runtime>,
pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<Runtime, ()>,

// RemovePallets only after they have been removed from the runtime. Otherwise, the on-chain
// storage version is removed for active pallets causing try-runtime to fail. The below code
// should be uncommented to fully remove the storage at the same time as the pallets are
// removed from the runtime, probably in 1.1.
// See https://github.com/paritytech/polkadot/issues/6749
// frame_support::migrations::RemovePallet<DemocracyStr, RocksDbWeight>,
// frame_support::migrations::RemovePallet<CouncilStr, RocksDbWeight>,
// frame_support::migrations::RemovePallet<TechnicalCommitteeStr, RocksDbWeight>,
// frame_support::migrations::RemovePallet<PhragmenElectionStr, RocksDbWeight>,
// frame_support::migrations::RemovePallet<TechnicalMembershipStr, RocksDbWeight>,
// frame_support::migrations::RemovePallet<TipsStr, RocksDbWeight>,
);

/// Migrations that set `StorageVersion`s we missed to set.
Expand Down