diff --git a/Cargo.lock b/Cargo.lock index 05c22d9f09..75ddac3458 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6656,14 +6656,17 @@ dependencies = [ "orml-traits", "pallet-asset-index", "pallet-chainlink-feed", + "pallet-collective", "pallet-committee", "pallet-local-treasury", + "pallet-membership", "pallet-price-feed", "pallet-remote-asset-manager", "pallet-saft-registry", "parity-scale-codec", "primitives", "scale-info", + "sp-core", "sp-std", "xcm", "xcm-calls", @@ -6707,7 +6710,9 @@ dependencies = [ "pallet-collator-selection", "pallet-collective", "pallet-committee", + "pallet-democracy", "pallet-local-treasury", + "pallet-membership", "pallet-price-feed", "pallet-randomness-collective-flip", "pallet-remote-asset-manager", @@ -6718,6 +6723,7 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", "pallet-xcm", "parachain-info", "parity-scale-codec", diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 31a0cc3e92..931f5ef0da 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -14,6 +14,11 @@ scale-info = { version = "1.0", default-features = false, features = ["derive"] frame-support = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } frame-system = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } sp-std = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } +sp-core = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } + +pallet-collective = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } +pallet-membership = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } + # xcm xcm = { git = 'https://github.com/paritytech/polkadot', branch = 'release-v0.9.12', default-features = false } @@ -43,7 +48,10 @@ std = [ "frame-support/std", 'frame-system/std', 'sp-std/std', + 'sp-core/std', 'scale-info/std', + 'pallet-collective/std', + 'pallet-membership/std', "xcm/std", "xcm-calls/std", diff --git a/runtime/common/src/governance.rs b/runtime/common/src/governance.rs new file mode 100644 index 0000000000..46a015a40e --- /dev/null +++ b/runtime/common/src/governance.rs @@ -0,0 +1,27 @@ +// Copyright 2021 ChainSafe Systems +// SPDX-License-Identifier: LGPL-3.0-only + +//! Governance related commonly used config types + +use frame_system::{EnsureOneOf, EnsureRoot}; +use primitives::AccountId; +use sp_core::u32_trait::{_1, _2}; + +pub type CommitteeInstance = pallet_collective::Instance1; +pub type CouncilInstance = pallet_collective::Instance2; + +pub type CouncilMembershipInstance = pallet_membership::Instance1; +pub type ConstituentMembershipInstance = pallet_membership::Instance2; + +// General Council +pub type EnsureRootOrAllGeneralCouncil = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilInstance>, +>; + +pub type EnsureRootOrHalfGeneralCouncil = EnsureOneOf< + AccountId, + EnsureRoot, + pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilInstance>, +>; diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 7062ca5154..025d97ed2c 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -4,6 +4,7 @@ #![cfg_attr(not(feature = "std"), no_std)] pub mod constants; +pub mod governance; pub mod payment; pub mod traits; pub mod types; diff --git a/runtime/dev/Cargo.toml b/runtime/dev/Cargo.toml index 16f8cd0bed..7763807b13 100644 --- a/runtime/dev/Cargo.toml +++ b/runtime/dev/Cargo.toml @@ -56,6 +56,9 @@ pallet-sudo = { git = 'https://github.com/paritytech/substrate', branch = 'polka pallet-timestamp = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } pallet-transaction-payment = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } +pallet-democracy = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } +pallet-membership = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } +pallet-treasury = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.12', default-features = false } # Cumulus Dependencies pallet-collator-selection = { git = 'https://github.com/paritytech/cumulus', branch = 'polkadot-v0.9.12', default-features = false } @@ -119,7 +122,11 @@ runtime-benchmarks = [ 'pallet-collator-selection/runtime-benchmarks', 'pallet-balances/runtime-benchmarks', 'pallet-timestamp/runtime-benchmarks', - + 'pallet-democracy/runtime-benchmarks', + 'pallet-collective/runtime-benchmarks', + 'pallet-membership/runtime-benchmarks', + 'pallet-treasury/runtime-benchmarks', + 'pallet-asset-index/runtime-benchmarks', 'pallet-price-feed/runtime-benchmarks', 'pallet-local-treasury/runtime-benchmarks', @@ -167,6 +174,10 @@ std = [ 'pallet-transaction-payment/std', 'pallet-xcm/std', 'pallet-asset-tx-payment/std', + 'pallet-democracy/std', + 'pallet-collective/std', + 'pallet-membership/std', + 'pallet-treasury/std', 'parachain-info/std', 'cumulus-pallet-aura-ext/std', diff --git a/runtime/dev/src/lib.rs b/runtime/dev/src/lib.rs index f9585e0c20..245e5bf54e 100644 --- a/runtime/dev/src/lib.rs +++ b/runtime/dev/src/lib.rs @@ -56,10 +56,17 @@ use xcm_builder::{ use xcm_executor::XcmExecutor; use frame_support::traits::{Everything, Nothing}; +use frame_system::EnsureRoot; use pallet_committee::EnsureMember; -use pint_runtime_common::payment::BalanceToAssetBalance; pub use pint_runtime_common::{constants::*, types::*, weights}; +use pint_runtime_common::{ + governance::{ + CommitteeInstance, ConstituentMembershipInstance, CouncilInstance, EnsureRootOrAllGeneralCouncil, + EnsureRootOrHalfGeneralCouncil, + }, + payment::BalanceToAssetBalance, +}; use primitives::traits::MultiAssetRegistry; pub use primitives::*; use xcm_calls::{ @@ -220,6 +227,79 @@ impl pallet_sudo::Config for Runtime { type Call = Call; } +parameter_types! { + pub const GeneralCouncilMotionDuration: BlockNumber = 3 * DAYS; + pub const GeneralCouncilMaxProposals: u32 = 20; + pub const GeneralCouncilMaxMembers: u32 = 7; +} + +impl pallet_collective::Config for Runtime { + type Origin = Origin; + type Proposal = Call; + type Event = Event; + type MotionDuration = GeneralCouncilMotionDuration; + type MaxProposals = GeneralCouncilMaxProposals; + type MaxMembers = GeneralCouncilMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; + type WeightInfo = (); +} + +parameter_types! { + pub const LaunchPeriod: BlockNumber = 5 * DAYS; + pub const VotingPeriod: BlockNumber = 5 * DAYS; + pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS; + pub MinimumDeposit: Balance = 100 * dollar(KAR); + pub const EnactmentPeriod: BlockNumber = 2 * DAYS; + pub const VoteLockingPeriod: BlockNumber = 7 * DAYS; + pub const CooloffPeriod: BlockNumber = 7 * DAYS; + pub PreimageByteDeposit: Balance = deposit(0, 1); + 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 LaunchPeriod = LaunchPeriod; + type VotingPeriod = VotingPeriod; + type VoteLockingPeriod = VoteLockingPeriod; + type MinimumDeposit = MinimumDeposit; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = EnsureRootOrHalfGeneralCouncil; + /// A majority can have the next scheduled referendum be a straight majority-carries vote. + type ExternalMajorityOrigin = EnsureRootOrHalfGeneralCouncil; + /// A unanimous council can have the next scheduled referendum be a straight default-carries + /// (NTB) vote. + type ExternalDefaultOrigin = EnsureRootOrAllGeneralCouncil; + /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote + /// be tabled immediately and with a shorter voting/enactment period. + type FastTrackOrigin = EnsureRootOrAllGeneralCouncil; + type InstantOrigin = EnsureRootOrAllGeneralCouncil; + type InstantAllowed = InstantAllowed; + type FastTrackVotingPeriod = FastTrackVotingPeriod; + // To cancel a proposal which has been passed, 1/2 of the council must agree to it. + type CancellationOrigin = EnsureRootOrHalfGeneralCouncil; + type BlacklistOrigin = EnsureRoot; + // To cancel a proposal before it has been passed, the council must be unanimous + // Root must agree. + type CancelProposalOrigin = EnsureRootOrHalfGeneralCouncil; + // Any single constituent 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; + type CooloffPeriod = CooloffPeriod; + type PreimageByteDeposit = PreimageByteDeposit; + type OperationalPreimageOrigin = pallet_collective::EnsureMember; + type Slash = Treasury; + type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; + type MaxVotes = MaxVotes; + type WeightInfo = pallet_democracy::weights::SubstrateWeight; + type MaxProposals = MaxProposals; +} + impl cumulus_pallet_parachain_system::Config for Runtime { type Event = Event; type OnValidationData = (); @@ -753,7 +833,14 @@ construct_runtime!( XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 100, DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 101, PolkadotXcm: pallet_xcm::{Pallet, Storage, Call, Event, Origin, Config} = 102, - CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 103 + CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 103, + + // Governance + GeneralCommittee: pallet_collective::::{Pallet, Call, Storage, Origin, Event, Config} = 110, + // CouncilMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 111, + // ConstituentMembership: pallet_membership::::{Pallet, Call, Storage, Event, Config} = 112, + // Democracy: pallet_democracy::{Pallet, Call, Storage, Config, Event} = 113, + } );