This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Governance 2 (Part 1, Non-Controversial Changes) #5892
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// 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/>. | ||
|
||
//! Governance configurations for the Kusama runtime. | ||
|
||
// Old governance configurations. | ||
pub mod old; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
// Copyright 2022 Parity Technologies (UK) Ltd. | ||
// This file is part of Polkadot. | ||
|
||
// Polkadot is free software: you can redistribute it and/or modify | ||
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is exactly copy and paste from the existing runtime configuration. |
||
// 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}; | ||
|
||
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; | ||
} | ||
|
||
impl pallet_democracy::Config for Runtime { | ||
type Proposal = Call; | ||
type Event = Event; | ||
type Currency = Balances; | ||
type EnactmentPeriod = EnactmentPeriod; | ||
type VoteLockingPeriod = EnactmentPeriod; | ||
type LaunchPeriod = LaunchPeriod; | ||
type VotingPeriod = VotingPeriod; | ||
type MinimumDeposit = MinimumDeposit; | ||
/// 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>, | ||
>; | ||
// 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 PreimageByteDeposit = PreimageByteDeposit; | ||
type OperationalPreimageOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>; | ||
type Slash = Treasury; | ||
type Scheduler = Scheduler; | ||
type PalletsOrigin = OriginCaller; | ||
type MaxVotes = MaxVotes; | ||
type WeightInfo = weights::pallet_democracy::WeightInfo<Runtime>; | ||
type MaxProposals = MaxProposals; | ||
} | ||
|
||
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 Origin = Origin; | ||
type Proposal = Call; | ||
type Event = Event; | ||
type MotionDuration = CouncilMotionDuration; | ||
type MaxProposals = CouncilMaxProposals; | ||
type MaxMembers = CouncilMaxMembers; | ||
type DefaultVote = pallet_collective::PrimeDefaultVote; | ||
type WeightInfo = weights::pallet_collective_council::WeightInfo<Runtime>; | ||
} | ||
|
||
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 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 Event = Event; | ||
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 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 Origin = Origin; | ||
type Proposal = Call; | ||
type Event = Event; | ||
type MotionDuration = TechnicalMotionDuration; | ||
type MaxProposals = TechnicalMaxProposals; | ||
type MaxMembers = TechnicalMaxMembers; | ||
type DefaultVote = pallet_collective::PrimeDefaultVote; | ||
type WeightInfo = weights::pallet_collective_technical_committee::WeightInfo<Runtime>; | ||
} | ||
|
||
impl pallet_membership::Config<pallet_membership::Instance1> for Runtime { | ||
type Event = Event; | ||
type AddOrigin = MoreThanHalfCouncil; | ||
type RemoveOrigin = MoreThanHalfCouncil; | ||
type SwapOrigin = MoreThanHalfCouncil; | ||
type ResetOrigin = MoreThanHalfCouncil; | ||
type PrimeOrigin = MoreThanHalfCouncil; | ||
type MembershipInitialized = TechnicalCommittee; | ||
type MembershipChanged = TechnicalCommittee; | ||
type MaxMembers = TechnicalMaxMembers; | ||
type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here it is again without try?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is
try_successful_origin
andsuccessful_origin
, which is automatically implemented astry_successful_origin().unwrap()
.In this case, we need the successful origin