Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Ranked Collective pallet (based on gav-gov2-tweaks) #11474

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2c7960e
Add stepped curve for referenda
gavofyork Mar 26, 2022
f756d98
Treasury SpendOrigin
gavofyork Mar 28, 2022
de49a27
Merge remote-tracking branch 'origin/master' into gav-gov2-tweaks
gavofyork Apr 4, 2022
788a85f
Add tests
gavofyork Apr 4, 2022
9b967e7
Better Origin Or-gating
gavofyork Apr 4, 2022
b84e299
Reciprocal curve
gavofyork Apr 10, 2022
c8e8a5c
Tests for reciprical and rounding in PerThings
gavofyork Apr 11, 2022
a1a4619
Tweaks and new quad curve
gavofyork Apr 12, 2022
5710058
Const derivation of reciprocal curve parameters
gavofyork Apr 12, 2022
6bde6aa
Remove some unneeded code
gavofyork Apr 12, 2022
abb8a8f
Actually useful linear curve
gavofyork Apr 12, 2022
9cecb07
Fixes
gavofyork Apr 12, 2022
31da176
Provisional curves
gavofyork Apr 12, 2022
e6c0f02
Rejig 'turnout' as 'support'
gavofyork Apr 13, 2022
7aeab6c
Merge remote-tracking branch 'origin/master' into gav-gov2-tweaks
gavofyork Apr 13, 2022
ed050ca
Use TypedGet
gavofyork Apr 13, 2022
386977a
Fixes
gavofyork Apr 13, 2022
2cd8a46
Enable curve's ceil to be configured
gavofyork Apr 13, 2022
cb567e5
Merge remote-tracking branch 'origin/master' into gav-gov2-tweaks
gavofyork Apr 27, 2022
3f424ae
Merge remote-tracking branch 'origin/master' into gav-gov2-tweaks
gavofyork May 11, 2022
485fd23
Formatting
gavofyork May 11, 2022
f5d6f45
Fixes
gavofyork May 11, 2022
7ce42e8
Fixes
gavofyork May 11, 2022
b25bc5f
Fixes
gavofyork May 11, 2022
45208e0
Remove EnsureOneOf
gavofyork May 11, 2022
35764fb
Fixes
gavofyork May 11, 2022
3b53be6
Fixes
gavofyork May 11, 2022
cbadc3e
Fixes
gavofyork May 12, 2022
940f4b3
Fixes
gavofyork May 12, 2022
a091e9d
Formatting
gavofyork May 12, 2022
73bbf7c
Fixes
gavofyork May 12, 2022
ef59083
Merge remote-tracking branch 'origin/master' into gav-gov2-tweaks
gavofyork May 12, 2022
a291d47
Merge remote-tracking branch 'origin/master' into gav-gov2-tweaks
gavofyork May 17, 2022
8019e33
Update frame/support/src/traits/dispatch.rs
gavofyork May 18, 2022
7596264
Grumbles
gavofyork May 18, 2022
2b4a20a
Merge remote-tracking branch 'origin/master' into gav-gov2-tweaks
gavofyork May 18, 2022
40ca11e
Formatting
gavofyork May 18, 2022
18c6438
Fixes
gavofyork May 18, 2022
ed23dc4
Merge remote-tracking branch 'origin/master' into gav-gov2-tweaks
gavofyork May 19, 2022
d04ebd0
APIs of VoteTally should include class
gavofyork May 19, 2022
91b1094
Fixes
gavofyork May 19, 2022
471b43a
Fix overlay prefix removal result
gavofyork May 18, 2022
92cd9a3
Second part of the overlay prefix removal fix.
gavofyork May 18, 2022
0239621
Merge remote-tracking branch 'origin/master' into gav-gov2-tweaks
gavofyork May 19, 2022
d504d70
Formatting
gavofyork May 19, 2022
cace119
Fixes
gavofyork May 19, 2022
e988654
Add some tests and make clear rounding algo
gavofyork May 19, 2022
38f14fd
Fixes
gavofyork May 20, 2022
064de3d
Formatting
gavofyork May 20, 2022
4f456f8
Revert questionable fix
gavofyork May 24, 2022
06d9823
Ranked Collective pallet
gavofyork May 18, 2022
e8f0765
Fixes
gavofyork May 18, 2022
60d357e
benchmarks
gavofyork May 18, 2022
3693350
Weights
gavofyork May 18, 2022
049b0f1
Allow class voting in rank
gavofyork May 19, 2022
374daab
Index by rank, still O(1).
gavofyork May 19, 2022
aaca320
Custom vote weights
gavofyork May 19, 2022
abba95a
Formatting
gavofyork May 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 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 @@ members = [
"frame/nomination-pools",
"frame/nomination-pools/benchmarking",
"frame/randomness-collective-flip",
"frame/ranked-collective",
"frame/recovery",
"frame/referenda",
"frame/remark",
Expand Down
4 changes: 4 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pallet-offences-benchmarking = { version = "4.0.0-dev", path = "../../../frame/o
pallet-preimage = { version = "4.0.0-dev", default-features = false, path = "../../../frame/preimage" }
pallet-proxy = { version = "4.0.0-dev", default-features = false, path = "../../../frame/proxy" }
pallet-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, path = "../../../frame/randomness-collective-flip" }
pallet-ranked-collective = { version = "4.0.0-dev", default-features = false, path = "../../../frame/ranked-collective" }
pallet-recovery = { version = "4.0.0-dev", default-features = false, path = "../../../frame/recovery" }
pallet-referenda = { version = "4.0.0-dev", default-features = false, path = "../../../frame/referenda" }
pallet-remark = { version = "4.0.0-dev", default-features = false, path = "../../../frame/remark" }
Expand Down Expand Up @@ -176,6 +177,7 @@ std = [
"pallet-utility/std",
"sp-version/std",
"pallet-society/std",
"pallet-ranked-collective/std",
"pallet-referenda/std",
"pallet-remark/std",
"pallet-recovery/std",
Expand Down Expand Up @@ -218,6 +220,7 @@ runtime-benchmarks = [
"pallet-preimage/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-ranked-collective/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
"pallet-recovery/runtime-benchmarks",
"pallet-remark/runtime-benchmarks",
Expand Down Expand Up @@ -265,6 +268,7 @@ try-runtime = [
"pallet-offences/try-runtime",
"pallet-preimage/try-runtime",
"pallet-proxy/try-runtime",
"pallet-ranked-collective/try-runtime",
"pallet-randomness-collective-flip/try-runtime",
"pallet-recovery/try-runtime",
"pallet-referenda/try-runtime",
Expand Down
62 changes: 47 additions & 15 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]
#![recursion_limit = "512"]

use codec::{Decode, Encode, MaxEncodedLen};
use frame_election_provider_support::{
Expand All @@ -31,7 +31,7 @@ use frame_support::{
pallet_prelude::Get,
parameter_types,
traits::{
AsEnsureOriginWithArg, ConstU128, ConstU16, ConstU32, Currency, EnsureOneOf,
AsEnsureOriginWithArg, ConstU128, ConstU16, ConstU32, Currency, EitherOfDiverse,
EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter, KeyOwnerProofSystem,
LockIdentifier, Nothing, OnUnbalanced, U128CurrencyToVote,
},
Expand Down Expand Up @@ -550,7 +550,7 @@ impl pallet_staking::Config for Runtime {
type BondingDuration = BondingDuration;
type SlashDeferDuration = SlashDeferDuration;
/// A super-majority of the council can cancel the slash.
type SlashCancelOrigin = EnsureOneOf<
type SlashCancelOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 4>,
>;
Expand Down Expand Up @@ -780,11 +780,11 @@ parameter_types! {

pub struct TracksInfo;
impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
type Id = u8;
type Id = u16;
type Origin = <Origin as frame_support::traits::OriginTrait>::PalletsOrigin;
fn tracks() -> &'static [(Self::Id, pallet_referenda::TrackInfo<Balance, BlockNumber>)] {
static DATA: [(u8, pallet_referenda::TrackInfo<Balance, BlockNumber>); 1] = [(
0u8,
static DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 1] = [(
0u16,
pallet_referenda::TrackInfo {
name: "root",
max_deciding: 1,
Expand All @@ -794,12 +794,14 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
confirm_period: 2,
min_enactment_period: 4,
min_approval: pallet_referenda::Curve::LinearDecreasing {
begin: Perbill::from_percent(100),
delta: Perbill::from_percent(50),
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
ceil: Perbill::from_percent(100),
},
min_turnout: pallet_referenda::Curve::LinearDecreasing {
begin: Perbill::from_percent(100),
delta: Perbill::from_percent(100),
min_support: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(0),
ceil: Perbill::from_percent(100),
},
},
)];
Expand Down Expand Up @@ -835,6 +837,32 @@ impl pallet_referenda::Config for Runtime {
type Tracks = TracksInfo;
}

impl pallet_referenda::Config<pallet_referenda::Instance2> for Runtime {
type WeightInfo = pallet_referenda::weights::SubstrateWeight<Self>;
type Call = Call;
type Event = Event;
type Scheduler = Scheduler;
type Currency = pallet_balances::Pallet<Self>;
type CancelOrigin = EnsureRoot<AccountId>;
type KillOrigin = EnsureRoot<AccountId>;
type Slash = ();
type Votes = pallet_ranked_collective::Votes;
type Tally = pallet_ranked_collective::TallyOf<Runtime>;
type SubmissionDeposit = SubmissionDeposit;
type MaxQueued = ConstU32<100>;
type UndecidingTimeout = UndecidingTimeout;
type AlarmInterval = AlarmInterval;
type Tracks = TracksInfo;
}

impl pallet_ranked_collective::Config for Runtime {
type WeightInfo = pallet_ranked_collective::weights::SubstrateWeight<Self>;
type Event = Event;
type AdminOrigin = EnsureRoot<AccountId>;
type Polls = RankedPolls;
type VoteWeight = pallet_ranked_collective::Geometric;
}

impl pallet_remark::Config for Runtime {
type WeightInfo = pallet_remark::weights::SubstrateWeight<Self>;
type Event = Event;
Expand Down Expand Up @@ -882,7 +910,7 @@ impl pallet_democracy::Config for Runtime {
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>;
// To cancel a proposal before it has been passed, the technical committee must be unanimous or
// Root must agree.
type CancelProposalOrigin = EnsureOneOf<
type CancelProposalOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>,
>;
Expand Down Expand Up @@ -972,7 +1000,7 @@ impl pallet_collective::Config<TechnicalCollective> for Runtime {
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
}

type EnsureRootOrHalfCouncil = EnsureOneOf<
type EnsureRootOrHalfCouncil = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
>;
Expand Down Expand Up @@ -1006,11 +1034,11 @@ parameter_types! {
impl pallet_treasury::Config for Runtime {
type PalletId = TreasuryPalletId;
type Currency = Balances;
type ApproveOrigin = EnsureOneOf<
type ApproveOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 5>,
>;
type RejectOrigin = EnsureOneOf<
type RejectOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
>;
Expand All @@ -1025,6 +1053,7 @@ impl pallet_treasury::Config for Runtime {
type SpendFunds = Bounties;
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
type MaxApprovals = MaxApprovals;
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<u128>;
}

parameter_types! {
Expand Down Expand Up @@ -1531,6 +1560,8 @@ construct_runtime!(
ConvictionVoting: pallet_conviction_voting,
Whitelist: pallet_whitelist,
NominationPools: pallet_nomination_pools,
RankedPolls: pallet_referenda::<Instance2>,
RankedCollective: pallet_ranked_collective,
}
);

Expand Down Expand Up @@ -1619,6 +1650,7 @@ mod benches {
[pallet_offences, OffencesBench::<Runtime>]
[pallet_preimage, Preimage]
[pallet_proxy, Proxy]
[pallet_ranked_collective, RankedCollective]
[pallet_referenda, Referenda]
[pallet_recovery, Recovery]
[pallet_remark, Remark]
Expand Down
2 changes: 1 addition & 1 deletion docs/Upgrading-2.0-to-3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Democracy brings three new settings with this release, all to allow for better i
type CancellationOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>;
+ // To cancel a proposal before it has been passed, the technical committee must be unanimous or
+ // Root must agree.
+ type CancelProposalOrigin = EnsureOneOf<
+ type CancelProposalOrigin = EitherOfDiverse<
+ AccountId,
+ EnsureRoot<AccountId>,
+ pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>,
Expand Down
2 changes: 1 addition & 1 deletion frame/bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ parameter_types! {
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
}

// impl pallet_treasury::Config for Test {
impl pallet_treasury::Config for Test {
type PalletId = TreasuryPalletId;
type Currency = pallet_balances::Pallet<Test>;
Expand All @@ -126,6 +125,7 @@ impl pallet_treasury::Config for Test {
type WeightInfo = ();
type SpendFunds = Bounties;
type MaxApprovals = ConstU32<100>;
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<u64>;
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions frame/child-bounties/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl pallet_treasury::Config for Test {
type WeightInfo = ();
type SpendFunds = Bounties;
type MaxApprovals = ConstU32<100>;
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<u64>;
}
parameter_types! {
// This will be 50% of the bounty fee.
Expand Down
Loading