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 3 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
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
184 changes: 184 additions & 0 deletions runtime/kusama/src/governance/old.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// 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.

use crate::*;
use frame_support::{
parameter_types,
traits::{EitherOfDiverse, LockIdentifier},
};
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<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>,
>;
type BlacklistOrigin = EnsureRoot<AccountId>;
// To cancel a proposal before it has been passed, the technical committee must be unanimous or
// Root must agree.
type CancelProposalOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>,
>;
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
// 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 = EnsureRoot<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 = frame_support::traits::U128CurrencyToVote;
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 = EnsureRoot<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 = EnsureRoot<AccountId>;
type RemoveOrigin = EnsureRoot<AccountId>;
type SwapOrigin = EnsureRoot<AccountId>;
type ResetOrigin = EnsureRoot<AccountId>;
type PrimeOrigin = EnsureRoot<AccountId>;
type MembershipInitialized = TechnicalCommittee;
type MembershipChanged = TechnicalCommittee;
type MaxMembers = TechnicalMaxMembers;
type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>;
}
73 changes: 72 additions & 1 deletion runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,17 @@ impl pallet_offences::Config for Runtime {
type OnOffenceHandler = Staking;
}

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 @@ -1375,6 +1386,14 @@ construct_runtime! {
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>} = 11,
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config} = 12,

// Old, deprecated governance pallets. Here purely so storage can be migrated.
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, Event<T>} = 18,
ConvictionVoting: pallet_conviction_voting::{Pallet, Call, Storage, Event<T>} = 20,
Expand Down Expand Up @@ -1499,6 +1518,16 @@ impl Get<Perbill> for NominationPoolsMigrationV4OldPallet {
}
}

// Gov V1 pallets pending storage removal using the frame_support RemovePallet migration.
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 Down Expand Up @@ -1529,6 +1558,23 @@ pub mod migrations {
/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
SetStorageVersions,

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_all_funds::UnreserveAllFunds<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 when the pallets are removed from the runtime.
// 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>,

// Remove UMP dispatch queue <https://github.com/paritytech/polkadot/pull/6271>
parachains_configuration::migration::v6::MigrateToV6<Runtime>,
ump_migrations::UpdateUmpLimits,
Expand All @@ -1552,7 +1598,32 @@ pub mod migrations {
StorageVersion::new(1).put::<Historical>();
}

RocksDbWeight::get().reads_writes(2, 2)
let storage_version = Democracy::on_chain_storage_version();
if storage_version < 1 {
StorageVersion::new(1).put::<Democracy>();
}

let storage_version = Council::on_chain_storage_version();
if storage_version < 4 {
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
StorageVersion::new(4).put::<Council>();
}

let storage_version = TechnicalCommittee::on_chain_storage_version();
if storage_version < 4 {
StorageVersion::new(4).put::<TechnicalCommittee>();
}

let storage_version = PhragmenElection::on_chain_storage_version();
if storage_version < 4 {
StorageVersion::new(4).put::<PhragmenElection>();
}

let storage_version = TechnicalMembership::on_chain_storage_version();
if storage_version < 4 {
StorageVersion::new(4).put::<TechnicalMembership>();
}

RocksDbWeight::get().reads_writes(7, 7)
}
}
}
Expand Down