Skip to content
Snippets Groups Projects
Commit 2950340e authored by Shawn Tabrizi's avatar Shawn Tabrizi Committed by GitHub
Browse files

Fix Gov V2 Benchmarks (#12022)

* better benchmark log

* Update lib.rs

* fix gov2 benchmarks

* saturating math + fmt

* add comment
parent 2bff2f84
No related merge requests found
......@@ -101,8 +101,16 @@ fn info<T: Config>(index: ReferendumIndex) -> &'static TrackInfoOf<T> {
}
fn make_passing_after<T: Config>(index: ReferendumIndex, period_portion: Perbill) {
let support = info::<T>(index).min_support.threshold(period_portion);
let approval = info::<T>(index).min_approval.threshold(period_portion);
// We add an extra 1 percent to handle any perbill rounding errors which may cause
// a proposal to not actually pass.
let support = info::<T>(index)
.min_support
.threshold(period_portion)
.saturating_add(Perbill::from_percent(1));
let approval = info::<T>(index)
.min_approval
.threshold(period_portion)
.saturating_add(Perbill::from_percent(1));
Referenda::<T>::access_poll(index, |status| {
if let PollStatus::Ongoing(tally, class) = status {
*tally = T::Tally::from_requirements(support, approval, class);
......
......@@ -699,7 +699,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
when: T::BlockNumber,
) -> Option<(T::BlockNumber, ScheduleAddressOf<T, I>)> {
let alarm_interval = T::AlarmInterval::get().max(One::one());
let when = (when + alarm_interval - One::one()) / alarm_interval * alarm_interval;
let when = when.saturating_add(alarm_interval).saturating_sub(One::one()) /
(alarm_interval.saturating_mul(alarm_interval)).max(One::one());
let maybe_result = T::Scheduler::schedule(
DispatchTime::At(when),
None,
......@@ -752,7 +753,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
None
};
let deciding_status = DecidingStatus { since: now, confirming };
let alarm = Self::decision_time(&deciding_status, &status.tally, status.track, track);
let alarm = Self::decision_time(&deciding_status, &status.tally, status.track, track)
.max(now.saturating_add(One::one()));
status.deciding = Some(deciding_status);
let branch =
if is_passing { BeginDecidingBranch::Passing } else { BeginDecidingBranch::Failing };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment