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

Integrate Democracy Pallet into Runtime and Configuration #759

Merged
merged 16 commits into from
Sep 5, 2024
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "re
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-elections-phragmen = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
Expand Down
6 changes: 5 additions & 1 deletion runtime/laos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pallet-multisig = { workspace = true }
pallet-session = { workspace = true }
pallet-identity = { workspace = true }
pallet-sudo = { workspace = true }
pallet-democracy = { workspace = true }
pallet-treasury = { workspace = true }
pallet-preimage = { workspace = true }
pallet-timestamp = { workspace = true }
Expand Down Expand Up @@ -124,7 +125,7 @@ test-utils = { workspace = true }
ethereum = { workspace = true }

[features]
fast-mode=[]
fast-runtime=[]
default = [
"std",
]
Expand All @@ -149,6 +150,7 @@ std = [
"pallet-balances/std",
"pallet-elections-phragmen/std",
"pallet-session/std",
"pallet-democracy/std",
"pallet-sudo/std",
"pallet-treasury/std",
"pallet-collective/std",
Expand Down Expand Up @@ -226,6 +228,7 @@ runtime-benchmarks = [
"pallet-preimage/runtime-benchmarks",
"pallet-laos-evolution/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-elections-phragmen/runtime-benchmarks",
Expand Down Expand Up @@ -269,6 +272,7 @@ try-runtime = [
"pallet-sudo/try-runtime",
"pallet-collective/try-runtime",
"pallet-preimage/try-runtime",
"pallet-democracy/try-runtime",
"pallet-laos-evolution/try-runtime",
"pallet-multisig/try-runtime",
"pallet-scheduler/try-runtime",
Expand Down
1 change: 1 addition & 0 deletions runtime/laos/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ frame_benchmarking::define_benchmarks!(
[cumulus_pallet_parachain_system, ParachainSystem]
[pallet_scheduler, Scheduler]
[pallet_treasury, Treasury]
[pallet_democracy, Democracy]
// TODO pallet_xcm?
);
9 changes: 8 additions & 1 deletion runtime/laos/src/configs/collective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ parameter_types! {

pub type CouncilMajority =
pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>;
pub type AllOfCouncil =
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>;
pub type TwoThirdOfCouncil =
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>;
pub type TechnicalCommitteeMajority =
pallet_collective::EnsureProportionMoreThan<AccountId, TechnicalCommittee, 1, 2>;
pub type AllOfTechnicalCommittee =
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCommittee, 1, 1>;

pub type CouncilCollective = pallet_collective::Instance1;
impl pallet_collective::Config<CouncilCollective> for Runtime {
Expand All @@ -30,7 +38,6 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
}

#[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<TechnicalCommittee> for Runtime {
type DefaultVote = pallet_collective::MoreThanMajorityThenPrimeDefaultVote;
Expand Down
84 changes: 84 additions & 0 deletions runtime/laos/src/configs/democracy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
use super::collective::{
AllOfCouncil, AllOfTechnicalCommittee, CouncilMajority, TechnicalCommittee,
TechnicalCommitteeMajority, TwoThirdOfCouncil,
};
use crate::{
currency::UNIT, weights, AccountId, Balance, Balances, BlockNumber, OriginCaller, Preimage,
Runtime, RuntimeEvent, Scheduler, Treasury,
};
use frame_support::{parameter_types, traits::EitherOfDiverse};
use frame_system::{EnsureRoot, EnsureSigned};
use parachains_common::{DAYS, HOURS, MINUTES};
use polkadot_runtime_common::prod_or_fast;

parameter_types! {
pub LaunchPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 5 * MINUTES, "LAUNCH_PERIOD");
pub VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 5 * MINUTES, "VOTING_PERIOD");
pub FastTrackVotingPeriod: BlockNumber = prod_or_fast!(3 * HOURS, 3 * MINUTES, "FAST_TRACK_VOTING_PERIOD");
pub EnactmentPeriod: BlockNumber = prod_or_fast!(8 * DAYS, 6 * MINUTES, "ENACTMENT_PERIOD");
pub CooloffPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 5 * MINUTES, "COOLOFF_PERIOD");
pub const MaxProposals: u32 = 100;
pub const InstantAllowed: bool = true;
pub const MinimumDeposit: Balance = 1000 * UNIT;
pub const MaxVotes: u32 = 100;
pub const MaxDeposits: u32 = 100;
pub const MaxBlacklisted: u32 = 100;
}

impl pallet_democracy::Config for Runtime {
type BlacklistOrigin = EnsureRoot<AccountId>;
// To cancel a proposal before it has been passed, the technical committee must be unanimous or
// Root must agree.
type CancelProposalOrigin = EitherOfDiverse<EnsureRoot<AccountId>, AllOfTechnicalCommittee>;
// To cancel a proposal which has been passed, 2/3 of the council must agree to it.
type CancellationOrigin = TwoThirdOfCouncil;
/// Period in blocks where an external proposal may not be re-submitted
/// after being vetoed.
type CooloffPeriod = CooloffPeriod;
type Currency = Balances;
/// The minimum period of locking and the period between a proposal being
/// approved and enacted.
///
/// It should generally be a little more than the unstake period to ensure
/// that voting stakers have an opportunity to remove themselves from the
/// system in the case where they are on the losing side of a vote.
type EnactmentPeriod = EnactmentPeriod;
/// A unanimous council can have the next scheduled referendum be a straight
/// default-carries (NTB) vote.
type ExternalDefaultOrigin = AllOfCouncil;
/// A simple-majority can have the next scheduled referendum be a straight
/// majority-carries vote.
type ExternalMajorityOrigin = CouncilMajority;
/// A straight majority of the council can decide what their next motion is.
type ExternalOrigin = CouncilMajority;
/// Majority of technical committee can have an ExternalMajority/ExternalDefault vote
/// be tabled immediately and with a shorter voting/enactment period.
type FastTrackOrigin = TechnicalCommitteeMajority;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
type InstantAllowed = InstantAllowed;
type InstantOrigin = AllOfTechnicalCommittee;
// Same as EnactmentPeriod
/// How often (in blocks) new public referenda are launched.
type LaunchPeriod = LaunchPeriod;
type MaxBlacklisted = MaxBlacklisted;
type MaxDeposits = MaxDeposits;
type MaxProposals = MaxProposals;
type MaxVotes = MaxVotes;
/// The minimum amount to be used as a deposit for a public referendum
/// proposal.
type MinimumDeposit = MinimumDeposit;
type PalletsOrigin = OriginCaller;
type Preimages = Preimage;
type RuntimeEvent = RuntimeEvent;
type Scheduler = Scheduler;
/// Handler for the unbalanced reduction when slashing a preimage deposit.
type Slash = Treasury;
type SubmitOrigin = EnsureSigned<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 cool-off period.
type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCommittee>;
type VoteLockingPeriod = EnactmentPeriod;
/// How often (in blocks) to check for new votes.
type VotingPeriod = VotingPeriod;
type WeightInfo = weights::pallet_democracy::WeightInfo<Runtime>;
}
1 change: 1 addition & 0 deletions runtime/laos/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod benchmark;
mod collective;
mod cumulus_parachain_system;
mod cumulus_xcmp_queue;
mod democracy;
mod election_phragmen;
mod ethereum;
pub(crate) mod evm;
Expand Down
1 change: 1 addition & 0 deletions runtime/laos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ construct_runtime!(
Preimage: pallet_preimage = 43,
TechnicalCommittee: pallet_collective::<Instance2> = 44,
Scheduler: pallet_scheduler = 45,
Democracy: pallet_democracy = 46,

// Frontier
Ethereum: pallet_ethereum = 50,
Expand Down
1 change: 1 addition & 0 deletions runtime/laos/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub mod cumulus_pallet_xcmp_queue;
pub mod extrinsic_weights;
pub mod pallet_asset_metadata_extender;
pub mod pallet_collective;
pub mod pallet_democracy;
pub mod pallet_elections_phragmen;
pub mod pallet_evm;
pub mod pallet_laos_evolution;
Expand Down
106 changes: 56 additions & 50 deletions runtime/laos/src/weights/pallet_collective.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

//! Autogenerated weights for `pallet_collective`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2024-08-08, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-09-04, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `titan`, CPU: `12th Gen Intel(R) Core(TM) i7-1260P`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024
Expand Down Expand Up @@ -45,13 +45,13 @@ impl<T: frame_system::Config> pallet_collective::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0 + m * (176 ±0) + p * (440 ±0)`
// Estimated: `1551 + m * (117 ±35) + p * (65536 ±101)`
// Minimum execution time: 17_236_000 picoseconds.
Weight::from_parts(17_236_000, 0)
// Minimum execution time: 10_225_000 picoseconds.
Weight::from_parts(10_225_000, 0)
.saturating_add(Weight::from_parts(0, 1551))
// Standard Error: 538_714
.saturating_add(Weight::from_parts(984_342, 0).saturating_mul(m.into()))
// Standard Error: 1_539_185
.saturating_add(Weight::from_parts(2_823_406, 0).saturating_mul(p.into()))
// Standard Error: 471_270
.saturating_add(Weight::from_parts(1_193_788, 0).saturating_mul(m.into()))
// Standard Error: 1_346_487
.saturating_add(Weight::from_parts(2_801_824, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into())))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -67,11 +67,13 @@ impl<T: frame_system::Config> pallet_collective::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `66 + m * (20 ±0)`
// Estimated: `1552 + m * (20 ±0)`
// Minimum execution time: 20_985_000 picoseconds.
Weight::from_parts(49_331_530, 0)
// Minimum execution time: 19_418_000 picoseconds.
Weight::from_parts(18_663_251, 0)
.saturating_add(Weight::from_parts(0, 1552))
// Standard Error: 22_292
.saturating_add(Weight::from_parts(14_892, 0).saturating_mul(b.into()))
// Standard Error: 723
.saturating_add(Weight::from_parts(689, 0).saturating_mul(b.into()))
// Standard Error: 38_925
.saturating_add(Weight::from_parts(48_368, 0).saturating_mul(m.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(Weight::from_parts(0, 20).saturating_mul(m.into()))
}
Expand All @@ -85,13 +87,13 @@ impl<T: frame_system::Config> pallet_collective::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `66 + m * (20 ±0)`
// Estimated: `3532 + m * (20 ±0)`
// Minimum execution time: 51_170_000 picoseconds.
Weight::from_parts(50_884_077, 0)
// Minimum execution time: 20_947_000 picoseconds.
Weight::from_parts(17_919_052, 0)
.saturating_add(Weight::from_parts(0, 3532))
// Standard Error: 1_224
.saturating_add(Weight::from_parts(198, 0).saturating_mul(b.into()))
// Standard Error: 65_863
.saturating_add(Weight::from_parts(83_026, 0).saturating_mul(m.into()))
// Standard Error: 2_933
.saturating_add(Weight::from_parts(2_789, 0).saturating_mul(b.into()))
// Standard Error: 157_798
.saturating_add(Weight::from_parts(171_368, 0).saturating_mul(m.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(Weight::from_parts(0, 20).saturating_mul(m.into()))
}
Expand All @@ -112,15 +114,15 @@ impl<T: frame_system::Config> pallet_collective::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `30 + m * (20 ±0) + p * (71 ±0)`
// Estimated: `3496 + m * (20 ±0) + p * (71 ±0)`
// Minimum execution time: 58_757_000 picoseconds.
Weight::from_parts(12_176_995, 0)
// Minimum execution time: 25_009_000 picoseconds.
Weight::from_parts(16_838_986, 0)
.saturating_add(Weight::from_parts(0, 3496))
// Standard Error: 40_337
.saturating_add(Weight::from_parts(21_566, 0).saturating_mul(b.into()))
// Standard Error: 2_290_257
.saturating_add(Weight::from_parts(1_308_907, 0).saturating_mul(m.into()))
// Standard Error: 6_870_772
.saturating_add(Weight::from_parts(3_125_388, 0).saturating_mul(p.into()))
// Standard Error: 1_737
.saturating_add(Weight::from_parts(4_571, 0).saturating_mul(b.into()))
// Standard Error: 98_628
.saturating_add(Weight::from_parts(139_574, 0).saturating_mul(m.into()))
// Standard Error: 295_884
.saturating_add(Weight::from_parts(767_055, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
.saturating_add(Weight::from_parts(0, 20).saturating_mul(m.into()))
Expand All @@ -135,8 +137,8 @@ impl<T: frame_system::Config> pallet_collective::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `328 + m * (40 ±0)`
// Estimated: `4593`
// Minimum execution time: 23_097_000 picoseconds.
Weight::from_parts(25_093_000, 0)
// Minimum execution time: 18_943_000 picoseconds.
Weight::from_parts(20_254_000, 0)
.saturating_add(Weight::from_parts(0, 4593))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -155,11 +157,13 @@ impl<T: frame_system::Config> pallet_collective::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `176 + m * (40 ±0) + p * (55 ±0)`
// Estimated: `3642 + m * (40 ±0) + p * (55 ±0)`
// Minimum execution time: 24_409_000 picoseconds.
Weight::from_parts(26_028_750, 0)
// Minimum execution time: 25_665_000 picoseconds.
Weight::from_parts(24_786_958, 0)
.saturating_add(Weight::from_parts(0, 3642))
// Standard Error: 229_785
.saturating_add(Weight::from_parts(991_500, 0).saturating_mul(p.into()))
// Standard Error: 24_844
.saturating_add(Weight::from_parts(28_906, 0).saturating_mul(m.into()))
// Standard Error: 66_250
.saturating_add(Weight::from_parts(299_916, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(Weight::from_parts(0, 40).saturating_mul(m.into()))
Expand All @@ -180,15 +184,13 @@ impl<T: frame_system::Config> pallet_collective::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `248 + m * (40 ±0) + p * (78 ±0)`
// Estimated: `3714 + b * (1 ±0) + m * (40 ±0) + p * (78 ±0)`
// Minimum execution time: 50_532_000 picoseconds.
Weight::from_parts(35_629_592, 0)
// Minimum execution time: 37_653_000 picoseconds.
Weight::from_parts(36_834_554, 0)
.saturating_add(Weight::from_parts(0, 3714))
// Standard Error: 14_617
.saturating_add(Weight::from_parts(6_009, 0).saturating_mul(b.into()))
// Standard Error: 933_690
.saturating_add(Weight::from_parts(539_583, 0).saturating_mul(m.into()))
// Standard Error: 2_489_840
.saturating_add(Weight::from_parts(1_004_388, 0).saturating_mul(p.into()))
// Standard Error: 100_500
.saturating_add(Weight::from_parts(61_812, 0).saturating_mul(m.into()))
// Standard Error: 268_000
.saturating_add(Weight::from_parts(506_000, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into()))
Expand All @@ -211,11 +213,13 @@ impl<T: frame_system::Config> pallet_collective::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `230 + m * (31 ±0) + p * (55 ±0)`
// Estimated: `3696 + m * (31 ±0) + p * (55 ±0)`
// Minimum execution time: 37_864_000 picoseconds.
Weight::from_parts(38_462_208, 0)
// Minimum execution time: 25_553_000 picoseconds.
Weight::from_parts(23_703_041, 0)
.saturating_add(Weight::from_parts(0, 3696))
// Standard Error: 67_405
.saturating_add(Weight::from_parts(292_416, 0).saturating_mul(p.into()))
// Standard Error: 40_540
.saturating_add(Weight::from_parts(67_468, 0).saturating_mul(m.into()))
// Standard Error: 108_108
.saturating_add(Weight::from_parts(500_583, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(Weight::from_parts(0, 31).saturating_mul(m.into()))
Expand All @@ -238,11 +242,13 @@ impl<T: frame_system::Config> pallet_collective::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `267 + m * (40 ±0) + p * (78 ±0)`
// Estimated: `3733 + b * (1 ±0) + m * (40 ±0) + p * (78 ±0)`
// Minimum execution time: 57_164_000 picoseconds.
Weight::from_parts(197_987_852, 0)
// Minimum execution time: 41_326_000 picoseconds.
Weight::from_parts(40_599_109, 0)
.saturating_add(Weight::from_parts(0, 3733))
// Standard Error: 3_553
.saturating_add(Weight::from_parts(490, 0).saturating_mul(b.into()))
// Standard Error: 1_148
.saturating_add(Weight::from_parts(973, 0).saturating_mul(b.into()))
// Standard Error: 73_378
.saturating_add(Weight::from_parts(79_666, 0).saturating_mul(m.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(Weight::from_parts(0, 1).saturating_mul(b.into()))
Expand All @@ -260,8 +266,8 @@ impl<T: frame_system::Config> pallet_collective::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `224 + p * (32 ±0)`
// Estimated: `1935`
// Minimum execution time: 21_041_000 picoseconds.
Weight::from_parts(24_164_000, 0)
// Minimum execution time: 15_349_000 picoseconds.
Weight::from_parts(16_658_000, 0)
.saturating_add(Weight::from_parts(0, 1935))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(3))
Expand Down
Loading
Loading