From 86796d30fe45ec85fd9b1b8183039cce29d1521b Mon Sep 17 00:00:00 2001 From: luispdm <17044119+luispdm@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:29:22 +0200 Subject: [PATCH] technical committee + small refactoring of `CouncilMajority` --- runtime/laos/src/configs/collective.rs | 54 +++++++++++++++++++ .../laos/src/configs/collective_council.rs | 36 ------------- runtime/laos/src/configs/mod.rs | 2 +- runtime/laos/src/configs/treasury.rs | 4 +- runtime/laos/src/lib.rs | 1 + 5 files changed, 57 insertions(+), 40 deletions(-) create mode 100644 runtime/laos/src/configs/collective.rs delete mode 100644 runtime/laos/src/configs/collective_council.rs diff --git a/runtime/laos/src/configs/collective.rs b/runtime/laos/src/configs/collective.rs new file mode 100644 index 00000000..27e64ad1 --- /dev/null +++ b/runtime/laos/src/configs/collective.rs @@ -0,0 +1,54 @@ +use crate::{weights, AccountId, BlockNumber, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin}; +use frame_support::{pallet_prelude::Weight, parameter_types, traits::EitherOfDiverse}; +use frame_system::EnsureRoot; +use laos_primitives::RuntimeBlockWeights; +#[cfg(not(feature = "fast-mode"))] +use parachains_common::DAYS; +#[cfg(feature = "fast-mode")] +use parachains_common::MINUTES; +use sp_runtime::Perbill; + +#[cfg(feature = "fast-mode")] +pub const MOTION_DURATION: BlockNumber = 5 * MINUTES; +#[cfg(not(feature = "fast-mode"))] +pub const MOTION_DURATION: BlockNumber = 7 * DAYS; + +parameter_types! { + pub const MotionDuration: BlockNumber = MOTION_DURATION; + pub const MaxProposals: u32 = 7; + pub const MaxMembers: u32 = 20; + pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block; +} + +pub type CouncilMajority = + pallet_collective::EnsureProportionMoreThan; + +pub type CouncilCollective = pallet_collective::Instance1; +impl pallet_collective::Config for Runtime { + type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote; + type MaxMembers = MaxMembers; + type MaxProposalWeight = MaxProposalWeight; + type MaxProposals = MaxProposals; + type MotionDuration = MotionDuration; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SetMembersOrigin = EnsureRoot; + type WeightInfo = weights::pallet_collective::WeightInfo; +} + +#[allow(dead_code)] // TODO remove me when integrating https://github.com/freeverseio/laos/pull/759 +pub type TechnicalCommittee = pallet_collective::Instance2; +impl pallet_collective::Config for Runtime { + type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote; + type MaxMembers = MaxMembers; + type MaxProposalWeight = MaxProposalWeight; + type MaxProposals = MaxProposals; + type MotionDuration = MotionDuration; + type Proposal = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + // the root or a turnout of 50%+1 of the council can select the technical committee + type SetMembersOrigin = EitherOfDiverse, CouncilMajority>; + type WeightInfo = weights::pallet_collective::WeightInfo; +} diff --git a/runtime/laos/src/configs/collective_council.rs b/runtime/laos/src/configs/collective_council.rs deleted file mode 100644 index 848850fd..00000000 --- a/runtime/laos/src/configs/collective_council.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::{weights, AccountId, BlockNumber, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin}; -use frame_support::{pallet_prelude::Weight, parameter_types}; -use frame_system::EnsureRoot; -use laos_primitives::RuntimeBlockWeights; -#[cfg(not(feature = "fast-mode"))] -use parachains_common::DAYS; -#[cfg(feature = "fast-mode")] -use parachains_common::MINUTES; -use sp_runtime::Perbill; - -#[cfg(feature = "fast-mode")] -pub const COUNCIL_MOTION_DURATION: BlockNumber = 5 * MINUTES; -#[cfg(not(feature = "fast-mode"))] -pub const COUNCIL_MOTION_DURATION: BlockNumber = 7 * DAYS; - -parameter_types! { - pub const CouncilMotionDuration: BlockNumber = COUNCIL_MOTION_DURATION; - pub const CouncilMaxProposals: u32 = 7; - pub const CouncilMaxMembers: u32 = 20; - pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block; - pub MaxCollectivesProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block; -} - -pub type CouncilCollective = pallet_collective::Instance1; -impl pallet_collective::Config for Runtime { - type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote; - type MaxMembers = CouncilMaxMembers; - type MaxProposalWeight = MaxCollectivesProposalWeight; - type MaxProposals = CouncilMaxProposals; - type MotionDuration = CouncilMotionDuration; - type Proposal = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type SetMembersOrigin = EnsureRoot; - type WeightInfo = weights::pallet_collective::WeightInfo; -} diff --git a/runtime/laos/src/configs/mod.rs b/runtime/laos/src/configs/mod.rs index 82d970b0..488b6142 100644 --- a/runtime/laos/src/configs/mod.rs +++ b/runtime/laos/src/configs/mod.rs @@ -20,7 +20,7 @@ mod authorship; mod balances; mod base_fee; mod benchmark; -mod collective_council; +mod collective; mod cumulus_parachain_system; mod cumulus_xcmp_queue; mod election_phragmen; diff --git a/runtime/laos/src/configs/treasury.rs b/runtime/laos/src/configs/treasury.rs index be781bcb..293ce195 100644 --- a/runtime/laos/src/configs/treasury.rs +++ b/runtime/laos/src/configs/treasury.rs @@ -1,4 +1,4 @@ -use super::collective_council::CouncilCollective; +use super::collective::CouncilMajority; use crate::{ currency::UNIT, weights, AccountId, Balance, Balances, BlockNumber, Permill, Runtime, RuntimeEvent, Treasury, @@ -34,8 +34,6 @@ parameter_types! { pub TreasuryAccount: AccountId = Treasury::account_id(); } -type CouncilMajority = - pallet_collective::EnsureProportionMoreThan; type ApproveOrigin = EitherOfDiverse, CouncilMajority>; type RejectOrigin = EitherOfDiverse, CouncilMajority>; diff --git a/runtime/laos/src/lib.rs b/runtime/laos/src/lib.rs index b6b9cf25..d693c370 100644 --- a/runtime/laos/src/lib.rs +++ b/runtime/laos/src/lib.rs @@ -134,6 +134,7 @@ construct_runtime!( Treasury: pallet_treasury = 41, Elections: pallet_elections_phragmen = 42, Preimage: pallet_preimage = 43, + TechnicalCommittee: pallet_collective:: = 44, // Frontier Ethereum: pallet_ethereum = 50,