Introduce scheduler and use it for the democracy dispatch queue (#5412)

* Initial draft of the logic

* Build and tests

* Make work with new initialize infratructure.

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

* Fix test

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

* Rejig interface to make it more useful for democracy.

* Try to get democraxy module to make use of scheduler.

* Make democracy use scheduler.

* Use actual max weight for enactent

* Remove TODO

* Fix runtime build

* Minor cleanup

* Fix scheduler.

* Fix benchmarks

* Fix

* Fix

* Fix

* More bench fixes

* Fix

* Fix.

* Add more bench constants.

* Fix cancel_queued bench.

* Fix test comment.

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

Co-authored-by: Marcio Diaz <marcio.diaz@gmail.com>
This commit is contained in:
Gavin Wood
2020-04-01 15:52:39 +02:00
committed by GitHub
parent 433824511e
commit eac1a1964e
16 changed files with 825 additions and 121 deletions
@@ -50,13 +50,11 @@ fn cancel_queued_should_work() {
fast_forward_to(4);
assert_eq!(Democracy::dispatch_queue(), vec![
(6, set_balance_proposal_hash_and_note(2), 0)
]);
assert!(pallet_scheduler::Agenda::<Test>::get(6)[0].is_some());
assert_noop!(Democracy::cancel_queued(Origin::ROOT, 1), Error::<Test>::ProposalMissing);
assert_ok!(Democracy::cancel_queued(Origin::ROOT, 0));
assert_eq!(Democracy::dispatch_queue(), vec![]);
assert!(pallet_scheduler::Agenda::<Test>::get(6)[0].is_none());
});
}
@@ -152,7 +152,6 @@ fn reaping_imminent_preimage_should_fail() {
assert_ok!(Democracy::vote(Origin::signed(1), r, aye(1)));
next_block();
next_block();
// now imminent.
assert_noop!(Democracy::reap_preimage(Origin::signed(6), h), Error::<Test>::Imminent);
});
}
@@ -85,9 +85,7 @@ fn single_proposal_should_work() {
fast_forward_to(4);
assert!(Democracy::referendum_status(0).is_err());
assert_eq!(Democracy::dispatch_queue(), vec![
(6, set_balance_proposal_hash_and_note(2), 0)
]);
assert!(pallet_scheduler::Agenda::<Test>::get(6)[0].is_some());
// referendum passes and wait another two blocks for enactment.
fast_forward_to(6);