Skip to content

Commit

Permalink
Improve HostConfiguration consistency check (#3897)
Browse files Browse the repository at this point in the history
fixes #3886

---------

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
  • Loading branch information
sandreim authored and pgherveou committed Apr 2, 2024
1 parent d85636f commit bc18f9f
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit bc18f9f

Please sign in to comment.