difftreelog
Merge pull request #976 from UniqueNetwork/fix/governance-setup-inconsistencies
in: master
16 files changed
runtime/common/config/governance/council.rsdiffbeforeafterboth1use super::*;23parameter_types! {4 pub CouncilMaxProposals: u32 = 100;5 pub CouncilMaxMembers: u32 = 100;6}78#[cfg(not(feature = "test-env"))]9use crate::governance_timings::council as council_timings;1011#[cfg(feature = "test-env")]12pub mod council_timings {13 use super::*;1415 parameter_types! {16 pub CouncilMotionDuration: BlockNumber = 35;17 }18}1920pub type CouncilCollective = pallet_collective::Instance1;21impl pallet_collective::Config<CouncilCollective> for Runtime {22 type RuntimeOrigin = RuntimeOrigin;23 type Proposal = RuntimeCall;24 type RuntimeEvent = RuntimeEvent;25 type MotionDuration = council_timings::CouncilMotionDuration;26 type MaxProposals = CouncilMaxProposals;27 type MaxMembers = CouncilMaxMembers;28 type DefaultVote = pallet_collective::PrimeDefaultVote;29 type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;30 type SetMembersOrigin = EnsureRoot<AccountId>;31 type MaxProposalWeight = MaxCollectivesProposalWeight;32}3334pub type CouncilCollectiveMembership = pallet_membership::Instance1;35impl pallet_membership::Config<CouncilCollectiveMembership> for Runtime {36 type RuntimeEvent = RuntimeEvent;37 type AddOrigin = EnsureRoot<AccountId>;38 type RemoveOrigin = EnsureRoot<AccountId>;39 type SwapOrigin = EnsureRoot<AccountId>;40 type ResetOrigin = EnsureRoot<AccountId>;41 type PrimeOrigin = EnsureRoot<AccountId>;42 type MembershipInitialized = Council;43 type MembershipChanged = Council;44 type MaxMembers = CouncilMaxMembers;45 type WeightInfo = pallet_membership::weights::SubstrateWeight<Runtime>;46}4748pub type CouncilMember = pallet_collective::EnsureMember<AccountId, CouncilCollective>;4950pub type OneThirdsCouncil =51 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 3>;5253pub type HalfCouncil =54 pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>;5556pub type MoreThanHalfCouncil =57 pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>;5859pub type ThreeFourthsCouncil = EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 4>;6061pub type AllCouncil = EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>;6263pub type RootOrOneThirdsCouncil = EitherOfDiverse<EnsureRoot<AccountId>, OneThirdsCouncil>;6465pub type RootOrHalfCouncil = EitherOfDiverse<EnsureRoot<AccountId>, HalfCouncil>;6667pub type RootOrMoreThanHalfCouncil = EitherOfDiverse<EnsureRoot<AccountId>, MoreThanHalfCouncil>;6869pub type RootOrThreeFourthsCouncil = EitherOfDiverse<EnsureRoot<AccountId>, ThreeFourthsCouncil>;7071pub type RootOrAllCouncil = EitherOfDiverse<EnsureRoot<AccountId>, AllCouncil>;runtime/common/config/governance/democracy.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/common/config/governance/democracy.rs
@@ -0,0 +1,102 @@
+use super::*;
+
+parameter_types! {
+ pub MinimumDeposit: Balance = 0;
+ pub InstantAllowed: bool = false;
+ pub MaxVotes: u32 = 100;
+ pub MaxProposals: u32 = 100;
+}
+
+#[cfg(not(feature = "test-env"))]
+use crate::governance_timings::democracy as democracy_timings;
+
+#[cfg(feature = "test-env")]
+pub mod democracy_timings {
+ use super::*;
+
+ parameter_types! {
+ pub LaunchPeriod: BlockNumber = 35;
+ pub VotingPeriod: BlockNumber = 35;
+ pub FastTrackVotingPeriod: BlockNumber = 5;
+ pub EnactmentPeriod: BlockNumber = 40;
+ pub CooloffPeriod: BlockNumber = 35;
+ }
+}
+
+impl pallet_democracy::Config for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type Currency = Balances;
+ type Slash = Treasury;
+ type Scheduler = Scheduler;
+ type PalletsOrigin = OriginCaller;
+ type Preimages = Preimage;
+ type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
+
+ /// The period between a proposal being approved and enacted.
+ type EnactmentPeriod = democracy_timings::EnactmentPeriod;
+
+ /// The minimum period of vote locking.
+ type VoteLockingPeriod = democracy_timings::EnactmentPeriod;
+
+ /// How often new public referenda are launched.
+ type LaunchPeriod = democracy_timings::LaunchPeriod;
+
+ /// How long the referendum will last.
+ type VotingPeriod = democracy_timings::VotingPeriod;
+
+ /// The minimum amount to be used as a deposit for the Fellowship referendum proposal.
+ type MinimumDeposit = MinimumDeposit;
+
+ type SubmitOrigin = EitherOf<
+ MapSuccess<EnsureRoot<Self::AccountId>, Replace<fellowship::FellowshipAccountId>>,
+ EnsureFellowshipProposition,
+ >;
+
+ type ExternalOrigin = EnsureNever<Self::AccountId>;
+ type ExternalMajorityOrigin = EnsureNever<Self::AccountId>;
+
+ /// Root (for the initial referendums)
+ /// or >50% of council can have the next scheduled referendum be a straight default-carries
+ /// (NTB) vote (SuperMajorityAgainst).
+ type ExternalDefaultOrigin = RootOrMoreThanHalfCouncil;
+
+ /// A unanimous technical committee can have an ExternalMajority/ExternalDefault vote
+ /// be tabled immediately and with a shorter voting/enactment period.
+ type FastTrackOrigin = RootOrAllTechnicalCommittee;
+
+ /// Origin from which the next referendum may be tabled to vote immediately and asynchronously.
+ /// Can set a faster voting period.
+ type InstantOrigin = EnsureNever<Self::AccountId>;
+ type InstantAllowed = InstantAllowed;
+
+ /// Minimum voting period allowed for a fast-track referendum.
+ type FastTrackVotingPeriod = democracy_timings::FastTrackVotingPeriod;
+
+ /// To cancel a proposal which has been passed, the technical committee must be unanimous or
+ /// Root must agree.
+ type CancellationOrigin = RootOrAllTechnicalCommittee;
+
+ /// To cancel a proposal before it has been passed, the technical committee must be unanimous or
+ /// Root must agree.
+ type CancelProposalOrigin = RootOrAllTechnicalCommittee;
+
+ /// A unanimous council or Root can blacklist a proposal permanently.
+ type BlacklistOrigin = RootOrAllCouncil;
+
+ // 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 = TechnicalCommitteeMember;
+ type CooloffPeriod = democracy_timings::CooloffPeriod;
+
+ /// The maximum number of votes for an account
+ type MaxVotes = MaxVotes;
+
+ /// The maximum number of public proposals that can exist at any time.
+ type MaxProposals = MaxProposals;
+
+ /// The maximum number of deposits a public proposal may have at any time.
+ type MaxDeposits = ConstU32<100>;
+
+ /// The maximum number of items that can be blacklisted.
+ type MaxBlacklisted = ConstU32<100>;
+}
runtime/common/config/governance/fellowship.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/common/config/governance/fellowship.rs
@@ -0,0 +1,167 @@
+use crate::{Preimage, Treasury, RuntimeCall, RuntimeEvent, Scheduler, FellowshipReferenda, Runtime};
+use super::*;
+use pallet_gov_origins::Origin as GovOrigins;
+use pallet_ranked_collective::{Config as RankedConfig, Rank, TallyOf};
+
+pub const FELLOWSHIP_MODULE_ID: PalletId = PalletId(*b"flowship");
+pub const DEMOCRACY_TRACK_ID: u16 = 10;
+
+parameter_types! {
+ pub FellowshipAccountId: <Runtime as frame_system::Config>::AccountId = FELLOWSHIP_MODULE_ID.into_account_truncating();
+ pub AlarmInterval: BlockNumber = 1;
+ pub SubmissionDeposit: Balance = 1000;
+}
+
+#[cfg(not(feature = "test-env"))]
+use crate::governance_timings::fellowship as fellowship_timings;
+
+#[cfg(feature = "test-env")]
+pub mod fellowship_timings {
+ use super::*;
+
+ parameter_types! {
+ pub UndecidingTimeout: BlockNumber = 35;
+ }
+
+ pub mod track {
+ use super::*;
+
+ pub mod democracy_proposals {
+ use super::*;
+
+ pub const PREPARE_PERIOD: BlockNumber = 3;
+ pub const DECISION_PERIOD: BlockNumber = 35;
+ pub const CONFIRM_PERIOD: BlockNumber = 3;
+ pub const MIN_ENACTMENT_PERIOD: BlockNumber = 1;
+ }
+ }
+}
+
+impl pallet_referenda::Config for Runtime {
+ type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>;
+ type RuntimeCall = RuntimeCall;
+ type RuntimeEvent = RuntimeEvent;
+ type Scheduler = Scheduler;
+ type Currency = Balances;
+ type SubmitOrigin = pallet_ranked_collective::EnsureMember<Runtime, (), 1>;
+ type CancelOrigin = RootOrAllTechnicalCommittee;
+ type KillOrigin = RootOrAllTechnicalCommittee;
+ type Slash = Treasury;
+ type Votes = pallet_ranked_collective::Votes;
+ type Tally = pallet_ranked_collective::TallyOf<Runtime>;
+ type SubmissionDeposit = SubmissionDeposit;
+ type MaxQueued = ConstU32<100>;
+ type UndecidingTimeout = fellowship_timings::UndecidingTimeout;
+ type AlarmInterval = AlarmInterval;
+ type Tracks = TracksInfo;
+ type Preimages = Preimage;
+}
+
+impl RankedConfig for Runtime {
+ type WeightInfo = pallet_ranked_collective::weights::SubstrateWeight<Self>;
+ type RuntimeEvent = RuntimeEvent;
+ // Promotion is by any of:
+ // - Council member.
+ // - Technical committee member.
+ type PromoteOrigin = FellowshipPromoteDemoteOrigin<Self::AccountId>;
+ // Demotion is by any of:
+ // - Council member.
+ // - Technical committee member.
+ type DemoteOrigin = FellowshipPromoteDemoteOrigin<Self::AccountId>;
+ type Polls = FellowshipReferenda;
+ type MinRankOfClass = ClassToRankMapper<Self, ()>;
+ type VoteWeight = pallet_ranked_collective::Geometric;
+}
+
+pub struct EnsureFellowshipProposition;
+impl<O> EnsureOrigin<O> for EnsureFellowshipProposition
+where
+ O: Into<Result<GovOrigins, O>> + From<GovOrigins>,
+{
+ type Success = AccountId;
+
+ fn try_origin(o: O) -> Result<Self::Success, O> {
+ o.into().and_then(|o| match o {
+ GovOrigins::FellowshipProposition => Ok(FellowshipAccountId::get()),
+ o => Err(O::from(o)),
+ })
+ }
+
+ #[cfg(feature = "runtime-benchmarks")]
+ fn try_successful_origin() -> Result<O, ()> {
+ Ok(O::from(GovOrigins::FellowshipProposition))
+ }
+}
+
+pub type FellowshipPromoteDemoteOrigin<AccountId> = EitherOf<
+ MapSuccess<EnsureRoot<AccountId>, Replace<ConstU16<65535>>>,
+ MapSuccess<MoreThanHalfCouncil, Replace<ConstU16<9>>>,
+>;
+
+pub struct TracksInfo;
+impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
+ type Id = u16;
+ type RuntimeOrigin = <RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin;
+ fn tracks() -> &'static [(Self::Id, pallet_referenda::TrackInfo<Balance, BlockNumber>)] {
+ static DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 1] = [(
+ DEMOCRACY_TRACK_ID,
+ pallet_referenda::TrackInfo {
+ name: "democracy_proposals",
+ max_deciding: 10,
+ decision_deposit: 10 * UNIQUE,
+ prepare_period: fellowship_timings::track::democracy_proposals::PREPARE_PERIOD,
+ decision_period: fellowship_timings::track::democracy_proposals::DECISION_PERIOD,
+ confirm_period: fellowship_timings::track::democracy_proposals::CONFIRM_PERIOD,
+ min_enactment_period:
+ fellowship_timings::track::democracy_proposals::MIN_ENACTMENT_PERIOD,
+ min_approval: pallet_referenda::Curve::LinearDecreasing {
+ length: Perbill::from_percent(100),
+ floor: Perbill::from_percent(50),
+ ceil: Perbill::from_percent(100),
+ },
+ min_support: pallet_referenda::Curve::LinearDecreasing {
+ length: Perbill::from_percent(100),
+ floor: Perbill::from_percent(0),
+ ceil: Perbill::from_percent(50),
+ },
+ },
+ )];
+ &DATA[..]
+ }
+ fn track_for(id: &Self::RuntimeOrigin) -> Result<Self::Id, ()> {
+ #[cfg(feature = "runtime-benchmarks")]
+ {
+ // For benchmarks, we enable a root origin.
+ // It is important that this is not available in production!
+ let root: Self::RuntimeOrigin = frame_system::RawOrigin::Root.into();
+ if &root == id {
+ return Ok(9);
+ }
+ }
+
+ match GovOrigins::try_from(id.clone()) {
+ Ok(_) => Ok(DEMOCRACY_TRACK_ID),
+ _ => Err(()),
+ }
+ }
+}
+
+pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber);
+
+pub struct ClassToRankMapper<T, I>(PhantomData<(T, I)>);
+
+//TODO: Remove the type when it appears in the release.
+pub type ClassOf<T, I = ()> = <<T as RankedConfig<I>>::Polls as Polling<TallyOf<T, I>>>::Class;
+
+impl<T, I> Convert<ClassOf<T, I>, Rank> for ClassToRankMapper<T, I>
+where
+ T: RankedConfig<I>,
+ ClassOf<T, I>: Into<Rank>,
+{
+ fn convert(track_id: ClassOf<T, I>) -> Rank {
+ match track_id.into() {
+ DEMOCRACY_TRACK_ID => 3,
+ other => other,
+ }
+ }
+}
runtime/common/config/governance/mod.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/common/config/governance/mod.rs
@@ -0,0 +1,68 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network 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.
+
+// Unique Network 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 Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+use frame_support::{
+ PalletId, parameter_types,
+ traits::{
+ EnsureOrigin, EqualPrivilegeOnly, EitherOfDiverse, EitherOf, MapSuccess, ConstU16, Polling,
+ },
+ weights::Weight,
+ pallet_prelude::*,
+};
+use frame_system::{EnsureRoot, EnsureNever};
+use sp_runtime::{
+ Perbill,
+ traits::{AccountIdConversion, ConstU32, Replace, CheckedSub, Convert},
+ morph_types,
+};
+use crate::{
+ Runtime, RuntimeOrigin, RuntimeEvent, RuntimeCall, OriginCaller, Preimage, Balances, Treasury,
+ Scheduler, Council, TechnicalCommittee,
+};
+pub use up_common::{
+ constants::{UNIQUE, DAYS, HOURS, MINUTES, CENTIUNIQUE},
+ types::{AccountId, Balance, BlockNumber},
+};
+use pallet_collective::EnsureProportionAtLeast;
+
+pub mod council;
+pub use council::*;
+
+pub mod democracy;
+pub use democracy::*;
+
+pub mod technical_committee;
+pub use technical_committee::*;
+
+pub mod fellowship;
+pub use fellowship::*;
+
+pub mod scheduler;
+pub use scheduler::*;
+
+impl pallet_gov_origins::Config for Runtime {}
+
+morph_types! {
+ /// A `TryMorph` implementation to reduce a scalar by a particular amount, checking for
+ /// underflow.
+ pub type CheckedReduceBy<N: TypedGet>: TryMorph = |r: N::Type| -> Result<N::Type, ()> {
+ r.checked_sub(&N::get()).ok_or(())
+ } where N::Type: CheckedSub;
+}
+
+parameter_types! {
+ pub MaxCollectivesProposalWeight: Weight = Perbill::from_percent(80) * <Runtime as frame_system::Config>::BlockWeights::get().max_block;
+}
runtime/common/config/governance/scheduler.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/common/config/governance/scheduler.rs
@@ -0,0 +1,24 @@
+use up_common::constants::{MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO};
+
+use super::*;
+
+parameter_types! {
+ pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
+ <Runtime as frame_system::Config>::BlockWeights::get()
+ .per_class.get(frame_support::pallet_prelude::DispatchClass::Normal).max_total
+ .unwrap_or(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
+ pub MaxScheduledPerBlock: u32 = 50;
+}
+
+impl pallet_scheduler::Config for Runtime {
+ type RuntimeOrigin = RuntimeOrigin;
+ type RuntimeEvent = RuntimeEvent;
+ type PalletsOrigin = OriginCaller;
+ type RuntimeCall = RuntimeCall;
+ type MaximumWeight = MaximumSchedulerWeight;
+ type ScheduleOrigin = EnsureRoot<AccountId>;
+ type MaxScheduledPerBlock = MaxScheduledPerBlock;
+ type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
+ type OriginPrivilegeCmp = EqualPrivilegeOnly;
+ type Preimages = Preimage;
+}
runtime/common/config/governance/technical_committee.rsdiffbeforeafterboth--- /dev/null
+++ b/runtime/common/config/governance/technical_committee.rs
@@ -0,0 +1,57 @@
+use super::*;
+
+parameter_types! {
+ pub TechnicalMaxProposals: u32 = 100;
+ pub TechnicalMaxMembers: u32 = 100;
+}
+
+#[cfg(not(feature = "test-env"))]
+use crate::governance_timings::technical_committee as technical_committee_timings;
+
+#[cfg(feature = "test-env")]
+pub mod technical_committee_timings {
+ use super::*;
+
+ parameter_types! {
+ pub TechnicalMotionDuration: BlockNumber = 35;
+ }
+}
+
+pub type TechnicalCollective = pallet_collective::Instance2;
+impl pallet_collective::Config<TechnicalCollective> for Runtime {
+ type RuntimeOrigin = RuntimeOrigin;
+ type Proposal = RuntimeCall;
+ type RuntimeEvent = RuntimeEvent;
+ type MotionDuration = technical_committee_timings::TechnicalMotionDuration;
+ type MaxProposals = TechnicalMaxProposals;
+ type MaxMembers = TechnicalMaxMembers;
+ type DefaultVote = pallet_collective::PrimeDefaultVote;
+ type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
+ type SetMembersOrigin = EnsureRoot<AccountId>;
+ type MaxProposalWeight = MaxCollectivesProposalWeight;
+}
+
+pub type TechnicalCollectiveMembership = pallet_membership::Instance2;
+impl pallet_membership::Config<TechnicalCollectiveMembership> for Runtime {
+ type RuntimeEvent = RuntimeEvent;
+ type AddOrigin = RootOrMoreThanHalfCouncil;
+ type RemoveOrigin = RootOrMoreThanHalfCouncil;
+ type SwapOrigin = RootOrMoreThanHalfCouncil;
+ type ResetOrigin = EnsureRoot<AccountId>;
+ type PrimeOrigin = EnsureRoot<AccountId>;
+ type MembershipInitialized = TechnicalCommittee;
+ type MembershipChanged = TechnicalCommittee;
+ type MaxMembers = TechnicalMaxMembers;
+ type WeightInfo = pallet_membership::weights::SubstrateWeight<Runtime>;
+}
+
+pub type TechnicalCommitteeMember = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
+
+pub type RootOrTechnicalCommitteeMember =
+ EitherOfDiverse<EnsureRoot<AccountId>, TechnicalCommitteeMember>;
+
+pub type AllTechnicalCommittee =
+ pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>;
+
+pub type RootOrAllTechnicalCommittee =
+ EitherOfDiverse<EnsureRoot<AccountId>, AllTechnicalCommittee>;
runtime/common/config/mod.rsdiffbeforeafterboth--- a/runtime/common/config/mod.rs
+++ b/runtime/common/config/mod.rs
@@ -22,5 +22,8 @@
pub mod substrate;
pub mod xcm;
+#[cfg(feature = "governance")]
+pub mod governance;
+
#[cfg(feature = "test-env")]
pub mod test_pallets;
runtime/common/config/pallets/collator_selection.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/collator_selection.rs
+++ b/runtime/common/config/pallets/collator_selection.rs
@@ -22,7 +22,7 @@
};
#[cfg(feature = "governance")]
-use crate::config::pallets::governance;
+use crate::config::governance;
#[cfg(not(feature = "governance"))]
use frame_system::EnsureRoot;
@@ -85,10 +85,10 @@
type SubAccountDeposit = SubAccountDeposit;
#[cfg(feature = "governance")]
- type RegistrarOrigin = governance::RootOrAllTechnicalCommittee;
+ type RegistrarOrigin = governance::RootOrTechnicalCommitteeMember;
#[cfg(feature = "governance")]
- type ForceOrigin = governance::RootOrAllTechnicalCommittee;
+ type ForceOrigin = governance::RootOrTechnicalCommitteeMember;
#[cfg(not(feature = "governance"))]
type RegistrarOrigin = EnsureRoot<<Self as frame_system::Config>::AccountId>;
runtime/common/config/pallets/governance/council.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/governance/council.rs
+++ /dev/null
@@ -1,71 +0,0 @@
-use super::*;
-
-parameter_types! {
- pub CouncilMaxProposals: u32 = 100;
- pub CouncilMaxMembers: u32 = 100;
-}
-
-#[cfg(not(feature = "test-env"))]
-use crate::governance_timings::council as council_timings;
-
-#[cfg(feature = "test-env")]
-pub mod council_timings {
- use super::*;
-
- parameter_types! {
- pub CouncilMotionDuration: BlockNumber = 35;
- }
-}
-
-pub type CouncilCollective = pallet_collective::Instance1;
-impl pallet_collective::Config<CouncilCollective> for Runtime {
- type RuntimeOrigin = RuntimeOrigin;
- type Proposal = RuntimeCall;
- type RuntimeEvent = RuntimeEvent;
- type MotionDuration = council_timings::CouncilMotionDuration;
- type MaxProposals = CouncilMaxProposals;
- type MaxMembers = CouncilMaxMembers;
- type DefaultVote = pallet_collective::PrimeDefaultVote;
- type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
- type SetMembersOrigin = EnsureRoot<AccountId>;
- type MaxProposalWeight = MaxCollectivesProposalWeight;
-}
-
-pub type CouncilCollectiveMembership = pallet_membership::Instance1;
-impl pallet_membership::Config<CouncilCollectiveMembership> 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 = Council;
- type MembershipChanged = Council;
- type MaxMembers = CouncilMaxMembers;
- type WeightInfo = pallet_membership::weights::SubstrateWeight<Runtime>;
-}
-
-pub type CouncilMember = pallet_collective::EnsureMember<AccountId, CouncilCollective>;
-
-pub type OneThirdsCouncil =
- pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 3>;
-
-pub type HalfCouncil =
- pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>;
-
-pub type MoreThanHalfCouncil =
- pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>;
-
-pub type ThreeFourthsCouncil = EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 4>;
-
-pub type AllCouncil = EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>;
-
-pub type RootOrOneThirdsCouncil = EitherOfDiverse<EnsureRoot<AccountId>, OneThirdsCouncil>;
-
-pub type RootOrHalfCouncil = EitherOfDiverse<EnsureRoot<AccountId>, HalfCouncil>;
-
-pub type RootOrMoreThanHalfCouncil = EitherOfDiverse<EnsureRoot<AccountId>, MoreThanHalfCouncil>;
-
-pub type RootOrThreeFourthsCouncil = EitherOfDiverse<EnsureRoot<AccountId>, ThreeFourthsCouncil>;
-
-pub type RootOrAllCouncil = EitherOfDiverse<EnsureRoot<AccountId>, AllCouncil>;
runtime/common/config/pallets/governance/democracy.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/governance/democracy.rs
+++ /dev/null
@@ -1,101 +0,0 @@
-use super::*;
-
-parameter_types! {
- pub MinimumDeposit: Balance = 0;
- pub InstantAllowed: bool = false;
- pub MaxVotes: u32 = 100;
- pub MaxProposals: u32 = 100;
-}
-
-#[cfg(not(feature = "test-env"))]
-use crate::governance_timings::democracy as democracy_timings;
-
-#[cfg(feature = "test-env")]
-pub mod democracy_timings {
- use super::*;
-
- parameter_types! {
- pub LaunchPeriod: BlockNumber = 35;
- pub VotingPeriod: BlockNumber = 35;
- pub FastTrackVotingPeriod: BlockNumber = 5;
- pub EnactmentPeriod: BlockNumber = 40;
- pub CooloffPeriod: BlockNumber = 35;
- }
-}
-
-impl pallet_democracy::Config for Runtime {
- type RuntimeEvent = RuntimeEvent;
- type Currency = Balances;
- type Slash = Treasury;
- type Scheduler = Scheduler;
- type PalletsOrigin = OriginCaller;
- type Preimages = Preimage;
- type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
-
- /// The period between a proposal being approved and enacted.
- type EnactmentPeriod = democracy_timings::EnactmentPeriod;
-
- /// The minimum period of vote locking.
- type VoteLockingPeriod = democracy_timings::EnactmentPeriod;
-
- /// How often new public referenda are launched.
- type LaunchPeriod = democracy_timings::LaunchPeriod;
-
- /// How long the referendum will last.
- type VotingPeriod = democracy_timings::VotingPeriod;
-
- /// The minimum amount to be used as a deposit for the Fellowship referendum proposal.
- type MinimumDeposit = MinimumDeposit;
-
- type SubmitOrigin = EitherOf<
- MapSuccess<EnsureRoot<Self::AccountId>, Replace<fellowship::FellowshipAccountId>>,
- EnsureFellowshipProposition,
- >;
-
- type ExternalOrigin = EnsureNever<Self::AccountId>;
- type ExternalMajorityOrigin = EnsureNever<Self::AccountId>;
-
- /// Root (for the initial referendums)
- /// or >50% of council can have the next scheduled referendum be a straight default-carries
- /// (NTB) vote (SuperMajorityAgainst).
- type ExternalDefaultOrigin = RootOrMoreThanHalfCouncil;
-
- /// A unanimous technical committee can have an ExternalMajority/ExternalDefault vote
- /// be tabled immediately and with a shorter voting/enactment period.
- type FastTrackOrigin = RootOrAllTechnicalCommittee;
-
- /// Origin from which the next referendum may be tabled to vote immediately and asynchronously.
- /// Can set a faster voting period.
- type InstantOrigin = EnsureNever<Self::AccountId>;
- type InstantAllowed = InstantAllowed;
-
- /// Minimum voting period allowed for a fast-track referendum.
- type FastTrackVotingPeriod = democracy_timings::FastTrackVotingPeriod;
-
- /// A single technical committee member can cancel a proposal which has been passed.
- type CancellationOrigin = RootOrAllTechnicalCommittee;
-
- /// To cancel a proposal before it has been passed, the technical committee must be unanimous or
- /// Root must agree.
- type CancelProposalOrigin = RootOrAllTechnicalCommittee;
-
- /// A unanimous council or Root can blacklist a proposal permanently.
- type BlacklistOrigin = RootOrAllCouncil;
-
- // 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 = TechnicalCommitteeMember;
- type CooloffPeriod = democracy_timings::CooloffPeriod;
-
- /// The maximum number of votes for an account
- type MaxVotes = MaxVotes;
-
- /// The maximum number of public proposals that can exist at any time.
- type MaxProposals = MaxProposals;
-
- /// The maximum number of deposits a public proposal may have at any time.
- type MaxDeposits = ConstU32<100>;
-
- /// The maximum number of items that can be blacklisted.
- type MaxBlacklisted = ConstU32<100>;
-}
runtime/common/config/pallets/governance/fellowship.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/governance/fellowship.rs
+++ /dev/null
@@ -1,167 +0,0 @@
-use crate::{Preimage, Treasury, RuntimeCall, RuntimeEvent, Scheduler, FellowshipReferenda, Runtime};
-use super::*;
-use pallet_gov_origins::Origin as GovOrigins;
-use pallet_ranked_collective::{Config as RankedConfig, Rank, TallyOf};
-
-pub const FELLOWSHIP_MODULE_ID: PalletId = PalletId(*b"flowship");
-pub const DEMOCRACY_TRACK_ID: u16 = 10;
-
-parameter_types! {
- pub FellowshipAccountId: <Runtime as frame_system::Config>::AccountId = FELLOWSHIP_MODULE_ID.into_account_truncating();
- pub AlarmInterval: BlockNumber = 1;
- pub SubmissionDeposit: Balance = 1000;
-}
-
-#[cfg(not(feature = "test-env"))]
-use crate::governance_timings::fellowship as fellowship_timings;
-
-#[cfg(feature = "test-env")]
-pub mod fellowship_timings {
- use super::*;
-
- parameter_types! {
- pub UndecidingTimeout: BlockNumber = 35;
- }
-
- pub mod track {
- use super::*;
-
- pub mod democracy_proposals {
- use super::*;
-
- pub const PREPARE_PERIOD: BlockNumber = 3;
- pub const DECISION_PERIOD: BlockNumber = 35;
- pub const CONFIRM_PERIOD: BlockNumber = 3;
- pub const MIN_ENACTMENT_PERIOD: BlockNumber = 1;
- }
- }
-}
-
-impl pallet_referenda::Config for Runtime {
- type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>;
- type RuntimeCall = RuntimeCall;
- type RuntimeEvent = RuntimeEvent;
- type Scheduler = Scheduler;
- type Currency = Balances;
- type SubmitOrigin = pallet_ranked_collective::EnsureMember<Runtime, (), 1>;
- type CancelOrigin = RootOrAllTechnicalCommittee;
- type KillOrigin = RootOrAllTechnicalCommittee;
- type Slash = Treasury;
- type Votes = pallet_ranked_collective::Votes;
- type Tally = pallet_ranked_collective::TallyOf<Runtime>;
- type SubmissionDeposit = SubmissionDeposit;
- type MaxQueued = ConstU32<100>;
- type UndecidingTimeout = fellowship_timings::UndecidingTimeout;
- type AlarmInterval = AlarmInterval;
- type Tracks = TracksInfo;
- type Preimages = Preimage;
-}
-
-impl RankedConfig for Runtime {
- type WeightInfo = pallet_ranked_collective::weights::SubstrateWeight<Self>;
- type RuntimeEvent = RuntimeEvent;
- // Promotion is by any of:
- // - Council member.
- // - Technical committee member.
- type PromoteOrigin = FellowshipPromoteDemoteOrigin<Self::AccountId>;
- // Demotion is by any of:
- // - Council member.
- // - Technical committee member.
- type DemoteOrigin = FellowshipPromoteDemoteOrigin<Self::AccountId>;
- type Polls = FellowshipReferenda;
- type MinRankOfClass = ClassToRankMapper<Self, ()>;
- type VoteWeight = pallet_ranked_collective::Geometric;
-}
-
-pub struct EnsureFellowshipProposition;
-impl<O> EnsureOrigin<O> for EnsureFellowshipProposition
-where
- O: Into<Result<GovOrigins, O>> + From<GovOrigins>,
-{
- type Success = AccountId;
-
- fn try_origin(o: O) -> Result<Self::Success, O> {
- o.into().and_then(|o| match o {
- GovOrigins::FellowshipProposition => Ok(FellowshipAccountId::get()),
- o => Err(O::from(o)),
- })
- }
-
- #[cfg(feature = "runtime-benchmarks")]
- fn try_successful_origin() -> Result<O, ()> {
- Ok(O::from(GovOrigins::FellowshipProposition))
- }
-}
-
-pub type FellowshipPromoteDemoteOrigin<AccountId> = EitherOf<
- MapSuccess<EnsureRoot<AccountId>, Replace<ConstU16<65535>>>,
- MapSuccess<MoreThanHalfCouncil, Replace<ConstU16<9>>>,
->;
-
-pub struct TracksInfo;
-impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
- type Id = u16;
- type RuntimeOrigin = <RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin;
- fn tracks() -> &'static [(Self::Id, pallet_referenda::TrackInfo<Balance, BlockNumber>)] {
- static DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 1] = [(
- DEMOCRACY_TRACK_ID,
- pallet_referenda::TrackInfo {
- name: "democracy_proposals",
- max_deciding: 10,
- decision_deposit: 10 * UNIQUE,
- prepare_period: fellowship_timings::track::democracy_proposals::PREPARE_PERIOD,
- decision_period: fellowship_timings::track::democracy_proposals::DECISION_PERIOD,
- confirm_period: fellowship_timings::track::democracy_proposals::CONFIRM_PERIOD,
- min_enactment_period:
- fellowship_timings::track::democracy_proposals::MIN_ENACTMENT_PERIOD,
- min_approval: pallet_referenda::Curve::LinearDecreasing {
- length: Perbill::from_percent(100),
- floor: Perbill::from_percent(50),
- ceil: Perbill::from_percent(100),
- },
- min_support: pallet_referenda::Curve::LinearDecreasing {
- length: Perbill::from_percent(100),
- floor: Perbill::from_percent(0),
- ceil: Perbill::from_percent(50),
- },
- },
- )];
- &DATA[..]
- }
- fn track_for(id: &Self::RuntimeOrigin) -> Result<Self::Id, ()> {
- #[cfg(feature = "runtime-benchmarks")]
- {
- // For benchmarks, we enable a root origin.
- // It is important that this is not available in production!
- let root: Self::RuntimeOrigin = frame_system::RawOrigin::Root.into();
- if &root == id {
- return Ok(9);
- }
- }
-
- match GovOrigins::try_from(id.clone()) {
- Ok(_) => Ok(DEMOCRACY_TRACK_ID),
- _ => Err(()),
- }
- }
-}
-
-pallet_referenda::impl_tracksinfo_get!(TracksInfo, Balance, BlockNumber);
-
-pub struct ClassToRankMapper<T, I>(PhantomData<(T, I)>);
-
-//TODO: Remove the type when it appears in the release.
-pub type ClassOf<T, I = ()> = <<T as RankedConfig<I>>::Polls as Polling<TallyOf<T, I>>>::Class;
-
-impl<T, I> Convert<ClassOf<T, I>, Rank> for ClassToRankMapper<T, I>
-where
- T: RankedConfig<I>,
- ClassOf<T, I>: Into<Rank>,
-{
- fn convert(track_id: ClassOf<T, I>) -> Rank {
- match track_id.into() {
- DEMOCRACY_TRACK_ID => 3,
- other => other,
- }
- }
-}
runtime/common/config/pallets/governance/mod.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/governance/mod.rs
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
-// This file is part of Unique Network.
-
-// Unique Network 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.
-
-// Unique Network 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 Unique Network. If not, see <http://www.gnu.org/licenses/>.
-
-use frame_support::{
- PalletId, parameter_types,
- traits::{
- EnsureOrigin, EqualPrivilegeOnly, EitherOfDiverse, EitherOf, MapSuccess, ConstU16, Polling,
- },
- weights::Weight,
- pallet_prelude::*,
-};
-use frame_system::{EnsureRoot, EnsureNever};
-use sp_runtime::{
- Perbill,
- traits::{AccountIdConversion, ConstU32, Replace, CheckedSub, Convert},
- morph_types,
-};
-use crate::{
- Runtime, RuntimeOrigin, RuntimeEvent, RuntimeCall, OriginCaller, Preimage, Balances, Treasury,
- Scheduler, Council, TechnicalCommittee,
-};
-pub use up_common::{
- constants::{UNIQUE, DAYS, HOURS, MINUTES, CENTIUNIQUE},
- types::{AccountId, Balance, BlockNumber},
-};
-use pallet_collective::EnsureProportionAtLeast;
-
-pub mod council;
-pub use council::*;
-
-pub mod democracy;
-pub use democracy::*;
-
-pub mod technical_committee;
-pub use technical_committee::*;
-
-pub mod fellowship;
-pub use fellowship::*;
-
-pub mod scheduler;
-pub use scheduler::*;
-
-impl pallet_gov_origins::Config for Runtime {}
-
-morph_types! {
- /// A `TryMorph` implementation to reduce a scalar by a particular amount, checking for
- /// underflow.
- pub type CheckedReduceBy<N: TypedGet>: TryMorph = |r: N::Type| -> Result<N::Type, ()> {
- r.checked_sub(&N::get()).ok_or(())
- } where N::Type: CheckedSub;
-}
-
-parameter_types! {
- pub MaxCollectivesProposalWeight: Weight = Perbill::from_percent(80) * <Runtime as frame_system::Config>::BlockWeights::get().max_block;
-}
runtime/common/config/pallets/governance/scheduler.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/governance/scheduler.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-use up_common::constants::{MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO};
-
-use super::*;
-
-parameter_types! {
- pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
- <Runtime as frame_system::Config>::BlockWeights::get()
- .per_class.get(frame_support::pallet_prelude::DispatchClass::Normal).max_total
- .unwrap_or(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
- pub MaxScheduledPerBlock: u32 = 50;
-}
-
-impl pallet_scheduler::Config for Runtime {
- type RuntimeOrigin = RuntimeOrigin;
- type RuntimeEvent = RuntimeEvent;
- type PalletsOrigin = OriginCaller;
- type RuntimeCall = RuntimeCall;
- type MaximumWeight = MaximumSchedulerWeight;
- type ScheduleOrigin = EnsureRoot<AccountId>;
- type MaxScheduledPerBlock = MaxScheduledPerBlock;
- type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
- type OriginPrivilegeCmp = EqualPrivilegeOnly;
- type Preimages = Preimage;
-}
runtime/common/config/pallets/governance/technical_committee.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/governance/technical_committee.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-use super::*;
-
-parameter_types! {
- pub TechnicalMaxProposals: u32 = 100;
- pub TechnicalMaxMembers: u32 = 100;
-}
-
-#[cfg(not(feature = "test-env"))]
-use crate::governance_timings::technical_committee as technical_committee_timings;
-
-#[cfg(feature = "test-env")]
-pub mod technical_committee_timings {
- use super::*;
-
- parameter_types! {
- pub TechnicalMotionDuration: BlockNumber = 35;
- }
-}
-
-pub type TechnicalCollective = pallet_collective::Instance2;
-impl pallet_collective::Config<TechnicalCollective> for Runtime {
- type RuntimeOrigin = RuntimeOrigin;
- type Proposal = RuntimeCall;
- type RuntimeEvent = RuntimeEvent;
- type MotionDuration = technical_committee_timings::TechnicalMotionDuration;
- type MaxProposals = TechnicalMaxProposals;
- type MaxMembers = TechnicalMaxMembers;
- type DefaultVote = pallet_collective::PrimeDefaultVote;
- type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
- type SetMembersOrigin = EnsureRoot<AccountId>;
- type MaxProposalWeight = MaxCollectivesProposalWeight;
-}
-
-pub type TechnicalCollectiveMembership = pallet_membership::Instance2;
-impl pallet_membership::Config<TechnicalCollectiveMembership> for Runtime {
- type RuntimeEvent = RuntimeEvent;
- type AddOrigin = RootOrMoreThanHalfCouncil;
- type RemoveOrigin = RootOrMoreThanHalfCouncil;
- type SwapOrigin = RootOrMoreThanHalfCouncil;
- type ResetOrigin = EnsureRoot<AccountId>;
- type PrimeOrigin = EnsureRoot<AccountId>;
- type MembershipInitialized = TechnicalCommittee;
- type MembershipChanged = TechnicalCommittee;
- type MaxMembers = TechnicalMaxMembers;
- type WeightInfo = pallet_membership::weights::SubstrateWeight<Runtime>;
-}
-
-pub type TechnicalCommitteeMember = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
-
-pub type RootOrTechnicalCommitteeMember =
- EitherOfDiverse<EnsureRoot<AccountId>, TechnicalCommitteeMember>;
-
-pub type AllTechnicalCommittee =
- pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>;
-
-pub type RootOrAllTechnicalCommittee =
- EitherOfDiverse<EnsureRoot<AccountId>, AllTechnicalCommittee>;
runtime/common/config/pallets/mod.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -36,6 +36,9 @@
};
use sp_arithmetic::Perbill;
+#[cfg(feature = "governance")]
+use crate::runtime_common::config::governance;
+
#[cfg(feature = "unique-scheduler")]
pub mod scheduler;
@@ -50,9 +53,6 @@
#[cfg(feature = "preimage")]
pub mod preimage;
-
-#[cfg(feature = "governance")]
-pub mod governance;
parameter_types! {
pub const CollectionCreationPrice: Balance = 2 * UNIQUE;
runtime/common/config/xcm/mod.rsdiffbeforeafterboth--- a/runtime/common/config/xcm/mod.rs
+++ b/runtime/common/config/xcm/mod.rs
@@ -50,7 +50,7 @@
pub use nativeassets as xcm_assets;
#[cfg(feature = "governance")]
-use crate::runtime_common::config::pallets::governance;
+use crate::runtime_common::config::governance;
use xcm_assets::{AssetTransactor, IsReserve, Trader};