Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve HostConfiguration consistency check #3897

Merged
merged 2 commits into from
Apr 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions polkadot/runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub struct HostConfiguration<BlockNumber> {
///
/// Must be at least 1.
pub no_show_slots: u32,
/// The number of delay tranches in total.
/// The number of delay tranches in total. Must be at least 1.
pub n_delay_tranches: u32,
/// The width of the zeroth delay tranche for approval assignments. This many delay tranches
/// beyond 0 are all consolidated to form a wide 0 tranche.
Expand Down Expand Up @@ -247,7 +247,7 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
max_validators: None,
dispute_period: 6,
dispute_post_conclusion_acceptance_period: 100.into(),
n_delay_tranches: Default::default(),
n_delay_tranches: 1,
zeroth_delay_tranche_width: Default::default(),
needed_approvals: Default::default(),
relay_vrf_modulo_samples: Default::default(),
Expand Down Expand Up @@ -315,6 +315,8 @@ pub enum InconsistentError<BlockNumber> {
LookaheadExceedsTTL,
/// Passed in queue size for on-demand was too large.
OnDemandQueueSizeTooLarge,
/// Number of delay tranches cannot be 0.
ZeroDelayTranches,
}

impl<BlockNumber> HostConfiguration<BlockNumber>
Expand Down Expand Up @@ -412,6 +414,10 @@ where
return Err(OnDemandQueueSizeTooLarge)
}

if self.n_delay_tranches.is_zero() {
return Err(ZeroDelayTranches)
}

Ok(())
}

Expand Down
Loading