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

Referendum decision period quantization #12810

Closed
wants to merge 3 commits into from

Conversation

muharem
Copy link
Contributor

@muharem muharem commented Nov 30, 2022

Right now if AlarmInterval set to > 1, the time for alarm will be calculated to the past, and scheduler will fail.

This PR fixes it.

@muharem muharem added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Nov 30, 2022
@muharem muharem changed the title Decision period quantization Referendum decision period quantization Nov 30, 2022
@@ -754,9 +759,6 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
call: BoundedCallOf<T, I>,
when: T::BlockNumber,
) -> Option<(T::BlockNumber, ScheduleAddressOf<T, I>)> {
let alarm_interval = T::AlarmInterval::get().max(One::one());
let when = when.saturating_add(alarm_interval).saturating_sub(One::one()) /
(alarm_interval.saturating_mul(alarm_interval)).max(One::one());
Copy link
Contributor Author

@muharem muharem Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its probably supposed to be calculated from the duration.

I moved this logic to decision_alarm, because we need the quantization only for the decision period.
The preparation and confirmation period has to pass fully for each stage, at least this how I understand it.

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-check-benches
Logs: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/2103276

/// Minimum alarm period for the referendum wakeup scheduler during the decision stage.
/// Prevents wake up calls from being too frequent as a result of the quantization.
#[pallet::constant]
type MinAlarmPeriod: Get<Self::BlockNumber>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the actual use-case for this?

@gavofyork
Copy link
Member

Please add a test.

@gavofyork
Copy link
Member

Please see #12815 and check if it passes your test.

@muharem
Copy link
Contributor Author

muharem commented Dec 1, 2022

Please see #12815 and check if it passes your test.

got it wrong actually in this PR, please check an addition to your pr, test and note_one_fewer_deciding uses set_alarm #12818

@muharem
Copy link
Contributor Author

muharem commented Dec 1, 2022

Closing in favor of this pr #12815

@muharem muharem closed this Dec 1, 2022
@muharem muharem removed the request for review from shawntabrizi December 1, 2022 11:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants