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

Several tweaks needed for Governance 2.0 #11124

Merged
merged 67 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
67 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
697bff5
Introduce test for kill_prefix
gavofyork May 24, 2022
d111c87
Fixes
gavofyork May 25, 2022
244c5f4
Formatting
gavofyork May 25, 2022
656baff
Fixes
gavofyork May 25, 2022
bcce142
Fix possible overflow
gavofyork May 25, 2022
af7b81e
Docs
gavofyork May 25, 2022
ad9a732
Add benchmark test
gavofyork May 25, 2022
fd5e03a
Formatting
gavofyork May 25, 2022
18c72d3
Merge remote-tracking branch 'origin/master' into gav-gov2-tweaks
gavofyork May 29, 2022
db730db
Update frame/referenda/src/types.rs
gavofyork May 30, 2022
c251948
Docs
gavofyork May 30, 2022
4088a11
Merge branch 'gav-gov2-tweaks' of github.com:paritytech/substrate int…
gavofyork May 30, 2022
9b1bd8b
Fixes
gavofyork May 30, 2022
d2730c2
Use latest API in tests
gavofyork May 30, 2022
5f7b13e
Formatting
gavofyork May 30, 2022
b58dbbc
Whitespace
gavofyork May 30, 2022
e1b00d8
Use latest API in tests
gavofyork May 30, 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
6 changes: 4 additions & 2 deletions Cargo.lock

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

