parachains: Fix configuration module (#4540)

* parachains: Fix configuration module

Closes #4529
Closes #4533

I figured that trying to avoid updates does not really worth it to keep.
This is because we seem to not update the configuration often and when
we do we approach this carefully. Thus possibility of a redundant update
is really negligable. At the same time, if such a redundant update does
happen then the effects of that are really small: just some wasted
storage interactions.

On the other hand, making it work was a little bit annoying. With the
proper fix for the pending updates this would be even more annoying
since now we would have to add combinatorically more cases to test this.

So I figured that I will just scrap that and simplify the code.

* cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_parachains::configuration --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_parachains_configuration.rs

* cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=polkadot-dev --steps=50 --repeat=20 --pallet=runtime_parachains::configuration --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/polkadot/src/weights/runtime_parachains_configuration.rs

* cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=runtime_parachains::configuration --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/westend/src/weights/runtime_parachains_configuration.rs

* review fixes

Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Sergei Shulepov
2021-12-21 14:28:56 +01:00
committed by GitHub
parent 478ac9589b
commit 5a3ee43cda
5 changed files with 444 additions and 178 deletions
@@ -16,7 +16,7 @@
//! Autogenerated weights for `runtime_parachains::configuration` //! Autogenerated weights for `runtime_parachains::configuration`
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! 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 //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 128
// Executed Command: // Executed Command:
@@ -33,7 +33,6 @@
// --header=./file_header.txt // --header=./file_header.txt
// --output=./runtime/kusama/src/weights/runtime_parachains_configuration.rs // --output=./runtime/kusama/src/weights/runtime_parachains_configuration.rs
#![cfg_attr(rustfmt, rustfmt_skip)] #![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -44,35 +43,35 @@ use sp_std::marker::PhantomData;
/// Weight functions for `runtime_parachains::configuration`. /// Weight functions for `runtime_parachains::configuration`.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for WeightInfo<T> {
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration ActiveConfig (r:1 w:0)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
fn set_config_with_block_number() -> Weight { 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().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration ActiveConfig (r:1 w:0)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
fn set_config_with_u32() -> Weight { 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().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration ActiveConfig (r:1 w:0)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
fn set_config_with_option_u32() -> Weight { 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().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration ActiveConfig (r:1 w:0)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
fn set_config_with_weight() -> Weight { 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().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
@@ -80,11 +79,11 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
fn set_hrmp_open_request_ttl() -> Weight { fn set_hrmp_open_request_ttl() -> Weight {
(2_000_000_000_000 as Weight) (2_000_000_000_000 as Weight)
} }
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration ActiveConfig (r:1 w:0)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
fn set_config_with_balance() -> Weight { 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().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
+275 -71
View File
@@ -33,7 +33,6 @@ pub use pallet::*;
pub mod migration; pub mod migration;
#[allow(dead_code)]
const LOG_TARGET: &str = "runtime::configuration"; const LOG_TARGET: &str = "runtime::configuration";
/// All configuration of the runtime with respect to parachains and parathreads. /// All configuration of the runtime with respect to parachains and parathreads.
@@ -361,9 +360,22 @@ pub mod pallet {
StorageValue<_, HostConfiguration<T::BlockNumber>, ValueQuery>; StorageValue<_, HostConfiguration<T::BlockNumber>, ValueQuery>;
/// Pending configuration (if any) for the next session. /// Pending configuration (if any) for the next session.
///
/// DEPRECATED: This is no longer used, and will be removed in the future.
#[pallet::storage] #[pallet::storage]
pub(crate) type PendingConfig<T: Config> = pub(crate) type PendingConfig<T: Config> =
StorageMap<_, Twox64Concat, SessionIndex, HostConfiguration<T::BlockNumber>>; StorageMap<_, Twox64Concat, SessionIndex, migration::v1::HostConfiguration<T::BlockNumber>>;
/// 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<T: Config> =
StorageValue<_, Vec<(SessionIndex, HostConfiguration<T::BlockNumber>)>, ValueQuery>;
#[pallet::genesis_config] #[pallet::genesis_config]
pub struct GenesisConfig<T: Config> { pub struct GenesisConfig<T: Config> {
@@ -398,7 +410,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.validation_upgrade_frequency, new) != new config.validation_upgrade_frequency = new;
}); });
Ok(()) Ok(())
} }
@@ -414,7 +426,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.validation_upgrade_delay, new) != new config.validation_upgrade_delay = new;
}); });
Ok(()) Ok(())
} }
@@ -430,7 +442,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.code_retention_period, new) != new config.code_retention_period = new;
}); });
Ok(()) Ok(())
} }
@@ -444,7 +456,7 @@ pub mod pallet {
ensure_root(origin)?; ensure_root(origin)?;
ensure!(new <= MAX_CODE_SIZE, Error::<T>::InvalidNewValue); ensure!(new <= MAX_CODE_SIZE, Error::<T>::InvalidNewValue);
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_code_size, new) != new config.max_code_size = new;
}); });
Ok(()) Ok(())
} }
@@ -458,7 +470,7 @@ pub mod pallet {
ensure_root(origin)?; ensure_root(origin)?;
ensure!(new <= MAX_POV_SIZE, Error::<T>::InvalidNewValue); ensure!(new <= MAX_POV_SIZE, Error::<T>::InvalidNewValue);
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_pov_size, new) != new config.max_pov_size = new;
}); });
Ok(()) Ok(())
} }
@@ -472,7 +484,7 @@ pub mod pallet {
ensure_root(origin)?; ensure_root(origin)?;
ensure!(new <= MAX_HEAD_DATA_SIZE, Error::<T>::InvalidNewValue); ensure!(new <= MAX_HEAD_DATA_SIZE, Error::<T>::InvalidNewValue);
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_head_data_size, new) != new config.max_head_data_size = new;
}); });
Ok(()) Ok(())
} }
@@ -485,7 +497,7 @@ pub mod pallet {
pub fn set_parathread_cores(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_parathread_cores(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.parathread_cores, new) != new config.parathread_cores = new;
}); });
Ok(()) Ok(())
} }
@@ -498,7 +510,7 @@ pub mod pallet {
pub fn set_parathread_retries(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_parathread_retries(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.parathread_retries, new) != new config.parathread_retries = new;
}); });
Ok(()) Ok(())
} }
@@ -517,7 +529,7 @@ pub mod pallet {
ensure!(!new.is_zero(), Error::<T>::InvalidNewValue); ensure!(!new.is_zero(), Error::<T>::InvalidNewValue);
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.group_rotation_frequency, new) != new config.group_rotation_frequency = new;
}); });
Ok(()) Ok(())
} }
@@ -536,7 +548,7 @@ pub mod pallet {
ensure!(!new.is_zero(), Error::<T>::InvalidNewValue); ensure!(!new.is_zero(), Error::<T>::InvalidNewValue);
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.chain_availability_period, new) != new config.chain_availability_period = new;
}); });
Ok(()) Ok(())
} }
@@ -555,7 +567,7 @@ pub mod pallet {
ensure!(!new.is_zero(), Error::<T>::InvalidNewValue); ensure!(!new.is_zero(), Error::<T>::InvalidNewValue);
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.thread_availability_period, new) != new config.thread_availability_period = new;
}); });
Ok(()) Ok(())
} }
@@ -568,7 +580,7 @@ pub mod pallet {
pub fn set_scheduling_lookahead(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_scheduling_lookahead(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.scheduling_lookahead, new) != new config.scheduling_lookahead = new;
}); });
Ok(()) Ok(())
} }
@@ -584,7 +596,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_validators_per_core, new) != new config.max_validators_per_core = new;
}); });
Ok(()) Ok(())
} }
@@ -597,7 +609,7 @@ pub mod pallet {
pub fn set_max_validators(origin: OriginFor<T>, new: Option<u32>) -> DispatchResult { pub fn set_max_validators(origin: OriginFor<T>, new: Option<u32>) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_validators, new) != new config.max_validators = new;
}); });
Ok(()) Ok(())
} }
@@ -610,7 +622,7 @@ pub mod pallet {
pub fn set_dispute_period(origin: OriginFor<T>, new: SessionIndex) -> DispatchResult { pub fn set_dispute_period(origin: OriginFor<T>, new: SessionIndex) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.dispute_period, new) != new config.dispute_period = new;
}); });
Ok(()) Ok(())
} }
@@ -626,8 +638,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.dispute_post_conclusion_acceptance_period, new) != config.dispute_post_conclusion_acceptance_period = new;
new
}); });
Ok(()) Ok(())
} }
@@ -640,7 +651,7 @@ pub mod pallet {
pub fn set_dispute_max_spam_slots(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_dispute_max_spam_slots(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.dispute_max_spam_slots, new) != new config.dispute_max_spam_slots = new;
}); });
Ok(()) Ok(())
} }
@@ -656,7 +667,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { 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(()) Ok(())
} }
@@ -673,7 +684,7 @@ pub mod pallet {
ensure!(!new.is_zero(), Error::<T>::InvalidNewValue); ensure!(!new.is_zero(), Error::<T>::InvalidNewValue);
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.no_show_slots, new) != new config.no_show_slots = new;
}); });
Ok(()) Ok(())
} }
@@ -686,7 +697,7 @@ pub mod pallet {
pub fn set_n_delay_tranches(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_n_delay_tranches(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.n_delay_tranches, new) != new config.n_delay_tranches = new;
}); });
Ok(()) Ok(())
} }
@@ -699,7 +710,7 @@ pub mod pallet {
pub fn set_zeroth_delay_tranche_width(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_zeroth_delay_tranche_width(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.zeroth_delay_tranche_width, new) != new config.zeroth_delay_tranche_width = new;
}); });
Ok(()) Ok(())
} }
@@ -712,7 +723,7 @@ pub mod pallet {
pub fn set_needed_approvals(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_needed_approvals(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.needed_approvals, new) != new config.needed_approvals = new;
}); });
Ok(()) Ok(())
} }
@@ -725,7 +736,7 @@ pub mod pallet {
pub fn set_relay_vrf_modulo_samples(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_relay_vrf_modulo_samples(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.relay_vrf_modulo_samples, new) != new config.relay_vrf_modulo_samples = new;
}); });
Ok(()) Ok(())
} }
@@ -738,7 +749,7 @@ pub mod pallet {
pub fn set_max_upward_queue_count(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_max_upward_queue_count(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_upward_queue_count, new) != new config.max_upward_queue_count = new;
}); });
Ok(()) Ok(())
} }
@@ -751,7 +762,7 @@ pub mod pallet {
pub fn set_max_upward_queue_size(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_max_upward_queue_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_upward_queue_size, new) != new config.max_upward_queue_size = new;
}); });
Ok(()) Ok(())
} }
@@ -764,7 +775,7 @@ pub mod pallet {
pub fn set_max_downward_message_size(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_max_downward_message_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_downward_message_size, new) != new config.max_downward_message_size = new;
}); });
Ok(()) Ok(())
} }
@@ -777,7 +788,7 @@ pub mod pallet {
pub fn set_ump_service_total_weight(origin: OriginFor<T>, new: Weight) -> DispatchResult { pub fn set_ump_service_total_weight(origin: OriginFor<T>, new: Weight) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.ump_service_total_weight, new) != new config.ump_service_total_weight = new;
}); });
Ok(()) Ok(())
} }
@@ -790,7 +801,7 @@ pub mod pallet {
pub fn set_max_upward_message_size(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_max_upward_message_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_upward_message_size, new) != new config.max_upward_message_size = new;
}); });
Ok(()) Ok(())
} }
@@ -806,7 +817,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { 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(()) Ok(())
} }
@@ -830,7 +841,7 @@ pub mod pallet {
pub fn set_hrmp_sender_deposit(origin: OriginFor<T>, new: Balance) -> DispatchResult { pub fn set_hrmp_sender_deposit(origin: OriginFor<T>, new: Balance) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_sender_deposit, new) != new config.hrmp_sender_deposit = new;
}); });
Ok(()) Ok(())
} }
@@ -844,7 +855,7 @@ pub mod pallet {
pub fn set_hrmp_recipient_deposit(origin: OriginFor<T>, new: Balance) -> DispatchResult { pub fn set_hrmp_recipient_deposit(origin: OriginFor<T>, new: Balance) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_recipient_deposit, new) != new config.hrmp_recipient_deposit = new;
}); });
Ok(()) Ok(())
} }
@@ -857,7 +868,7 @@ pub mod pallet {
pub fn set_hrmp_channel_max_capacity(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_hrmp_channel_max_capacity(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_channel_max_capacity, new) != new config.hrmp_channel_max_capacity = new;
}); });
Ok(()) Ok(())
} }
@@ -870,7 +881,7 @@ pub mod pallet {
pub fn set_hrmp_channel_max_total_size(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_hrmp_channel_max_total_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { 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(()) Ok(())
} }
@@ -886,7 +897,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { 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(()) Ok(())
} }
@@ -902,7 +913,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { 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(()) Ok(())
} }
@@ -915,7 +926,7 @@ pub mod pallet {
pub fn set_hrmp_channel_max_message_size(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_hrmp_channel_max_message_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { 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(()) Ok(())
} }
@@ -931,7 +942,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { 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(()) Ok(())
} }
@@ -947,7 +958,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { 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(()) Ok(())
} }
@@ -963,7 +974,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { 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(()) Ok(())
} }
@@ -976,7 +987,7 @@ pub mod pallet {
pub fn set_ump_max_individual_weight(origin: OriginFor<T>, new: Weight) -> DispatchResult { pub fn set_ump_max_individual_weight(origin: OriginFor<T>, new: Weight) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.ump_max_individual_weight, new) != new config.ump_max_individual_weight = new;
}); });
Ok(()) Ok(())
} }
@@ -990,7 +1001,7 @@ pub mod pallet {
pub fn set_pvf_checking_enabled(origin: OriginFor<T>, new: bool) -> DispatchResult { pub fn set_pvf_checking_enabled(origin: OriginFor<T>, new: bool) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.pvf_checking_enabled, new) != new config.pvf_checking_enabled = new;
}); });
Ok(()) Ok(())
} }
@@ -1003,7 +1014,7 @@ pub mod pallet {
pub fn set_pvf_voting_ttl(origin: OriginFor<T>, new: SessionIndex) -> DispatchResult { pub fn set_pvf_voting_ttl(origin: OriginFor<T>, new: SessionIndex) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.pvf_voting_ttl, new) != new config.pvf_voting_ttl = new;
}); });
Ok(()) Ok(())
} }
@@ -1020,7 +1031,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::update_config_member(|config| { Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.minimum_validation_upgrade_delay, new) != new config.minimum_validation_upgrade_delay = new;
}); });
Ok(()) Ok(())
} }
@@ -1054,9 +1065,28 @@ impl<T: Config> Pallet<T> {
/// Called by the initializer to note that a new session has started. /// Called by the initializer to note that a new session has started.
pub(crate) fn initializer_on_new_session(session_index: &SessionIndex) { pub(crate) fn initializer_on_new_session(session_index: &SessionIndex) {
if let Some(pending) = <Self as Store>::PendingConfig::take(session_index) { let pending_configs = <PendingConfigs<T>>::get();
<Self as Store>::ActiveConfig::set(pending); if pending_configs.is_empty() {
return
} }
let (past_and_present, future) = pending_configs
.into_iter()
.partition::<Vec<_>, _>(|&(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() {
<Self as Store>::ActiveConfig::put(pending);
}
<PendingConfigs<T>>::put(future);
} }
/// Return the session index that should be used for any future scheduled changes. /// Return the session index that should be used for any future scheduled changes.
@@ -1076,24 +1106,82 @@ impl<T: Config> Pallet<T> {
// duplicated code (making this function to show up in the top of heaviest functions) only for // 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. // the sake of essentially avoiding an indirect call. Doesn't worth it.
#[inline(never)] #[inline(never)]
fn update_config_member(updater: impl FnOnce(&mut HostConfiguration<T::BlockNumber>) -> bool) { fn update_config_member(updater: impl FnOnce(&mut HostConfiguration<T::BlockNumber>)) {
let scheduled_session = Self::scheduled_session(); let mut pending_configs = <PendingConfigs<T>>::get();
let pending = <Self as Store>::PendingConfig::get(scheduled_session);
let mut prev = pending.unwrap_or_else(Self::config);
if updater(&mut prev) { // 1. pending_configs = []
<Self as Store>::PendingConfig::insert(scheduled_session, prev); // 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();
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));
} }
<PendingConfigs<T>>::put(pending_configs);
} }
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::mock::{new_test_ext, Configuration, Origin}; use crate::mock::{new_test_ext, Configuration, Origin, ParasShared};
use frame_support::assert_ok; 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] #[test]
fn config_changes_after_2_session_boundary() { fn config_changes_after_2_session_boundary() {
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
@@ -1104,21 +1192,146 @@ mod tests {
assert_ok!(Configuration::set_validation_upgrade_delay(Origin::root(), 100)); 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!(Configuration::config(), old_config);
assert_eq!(<Configuration as Store>::PendingConfig::get(1), None); assert_eq!(<Configuration as Store>::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!(Configuration::config(), old_config);
assert_eq!(<Configuration as Store>::PendingConfig::get(2), Some(config.clone())); assert_eq!(<Configuration as Store>::PendingConfigs::get(), vec![(2, config.clone())]);
Configuration::initializer_on_new_session(&2); on_new_session(2);
assert_eq!(Configuration::config(), config); assert_eq!(Configuration::config(), config);
assert_eq!(<Configuration as Store>::PendingConfig::get(3), None); assert_eq!(<Configuration as Store>::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!(<Configuration as Store>::PendingConfigs::get(), vec![(2, config.clone())]);
on_new_session(1);
assert_eq!(Configuration::config(), old_config);
assert_eq!(<Configuration as Store>::PendingConfigs::get(), vec![(2, config.clone())]);
on_new_session(2);
assert_eq!(Configuration::config(), config);
assert_eq!(<Configuration as Store>::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!(
<Configuration as Store>::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!(
<Configuration as Store>::PendingConfigs::get(),
vec![(2, intermediate_config.clone()), (3, final_config.clone())]
);
on_new_session(2);
assert_eq!(Configuration::config(), intermediate_config);
assert_eq!(
<Configuration as Store>::PendingConfigs::get(),
vec![(3, final_config.clone())]
);
on_new_session(3);
assert_eq!(Configuration::config(), final_config);
assert_eq!(<Configuration as Store>::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!(
<Configuration as Store>::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!(
<Configuration as Store>::PendingConfigs::get(),
vec![(2, intermediate_config.clone()), (3, final_config.clone())]
);
on_new_session(2);
assert_eq!(Configuration::config(), intermediate_config);
assert_eq!(
<Configuration as Store>::PendingConfigs::get(),
vec![(3, final_config.clone())]
);
on_new_session(3);
assert_eq!(Configuration::config(), final_config);
assert_eq!(<Configuration as Store>::PendingConfigs::get(), vec![]);
});
}
#[test] #[test]
fn setting_pending_config_members() { fn setting_pending_config_members() {
new_test_ext(Default::default()).execute_with(|| { new_test_ext(Default::default()).execute_with(|| {
@@ -1345,8 +1558,8 @@ mod tests {
.unwrap(); .unwrap();
assert_eq!( assert_eq!(
<Configuration as Store>::PendingConfig::get(shared::SESSION_DELAY), <Configuration as Store>::PendingConfigs::get(),
Some(new_config) 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!(<Configuration as Store>::PendingConfig::get(shared::SESSION_DELAY).is_none())
});
}
#[test] #[test]
fn verify_externally_accessible() { fn verify_externally_accessible() {
// This test verifies that the value can be accessed through the well known keys and the // This test verifies that the value can be accessed through the well known keys and the
@@ -19,6 +19,7 @@
use crate::configuration::{self, Config, Pallet, Store}; use crate::configuration::{self, Config, Pallet, Store};
use frame_support::{pallet_prelude::*, traits::StorageVersion, weights::Weight}; use frame_support::{pallet_prelude::*, traits::StorageVersion, weights::Weight};
use frame_system::pallet_prelude::BlockNumberFor; use frame_system::pallet_prelude::BlockNumberFor;
use sp_std::prelude::*;
/// The current storage version. /// The current storage version.
/// ///
@@ -36,13 +37,15 @@ pub fn migrate_to_latest<T: Config>() -> Weight {
weight weight
} }
mod v1 { pub mod v1 {
use super::*; use super::*;
use primitives::v1::{Balance, SessionIndex}; use primitives::v1::{Balance, SessionIndex};
// Copied over from configuration.rs @ 656dd280f266dc56bd0cf1dbe3ca232960912f34 and removed // Copied over from configuration.rs @ 656dd280f266dc56bd0cf1dbe3ca232960912f34 and removed
// all the comments. // 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<BlockNumber> { pub struct HostConfiguration<BlockNumber> {
pub max_code_size: u32, pub max_code_size: u32,
pub max_head_data_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(_) = <Pallet<T> as Store>::ActiveConfig::translate(|pre| pre.map(translate)) { if let Err(_) = <Pallet<T> as Store>::ActiveConfig::translate(|pre| pre.map(translate)) {
// `Err` is returned when the pre-migration type cannot be deserialized. This // `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. // 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::<T>::session_index();
let scheduled_session = crate::shared::Pallet::<T>::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) = <Pallet<T> as Store>::PendingConfig::get(session_index) {
pending_configs.push((session_index, translate(pending_config)));
}
}
weight += T::DbWeight::get().writes(1);
<Pallet<T> as Store>::PendingConfigs::put(&pending_configs);
weight
} }
#[cfg(test)] #[cfg(test)]
@@ -254,21 +279,67 @@ mod tests {
chain_availability_period: 33, chain_availability_period: 33,
..Default::default() ..Default::default()
}; };
let pending_configs_v1 = vec![
(
1,
v1::HostConfiguration::<primitives::v1::BlockNumber> {
n_delay_tranches: 150,
..v1.clone()
},
),
(
2,
v1::HostConfiguration::<primitives::v1::BlockNumber> {
max_validators_per_core: Some(33),
..v1.clone()
},
),
(
3,
v1::HostConfiguration::<primitives::v1::BlockNumber> {
parathread_retries: 11,
..v1.clone()
},
),
];
new_test_ext(Default::default()).execute_with(|| { 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( frame_support::storage::unhashed::put_raw(
&configuration::ActiveConfig::<Test>::hashed_key(), &configuration::ActiveConfig::<Test>::hashed_key(),
&v1.encode(), &v1.encode(),
); );
for (session_index, pending_config) in &pending_configs_v1 {
frame_support::storage::unhashed::put_raw(
&configuration::PendingConfig::<Test>::hashed_key_for(session_index),
&pending_config.encode(),
);
}
// Assume the session index 1.
crate::shared::Pallet::<Test>::set_session_index(1);
migrate_to_v2::<Test>(); migrate_to_v2::<Test>();
let v2 = configuration::ActiveConfig::<Test>::get(); let v2 = configuration::ActiveConfig::<Test>::get();
assert_correct_translation(v1, v2);
let pending_configs_v2 = configuration::PendingConfigs::<Test>::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!(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`. // The same motivation as for the migration code. See `migrate_to_v2`.
#[rustfmt::skip] #[rustfmt::skip]
{ fn assert_correct_translation(
v1: v1::HostConfiguration<primitives::v1::BlockNumber>,
v2: configuration::HostConfiguration<primitives::v1::BlockNumber>
) {
assert_eq!(v1.max_code_size , v2.max_code_size); 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_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_count , v2.max_upward_queue_count);
@@ -313,7 +384,6 @@ mod tests {
assert_eq!(v2.pvf_checking_enabled, false); assert_eq!(v2.pvf_checking_enabled, false);
assert_eq!(v2.pvf_voting_ttl, 2); assert_eq!(v2.pvf_voting_ttl, 2);
assert_eq!(v2.minimum_validation_upgrade_delay, 43); assert_eq!(v2.minimum_validation_upgrade_delay, 43);
}; // ; makes this a statement. `rustfmt::skip` cannot be put on an expression. }
});
} }
} }
@@ -16,7 +16,7 @@
//! Autogenerated weights for `runtime_parachains::configuration` //! Autogenerated weights for `runtime_parachains::configuration`
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! 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 //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 128
// Executed Command: // Executed Command:
@@ -33,7 +33,6 @@
// --header=./file_header.txt // --header=./file_header.txt
// --output=./runtime/polkadot/src/weights/runtime_parachains_configuration.rs // --output=./runtime/polkadot/src/weights/runtime_parachains_configuration.rs
#![cfg_attr(rustfmt, rustfmt_skip)] #![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -44,35 +43,35 @@ use sp_std::marker::PhantomData;
/// Weight functions for `runtime_parachains::configuration`. /// Weight functions for `runtime_parachains::configuration`.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for WeightInfo<T> {
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration ActiveConfig (r:1 w:0)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
fn set_config_with_block_number() -> Weight { 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().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration ActiveConfig (r:1 w:0)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
fn set_config_with_u32() -> Weight { 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().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration ActiveConfig (r:1 w:0)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
fn set_config_with_option_u32() -> Weight { 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().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration ActiveConfig (r:1 w:0)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
fn set_config_with_weight() -> Weight { 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().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
@@ -80,11 +79,11 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
fn set_hrmp_open_request_ttl() -> Weight { fn set_hrmp_open_request_ttl() -> Weight {
(2_000_000_000_000 as Weight) (2_000_000_000_000 as Weight)
} }
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: Configuration PendingConfig (r:1 w:1)
// Storage: Configuration ActiveConfig (r:1 w:0) // Storage: Configuration ActiveConfig (r:1 w:0)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0)
fn set_config_with_balance() -> Weight { 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().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
@@ -16,7 +16,7 @@
//! Autogenerated weights for `runtime_parachains::configuration` //! Autogenerated weights for `runtime_parachains::configuration`
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! 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 //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128
// Executed Command: // Executed Command:
@@ -33,7 +33,6 @@
// --header=./file_header.txt // --header=./file_header.txt
// --output=./runtime/westend/src/weights/runtime_parachains_configuration.rs // --output=./runtime/westend/src/weights/runtime_parachains_configuration.rs
#![cfg_attr(rustfmt, rustfmt_skip)] #![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -44,48 +43,43 @@ use sp_std::marker::PhantomData;
/// Weight functions for `runtime_parachains::configuration`. /// Weight functions for `runtime_parachains::configuration`.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for WeightInfo<T> {
// Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // 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 { fn set_config_with_block_number() -> Weight {
(12_795_000 as Weight) (7_735_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 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: 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 { fn set_config_with_u32() -> Weight {
(12_758_000 as Weight) (7_824_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 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: 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 { fn set_config_with_option_u32() -> Weight {
(12_861_000 as Weight) (8_121_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 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: 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 { fn set_config_with_weight() -> Weight {
(12_854_000 as Weight) (8_011_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
// Storage: Benchmark Override (r:0 w:0) // Storage: Benchmark Override (r:0 w:0)
fn set_hrmp_open_request_ttl() -> Weight { fn set_hrmp_open_request_ttl() -> Weight {
(2_000_000_000_000 as Weight) (2_000_000_000_000 as Weight)
} }
// Storage: Configuration PendingConfigs (r:1 w:1)
// Storage: ParasShared CurrentSessionIndex (r:1 w:0) // 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 { fn set_config_with_balance() -> Weight {
(12_838_000 as Weight) (7_954_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
} }