Several tweaks needed for Governance 2.0 (#11124)

* Add stepped curve for referenda

* Treasury SpendOrigin

* Add tests

* Better Origin Or-gating

* Reciprocal curve

* Tests for reciprical and rounding in PerThings

* Tweaks and new quad curve

* Const derivation of reciprocal curve parameters

* Remove some unneeded code

* Actually useful linear curve

* Fixes

* Provisional curves

* Rejig 'turnout' as 'support'

* Use TypedGet

* Fixes

* Enable curve's ceil to be configured

* Formatting

* Fixes

* Fixes

* Fixes

* Remove EnsureOneOf

* Fixes

* Fixes

* Fixes

* Formatting

* Fixes

* Update frame/support/src/traits/dispatch.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Grumbles

* Formatting

* Fixes

* APIs of VoteTally should include class

* Fixes

* Fix overlay prefix removal result

* Second part of the overlay prefix removal fix.

* Formatting

* Fixes

* Add some tests and make clear rounding algo

* Fixes

* Formatting

* Revert questionable fix

* Introduce test for kill_prefix

* Fixes

* Formatting

* Fixes

* Fix possible overflow

* Docs

* Add benchmark test

* Formatting

* Update frame/referenda/src/types.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* Docs

* Fixes

* Use latest API in tests

* Formatting

* Whitespace

* Use latest API in tests

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
Gavin Wood
2022-05-31 11:12:34 +01:00
committed by GitHub
parent c808340d9a
commit 7808b0c349
34 changed files with 2050 additions and 339 deletions
@@ -101,27 +101,27 @@ fn info<T: Config>(index: ReferendumIndex) -> &'static TrackInfoOf<T> {
}
fn make_passing_after<T: Config>(index: ReferendumIndex, period_portion: Perbill) {
let turnout = info::<T>(index).min_turnout.threshold(period_portion);
let support = info::<T>(index).min_support.threshold(period_portion);
let approval = info::<T>(index).min_approval.threshold(period_portion);
Referenda::<T>::access_poll(index, |status| {
if let PollStatus::Ongoing(tally, ..) = status {
*tally = T::Tally::from_requirements(turnout, approval);
if let PollStatus::Ongoing(tally, class) = status {
*tally = T::Tally::from_requirements(support, approval, class);
}
});
}
fn make_passing<T: Config>(index: ReferendumIndex) {
Referenda::<T>::access_poll(index, |status| {
if let PollStatus::Ongoing(tally, ..) = status {
*tally = T::Tally::unanimity();
if let PollStatus::Ongoing(tally, class) = status {
*tally = T::Tally::unanimity(class);
}
});
}
fn make_failing<T: Config>(index: ReferendumIndex) {
Referenda::<T>::access_poll(index, |status| {
if let PollStatus::Ongoing(tally, ..) = status {
*tally = T::Tally::default();
if let PollStatus::Ongoing(tally, class) = status {
*tally = T::Tally::rejection(class);
}
});
}
@@ -501,6 +501,7 @@ benchmarks! {
let (_caller, index) = create_referendum::<T>();
place_deposit::<T>(index);
skip_prepare_period::<T>(index);
make_failing::<T>(index);
nudge::<T>(index);
skip_decision_period::<T>(index);
}: nudge_referendum(RawOrigin::Root, index)