mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-08 22:58:00 +00:00
migration: unlock/unreserve Gov v1 balances and remove kvs (#7314)
* restore old gov configs * migrate old gov v1 storage * exclude the Call enum for gov v1 pallets * update substrate * update tips pallet * update chain_spec * fix migrations tuple * oliver comments * format comment * ".git/.scripts/commands/fmt/fmt.sh" * comments * polkadot migrations * fix cargo.lock * fix compilation * use democracy standalone migration * re-remove gov v1 pallets from kusama * remove unnecessary feature * fix unlock configs * use substrate master * reset cargo.lock * cargo update -p sp-io * remove from chainspec * remove polkadot gov v1 pallets * clean up chain spec * cargo fmt * remove old gov import --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -1284,14 +1284,6 @@ pub fn polkadot_testnet_genesis(
|
||||
slash_reward_fraction: Perbill::from_percent(10),
|
||||
..Default::default()
|
||||
},
|
||||
phragmen_election: Default::default(),
|
||||
democracy: polkadot::DemocracyConfig::default(),
|
||||
council: polkadot::CouncilConfig { members: vec![], phantom: Default::default() },
|
||||
technical_committee: polkadot::TechnicalCommitteeConfig {
|
||||
members: vec![],
|
||||
phantom: Default::default(),
|
||||
},
|
||||
technical_membership: Default::default(),
|
||||
babe: polkadot::BabeConfig {
|
||||
authorities: Default::default(),
|
||||
epoch_config: Some(polkadot::BABE_GENESIS_EPOCH_CONFIG),
|
||||
|
||||
@@ -1533,6 +1533,51 @@ pub type Migrations = (migrations::Unreleased,);
|
||||
#[allow(deprecated, missing_docs)]
|
||||
pub mod migrations {
|
||||
use super::*;
|
||||
use frame_support::traits::LockIdentifier;
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
|
||||
parameter_types! {
|
||||
pub const DemocracyPalletName: &'static str = "Democracy";
|
||||
pub const CouncilPalletName: &'static str = "Council";
|
||||
pub const TechnicalCommitteePalletName: &'static str = "TechnicalCommittee";
|
||||
pub const PhragmenElectionPalletName: &'static str = "PhragmenElection";
|
||||
pub const TechnicalMembershipPalletName: &'static str = "TechnicalMembership";
|
||||
pub const TipsPalletName: &'static str = "Tips";
|
||||
pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect";
|
||||
}
|
||||
|
||||
// Special Config for Gov V1 pallets, allowing us to run migrations for them without
|
||||
// implementing their configs on [`Runtime`].
|
||||
pub struct UnlockConfig;
|
||||
impl pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockConfig for UnlockConfig {
|
||||
type Currency = Balances;
|
||||
type MaxVotes = ConstU32<100>;
|
||||
type MaxDeposits = ConstU32<100>;
|
||||
type AccountId = AccountId;
|
||||
type BlockNumber = BlockNumberFor<Runtime>;
|
||||
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
|
||||
type PalletName = DemocracyPalletName;
|
||||
}
|
||||
impl pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockConfig
|
||||
for UnlockConfig
|
||||
{
|
||||
type Currency = Balances;
|
||||
type MaxVotesPerVoter = ConstU32<16>;
|
||||
type PalletId = PhragmenElectionPalletId;
|
||||
type AccountId = AccountId;
|
||||
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
|
||||
type PalletName = PhragmenElectionPalletName;
|
||||
}
|
||||
impl pallet_tips::migrations::unreserve_deposits::UnlockConfig<()> for UnlockConfig {
|
||||
type Currency = Balances;
|
||||
type Hash = Hash;
|
||||
type DataDepositPerByte = DataDepositPerByte;
|
||||
type TipReportDepositBase = TipReportDepositBase;
|
||||
type AccountId = AccountId;
|
||||
type BlockNumber = BlockNumberFor<Runtime>;
|
||||
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
|
||||
type PalletName = TipsPalletName;
|
||||
}
|
||||
|
||||
/// Unreleased migrations. Add new ones here:
|
||||
pub type Unreleased = (
|
||||
@@ -1546,6 +1591,21 @@ pub mod migrations {
|
||||
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
|
||||
parachains_scheduler::migration::v1::MigrateToV1<Runtime>,
|
||||
parachains_configuration::migration::v8::MigrateToV8<Runtime>,
|
||||
|
||||
// Unlock/unreserve balances from Gov v1 pallets that hold them
|
||||
// https://github.com/paritytech/polkadot/issues/6749
|
||||
pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
|
||||
pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
|
||||
pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<UnlockConfig, ()>,
|
||||
|
||||
// Delete storage key/values from all Gov v1 pallets
|
||||
frame_support::migrations::RemovePallet<DemocracyPalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
frame_support::migrations::RemovePallet<CouncilPalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
frame_support::migrations::RemovePallet<TechnicalCommitteePalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
frame_support::migrations::RemovePallet<PhragmenElectionPalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
frame_support::migrations::RemovePallet<TechnicalMembershipPalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
frame_support::migrations::RemovePallet<TipsPalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,6 @@ use frame_system::EnsureRootWithSuccess;
|
||||
use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
|
||||
use xcm::latest::BodyId;
|
||||
|
||||
// Old governance configurations.
|
||||
pub mod old;
|
||||
|
||||
mod origins;
|
||||
pub use origins::{
|
||||
pallet_custom_origins, AuctionAdmin, FellowshipAdmin, GeneralAdmin, LeaseAdmin,
|
||||
|
||||
@@ -1,191 +0,0 @@
|
||||
// Copyright (C) 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 Polkadot runtime.
|
||||
|
||||
use crate::*;
|
||||
use frame_support::{parameter_types, traits::EitherOfDiverse};
|
||||
|
||||
parameter_types! {
|
||||
pub LaunchPeriod: BlockNumber = prod_or_fast!(28 * DAYS, 1, "DOT_LAUNCH_PERIOD");
|
||||
pub VotingPeriod: BlockNumber = prod_or_fast!(28 * DAYS, 1 * MINUTES, "DOT_VOTING_PERIOD");
|
||||
pub FastTrackVotingPeriod: BlockNumber = prod_or_fast!(3 * HOURS, 1 * MINUTES, "DOT_FAST_TRACK_VOTING_PERIOD");
|
||||
pub const MinimumDeposit: Balance = 100 * DOLLARS;
|
||||
pub EnactmentPeriod: BlockNumber = prod_or_fast!(28 * DAYS, 1, "DOT_ENACTMENT_PERIOD");
|
||||
pub CooloffPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1, "DOT_COOLOFF_PERIOD");
|
||||
pub const InstantAllowed: bool = true;
|
||||
pub const MaxVotes: u32 = 100;
|
||||
pub const MaxProposals: u32 = 100;
|
||||
}
|
||||
|
||||
impl pallet_democracy::Config for Runtime {
|
||||
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 = EitherOfDiverse<
|
||||
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>,
|
||||
frame_system::EnsureRoot<AccountId>,
|
||||
>;
|
||||
/// A 60% super-majority can have the next scheduled referendum be a straight majority-carries
|
||||
/// vote.
|
||||
type ExternalMajorityOrigin = EitherOfDiverse<
|
||||
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 5>,
|
||||
frame_system::EnsureRoot<AccountId>,
|
||||
>;
|
||||
/// A unanimous council can have the next scheduled referendum be a straight default-carries
|
||||
/// (NTB) vote.
|
||||
type ExternalDefaultOrigin = EitherOfDiverse<
|
||||
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>,
|
||||
frame_system::EnsureRoot<AccountId>,
|
||||
>;
|
||||
/// Two thirds of the technical committee can have an `ExternalMajority/ExternalDefault` vote
|
||||
/// be tabled immediately and with a shorter voting/enactment period.
|
||||
type FastTrackOrigin = EitherOfDiverse<
|
||||
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 2, 3>,
|
||||
frame_system::EnsureRoot<AccountId>,
|
||||
>;
|
||||
type InstantOrigin = EitherOfDiverse<
|
||||
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>,
|
||||
frame_system::EnsureRoot<AccountId>,
|
||||
>;
|
||||
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<
|
||||
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>,
|
||||
EnsureRoot<AccountId>,
|
||||
>;
|
||||
// To cancel a proposal before it has been passed, the technical committee must be unanimous or
|
||||
// Root must agree.
|
||||
type CancelProposalOrigin = EitherOfDiverse<
|
||||
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>,
|
||||
EnsureRoot<AccountId>,
|
||||
>;
|
||||
type BlacklistOrigin = EnsureRoot<AccountId>;
|
||||
// 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!(7 * DAYS, 2 * MINUTES, "DOT_MOTION_DURATION");
|
||||
pub const CouncilMaxProposals: u32 = 100;
|
||||
pub const CouncilMaxMembers: u32 = 100;
|
||||
pub MaxProposalWeight: Weight = Perbill::from_percent(50) * BlockWeights::get().max_block;
|
||||
}
|
||||
|
||||
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 * DOLLARS;
|
||||
// 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);
|
||||
/// Weekly council elections; scaling up to monthly eventually.
|
||||
pub TermDuration: BlockNumber = prod_or_fast!(7 * DAYS, 2 * MINUTES, "DOT_TERM_DURATION");
|
||||
/// 13 members initially, to be increased to 23 eventually.
|
||||
pub const DesiredMembers: u32 = 13;
|
||||
pub const DesiredRunnersUp: u32 = 20;
|
||||
pub const MaxVoters: u32 = 10 * 1000;
|
||||
pub const MaxVotesPerVoter: u32 = 16;
|
||||
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 PalletId = PhragmenElectionPalletId;
|
||||
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 MaxVotesPerVoter = MaxVotesPerVoter;
|
||||
type MaxCandidates = MaxCandidates;
|
||||
type WeightInfo = weights::pallet_elections_phragmen::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const TechnicalMotionDuration: BlockNumber = 7 * DAYS;
|
||||
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>;
|
||||
}
|
||||
@@ -47,8 +47,8 @@ use frame_election_provider_support::{
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{
|
||||
ConstU32, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, LockIdentifier,
|
||||
PrivilegeCmp, ProcessMessage, ProcessMessageError, WithdrawReasons,
|
||||
ConstU32, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, PrivilegeCmp,
|
||||
ProcessMessage, ProcessMessageError, WithdrawReasons,
|
||||
},
|
||||
weights::{ConstantMultiplier, WeightMeter},
|
||||
PalletId, RuntimeDebug,
|
||||
@@ -85,7 +85,6 @@ use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use sp_version::NativeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
use static_assertions::const_assert;
|
||||
use xcm::latest::Junction;
|
||||
|
||||
pub use frame_system::Call as SystemCall;
|
||||
@@ -202,11 +201,6 @@ impl PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
|
||||
match (left, right) {
|
||||
// Root is greater than anything.
|
||||
(OriginCaller::system(frame_system::RawOrigin::Root), _) => Some(Ordering::Greater),
|
||||
// Check which one has more yes votes.
|
||||
(
|
||||
OriginCaller::Council(pallet_collective::RawOrigin::Members(l_yes_votes, l_count)),
|
||||
OriginCaller::Council(pallet_collective::RawOrigin::Members(r_yes_votes, r_count)),
|
||||
) => Some((l_yes_votes * r_count).cmp(&(r_yes_votes * l_count))),
|
||||
// For every other origin we don't care, as they are not used for `ScheduleOrigin`.
|
||||
_ => None,
|
||||
}
|
||||
@@ -718,17 +712,6 @@ impl pallet_child_bounties::Config for Runtime {
|
||||
type WeightInfo = weights::pallet_child_bounties::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
impl pallet_tips::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type DataDepositPerByte = DataDepositPerByte;
|
||||
type MaximumReasonLength = MaximumReasonLength;
|
||||
type Tippers = PhragmenElection;
|
||||
type TipCountdown = TipCountdown;
|
||||
type TipFindersFee = TipFindersFee;
|
||||
type TipReportDepositBase = TipReportDepositBase;
|
||||
type WeightInfo = weights::pallet_tips::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
impl pallet_offences::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
|
||||
@@ -988,15 +971,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
|
||||
RuntimeCall::Session(..) |
|
||||
RuntimeCall::Grandpa(..) |
|
||||
RuntimeCall::ImOnline(..) |
|
||||
RuntimeCall::Democracy(..) |
|
||||
RuntimeCall::Council(..) |
|
||||
RuntimeCall::TechnicalCommittee(..) |
|
||||
RuntimeCall::PhragmenElection(..) |
|
||||
RuntimeCall::TechnicalMembership(..) |
|
||||
RuntimeCall::Treasury(..) |
|
||||
RuntimeCall::Bounties(..) |
|
||||
RuntimeCall::ChildBounties(..) |
|
||||
RuntimeCall::Tips(..) |
|
||||
RuntimeCall::ConvictionVoting(..) |
|
||||
RuntimeCall::Referenda(..) |
|
||||
RuntimeCall::Whitelist(..) |
|
||||
@@ -1019,20 +996,16 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
|
||||
RuntimeCall::NominationPools(..) |
|
||||
RuntimeCall::FastUnstake(..)
|
||||
),
|
||||
ProxyType::Governance =>
|
||||
matches!(
|
||||
c,
|
||||
RuntimeCall::Democracy(..) |
|
||||
RuntimeCall::Council(..) | RuntimeCall::TechnicalCommittee(..) |
|
||||
RuntimeCall::PhragmenElection(..) |
|
||||
RuntimeCall::Treasury(..) |
|
||||
RuntimeCall::Bounties(..) |
|
||||
RuntimeCall::Tips(..) | RuntimeCall::Utility(..) |
|
||||
RuntimeCall::ChildBounties(..) |
|
||||
RuntimeCall::ConvictionVoting(..) |
|
||||
RuntimeCall::Referenda(..) |
|
||||
RuntimeCall::Whitelist(..)
|
||||
),
|
||||
ProxyType::Governance => matches!(
|
||||
c,
|
||||
RuntimeCall::Treasury(..) |
|
||||
RuntimeCall::Bounties(..) |
|
||||
RuntimeCall::Utility(..) |
|
||||
RuntimeCall::ChildBounties(..) |
|
||||
RuntimeCall::ConvictionVoting(..) |
|
||||
RuntimeCall::Referenda(..) |
|
||||
RuntimeCall::Whitelist(..)
|
||||
),
|
||||
ProxyType::Staking => {
|
||||
matches!(
|
||||
c,
|
||||
@@ -1375,15 +1348,8 @@ construct_runtime! {
|
||||
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>} = 12,
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config<T>} = 13,
|
||||
|
||||
// Old governance stuff.
|
||||
Democracy: pallet_democracy::{Pallet, Call, Storage, Config<T>, Event<T>} = 14,
|
||||
Council: pallet_collective::<Instance1>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 15,
|
||||
TechnicalCommittee: pallet_collective::<Instance2>::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 16,
|
||||
PhragmenElection: pallet_elections_phragmen::{Pallet, Call, Storage, Event<T>, Config<T>} = 17,
|
||||
TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>} = 18,
|
||||
Treasury: pallet_treasury::{Pallet, Call, Storage, Config<T>, Event<T>} = 19,
|
||||
|
||||
// OpenGov stuff.
|
||||
Treasury: pallet_treasury::{Pallet, Call, Storage, Config<T>, Event<T>} = 19,
|
||||
ConvictionVoting: pallet_conviction_voting::{Pallet, Call, Storage, Event<T>} = 20,
|
||||
Referenda: pallet_referenda::{Pallet, Call, Storage, Event<T>} = 21,
|
||||
Origins: pallet_custom_origins::{Origin} = 22,
|
||||
@@ -1409,9 +1375,6 @@ construct_runtime! {
|
||||
Bounties: pallet_bounties::{Pallet, Call, Storage, Event<T>} = 34,
|
||||
ChildBounties: pallet_child_bounties = 38,
|
||||
|
||||
// Tips module.
|
||||
Tips: pallet_tips::{Pallet, Call, Storage, Event<T>} = 35,
|
||||
|
||||
// Election pallet. Only works with staking, but placed here to maintain indices.
|
||||
ElectionProviderMultiPhase: pallet_election_provider_multi_phase::{Pallet, Call, Storage, Event<T>, ValidateUnsigned} = 36,
|
||||
|
||||
@@ -1495,6 +1458,51 @@ pub type Migrations = migrations::Unreleased;
|
||||
#[allow(deprecated, missing_docs)]
|
||||
pub mod migrations {
|
||||
use super::*;
|
||||
use frame_support::traits::LockIdentifier;
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
|
||||
parameter_types! {
|
||||
pub const DemocracyPalletName: &'static str = "Democracy";
|
||||
pub const CouncilPalletName: &'static str = "Council";
|
||||
pub const TechnicalCommitteePalletName: &'static str = "TechnicalCommittee";
|
||||
pub const PhragmenElectionPalletName: &'static str = "PhragmenElection";
|
||||
pub const TechnicalMembershipPalletName: &'static str = "TechnicalMembership";
|
||||
pub const TipsPalletName: &'static str = "Tips";
|
||||
pub const PhragmenElectionPalletId: LockIdentifier = *b"phrelect";
|
||||
}
|
||||
|
||||
// Special Config for Gov V1 pallets, allowing us to run migrations for them without
|
||||
// implementing their configs on [`Runtime`].
|
||||
pub struct UnlockConfig;
|
||||
impl pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockConfig for UnlockConfig {
|
||||
type Currency = Balances;
|
||||
type MaxVotes = ConstU32<100>;
|
||||
type MaxDeposits = ConstU32<100>;
|
||||
type AccountId = AccountId;
|
||||
type BlockNumber = BlockNumberFor<Runtime>;
|
||||
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
|
||||
type PalletName = DemocracyPalletName;
|
||||
}
|
||||
impl pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockConfig
|
||||
for UnlockConfig
|
||||
{
|
||||
type Currency = Balances;
|
||||
type MaxVotesPerVoter = ConstU32<16>;
|
||||
type PalletId = PhragmenElectionPalletId;
|
||||
type AccountId = AccountId;
|
||||
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
|
||||
type PalletName = PhragmenElectionPalletName;
|
||||
}
|
||||
impl pallet_tips::migrations::unreserve_deposits::UnlockConfig<()> for UnlockConfig {
|
||||
type Currency = Balances;
|
||||
type Hash = Hash;
|
||||
type DataDepositPerByte = DataDepositPerByte;
|
||||
type TipReportDepositBase = TipReportDepositBase;
|
||||
type AccountId = AccountId;
|
||||
type BlockNumber = BlockNumberFor<Runtime>;
|
||||
type DbWeight = <Runtime as frame_system::Config>::DbWeight;
|
||||
type PalletName = TipsPalletName;
|
||||
}
|
||||
|
||||
/// Unreleased migrations. Add new ones here:
|
||||
pub type Unreleased = (
|
||||
@@ -1502,6 +1510,20 @@ pub mod migrations {
|
||||
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
|
||||
parachains_scheduler::migration::v1::MigrateToV1<Runtime>,
|
||||
parachains_configuration::migration::v8::MigrateToV8<Runtime>,
|
||||
|
||||
// Gov v1 storage migrations
|
||||
// https://github.com/paritytech/polkadot/issues/6749
|
||||
pallet_elections_phragmen::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
|
||||
pallet_democracy::migrations::unlock_and_unreserve_all_funds::UnlockAndUnreserveAllFunds<UnlockConfig>,
|
||||
pallet_tips::migrations::unreserve_deposits::UnreserveDeposits<UnlockConfig, ()>,
|
||||
|
||||
// Delete all Gov v1 pallet storage key/values.
|
||||
frame_support::migrations::RemovePallet<DemocracyPalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
frame_support::migrations::RemovePallet<CouncilPalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
frame_support::migrations::RemovePallet<TechnicalCommitteePalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
frame_support::migrations::RemovePallet<PhragmenElectionPalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
frame_support::migrations::RemovePallet<TechnicalMembershipPalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
frame_support::migrations::RemovePallet<TipsPalletName, <Runtime as frame_system::Config>::DbWeight>,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1546,17 +1568,12 @@ mod benches {
|
||||
[frame_benchmarking::baseline, Baseline::<Runtime>]
|
||||
[pallet_bounties, Bounties]
|
||||
[pallet_child_bounties, ChildBounties]
|
||||
[pallet_collective, Council]
|
||||
[pallet_collective, TechnicalCommittee]
|
||||
[pallet_democracy, Democracy]
|
||||
[pallet_elections_phragmen, PhragmenElection]
|
||||
[pallet_election_provider_multi_phase, ElectionProviderMultiPhase]
|
||||
[frame_election_provider_support, ElectionProviderBench::<Runtime>]
|
||||
[pallet_fast_unstake, FastUnstake]
|
||||
[pallet_identity, Identity]
|
||||
[pallet_im_online, ImOnline]
|
||||
[pallet_indices, Indices]
|
||||
[pallet_membership, TechnicalMembership]
|
||||
[pallet_message_queue, MessageQueue]
|
||||
[pallet_multisig, Multisig]
|
||||
[pallet_nomination_pools, NominationPoolsBench::<Runtime>]
|
||||
@@ -1568,7 +1585,6 @@ mod benches {
|
||||
[pallet_staking, Staking]
|
||||
[frame_system, SystemBench::<Runtime>]
|
||||
[pallet_timestamp, Timestamp]
|
||||
[pallet_tips, Tips]
|
||||
[pallet_treasury, Treasury]
|
||||
[pallet_utility, Utility]
|
||||
[pallet_vesting, Vesting]
|
||||
@@ -2181,7 +2197,6 @@ sp_api::impl_runtime_apis! {
|
||||
#[cfg(test)]
|
||||
mod test_fees {
|
||||
use super::*;
|
||||
use crate::governance::old::*;
|
||||
use frame_support::{dispatch::GetDispatchInfo, weights::WeightToFee as WeightToFeeT};
|
||||
use keyring::Sr25519Keyring::{Alice, Charlie};
|
||||
use pallet_transaction_payment::Multiplier;
|
||||
@@ -2282,40 +2297,6 @@ mod test_fees {
|
||||
test_with_multiplier(Multiplier::saturating_from_rational(1u128, 1_000_000_000u128));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn full_block_council_election_cost() {
|
||||
// the number of voters needed to consume almost a full block in council election, and how
|
||||
// much it is going to cost.
|
||||
use pallet_elections_phragmen::WeightInfo;
|
||||
|
||||
// Loser candidate lose a lot of money; sybil attack by candidates is even more expensive,
|
||||
// and we don't care about it here. For now, we assume no extra candidates, and only
|
||||
// superfluous voters.
|
||||
let candidates = DesiredMembers::get() + DesiredRunnersUp::get();
|
||||
let mut voters = 1u32;
|
||||
let weight_with = |v| {
|
||||
<Runtime as pallet_elections_phragmen::Config>::WeightInfo::election_phragmen(
|
||||
candidates,
|
||||
v,
|
||||
v * 16,
|
||||
)
|
||||
};
|
||||
|
||||
while weight_with(voters).all_lte(BlockWeights::get().max_block) {
|
||||
voters += 1;
|
||||
}
|
||||
|
||||
let cost = voters as Balance * (VotingBondBase::get() + 16 * VotingBondFactor::get());
|
||||
let cost_dollars = cost / DOLLARS;
|
||||
println!(
|
||||
"can support {} voters in a single block for council elections; total bond {}",
|
||||
voters, cost_dollars,
|
||||
);
|
||||
// The minimal number of voters we expect per block.
|
||||
assert!(voters >= 1_000);
|
||||
assert!(cost_dollars >= 10_000);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nominator_limit() {
|
||||
use pallet_election_provider_multi_phase::WeightInfo;
|
||||
|
||||
Reference in New Issue
Block a user