25 changes: 14 additions & 11 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,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 @@ -548,7 +548,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 @@ -773,12 +773,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 @@ -861,7 +863,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 @@ -951,7 +953,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 @@ -985,11 +987,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 @@ -1004,6 +1006,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
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
50 changes: 25 additions & 25 deletions frame/conviction-voting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,19 @@ fn basic_voting_works() {
assert_ok!(Voting::vote(Origin::signed(1), 3, aye(2, 5)));
assert_eq!(tally(3), Tally::from_parts(10, 0, 2));
assert_ok!(Voting::vote(Origin::signed(1), 3, nay(2, 5)));
assert_eq!(tally(3), Tally::from_parts(0, 10, 2));
assert_eq!(tally(3), Tally::from_parts(0, 10, 0));
assert_eq!(Balances::usable_balance(1), 8);

assert_ok!(Voting::vote(Origin::signed(1), 3, aye(5, 1)));
assert_eq!(tally(3), Tally::from_parts(5, 0, 5));
assert_ok!(Voting::vote(Origin::signed(1), 3, nay(5, 1)));
assert_eq!(tally(3), Tally::from_parts(0, 5, 5));
assert_eq!(tally(3), Tally::from_parts(0, 5, 0));
assert_eq!(Balances::usable_balance(1), 5);

assert_ok!(Voting::vote(Origin::signed(1), 3, aye(10, 0)));
assert_eq!(tally(3), Tally::from_parts(1, 0, 10));
assert_ok!(Voting::vote(Origin::signed(1), 3, nay(10, 0)));
assert_eq!(tally(3), Tally::from_parts(0, 1, 10));
assert_eq!(tally(3), Tally::from_parts(0, 1, 0));
assert_eq!(Balances::usable_balance(1), 0);

assert_ok!(Voting::remove_vote(Origin::signed(1), None, 3));
Expand All @@ -300,19 +300,19 @@ fn voting_balance_gets_locked() {
assert_ok!(Voting::vote(Origin::signed(1), 3, aye(2, 5)));
assert_eq!(tally(3), Tally::from_parts(10, 0, 2));
assert_ok!(Voting::vote(Origin::signed(1), 3, nay(2, 5)));
assert_eq!(tally(3), Tally::from_parts(0, 10, 2));
assert_eq!(tally(3), Tally::from_parts(0, 10, 0));
assert_eq!(Balances::usable_balance(1), 8);

assert_ok!(Voting::vote(Origin::signed(1), 3, aye(5, 1)));
assert_eq!(tally(3), Tally::from_parts(5, 0, 5));
assert_ok!(Voting::vote(Origin::signed(1), 3, nay(5, 1)));
assert_eq!(tally(3), Tally::from_parts(0, 5, 5));
assert_eq!(tally(3), Tally::from_parts(0, 5, 0));
assert_eq!(Balances::usable_balance(1), 5);

assert_ok!(Voting::vote(Origin::signed(1), 3, aye(10, 0)));
assert_eq!(tally(3), Tally::from_parts(1, 0, 10));
assert_ok!(Voting::vote(Origin::signed(1), 3, nay(10, 0)));
assert_eq!(tally(3), Tally::from_parts(0, 1, 10));
assert_eq!(tally(3), Tally::from_parts(0, 1, 0));
assert_eq!(Balances::usable_balance(1), 0);

assert_ok!(Voting::remove_vote(Origin::signed(1), None, 3));
Expand Down Expand Up @@ -403,9 +403,9 @@ fn classwise_delegation_works() {
assert_eq!(
Polls::get(),
vec![
(0, Ongoing(Tally::from_parts(6, 2, 35), 0)),
(1, Ongoing(Tally::from_parts(6, 2, 35), 1)),
(2, Ongoing(Tally::from_parts(6, 2, 35), 2)),
(0, Ongoing(Tally::from_parts(6, 2, 15), 0)),
(1, Ongoing(Tally::from_parts(6, 2, 15), 1)),
(2, Ongoing(Tally::from_parts(6, 2, 15), 2)),
(3, Ongoing(Tally::from_parts(0, 0, 0), 2)),
]
.into_iter()
Expand All @@ -417,10 +417,10 @@ fn classwise_delegation_works() {
assert_eq!(
Polls::get(),
vec![
(0, Ongoing(Tally::from_parts(6, 2, 35), 0)),
(1, Ongoing(Tally::from_parts(6, 2, 35), 1)),
(2, Ongoing(Tally::from_parts(6, 2, 35), 2)),
(3, Ongoing(Tally::from_parts(0, 6, 15), 2)),
(0, Ongoing(Tally::from_parts(6, 2, 15), 0)),
(1, Ongoing(Tally::from_parts(6, 2, 15), 1)),
(2, Ongoing(Tally::from_parts(6, 2, 15), 2)),
(3, Ongoing(Tally::from_parts(0, 6, 0), 2)),
]
.into_iter()
.collect()
Expand All @@ -432,10 +432,10 @@ fn classwise_delegation_works() {
assert_eq!(
Polls::get(),
vec![
(0, Ongoing(Tally::from_parts(6, 2, 35), 0)),
(1, Ongoing(Tally::from_parts(6, 2, 35), 1)),
(2, Ongoing(Tally::from_parts(1, 7, 35), 2)),
(3, Ongoing(Tally::from_parts(0, 1, 10), 2)),
(0, Ongoing(Tally::from_parts(6, 2, 15), 0)),
(1, Ongoing(Tally::from_parts(6, 2, 15), 1)),
(2, Ongoing(Tally::from_parts(1, 7, 10), 2)),
(3, Ongoing(Tally::from_parts(0, 1, 0), 2)),
]
.into_iter()
.collect()
Expand All @@ -451,10 +451,10 @@ fn classwise_delegation_works() {
assert_eq!(
Polls::get(),
vec![
(0, Ongoing(Tally::from_parts(4, 2, 33), 0)),
(1, Ongoing(Tally::from_parts(4, 2, 33), 1)),
(2, Ongoing(Tally::from_parts(4, 2, 33), 2)),
(3, Ongoing(Tally::from_parts(0, 4, 13), 2)),
(0, Ongoing(Tally::from_parts(4, 2, 13), 0)),
(1, Ongoing(Tally::from_parts(4, 2, 13), 1)),
(2, Ongoing(Tally::from_parts(4, 2, 13), 2)),
(3, Ongoing(Tally::from_parts(0, 4, 0), 2)),
]
.into_iter()
.collect()
Expand Down Expand Up @@ -483,10 +483,10 @@ fn classwise_delegation_works() {
assert_eq!(
Polls::get(),
vec![
(0, Ongoing(Tally::from_parts(7, 2, 36), 0)),
(1, Ongoing(Tally::from_parts(8, 2, 37), 1)),
(2, Ongoing(Tally::from_parts(9, 2, 38), 2)),
(3, Ongoing(Tally::from_parts(0, 9, 18), 2)),
(0, Ongoing(Tally::from_parts(7, 2, 16), 0)),
(1, Ongoing(Tally::from_parts(8, 2, 17), 1)),
(2, Ongoing(Tally::from_parts(9, 2, 18), 2)),
(3, Ongoing(Tally::from_parts(0, 9, 0), 2)),
]
.into_iter()
.collect()
Expand Down
Loading