Skip to content

Commit

Permalink
Adds Governance v2 (moonbase only) (moonbeam-foundation#1838)
Browse files Browse the repository at this point in the history
* move democracy to old and councils to own file until decided how to migrate councils

* fix

* Gov2 (moonbeam-foundation#1839)

* gov2 config init with whitelist origin configured with tech committee 2 of 3

* test

* clean

* fix and docs

* fix

* try fix

* try fix

* fix and clean

* fix

* fix test and add curve docs above curves

* revert accidental change

* give power to Treasurer and rename GeneralAdmin to IdentityAdmin

* finish rename of general admin to identity admin as it only manages the identity registrar

* accept suggestion to use SUPPLY FACTOR in Spender definition

* use supply factor for all currency

* fix import

* Playing with tracks values

* fix build and update tracks curve evolution gist

* update track curve format

* improve

* Configure referendum tracks

Co-authored-by: Crystalin <alan@purestake.com>
  • Loading branch information
2 people authored and imstar15 committed May 16, 2023
1 parent 79ed43f commit cb4973f
Show file tree
Hide file tree
Showing 9 changed files with 684 additions and 104 deletions.
49 changes: 49 additions & 0 deletions Cargo.lock

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

10 changes: 10 additions & 0 deletions runtime/moonbase/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,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 @@ -215,10 +216,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 @@ -227,6 +230,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 @@ -280,12 +284,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-benchmarks",
Expand All @@ -305,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

0 comments on commit cb4973f

Please sign in to comment.