Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduces Governance v2 in Moonbase Alpha #1838

Merged
merged 16 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
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
57 changes: 55 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions runtime/moonbase/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ frame-system-rpc-runtime-api = { git = "https://github.com/purestake/substrate",
pallet-assets = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-balances = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-collective = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-conviction-voting = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-democracy = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-identity = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-preimage = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-proxy = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-randomness-collective-flip = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-referenda = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-scheduler = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-society = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-sudo = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
Expand All @@ -82,6 +85,7 @@ pallet-transaction-payment = { git = "https://github.com/purestake/substrate", b
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-treasury = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-utility = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
pallet-whitelist = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
parity-scale-codec = { version = "3.0.0", default-features = false, features = [ "derive", "max-encoded-len" ] }
scale-info = { version = "2.0", default-features = false, features = [ "derive" ] }
sp-api = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.29", default-features = false }
Expand Down Expand Up @@ -190,6 +194,7 @@ std = [
"pallet-balances/std",
"pallet-base-fee/std",
"pallet-collective/std",
"pallet-conviction-voting/std",
"pallet-crowdloan-rewards/std",
"pallet-democracy/std",
"pallet-ethereum-chain-id/std",
Expand All @@ -213,10 +218,12 @@ std = [
"pallet-migrations/std",
"pallet-moonbeam-orbiters/std",
"pallet-parachain-staking/std",
"pallet-preimage/std",
"pallet-proxy-genesis-companion/std",
"pallet-proxy/std",
"pallet-randomness-collective-flip/std",
"pallet-randomness/std",
"pallet-referenda/std",
"pallet-scheduler/std",
"pallet-society/std",
"pallet-sudo/std",
Expand All @@ -225,6 +232,7 @@ std = [
"pallet-transaction-payment/std",
"pallet-treasury/std",
"pallet-utility/std",
"pallet-whitelist/std",
"pallet-xcm-transactor/std",
"pallet-xcm/std",
"parachain-info/std",
Expand Down Expand Up @@ -277,12 +285,15 @@ runtime-benchmarks = [
"pallet-author-slot-filter/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-conviction-voting/runtime-benchmarks",
"pallet-crowdloan-rewards/runtime-benchmarks",
"pallet-ethereum-xcm/runtime-benchmarks",
"pallet-ethereum/runtime-benchmarks",
"pallet-moonbeam-orbiters/runtime-benchmarks",
"pallet-parachain-staking/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-randomness/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
"pallet-society/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-xcm-transactor/runtime-benchmarks",
Expand All @@ -301,11 +312,14 @@ try-runtime = [
"pallet-author-slot-filter/try-runtime",
"pallet-balances/try-runtime",
"pallet-collective/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-maintenance-mode/try-runtime",
#"pallet-crowdloan-rewards/try-runtime",
"pallet-maintenance-mode/try-runtime",
"pallet-migrations/try-runtime",
"pallet-parachain-staking/try-runtime",
"pallet-preimage/try-runtime",
"pallet-referenda/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-society/try-runtime",
"pallet-timestamp/try-runtime",
Expand Down
68 changes: 68 additions & 0 deletions runtime/moonbase/src/governance/councils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright 2019-2022 PureStake Inc.
// This file is part of Moonbeam.

// Moonbeam 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.

// Moonbeam 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 Moonbeam. If not, see <http://www.gnu.org/licenses/>.

//! Councils for Gov1

use super::*;

pub type CouncilInstance = pallet_collective::Instance1;
pub type TechCommitteeInstance = pallet_collective::Instance2;
pub type TreasuryCouncilInstance = pallet_collective::Instance3;

impl pallet_collective::Config<CouncilInstance> for Runtime {
type Origin = Origin;
type Event = Event;
type Proposal = Call;
/// The maximum amount of time (in blocks) for council members to vote on motions.
/// Motions may end in fewer blocks if enough votes are cast to determine the result.
type MotionDuration = ConstU32<{ 3 * DAYS }>;
/// The maximum number of proposals that can be open in the council at once.
type MaxProposals = ConstU32<100>;
/// The maximum number of council members.
type MaxMembers = ConstU32<100>;
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
}

impl pallet_collective::Config<TechCommitteeInstance> for Runtime {
type Origin = Origin;
type Event = Event;
type Proposal = Call;
/// The maximum amount of time (in blocks) for technical committee members to vote on motions.
/// Motions may end in fewer blocks if enough votes are cast to determine the result.
type MotionDuration = ConstU32<{ 3 * DAYS }>;
/// The maximum number of proposals that can be open in the technical committee at once.
type MaxProposals = ConstU32<100>;
/// The maximum number of technical committee members.
type MaxMembers = ConstU32<100>;
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
}

impl pallet_collective::Config<TreasuryCouncilInstance> for Runtime {
type Origin = Origin;
type Event = Event;
type Proposal = Call;
/// The maximum amount of time (in blocks) for treasury council members to vote on motions.
/// Motions may end in fewer blocks if enough votes are cast to determine the result.
type MotionDuration = ConstU32<{ 3 * DAYS }>;
/// The maximum number of proposals that can be open in the treasury council at once.
type MaxProposals = ConstU32<20>;
/// The maximum number of treasury council members.
type MaxMembers = ConstU32<9>;
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
}
75 changes: 75 additions & 0 deletions runtime/moonbase/src/governance/democracy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright 2019-2022 PureStake Inc.
// This file is part of Moonbeam.

// Moonbeam 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.

// Moonbeam 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 Moonbeam. If not, see <http://www.gnu.org/licenses/>.

//! Democracy config for Gov1

use super::councils::*;
use crate::*;

// The purpose of this offset is to ensure that a democratic proposal will not apply in the same
// block as a round change.
const ENACTMENT_OFFSET: u32 = 300;

impl pallet_democracy::Config for Runtime {
type Proposal = Call;
type Event = Event;
type Currency = Balances;
type EnactmentPeriod = ConstU32<{ 1 * DAYS + ENACTMENT_OFFSET }>;
type LaunchPeriod = ConstU32<{ 1 * DAYS }>;
type VotingPeriod = ConstU32<{ 5 * DAYS }>;
type VoteLockingPeriod = ConstU32<{ 1 * DAYS }>;
type FastTrackVotingPeriod = ConstU32<{ 4 * HOURS }>;
type MinimumDeposit = ConstU128<{ 4 * currency::UNIT * currency::SUPPLY_FACTOR }>;
/// To decide what their next motion is.
type ExternalOrigin =
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilInstance, 1, 2>;
/// To have the next scheduled referendum be a straight majority-carries vote.
type ExternalMajorityOrigin =
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilInstance, 3, 5>;
/// To have the next scheduled referendum be a straight default-carries (NTB) vote.
type ExternalDefaultOrigin =
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilInstance, 3, 5>;
/// To allow a shorter voting/enactment period for external proposals.
type FastTrackOrigin =
pallet_collective::EnsureProportionAtLeast<AccountId, TechCommitteeInstance, 1, 2>;
/// To instant fast track.
type InstantOrigin =
pallet_collective::EnsureProportionAtLeast<AccountId, TechCommitteeInstance, 3, 5>;
// To cancel a proposal which has been passed.
type CancellationOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilInstance, 3, 5>,
>;
// To cancel a proposal before it has been passed.
type CancelProposalOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, TechCommitteeInstance, 3, 5>,
>;
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, TechCommitteeInstance>;
type CooloffPeriod = ConstU32<{ 7 * DAYS }>;
type PreimageByteDeposit = ConstU128<{ currency::STORAGE_BYTE_FEE }>;
type Slash = ();
type InstantAllowed = ConstBool<true>;
type Scheduler = Scheduler;
type MaxVotes = ConstU32<100>;
type OperationalPreimageOrigin = pallet_collective::EnsureMember<AccountId, CouncilInstance>;
type PalletsOrigin = OriginCaller;
type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
type MaxProposals = ConstU32<100>;
}
30 changes: 30 additions & 0 deletions runtime/moonbase/src/governance/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2019-2022 PureStake Inc.
// This file is part of Moonbeam.

// Moonbeam 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.

// Moonbeam 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 Moonbeam. If not, see <http://www.gnu.org/licenses/>.

//! Governance configurations

pub mod councils;
mod democracy;
pub mod referenda;

use super::*;

mod origins;
pub use origins::{
pallet_custom_origins, ReferendumCanceller, ReferendumKiller, Spender, WhitelistedCaller,
};
mod tracks;
pub use tracks::TracksInfo;
Loading