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

Commit

Permalink
configuration: Unified consistency checks (#4581)
Browse files Browse the repository at this point in the history
This commit refactors the consistency checks. Instead of each individual
setter performs its checks locally, we delegate those checks to the
already existing function `check_consistency`. This removes duplication
and simplifies the logic.

A motivating example of this one is the next PR in the stack that will
introduce a check for a field, which validity depends on the validity of
other two fields. Without this refactoring we will have to place a check
not only to the field in question, but also to the other two fields so
that if they are changed they do not violate consistency criteria. It's
easy to imagine how this can go unwieldy with the number of checks.

This also adds a test that verifies that the default chain spec host
configuration is consistent.
  • Loading branch information
pepyakin committed Dec 27, 2021
1 parent dab8498 commit d8bd492
Show file tree
Hide file tree
Showing 2 changed files with 276 additions and 169 deletions.
15 changes: 13 additions & 2 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ fn default_parachains_host_configuration(
use polkadot_primitives::v1::{MAX_CODE_SIZE, MAX_POV_SIZE};

polkadot_runtime_parachains::configuration::HostConfiguration {
validation_upgrade_frequency: 1u32,
validation_upgrade_delay: 1,
validation_upgrade_frequency: 2u32,
validation_upgrade_delay: 2,
code_retention_period: 1200,
max_code_size: MAX_CODE_SIZE,
max_pov_size: MAX_POV_SIZE,
Expand Down Expand Up @@ -214,6 +214,17 @@ fn default_parachains_host_configuration(
}
}

#[cfg(any(
feature = "rococo-native",
feature = "kusama-native",
feature = "westend-native",
feature = "polkadot-native"
))]
#[test]
fn default_parachains_host_configuration_is_consistent() {
default_parachains_host_configuration().panic_if_not_consistent();
}

#[cfg(feature = "polkadot-native")]
fn polkadot_session_keys(
babe: BabeId,
Expand Down
Loading

0 comments on commit d8bd492

Please sign in to comment.