From d31e0a0e9a796748eb51163499f31da4a4225194 Mon Sep 17 00:00:00 2001 From: alindima Date: Tue, 17 Sep 2024 17:34:23 +0300 Subject: [PATCH] remove fields from configuration --- polkadot/primitives/src/v8/mod.rs | 8 - .../runtime/parachains/src/configuration.rs | 33 +- .../parachains/src/configuration/migration.rs | 1 + .../src/configuration/migration/v12.rs | 125 +++++- .../src/configuration/migration/v13.rs | 357 ++++++++++++++++++ .../parachains/src/configuration/tests.rs | 7 - polkadot/runtime/rococo/src/lib.rs | 2 + polkadot/runtime/westend/src/lib.rs | 1 + 8 files changed, 486 insertions(+), 48 deletions(-) create mode 100644 polkadot/runtime/parachains/src/configuration/migration/v13.rs diff --git a/polkadot/primitives/src/v8/mod.rs b/polkadot/primitives/src/v8/mod.rs index a51ee0bd99bf..bc237329f872 100644 --- a/polkadot/primitives/src/v8/mod.rs +++ b/polkadot/primitives/src/v8/mod.rs @@ -2093,8 +2093,6 @@ pub struct SchedulerParams { pub lookahead: u32, /// How many cores are managed by the coretime chain. pub num_cores: u32, - /// The max number of times a claim can time out in availability. - pub max_availability_timeouts: u32, /// The maximum queue size of the pay as you go module. pub on_demand_queue_max_size: u32, /// The target utilization of the spot price queue in percentages. @@ -2104,10 +2102,6 @@ pub struct SchedulerParams { pub on_demand_fee_variability: Perbill, /// The minimum amount needed to claim a slot in the spot pricing queue. pub on_demand_base_fee: Balance, - /// The number of blocks a claim stays in the scheduler's claim queue before getting cleared. - /// This number should go reasonably higher than the number of blocks in the async backing - /// lookahead. - pub ttl: BlockNumber, } impl> Default for SchedulerParams { @@ -2118,12 +2112,10 @@ impl> Default for SchedulerParams max_validators_per_core: Default::default(), lookahead: 1, num_cores: Default::default(), - max_availability_timeouts: Default::default(), on_demand_queue_max_size: ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, on_demand_target_queue_utilization: Perbill::from_percent(25), on_demand_fee_variability: Perbill::from_percent(3), on_demand_base_fee: 10_000_000u128, - ttl: 5u32.into(), } } } diff --git a/polkadot/runtime/parachains/src/configuration.rs b/polkadot/runtime/parachains/src/configuration.rs index 30fe95883e77..1dafbfe4407d 100644 --- a/polkadot/runtime/parachains/src/configuration.rs +++ b/polkadot/runtime/parachains/src/configuration.rs @@ -333,8 +333,6 @@ pub enum InconsistentError { ZeroMinimumBackingVotes, /// `executor_params` are inconsistent. InconsistentExecutorParams { inner: ExecutorParamError }, - /// TTL should be bigger than lookahead - LookaheadExceedsTTL, /// Lookahead is zero, while it must be at least 1 for parachains to work. LookaheadZero, /// Passed in queue size for on-demand was too large. @@ -430,10 +428,6 @@ where return Err(InconsistentExecutorParams { inner }) } - if self.scheduler_params.ttl < self.scheduler_params.lookahead.into() { - return Err(LookaheadExceedsTTL) - } - if self.scheduler_params.lookahead == 0 { return Err(LookaheadZero) } @@ -682,18 +676,7 @@ pub mod pallet { Self::set_coretime_cores_unchecked(new) } - /// Set the max number of times a claim may timeout on a core before it is abandoned - #[pallet::call_index(7)] - #[pallet::weight(( - T::WeightInfo::set_config_with_u32(), - DispatchClass::Operational, - ))] - pub fn set_max_availability_timeouts(origin: OriginFor, new: u32) -> DispatchResult { - ensure_root(origin)?; - Self::schedule_config_update(|config| { - config.scheduler_params.max_availability_timeouts = new; - }) - } + // Call index 7 used to be `set_max_availability_timeouts`, which was removed. /// Set the parachain validator-group rotation frequency #[pallet::call_index(8)] @@ -1189,18 +1172,8 @@ pub mod pallet { config.scheduler_params.on_demand_target_queue_utilization = new; }) } - /// Set the on demand (parathreads) ttl in the claimqueue. - #[pallet::call_index(51)] - #[pallet::weight(( - T::WeightInfo::set_config_with_block_number(), - DispatchClass::Operational - ))] - pub fn set_on_demand_ttl(origin: OriginFor, new: BlockNumberFor) -> DispatchResult { - ensure_root(origin)?; - Self::schedule_config_update(|config| { - config.scheduler_params.ttl = new; - }) - } + + // Call index 51 used to be `set_on_demand_ttl`, which was removed. /// Set the minimum backing votes threshold. #[pallet::call_index(52)] diff --git a/polkadot/runtime/parachains/src/configuration/migration.rs b/polkadot/runtime/parachains/src/configuration/migration.rs index 87b30b177e73..74cf785eaa02 100644 --- a/polkadot/runtime/parachains/src/configuration/migration.rs +++ b/polkadot/runtime/parachains/src/configuration/migration.rs @@ -19,6 +19,7 @@ pub mod v10; pub mod v11; pub mod v12; +pub mod v13; pub mod v6; pub mod v7; pub mod v8; diff --git a/polkadot/runtime/parachains/src/configuration/migration/v12.rs b/polkadot/runtime/parachains/src/configuration/migration/v12.rs index 111b1a199966..5ee31e87db54 100644 --- a/polkadot/runtime/parachains/src/configuration/migration/v12.rs +++ b/polkadot/runtime/parachains/src/configuration/migration/v12.rs @@ -24,11 +24,130 @@ use frame_support::{ traits::{Defensive, UncheckedOnRuntimeUpgrade}, }; use frame_system::pallet_prelude::BlockNumberFor; -use polkadot_primitives::SchedulerParams; +use polkadot_primitives::{ + ApprovalVotingParams, AsyncBackingParams, Balance, ExecutorParams, NodeFeatures, + LEGACY_MIN_BACKING_VOTES, MAX_CODE_SIZE, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, +}; +use sp_arithmetic::Perbill; use sp_core::Get; use sp_staking::SessionIndex; -type V12HostConfiguration = configuration::HostConfiguration; +#[derive(Clone, Encode, PartialEq, Decode, Debug)] +pub struct V12SchedulerParams { + pub group_rotation_frequency: BlockNumber, + pub paras_availability_period: BlockNumber, + pub max_validators_per_core: Option, + pub lookahead: u32, + pub num_cores: u32, + pub max_availability_timeouts: u32, + pub on_demand_queue_max_size: u32, + pub on_demand_target_queue_utilization: Perbill, + pub on_demand_fee_variability: Perbill, + pub on_demand_base_fee: Balance, + pub ttl: BlockNumber, +} + +impl> Default for V12SchedulerParams { + fn default() -> Self { + Self { + group_rotation_frequency: 1u32.into(), + paras_availability_period: 1u32.into(), + max_validators_per_core: Default::default(), + lookahead: 1, + num_cores: Default::default(), + max_availability_timeouts: Default::default(), + on_demand_queue_max_size: ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE, + on_demand_target_queue_utilization: Perbill::from_percent(25), + on_demand_fee_variability: Perbill::from_percent(3), + on_demand_base_fee: 10_000_000u128, + ttl: 5u32.into(), + } + } +} + +#[derive(Clone, Encode, PartialEq, Decode, Debug)] +pub struct V12HostConfiguration { + pub max_code_size: u32, + pub max_head_data_size: u32, + pub max_upward_queue_count: u32, + pub max_upward_queue_size: u32, + pub max_upward_message_size: u32, + pub max_upward_message_num_per_candidate: u32, + pub hrmp_max_message_num_per_candidate: u32, + pub validation_upgrade_cooldown: BlockNumber, + pub validation_upgrade_delay: BlockNumber, + pub async_backing_params: AsyncBackingParams, + pub max_pov_size: u32, + pub max_downward_message_size: u32, + pub hrmp_max_parachain_outbound_channels: u32, + pub hrmp_sender_deposit: Balance, + pub hrmp_recipient_deposit: Balance, + pub hrmp_channel_max_capacity: u32, + pub hrmp_channel_max_total_size: u32, + pub hrmp_max_parachain_inbound_channels: u32, + pub hrmp_channel_max_message_size: u32, + pub executor_params: ExecutorParams, + pub code_retention_period: BlockNumber, + pub max_validators: Option, + pub dispute_period: SessionIndex, + pub dispute_post_conclusion_acceptance_period: BlockNumber, + pub no_show_slots: u32, + pub n_delay_tranches: u32, + pub zeroth_delay_tranche_width: u32, + pub needed_approvals: u32, + pub relay_vrf_modulo_samples: u32, + pub pvf_voting_ttl: SessionIndex, + pub minimum_validation_upgrade_delay: BlockNumber, + pub minimum_backing_votes: u32, + pub node_features: NodeFeatures, + pub approval_voting_params: ApprovalVotingParams, + pub scheduler_params: V12SchedulerParams, +} + +impl> Default for V12HostConfiguration { + fn default() -> Self { + Self { + async_backing_params: AsyncBackingParams { + max_candidate_depth: 0, + allowed_ancestry_len: 0, + }, + no_show_slots: 1u32.into(), + validation_upgrade_cooldown: Default::default(), + validation_upgrade_delay: 2u32.into(), + code_retention_period: Default::default(), + max_code_size: MAX_CODE_SIZE, + max_pov_size: Default::default(), + max_head_data_size: Default::default(), + max_validators: None, + dispute_period: 6, + dispute_post_conclusion_acceptance_period: 100.into(), + n_delay_tranches: 1, + zeroth_delay_tranche_width: Default::default(), + needed_approvals: Default::default(), + relay_vrf_modulo_samples: Default::default(), + max_upward_queue_count: Default::default(), + max_upward_queue_size: Default::default(), + max_downward_message_size: Default::default(), + max_upward_message_size: Default::default(), + max_upward_message_num_per_candidate: Default::default(), + hrmp_sender_deposit: Default::default(), + hrmp_recipient_deposit: Default::default(), + hrmp_channel_max_capacity: Default::default(), + hrmp_channel_max_total_size: Default::default(), + hrmp_max_parachain_inbound_channels: Default::default(), + hrmp_channel_max_message_size: Default::default(), + hrmp_max_parachain_outbound_channels: Default::default(), + hrmp_max_message_num_per_candidate: Default::default(), + pvf_voting_ttl: 2u32.into(), + minimum_validation_upgrade_delay: 2.into(), + executor_params: Default::default(), + approval_voting_params: ApprovalVotingParams { max_approval_coalesce_count: 1 }, + minimum_backing_votes: LEGACY_MIN_BACKING_VOTES, + node_features: NodeFeatures::EMPTY, + scheduler_params: Default::default(), + } + } +} mod v11 { use super::*; @@ -143,7 +262,7 @@ fn migrate_to_v12() -> Weight { minimum_backing_votes : pre.minimum_backing_votes, node_features : pre.node_features, approval_voting_params : pre.approval_voting_params, - scheduler_params: SchedulerParams { + scheduler_params: V12SchedulerParams { group_rotation_frequency : pre.group_rotation_frequency, paras_availability_period : pre.paras_availability_period, max_validators_per_core : pre.max_validators_per_core, diff --git a/polkadot/runtime/parachains/src/configuration/migration/v13.rs b/polkadot/runtime/parachains/src/configuration/migration/v13.rs new file mode 100644 index 000000000000..65995e4bd0f5 --- /dev/null +++ b/polkadot/runtime/parachains/src/configuration/migration/v13.rs @@ -0,0 +1,357 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +//! A module that is responsible for migration of storage. + +use crate::configuration::{ + self, migration::v12::V12HostConfiguration, Config, HostConfiguration as V13HostConfiguration, + Pallet, +}; +use alloc::vec::Vec; +use frame_support::{ + migrations::VersionedMigration, + pallet_prelude::*, + traits::{Defensive, UncheckedOnRuntimeUpgrade}, +}; +use frame_system::pallet_prelude::BlockNumberFor; +use polkadot_primitives::SchedulerParams; +use sp_core::Get; +use sp_staking::SessionIndex; + +mod v12 { + use super::*; + + #[frame_support::storage_alias] + pub(crate) type ActiveConfig = + StorageValue, V12HostConfiguration>, OptionQuery>; + + #[frame_support::storage_alias] + pub(crate) type PendingConfigs = StorageValue< + Pallet, + Vec<(SessionIndex, V12HostConfiguration>)>, + OptionQuery, + >; +} + +mod v13 { + use super::*; + + #[frame_support::storage_alias] + pub(crate) type ActiveConfig = + StorageValue, V13HostConfiguration>, OptionQuery>; + + #[frame_support::storage_alias] + pub(crate) type PendingConfigs = StorageValue< + Pallet, + Vec<(SessionIndex, V13HostConfiguration>)>, + OptionQuery, + >; +} + +pub type MigrateToV13 = VersionedMigration< + 12, + 13, + UncheckedMigrateToV13, + Pallet, + ::DbWeight, +>; + +pub struct UncheckedMigrateToV13(core::marker::PhantomData); + +impl UncheckedOnRuntimeUpgrade for UncheckedMigrateToV13 { + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, sp_runtime::TryRuntimeError> { + log::trace!(target: crate::configuration::LOG_TARGET, "Running pre_upgrade() for HostConfiguration MigrateToV13"); + Ok(Vec::new()) + } + + fn on_runtime_upgrade() -> Weight { + log::info!(target: configuration::LOG_TARGET, "HostConfiguration MigrateToV13 started"); + let weight_consumed = migrate_to_v13::(); + + log::info!(target: configuration::LOG_TARGET, "HostConfiguration MigrateToV13 executed successfully"); + + weight_consumed + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_state: Vec) -> Result<(), sp_runtime::TryRuntimeError> { + log::trace!(target: crate::configuration::LOG_TARGET, "Running post_upgrade() for HostConfiguration MigrateToV13"); + ensure!( + StorageVersion::get::>() >= 13, + "Storage version should be >= 13 after the migration" + ); + + Ok(()) + } +} + +fn migrate_to_v13() -> Weight { + // Unusual formatting is justified: + // - make it easier to verify that fields assign what they supposed to assign. + // - this code is transient and will be removed after all migrations are done. + // - this code is important enough to optimize for legibility sacrificing consistency. + #[rustfmt::skip] + let translate = + |pre: V12HostConfiguration>| -> + V13HostConfiguration> + { + V13HostConfiguration { + max_code_size : pre.max_code_size, + max_head_data_size : pre.max_head_data_size, + max_upward_queue_count : pre.max_upward_queue_count, + max_upward_queue_size : pre.max_upward_queue_size, + max_upward_message_size : pre.max_upward_message_size, + max_upward_message_num_per_candidate : pre.max_upward_message_num_per_candidate, + hrmp_max_message_num_per_candidate : pre.hrmp_max_message_num_per_candidate, + validation_upgrade_cooldown : pre.validation_upgrade_cooldown, + validation_upgrade_delay : pre.validation_upgrade_delay, + max_pov_size : pre.max_pov_size, + max_downward_message_size : pre.max_downward_message_size, + hrmp_sender_deposit : pre.hrmp_sender_deposit, + hrmp_recipient_deposit : pre.hrmp_recipient_deposit, + hrmp_channel_max_capacity : pre.hrmp_channel_max_capacity, + hrmp_channel_max_total_size : pre.hrmp_channel_max_total_size, + hrmp_max_parachain_inbound_channels : pre.hrmp_max_parachain_inbound_channels, + hrmp_max_parachain_outbound_channels : pre.hrmp_max_parachain_outbound_channels, + hrmp_channel_max_message_size : pre.hrmp_channel_max_message_size, + code_retention_period : pre.code_retention_period, + max_validators : pre.max_validators, + dispute_period : pre.dispute_period, + dispute_post_conclusion_acceptance_period: pre.dispute_post_conclusion_acceptance_period, + no_show_slots : pre.no_show_slots, + n_delay_tranches : pre.n_delay_tranches, + zeroth_delay_tranche_width : pre.zeroth_delay_tranche_width, + needed_approvals : pre.needed_approvals, + relay_vrf_modulo_samples : pre.relay_vrf_modulo_samples, + pvf_voting_ttl : pre.pvf_voting_ttl, + minimum_validation_upgrade_delay : pre.minimum_validation_upgrade_delay, + async_backing_params : pre.async_backing_params, + executor_params : pre.executor_params, + minimum_backing_votes : pre.minimum_backing_votes, + node_features : pre.node_features, + approval_voting_params : pre.approval_voting_params, + scheduler_params: SchedulerParams { + group_rotation_frequency : pre.scheduler_params.group_rotation_frequency, + paras_availability_period : pre.scheduler_params.paras_availability_period, + max_validators_per_core : pre.scheduler_params.max_validators_per_core, + lookahead : pre.scheduler_params.lookahead, + num_cores : pre.scheduler_params.num_cores, + // `max_availability_timeouts`` value was removed here. + on_demand_queue_max_size : pre.scheduler_params.on_demand_queue_max_size, + on_demand_target_queue_utilization : pre.scheduler_params.on_demand_target_queue_utilization, + on_demand_fee_variability : pre.scheduler_params.on_demand_fee_variability, + on_demand_base_fee : pre.scheduler_params.on_demand_base_fee, + // `ttl` value was removed here. + } + } + }; + + let v12 = v12::ActiveConfig::::get() + .defensive_proof("Could not decode old config") + .unwrap_or_default(); + let v13 = translate(v12); + v13::ActiveConfig::::set(Some(v13)); + + // Allowed to be empty. + let pending_v12 = v12::PendingConfigs::::get().unwrap_or_default(); + let mut pending_v13 = Vec::new(); + + for (session, v12) in pending_v12.into_iter() { + let v13 = translate(v12); + pending_v13.push((session, v13)); + } + v13::PendingConfigs::::set(Some(pending_v13.clone())); + + let num_configs = (pending_v13.len() + 1) as u64; + T::DbWeight::get().reads_writes(num_configs, num_configs) +} + +#[cfg(test)] +mod tests { + use configuration::migration::v12::V12SchedulerParams; + use polkadot_primitives::LEGACY_MIN_BACKING_VOTES; + use sp_arithmetic::Perbill; + + use super::*; + use crate::mock::{new_test_ext, Test}; + + #[test] + fn v13_deserialized_from_actual_data() { + // Example how to get new `raw_config`: + // We'll obtain the raw_config at a specified a block + // Steps: + // 1. Go to Polkadot.js -> Developer -> Chain state -> Storage: https://polkadot.js.org/apps/#/chainstate + // 2. Set these parameters: + // 2.1. selected state query: configuration; activeConfig(): + // PolkadotRuntimeParachainsConfigurationHostConfiguration + // 2.2. blockhash to query at: + // 0xf89d3ab5312c5f70d396dc59612f0aa65806c798346f9db4b35278baed2e0e53 (the hash of + // the block) + // 2.3. Note the value of encoded storage key -> + // 0x06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385 for the + // referenced block. + // 2.4. You'll also need the decoded values to update the test. + // 3. Go to Polkadot.js -> Developer -> Chain state -> Raw storage + // 3.1 Enter the encoded storage key and you get the raw config. + + // This exceeds the maximal line width length, but that's fine, since this is not code and + // doesn't need to be read and also leaving it as one line allows to easily copy it. + let raw_config = + hex_literal::hex![ + "0000300000800000080000000000100000c8000005000000050000000200000002000000060000000200000000005000000010000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000000100000b004000000060000006400000002000000190000000000000002000000020000000200000005000000020000002002010000001400000004000000010100000002000000030000001027000080b2e60e80c3c90180969800000000000000000000000000" + ]; + + let v13 = + V13HostConfiguration::::decode(&mut &raw_config[..]) + .unwrap(); + + // We check only a sample of the values here. If we missed any fields or messed up data + // types that would skew all the fields coming after. + assert_eq!(v13.max_code_size, 3_145_728); + assert_eq!(v13.validation_upgrade_cooldown, 2); + assert_eq!(v13.max_pov_size, 5_242_880); + assert_eq!(v13.hrmp_channel_max_message_size, 1_048_576); + assert_eq!(v13.n_delay_tranches, 25); + assert_eq!(v13.minimum_validation_upgrade_delay, 5); + assert_eq!(v13.minimum_backing_votes, LEGACY_MIN_BACKING_VOTES); + assert_eq!(v13.approval_voting_params.max_approval_coalesce_count, 1); + assert_eq!(v13.scheduler_params.group_rotation_frequency, 20); + assert_eq!(v13.scheduler_params.paras_availability_period, 4); + assert_eq!(v13.scheduler_params.lookahead, 2); + assert_eq!(v13.scheduler_params.num_cores, 3); + assert_eq!(v13.scheduler_params.on_demand_queue_max_size, 10_000); + assert_eq!( + v13.scheduler_params.on_demand_target_queue_utilization, + Perbill::from_percent(25) + ); + assert_eq!(v13.scheduler_params.on_demand_fee_variability, Perbill::from_percent(3)); + assert_eq!(v13.scheduler_params.on_demand_base_fee, 10_000_000); + } + + #[test] + fn test_migrate_to_v13() { + // Host configuration has lots of fields. However, in this migration we only remove two + // fields on the `SchedulerParams`. The most important part to check are a couple of the + // last fields. We also pick extra fields to check arbitrarily, e.g. depending on their + // position (i.e. the middle) and also their type. + // + // We specify only the picked fields and the rest should be provided by the `Default` + // implementation. That implementation is copied over between the two types and should work + // fine. + let v12 = V12HostConfiguration:: { + needed_approvals: 69, + hrmp_recipient_deposit: 1337, + max_pov_size: 1111, + minimum_validation_upgrade_delay: 20, + scheduler_params: V12SchedulerParams { + group_rotation_frequency: 10u32.into(), + paras_availability_period: 11u32.into(), + max_validators_per_core: Some(5), + lookahead: 2, + num_cores: 10, + max_availability_timeouts: 5, + on_demand_queue_max_size: 3, + on_demand_target_queue_utilization: Perbill::from_percent(30), + on_demand_fee_variability: Perbill::from_percent(4), + on_demand_base_fee: 20_000_000u128, + ttl: 3u32.into(), + }, + ..Default::default() + }; + + let mut pending_configs = Vec::new(); + pending_configs.push((100, v12.clone())); + pending_configs.push((300, v12.clone())); + + new_test_ext(Default::default()).execute_with(|| { + // Implant the v12 version in the state. + v12::ActiveConfig::::set(Some(v12.clone())); + v12::PendingConfigs::::set(Some(pending_configs)); + + migrate_to_v13::(); + + let v13 = v13::ActiveConfig::::get().unwrap(); + + let mut configs_to_check = v13::PendingConfigs::::get().unwrap(); + configs_to_check.push((0, v13.clone())); + + for (_, v13) in configs_to_check { + #[rustfmt::skip] + { + assert_eq!(v13.max_code_size , v12.max_code_size); + assert_eq!(v13.max_head_data_size , v12.max_head_data_size); + assert_eq!(v13.max_upward_queue_count , v12.max_upward_queue_count); + assert_eq!(v13.max_upward_queue_size , v12.max_upward_queue_size); + assert_eq!(v13.max_upward_message_size , v12.max_upward_message_size); + assert_eq!(v13.max_upward_message_num_per_candidate , v12.max_upward_message_num_per_candidate); + assert_eq!(v13.hrmp_max_message_num_per_candidate , v12.hrmp_max_message_num_per_candidate); + assert_eq!(v13.validation_upgrade_cooldown , v12.validation_upgrade_cooldown); + assert_eq!(v13.validation_upgrade_delay , v12.validation_upgrade_delay); + assert_eq!(v13.max_pov_size , v12.max_pov_size); + assert_eq!(v13.max_downward_message_size , v12.max_downward_message_size); + assert_eq!(v13.hrmp_max_parachain_outbound_channels , v12.hrmp_max_parachain_outbound_channels); + assert_eq!(v13.hrmp_sender_deposit , v12.hrmp_sender_deposit); + assert_eq!(v13.hrmp_recipient_deposit , v12.hrmp_recipient_deposit); + assert_eq!(v13.hrmp_channel_max_capacity , v12.hrmp_channel_max_capacity); + assert_eq!(v13.hrmp_channel_max_total_size , v12.hrmp_channel_max_total_size); + assert_eq!(v13.hrmp_max_parachain_inbound_channels , v12.hrmp_max_parachain_inbound_channels); + assert_eq!(v13.hrmp_channel_max_message_size , v12.hrmp_channel_max_message_size); + assert_eq!(v13.code_retention_period , v12.code_retention_period); + assert_eq!(v13.max_validators , v12.max_validators); + assert_eq!(v13.dispute_period , v12.dispute_period); + assert_eq!(v13.no_show_slots , v12.no_show_slots); + assert_eq!(v13.n_delay_tranches , v12.n_delay_tranches); + assert_eq!(v13.zeroth_delay_tranche_width , v12.zeroth_delay_tranche_width); + assert_eq!(v13.needed_approvals , v12.needed_approvals); + assert_eq!(v13.relay_vrf_modulo_samples , v12.relay_vrf_modulo_samples); + assert_eq!(v13.pvf_voting_ttl , v12.pvf_voting_ttl); + assert_eq!(v13.minimum_validation_upgrade_delay , v12.minimum_validation_upgrade_delay); + assert_eq!(v13.async_backing_params.allowed_ancestry_len , v12.async_backing_params.allowed_ancestry_len); + assert_eq!(v13.async_backing_params.max_candidate_depth , v12.async_backing_params.max_candidate_depth); + assert_eq!(v13.executor_params , v12.executor_params); + assert_eq!(v13.minimum_backing_votes , v12.minimum_backing_votes); + assert_eq!(v13.scheduler_params.group_rotation_frequency , v12.scheduler_params.group_rotation_frequency); + assert_eq!(v13.scheduler_params.paras_availability_period , v12.scheduler_params.paras_availability_period); + assert_eq!(v13.scheduler_params.max_validators_per_core , v12.scheduler_params.max_validators_per_core); + assert_eq!(v13.scheduler_params.lookahead , v12.scheduler_params.lookahead); + assert_eq!(v13.scheduler_params.num_cores , v12.scheduler_params.num_cores); + assert_eq!(v13.scheduler_params.on_demand_queue_max_size , v12.scheduler_params.on_demand_queue_max_size); + assert_eq!(v13.scheduler_params.on_demand_target_queue_utilization , v12.scheduler_params.on_demand_target_queue_utilization); + assert_eq!(v13.scheduler_params.on_demand_fee_variability , v12.scheduler_params.on_demand_fee_variability); + assert_eq!(v13.scheduler_params.on_demand_base_fee , v12.scheduler_params.on_demand_base_fee); + }; // ; makes this a statement. `rustfmt::skip` cannot be put on an expression. + } + }); + } + + // Test that migration doesn't panic in case there are no pending configurations upgrades in + // pallet's storage. + #[test] + fn test_migrate_to_v13_no_pending() { + let v12 = V12HostConfiguration::::default(); + + new_test_ext(Default::default()).execute_with(|| { + // Implant the v12 version in the state. + v12::ActiveConfig::::set(Some(v12)); + // Ensure there are no pending configs. + v12::PendingConfigs::::set(None); + + // Shouldn't fail. + migrate_to_v13::(); + }); + } +} diff --git a/polkadot/runtime/parachains/src/configuration/tests.rs b/polkadot/runtime/parachains/src/configuration/tests.rs index dad8b6458e10..2ae5aa4b7239 100644 --- a/polkadot/runtime/parachains/src/configuration/tests.rs +++ b/polkadot/runtime/parachains/src/configuration/tests.rs @@ -322,12 +322,10 @@ fn setting_pending_config_members() { max_validators_per_core: None, lookahead: 3, num_cores: 2, - max_availability_timeouts: 5, on_demand_queue_max_size: 10_000u32, on_demand_base_fee: 10_000_000u128, on_demand_fee_variability: Perbill::from_percent(3), on_demand_target_queue_utilization: Perbill::from_percent(25), - ttl: 5u32, }, }; @@ -355,11 +353,6 @@ fn setting_pending_config_members() { new_config.scheduler_params.num_cores, ) .unwrap(); - Configuration::set_max_availability_timeouts( - RuntimeOrigin::root(), - new_config.scheduler_params.max_availability_timeouts, - ) - .unwrap(); Configuration::set_group_rotation_frequency( RuntimeOrigin::root(), new_config.scheduler_params.group_rotation_frequency, diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 6ec49c5830f7..7809aee0ccc8 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -1679,6 +1679,8 @@ pub mod migrations { // permanent pallet_xcm::migration::MigrateToLatestXcmVersion, parachains_inclusion::migration::MigrateToV1, + + parachains_configuration::migration::v13::MigrateToV13, ); } diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index d0c1cd89de32..6b403119a4f9 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -1786,6 +1786,7 @@ pub mod migrations { Runtime, MaxAgentsToMigrate, >, + parachains_configuration::migration::v13::MigrateToV13, ); }