mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 21:01:05 +00:00
Fix Gov V2 Benchmarks (#12022)
* better benchmark log * Update lib.rs * fix gov2 benchmarks * saturating math + fmt * add comment
This commit is contained in:
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user