diff --git a/runtime/kusama/src/weights/runtime_parachains_configuration.rs b/runtime/kusama/src/weights/runtime_parachains_configuration.rs index ae840f37752d..93c9e5e9c866 100644 --- a/runtime/kusama/src/weights/runtime_parachains_configuration.rs +++ b/runtime/kusama/src/weights/runtime_parachains_configuration.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_parachains::configuration` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-09-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-12-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128 // Executed Command: @@ -33,7 +33,6 @@ // --header=./file_header.txt // --output=./runtime/kusama/src/weights/runtime_parachains_configuration.rs - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -44,35 +43,35 @@ use sp_std::marker::PhantomData; /// Weight functions for `runtime_parachains::configuration`. pub struct WeightInfo(PhantomData); impl runtime_parachains::configuration::WeightInfo for WeightInfo { - // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_block_number() -> Weight { - (12_378_000 as Weight) + (8_240_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_u32() -> Weight { - (12_384_000 as Weight) + (8_123_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_option_u32() -> Weight { - (12_746_000 as Weight) + (8_547_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_weight() -> Weight { - (12_563_000 as Weight) + (8_379_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -80,11 +79,11 @@ impl runtime_parachains::configuration::WeightInfo for fn set_hrmp_open_request_ttl() -> Weight { (2_000_000_000_000 as Weight) } - // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_balance() -> Weight { - (12_644_000 as Weight) + (8_400_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } diff --git a/runtime/parachains/src/configuration.rs b/runtime/parachains/src/configuration.rs index f67f96ba8b3e..8b18c7d59559 100644 --- a/runtime/parachains/src/configuration.rs +++ b/runtime/parachains/src/configuration.rs @@ -33,7 +33,6 @@ pub use pallet::*; pub mod migration; -#[allow(dead_code)] const LOG_TARGET: &str = "runtime::configuration"; /// All configuration of the runtime with respect to parachains and parathreads. @@ -361,9 +360,22 @@ pub mod pallet { StorageValue<_, HostConfiguration, ValueQuery>; /// Pending configuration (if any) for the next session. + /// + /// DEPRECATED: This is no longer used, and will be removed in the future. #[pallet::storage] pub(crate) type PendingConfig = - StorageMap<_, Twox64Concat, SessionIndex, HostConfiguration>; + StorageMap<_, Twox64Concat, SessionIndex, migration::v1::HostConfiguration>; + + /// Pending configuration changes. + /// + /// This is a list of configuration changes, each with a session index at which it should + /// be applied. + /// + /// The list is sorted ascending by session index. Also, this list can only contain at most + /// 2 items: for the next session and for the `scheduled_session`. + #[pallet::storage] + pub(crate) type PendingConfigs = + StorageValue<_, Vec<(SessionIndex, HostConfiguration)>, ValueQuery>; #[pallet::genesis_config] pub struct GenesisConfig { @@ -398,7 +410,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.validation_upgrade_frequency, new) != new + config.validation_upgrade_frequency = new; }); Ok(()) } @@ -414,7 +426,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.validation_upgrade_delay, new) != new + config.validation_upgrade_delay = new; }); Ok(()) } @@ -430,7 +442,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.code_retention_period, new) != new + config.code_retention_period = new; }); Ok(()) } @@ -444,7 +456,7 @@ pub mod pallet { ensure_root(origin)?; ensure!(new <= MAX_CODE_SIZE, Error::::InvalidNewValue); Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.max_code_size, new) != new + config.max_code_size = new; }); Ok(()) } @@ -458,7 +470,7 @@ pub mod pallet { ensure_root(origin)?; ensure!(new <= MAX_POV_SIZE, Error::::InvalidNewValue); Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.max_pov_size, new) != new + config.max_pov_size = new; }); Ok(()) } @@ -472,7 +484,7 @@ pub mod pallet { ensure_root(origin)?; ensure!(new <= MAX_HEAD_DATA_SIZE, Error::::InvalidNewValue); Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.max_head_data_size, new) != new + config.max_head_data_size = new; }); Ok(()) } @@ -485,7 +497,7 @@ pub mod pallet { pub fn set_parathread_cores(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.parathread_cores, new) != new + config.parathread_cores = new; }); Ok(()) } @@ -498,7 +510,7 @@ pub mod pallet { pub fn set_parathread_retries(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.parathread_retries, new) != new + config.parathread_retries = new; }); Ok(()) } @@ -517,7 +529,7 @@ pub mod pallet { ensure!(!new.is_zero(), Error::::InvalidNewValue); Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.group_rotation_frequency, new) != new + config.group_rotation_frequency = new; }); Ok(()) } @@ -536,7 +548,7 @@ pub mod pallet { ensure!(!new.is_zero(), Error::::InvalidNewValue); Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.chain_availability_period, new) != new + config.chain_availability_period = new; }); Ok(()) } @@ -555,7 +567,7 @@ pub mod pallet { ensure!(!new.is_zero(), Error::::InvalidNewValue); Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.thread_availability_period, new) != new + config.thread_availability_period = new; }); Ok(()) } @@ -568,7 +580,7 @@ pub mod pallet { pub fn set_scheduling_lookahead(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.scheduling_lookahead, new) != new + config.scheduling_lookahead = new; }); Ok(()) } @@ -584,7 +596,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.max_validators_per_core, new) != new + config.max_validators_per_core = new; }); Ok(()) } @@ -597,7 +609,7 @@ pub mod pallet { pub fn set_max_validators(origin: OriginFor, new: Option) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.max_validators, new) != new + config.max_validators = new; }); Ok(()) } @@ -610,7 +622,7 @@ pub mod pallet { pub fn set_dispute_period(origin: OriginFor, new: SessionIndex) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.dispute_period, new) != new + config.dispute_period = new; }); Ok(()) } @@ -626,8 +638,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.dispute_post_conclusion_acceptance_period, new) != - new + config.dispute_post_conclusion_acceptance_period = new; }); Ok(()) } @@ -640,7 +651,7 @@ pub mod pallet { pub fn set_dispute_max_spam_slots(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.dispute_max_spam_slots, new) != new + config.dispute_max_spam_slots = new; }); Ok(()) } @@ -656,7 +667,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.dispute_conclusion_by_time_out_period, new) != new + config.dispute_conclusion_by_time_out_period = new; }); Ok(()) } @@ -673,7 +684,7 @@ pub mod pallet { ensure!(!new.is_zero(), Error::::InvalidNewValue); Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.no_show_slots, new) != new + config.no_show_slots = new; }); Ok(()) } @@ -686,7 +697,7 @@ pub mod pallet { pub fn set_n_delay_tranches(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.n_delay_tranches, new) != new + config.n_delay_tranches = new; }); Ok(()) } @@ -699,7 +710,7 @@ pub mod pallet { pub fn set_zeroth_delay_tranche_width(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.zeroth_delay_tranche_width, new) != new + config.zeroth_delay_tranche_width = new; }); Ok(()) } @@ -712,7 +723,7 @@ pub mod pallet { pub fn set_needed_approvals(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.needed_approvals, new) != new + config.needed_approvals = new; }); Ok(()) } @@ -725,7 +736,7 @@ pub mod pallet { pub fn set_relay_vrf_modulo_samples(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.relay_vrf_modulo_samples, new) != new + config.relay_vrf_modulo_samples = new; }); Ok(()) } @@ -738,7 +749,7 @@ pub mod pallet { pub fn set_max_upward_queue_count(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.max_upward_queue_count, new) != new + config.max_upward_queue_count = new; }); Ok(()) } @@ -751,7 +762,7 @@ pub mod pallet { pub fn set_max_upward_queue_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.max_upward_queue_size, new) != new + config.max_upward_queue_size = new; }); Ok(()) } @@ -764,7 +775,7 @@ pub mod pallet { pub fn set_max_downward_message_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.max_downward_message_size, new) != new + config.max_downward_message_size = new; }); Ok(()) } @@ -777,7 +788,7 @@ pub mod pallet { pub fn set_ump_service_total_weight(origin: OriginFor, new: Weight) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.ump_service_total_weight, new) != new + config.ump_service_total_weight = new; }); Ok(()) } @@ -790,7 +801,7 @@ pub mod pallet { pub fn set_max_upward_message_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.max_upward_message_size, new) != new + config.max_upward_message_size = new; }); Ok(()) } @@ -806,7 +817,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.max_upward_message_num_per_candidate, new) != new + config.max_upward_message_num_per_candidate = new; }); Ok(()) } @@ -830,7 +841,7 @@ pub mod pallet { pub fn set_hrmp_sender_deposit(origin: OriginFor, new: Balance) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.hrmp_sender_deposit, new) != new + config.hrmp_sender_deposit = new; }); Ok(()) } @@ -844,7 +855,7 @@ pub mod pallet { pub fn set_hrmp_recipient_deposit(origin: OriginFor, new: Balance) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.hrmp_recipient_deposit, new) != new + config.hrmp_recipient_deposit = new; }); Ok(()) } @@ -857,7 +868,7 @@ pub mod pallet { pub fn set_hrmp_channel_max_capacity(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.hrmp_channel_max_capacity, new) != new + config.hrmp_channel_max_capacity = new; }); Ok(()) } @@ -870,7 +881,7 @@ pub mod pallet { pub fn set_hrmp_channel_max_total_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.hrmp_channel_max_total_size, new) != new + config.hrmp_channel_max_total_size = new; }); Ok(()) } @@ -886,7 +897,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.hrmp_max_parachain_inbound_channels, new) != new + config.hrmp_max_parachain_inbound_channels = new; }); Ok(()) } @@ -902,7 +913,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.hrmp_max_parathread_inbound_channels, new) != new + config.hrmp_max_parathread_inbound_channels = new; }); Ok(()) } @@ -915,7 +926,7 @@ pub mod pallet { pub fn set_hrmp_channel_max_message_size(origin: OriginFor, new: u32) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.hrmp_channel_max_message_size, new) != new + config.hrmp_channel_max_message_size = new; }); Ok(()) } @@ -931,7 +942,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.hrmp_max_parachain_outbound_channels, new) != new + config.hrmp_max_parachain_outbound_channels = new; }); Ok(()) } @@ -947,7 +958,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.hrmp_max_parathread_outbound_channels, new) != new + config.hrmp_max_parathread_outbound_channels = new; }); Ok(()) } @@ -963,7 +974,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.hrmp_max_message_num_per_candidate, new) != new + config.hrmp_max_message_num_per_candidate = new; }); Ok(()) } @@ -976,7 +987,7 @@ pub mod pallet { pub fn set_ump_max_individual_weight(origin: OriginFor, new: Weight) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.ump_max_individual_weight, new) != new + config.ump_max_individual_weight = new; }); Ok(()) } @@ -990,7 +1001,7 @@ pub mod pallet { pub fn set_pvf_checking_enabled(origin: OriginFor, new: bool) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.pvf_checking_enabled, new) != new + config.pvf_checking_enabled = new; }); Ok(()) } @@ -1003,7 +1014,7 @@ pub mod pallet { pub fn set_pvf_voting_ttl(origin: OriginFor, new: SessionIndex) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.pvf_voting_ttl, new) != new + config.pvf_voting_ttl = new; }); Ok(()) } @@ -1020,7 +1031,7 @@ pub mod pallet { ) -> DispatchResult { ensure_root(origin)?; Self::update_config_member(|config| { - sp_std::mem::replace(&mut config.minimum_validation_upgrade_delay, new) != new + config.minimum_validation_upgrade_delay = new; }); Ok(()) } @@ -1054,9 +1065,28 @@ impl Pallet { /// Called by the initializer to note that a new session has started. pub(crate) fn initializer_on_new_session(session_index: &SessionIndex) { - if let Some(pending) = ::PendingConfig::take(session_index) { - ::ActiveConfig::set(pending); + let pending_configs = >::get(); + if pending_configs.is_empty() { + return } + + let (past_and_present, future) = pending_configs + .into_iter() + .partition::, _>(|&(apply_at_session, _)| apply_at_session <= *session_index); + + if past_and_present.len() > 1 { + // This should never happen since we schedule configuration changes only into the future + // sessions and this handler called for each session change. + log::error!( + target: LOG_TARGET, + "Skipping applying configuration changes scheduled sessions in the past", + ); + } + if let Some((_, pending)) = past_and_present.last() { + ::ActiveConfig::put(pending); + } + + >::put(future); } /// Return the session index that should be used for any future scheduled changes. @@ -1076,24 +1106,82 @@ impl Pallet { // duplicated code (making this function to show up in the top of heaviest functions) only for // the sake of essentially avoiding an indirect call. Doesn't worth it. #[inline(never)] - fn update_config_member(updater: impl FnOnce(&mut HostConfiguration) -> bool) { + fn update_config_member(updater: impl FnOnce(&mut HostConfiguration)) { + let mut pending_configs = >::get(); + + // 1. pending_configs = [] + // No pending configuration changes. + // + // That means we should use the active config as the base configuration. We will insert + // the new pending configuration as (cur+2, new_config) into the list. + // + // 2. pending_configs = [(cur+2, X)] + // There is a configuration that is pending for the scheduled session. + // + // We will use X as the base configuration. We can update the pending configuration X + // directly. + // + // 3. pending_configs = [(cur+1, X)] + // There is a pending configuration scheduled and it will be applied in the next session. + // + // We will use X as the base configuration. We need to schedule a new configuration change + // for the `scheduled_session` and use X as the base for the new configuration. + // + // 4. pending_configs = [(cur+1, X), (cur+2, Y)] + // There is a pending configuration change in the next session and for the scheduled + // session. Due to case №3, we can be sure that Y is based on top of X. This means we + // can use Y as the base configuration and update Y directly. + // + // There cannot be (cur, X) because those are applied in the session change handler for the + // current session. + + // First, we need to decide what we should use as the base configuration. + let mut base_config = pending_configs + .last() + .map(|&(_, ref config)| config.clone()) + .unwrap_or_else(Self::config); + + // Now, we need to decide what the new configuration should be. + updater(&mut base_config); + let scheduled_session = Self::scheduled_session(); - let pending = ::PendingConfig::get(scheduled_session); - let mut prev = pending.unwrap_or_else(Self::config); - if updater(&mut prev) { - ::PendingConfig::insert(scheduled_session, prev); + if let Some(&mut (_, ref mut config)) = pending_configs + .iter_mut() + .find(|&&mut (apply_at_session, _)| apply_at_session >= scheduled_session) + { + *config = base_config; + } else { + // We are scheduling a new configuration change for the scheduled session. + pending_configs.push((scheduled_session, base_config)); } + + >::put(pending_configs); } } #[cfg(test)] mod tests { use super::*; - use crate::mock::{new_test_ext, Configuration, Origin}; + use crate::mock::{new_test_ext, Configuration, Origin, ParasShared}; use frame_support::assert_ok; + fn on_new_session(session_index: SessionIndex) { + ParasShared::set_session_index(session_index); + Configuration::initializer_on_new_session(&session_index); + } + + #[test] + fn scheduled_session_is_two_sessions_from_now() { + new_test_ext(Default::default()).execute_with(|| { + // The logic here is really tested only with scheduled_session = 2. It should work + // with other values, but that should receive a more rigorious testing. + on_new_session(1); + assert_eq!(Configuration::scheduled_session(), 3); + }); + } + #[test] fn config_changes_after_2_session_boundary() { new_test_ext(Default::default()).execute_with(|| { @@ -1104,21 +1192,146 @@ mod tests { assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); + // Verify that the current configuration has not changed and that there is a scheduled + // change for the SESSION_DELAY sessions in advance. assert_eq!(Configuration::config(), old_config); - assert_eq!(::PendingConfig::get(1), None); + assert_eq!(::PendingConfigs::get(), vec![(2, config.clone())]); - Configuration::initializer_on_new_session(&1); + on_new_session(1); + // One session has passed, we should be still waiting for the pending configuration. assert_eq!(Configuration::config(), old_config); - assert_eq!(::PendingConfig::get(2), Some(config.clone())); + assert_eq!(::PendingConfigs::get(), vec![(2, config.clone())]); - Configuration::initializer_on_new_session(&2); + on_new_session(2); assert_eq!(Configuration::config(), config); - assert_eq!(::PendingConfig::get(3), None); + assert_eq!(::PendingConfigs::get(), vec![]); }) } + #[test] + fn consecutive_changes_within_one_session() { + new_test_ext(Default::default()).execute_with(|| { + let old_config = Configuration::config(); + let mut config = old_config.clone(); + config.validation_upgrade_delay = 100; + config.validation_upgrade_frequency = 100; + assert!(old_config != config); + + assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); + assert_ok!(Configuration::set_validation_upgrade_frequency(Origin::root(), 100)); + assert_eq!(Configuration::config(), old_config); + assert_eq!(::PendingConfigs::get(), vec![(2, config.clone())]); + + on_new_session(1); + + assert_eq!(Configuration::config(), old_config); + assert_eq!(::PendingConfigs::get(), vec![(2, config.clone())]); + + on_new_session(2); + + assert_eq!(Configuration::config(), config); + assert_eq!(::PendingConfigs::get(), vec![]); + }); + } + + #[test] + fn pending_next_session_but_we_upgrade_once_more() { + new_test_ext(Default::default()).execute_with(|| { + let initial_config = Configuration::config(); + let intermediate_config = + HostConfiguration { validation_upgrade_delay: 100, ..initial_config.clone() }; + let final_config = HostConfiguration { + validation_upgrade_delay: 100, + validation_upgrade_frequency: 99, + ..initial_config.clone() + }; + + assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); + assert_eq!(Configuration::config(), initial_config); + assert_eq!( + ::PendingConfigs::get(), + vec![(2, intermediate_config.clone())] + ); + + on_new_session(1); + + // We are still waiting until the pending configuration is applied and we add another + // update. + assert_ok!(Configuration::set_validation_upgrade_frequency(Origin::root(), 99)); + + // This should result in yet another configiguration change scheduled. + assert_eq!(Configuration::config(), initial_config); + assert_eq!( + ::PendingConfigs::get(), + vec![(2, intermediate_config.clone()), (3, final_config.clone())] + ); + + on_new_session(2); + + assert_eq!(Configuration::config(), intermediate_config); + assert_eq!( + ::PendingConfigs::get(), + vec![(3, final_config.clone())] + ); + + on_new_session(3); + + assert_eq!(Configuration::config(), final_config); + assert_eq!(::PendingConfigs::get(), vec![]); + }); + } + + #[test] + fn scheduled_session_config_update_while_next_session_pending() { + new_test_ext(Default::default()).execute_with(|| { + let initial_config = Configuration::config(); + let intermediate_config = + HostConfiguration { validation_upgrade_delay: 100, ..initial_config.clone() }; + let final_config = HostConfiguration { + validation_upgrade_delay: 100, + validation_upgrade_frequency: 99, + code_retention_period: 98, + ..initial_config.clone() + }; + + assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); + assert_eq!(Configuration::config(), initial_config); + assert_eq!( + ::PendingConfigs::get(), + vec![(2, intermediate_config.clone())] + ); + + on_new_session(1); + + // The second call should fall into the case where we already have a pending config + // update for the scheduled_session, but we want to update it once more. + assert_ok!(Configuration::set_validation_upgrade_frequency(Origin::root(), 99)); + assert_ok!(Configuration::set_code_retention_period(Origin::root(), 98)); + + // This should result in yet another configiguration change scheduled. + assert_eq!(Configuration::config(), initial_config); + assert_eq!( + ::PendingConfigs::get(), + vec![(2, intermediate_config.clone()), (3, final_config.clone())] + ); + + on_new_session(2); + + assert_eq!(Configuration::config(), intermediate_config); + assert_eq!( + ::PendingConfigs::get(), + vec![(3, final_config.clone())] + ); + + on_new_session(3); + + assert_eq!(Configuration::config(), final_config); + assert_eq!(::PendingConfigs::get(), vec![]); + }); + } + #[test] fn setting_pending_config_members() { new_test_ext(Default::default()).execute_with(|| { @@ -1345,8 +1558,8 @@ mod tests { .unwrap(); assert_eq!( - ::PendingConfig::get(shared::SESSION_DELAY), - Some(new_config) + ::PendingConfigs::get(), + vec![(shared::SESSION_DELAY, new_config)], ); }) } @@ -1358,15 +1571,6 @@ mod tests { }); } - #[test] - fn setting_config_to_same_as_current_is_noop() { - new_test_ext(Default::default()).execute_with(|| { - Configuration::set_validation_upgrade_delay(Origin::root(), Default::default()) - .unwrap(); - assert!(::PendingConfig::get(shared::SESSION_DELAY).is_none()) - }); - } - #[test] fn verify_externally_accessible() { // This test verifies that the value can be accessed through the well known keys and the diff --git a/runtime/parachains/src/configuration/migration.rs b/runtime/parachains/src/configuration/migration.rs index ed3a8a79d727..2d84dc5ec323 100644 --- a/runtime/parachains/src/configuration/migration.rs +++ b/runtime/parachains/src/configuration/migration.rs @@ -19,6 +19,7 @@ use crate::configuration::{self, Config, Pallet, Store}; use frame_support::{pallet_prelude::*, traits::StorageVersion, weights::Weight}; use frame_system::pallet_prelude::BlockNumberFor; +use sp_std::prelude::*; /// The current storage version. /// @@ -36,13 +37,15 @@ pub fn migrate_to_latest() -> Weight { weight } -mod v1 { +pub mod v1 { use super::*; use primitives::v1::{Balance, SessionIndex}; // Copied over from configuration.rs @ 656dd280f266dc56bd0cf1dbe3ca232960912f34 and removed // all the comments. - #[derive(parity_scale_codec::Encode, parity_scale_codec::Decode, Debug)] + #[derive( + parity_scale_codec::Encode, parity_scale_codec::Decode, scale_info::TypeInfo, Debug, Clone, + )] pub struct HostConfiguration { pub max_code_size: u32, pub max_head_data_size: u32, @@ -193,6 +196,11 @@ minimum_validation_upgrade_delay: pre.chain_availability_period + 10u32.into(), } }; + let mut weight = 0; + + // First, ActiveConfig + + weight += T::DbWeight::get().reads_writes(1, 1); if let Err(_) = as Store>::ActiveConfig::translate(|pre| pre.map(translate)) { // `Err` is returned when the pre-migration type cannot be deserialized. This // cannot happen if the migration runs correctly, i.e. against the expected version. @@ -205,7 +213,24 @@ minimum_validation_upgrade_delay: pre.chain_availability_period + 10u32.into(), ); } - T::DbWeight::get().reads_writes(1, 1) + // Second, PendingConfig -> PendingConfigs + + weight += T::DbWeight::get().reads(2); + let current_session_index = crate::shared::Pallet::::session_index(); + let scheduled_session = crate::shared::Pallet::::scheduled_session(); + let mut pending_configs = Vec::new(); + + for session_index in current_session_index..=scheduled_session { + weight += T::DbWeight::get().reads(1); + if let Some(pending_config) = as Store>::PendingConfig::get(session_index) { + pending_configs.push((session_index, translate(pending_config))); + } + } + + weight += T::DbWeight::get().writes(1); + as Store>::PendingConfigs::put(&pending_configs); + + weight } #[cfg(test)] @@ -254,66 +279,111 @@ mod tests { chain_availability_period: 33, ..Default::default() }; + let pending_configs_v1 = vec![ + ( + 1, + v1::HostConfiguration:: { + n_delay_tranches: 150, + ..v1.clone() + }, + ), + ( + 2, + v1::HostConfiguration:: { + max_validators_per_core: Some(33), + ..v1.clone() + }, + ), + ( + 3, + v1::HostConfiguration:: { + parathread_retries: 11, + ..v1.clone() + }, + ), + ]; new_test_ext(Default::default()).execute_with(|| { - // Implant the v1 version in the state. + // Implant the v1 data in the state. frame_support::storage::unhashed::put_raw( &configuration::ActiveConfig::::hashed_key(), &v1.encode(), ); + for (session_index, pending_config) in &pending_configs_v1 { + frame_support::storage::unhashed::put_raw( + &configuration::PendingConfig::::hashed_key_for(session_index), + &pending_config.encode(), + ); + } + + // Assume the session index 1. + crate::shared::Pallet::::set_session_index(1); migrate_to_v2::(); let v2 = configuration::ActiveConfig::::get(); - // The same motivation as for the migration code. See `migrate_to_v2`. - #[rustfmt::skip] + assert_correct_translation(v1, v2); + let pending_configs_v2 = configuration::PendingConfigs::::get(); + assert_eq!(pending_configs_v1.len(), pending_configs_v2.len()); + for ((session_index_v1, pending_config_v1), (session_index_v2, pending_configs_v2)) in + pending_configs_v1.into_iter().zip(pending_configs_v2.into_iter()) { - assert_eq!(v1.max_code_size , v2.max_code_size); - assert_eq!(v1.max_head_data_size , v2.max_head_data_size); - assert_eq!(v1.max_upward_queue_count , v2.max_upward_queue_count); - assert_eq!(v1.max_upward_queue_size , v2.max_upward_queue_size); - assert_eq!(v1.max_upward_message_size , v2.max_upward_message_size); - assert_eq!(v1.max_upward_message_num_per_candidate , v2.max_upward_message_num_per_candidate); - assert_eq!(v1.hrmp_max_message_num_per_candidate , v2.hrmp_max_message_num_per_candidate); - assert_eq!(v1.validation_upgrade_frequency , v2.validation_upgrade_frequency); - assert_eq!(v1.validation_upgrade_delay , v2.validation_upgrade_delay); - assert_eq!(v1.max_pov_size , v2.max_pov_size); - assert_eq!(v1.max_downward_message_size , v2.max_downward_message_size); - assert_eq!(v1.ump_service_total_weight , v2.ump_service_total_weight); - assert_eq!(v1.hrmp_max_parachain_outbound_channels , v2.hrmp_max_parachain_outbound_channels); - assert_eq!(v1.hrmp_max_parathread_outbound_channels , v2.hrmp_max_parathread_outbound_channels); - assert_eq!(v1.hrmp_sender_deposit , v2.hrmp_sender_deposit); - assert_eq!(v1.hrmp_recipient_deposit , v2.hrmp_recipient_deposit); - assert_eq!(v1.hrmp_channel_max_capacity , v2.hrmp_channel_max_capacity); - assert_eq!(v1.hrmp_channel_max_total_size , v2.hrmp_channel_max_total_size); - assert_eq!(v1.hrmp_max_parachain_inbound_channels , v2.hrmp_max_parachain_inbound_channels); - assert_eq!(v1.hrmp_max_parathread_inbound_channels , v2.hrmp_max_parathread_inbound_channels); - assert_eq!(v1.hrmp_channel_max_message_size , v2.hrmp_channel_max_message_size); - assert_eq!(v1.code_retention_period , v2.code_retention_period); - assert_eq!(v1.parathread_cores , v2.parathread_cores); - assert_eq!(v1.parathread_retries , v2.parathread_retries); - assert_eq!(v1.group_rotation_frequency , v2.group_rotation_frequency); - assert_eq!(v1.chain_availability_period , v2.chain_availability_period); - assert_eq!(v1.thread_availability_period , v2.thread_availability_period); - assert_eq!(v1.scheduling_lookahead , v2.scheduling_lookahead); - assert_eq!(v1.max_validators_per_core , v2.max_validators_per_core); - assert_eq!(v1.max_validators , v2.max_validators); - assert_eq!(v1.dispute_period , v2.dispute_period); - assert_eq!(v1.dispute_post_conclusion_acceptance_period, v2.dispute_post_conclusion_acceptance_period); - assert_eq!(v1.dispute_max_spam_slots , v2.dispute_max_spam_slots); - assert_eq!(v1.dispute_conclusion_by_time_out_period , v2.dispute_conclusion_by_time_out_period); - assert_eq!(v1.no_show_slots , v2.no_show_slots); - assert_eq!(v1.n_delay_tranches , v2.n_delay_tranches); - assert_eq!(v1.zeroth_delay_tranche_width , v2.zeroth_delay_tranche_width); - assert_eq!(v1.needed_approvals , v2.needed_approvals); - assert_eq!(v1.relay_vrf_modulo_samples , v2.relay_vrf_modulo_samples); - assert_eq!(v1.ump_max_individual_weight , v2.ump_max_individual_weight); - - assert_eq!(v2.pvf_checking_enabled, false); - assert_eq!(v2.pvf_voting_ttl, 2); - assert_eq!(v2.minimum_validation_upgrade_delay, 43); - }; // ; makes this a statement. `rustfmt::skip` cannot be put on an expression. + assert_eq!(session_index_v1, session_index_v2); + assert_correct_translation(pending_config_v1, pending_configs_v2); + } }); + + // The same motivation as for the migration code. See `migrate_to_v2`. + #[rustfmt::skip] + fn assert_correct_translation( + v1: v1::HostConfiguration, + v2: configuration::HostConfiguration + ) { + assert_eq!(v1.max_code_size , v2.max_code_size); + assert_eq!(v1.max_head_data_size , v2.max_head_data_size); + assert_eq!(v1.max_upward_queue_count , v2.max_upward_queue_count); + assert_eq!(v1.max_upward_queue_size , v2.max_upward_queue_size); + assert_eq!(v1.max_upward_message_size , v2.max_upward_message_size); + assert_eq!(v1.max_upward_message_num_per_candidate , v2.max_upward_message_num_per_candidate); + assert_eq!(v1.hrmp_max_message_num_per_candidate , v2.hrmp_max_message_num_per_candidate); + assert_eq!(v1.validation_upgrade_frequency , v2.validation_upgrade_frequency); + assert_eq!(v1.validation_upgrade_delay , v2.validation_upgrade_delay); + assert_eq!(v1.max_pov_size , v2.max_pov_size); + assert_eq!(v1.max_downward_message_size , v2.max_downward_message_size); + assert_eq!(v1.ump_service_total_weight , v2.ump_service_total_weight); + assert_eq!(v1.hrmp_max_parachain_outbound_channels , v2.hrmp_max_parachain_outbound_channels); + assert_eq!(v1.hrmp_max_parathread_outbound_channels , v2.hrmp_max_parathread_outbound_channels); + assert_eq!(v1.hrmp_sender_deposit , v2.hrmp_sender_deposit); + assert_eq!(v1.hrmp_recipient_deposit , v2.hrmp_recipient_deposit); + assert_eq!(v1.hrmp_channel_max_capacity , v2.hrmp_channel_max_capacity); + assert_eq!(v1.hrmp_channel_max_total_size , v2.hrmp_channel_max_total_size); + assert_eq!(v1.hrmp_max_parachain_inbound_channels , v2.hrmp_max_parachain_inbound_channels); + assert_eq!(v1.hrmp_max_parathread_inbound_channels , v2.hrmp_max_parathread_inbound_channels); + assert_eq!(v1.hrmp_channel_max_message_size , v2.hrmp_channel_max_message_size); + assert_eq!(v1.code_retention_period , v2.code_retention_period); + assert_eq!(v1.parathread_cores , v2.parathread_cores); + assert_eq!(v1.parathread_retries , v2.parathread_retries); + assert_eq!(v1.group_rotation_frequency , v2.group_rotation_frequency); + assert_eq!(v1.chain_availability_period , v2.chain_availability_period); + assert_eq!(v1.thread_availability_period , v2.thread_availability_period); + assert_eq!(v1.scheduling_lookahead , v2.scheduling_lookahead); + assert_eq!(v1.max_validators_per_core , v2.max_validators_per_core); + assert_eq!(v1.max_validators , v2.max_validators); + assert_eq!(v1.dispute_period , v2.dispute_period); + assert_eq!(v1.dispute_post_conclusion_acceptance_period, v2.dispute_post_conclusion_acceptance_period); + assert_eq!(v1.dispute_max_spam_slots , v2.dispute_max_spam_slots); + assert_eq!(v1.dispute_conclusion_by_time_out_period , v2.dispute_conclusion_by_time_out_period); + assert_eq!(v1.no_show_slots , v2.no_show_slots); + assert_eq!(v1.n_delay_tranches , v2.n_delay_tranches); + assert_eq!(v1.zeroth_delay_tranche_width , v2.zeroth_delay_tranche_width); + assert_eq!(v1.needed_approvals , v2.needed_approvals); + assert_eq!(v1.relay_vrf_modulo_samples , v2.relay_vrf_modulo_samples); + assert_eq!(v1.ump_max_individual_weight , v2.ump_max_individual_weight); + + assert_eq!(v2.pvf_checking_enabled, false); + assert_eq!(v2.pvf_voting_ttl, 2); + assert_eq!(v2.minimum_validation_upgrade_delay, 43); + } } } diff --git a/runtime/polkadot/src/weights/runtime_parachains_configuration.rs b/runtime/polkadot/src/weights/runtime_parachains_configuration.rs index ad84a780a4d0..c36dbc7544b5 100644 --- a/runtime/polkadot/src/weights/runtime_parachains_configuration.rs +++ b/runtime/polkadot/src/weights/runtime_parachains_configuration.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_parachains::configuration` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-10-09, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-12-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 128 // Executed Command: @@ -33,7 +33,6 @@ // --header=./file_header.txt // --output=./runtime/polkadot/src/weights/runtime_parachains_configuration.rs - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -44,35 +43,35 @@ use sp_std::marker::PhantomData; /// Weight functions for `runtime_parachains::configuration`. pub struct WeightInfo(PhantomData); impl runtime_parachains::configuration::WeightInfo for WeightInfo { - // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_block_number() -> Weight { - (12_506_000 as Weight) + (8_144_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_u32() -> Weight { - (12_550_000 as Weight) + (8_100_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_option_u32() -> Weight { - (12_521_000 as Weight) + (8_146_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } - // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_weight() -> Weight { - (12_867_000 as Weight) + (8_716_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -80,11 +79,11 @@ impl runtime_parachains::configuration::WeightInfo for fn set_hrmp_open_request_ttl() -> Weight { (2_000_000_000_000 as Weight) } - // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: Configuration ActiveConfig (r:1 w:0) + // Storage: ParasShared CurrentSessionIndex (r:1 w:0) fn set_config_with_balance() -> Weight { - (12_852_000 as Weight) + (8_735_000 as Weight) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } diff --git a/runtime/westend/src/weights/runtime_parachains_configuration.rs b/runtime/westend/src/weights/runtime_parachains_configuration.rs index 6c1753e7c3b3..976fcd025b57 100644 --- a/runtime/westend/src/weights/runtime_parachains_configuration.rs +++ b/runtime/westend/src/weights/runtime_parachains_configuration.rs @@ -16,7 +16,7 @@ //! Autogenerated weights for `runtime_parachains::configuration` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-09-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2021-12-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128 // Executed Command: @@ -33,7 +33,6 @@ // --header=./file_header.txt // --output=./runtime/westend/src/weights/runtime_parachains_configuration.rs - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -44,48 +43,43 @@ use sp_std::marker::PhantomData; /// Weight functions for `runtime_parachains::configuration`. pub struct WeightInfo(PhantomData); impl runtime_parachains::configuration::WeightInfo for WeightInfo { + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) - // Storage: Configuration ActiveConfig (r:1 w:0) fn set_config_with_block_number() -> Weight { - (12_795_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) + (7_735_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) - // Storage: Configuration ActiveConfig (r:1 w:0) fn set_config_with_u32() -> Weight { - (12_758_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) + (7_824_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) - // Storage: Configuration ActiveConfig (r:1 w:0) fn set_config_with_option_u32() -> Weight { - (12_861_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) + (8_121_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) - // Storage: Configuration ActiveConfig (r:1 w:0) fn set_config_with_weight() -> Weight { - (12_854_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) + (8_011_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Benchmark Override (r:0 w:0) fn set_hrmp_open_request_ttl() -> Weight { (2_000_000_000_000 as Weight) } + // Storage: Configuration PendingConfigs (r:1 w:1) // Storage: ParasShared CurrentSessionIndex (r:1 w:0) - // Storage: Configuration PendingConfig (r:1 w:1) - // Storage: Configuration ActiveConfig (r:1 w:0) fn set_config_with_balance() -> Weight { - (12_838_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) + (7_954_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } }