Remove AssignmentProviderConfig and use parameters from HostConfiguration instead (#3181)

This PR removes `AssignmentProviderConfig` and uses the corresponding
ondemand parameters from `HostConfiguration` instead. Additionally
`scheduling_lookahead` and all coretime/ondemand related parameters are
extracted in a separate struct - `SchedulerParams`.

The most relevant commit from the PR is [this
one](https://github.com/paritytech/polkadot-sdk/pull/3181/commits/830bc0f5e858944474171bbe33382ad96040b535).

Fixes https://github.com/paritytech/polkadot-sdk/issues/2268

---------

Co-authored-by: command-bot <>
This commit is contained in:
Tsvetomir Dimitrov
2024-02-29 09:12:02 +02:00
committed by GitHub
parent a22319cdd5
commit a035dc9be7
43 changed files with 900 additions and 438 deletions
@@ -4,7 +4,7 @@ default_command = "polkadot"
chain = "rococo-local" chain = "rococo-local"
[relaychain.genesis.runtimeGenesis.patch.configuration.config] [relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
# set parameters such that collators only connect to 1 validator as a backing group # set parameters such that collators only connect to 1 validator as a backing group
max_validators_per_core = 1 max_validators_per_core = 1
group_rotation_frequency = 100 # 10 mins group_rotation_frequency = 100 # 10 mins
+12 -4
View File
@@ -24,6 +24,8 @@ use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, ValidatorId};
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId; use sp_consensus_babe::AuthorityId as BabeId;
#[cfg(any(feature = "rococo-native", feature = "westend-native",))]
use polkadot_primitives::vstaging::SchedulerParams;
#[cfg(feature = "rococo-native")] #[cfg(feature = "rococo-native")]
use rococo_runtime as rococo; use rococo_runtime as rococo;
#[cfg(feature = "rococo-native")] #[cfg(feature = "rococo-native")]
@@ -129,8 +131,6 @@ fn default_parachains_host_configuration(
max_code_size: MAX_CODE_SIZE, max_code_size: MAX_CODE_SIZE,
max_pov_size: MAX_POV_SIZE, max_pov_size: MAX_POV_SIZE,
max_head_data_size: 32 * 1024, max_head_data_size: 32 * 1024,
group_rotation_frequency: 20,
paras_availability_period: 4,
max_upward_queue_count: 8, max_upward_queue_count: 8,
max_upward_queue_size: 1024 * 1024, max_upward_queue_size: 1024 * 1024,
max_downward_message_size: 1024 * 1024, max_downward_message_size: 1024 * 1024,
@@ -151,11 +151,16 @@ fn default_parachains_host_configuration(
relay_vrf_modulo_samples: 2, relay_vrf_modulo_samples: 2,
zeroth_delay_tranche_width: 0, zeroth_delay_tranche_width: 0,
minimum_validation_upgrade_delay: 5, minimum_validation_upgrade_delay: 5,
scheduling_lookahead: 2,
async_backing_params: AsyncBackingParams { async_backing_params: AsyncBackingParams {
max_candidate_depth: 3, max_candidate_depth: 3,
allowed_ancestry_len: 2, allowed_ancestry_len: 2,
}, },
scheduler_params: SchedulerParams {
lookahead: 2,
group_rotation_frequency: 20,
paras_availability_period: 4,
..Default::default()
},
..Default::default() ..Default::default()
} }
} }
@@ -891,7 +896,10 @@ pub fn rococo_testnet_genesis(
"sudo": { "key": Some(root_key.clone()) }, "sudo": { "key": Some(root_key.clone()) },
"configuration": { "configuration": {
"config": polkadot_runtime_parachains::configuration::HostConfiguration { "config": polkadot_runtime_parachains::configuration::HostConfiguration {
max_validators_per_core: Some(1), scheduler_params: SchedulerParams {
max_validators_per_core: Some(1),
..default_parachains_host_configuration().scheduler_params
},
..default_parachains_host_configuration() ..default_parachains_host_configuration()
}, },
}, },
+8 -3
View File
@@ -19,7 +19,9 @@
use babe_primitives::AuthorityId as BabeId; use babe_primitives::AuthorityId as BabeId;
use grandpa::AuthorityId as GrandpaId; use grandpa::AuthorityId as GrandpaId;
use pallet_staking::Forcing; use pallet_staking::Forcing;
use polkadot_primitives::{AccountId, AssignmentId, ValidatorId, MAX_CODE_SIZE, MAX_POV_SIZE}; use polkadot_primitives::{
vstaging::SchedulerParams, AccountId, AssignmentId, ValidatorId, MAX_CODE_SIZE, MAX_POV_SIZE,
};
use polkadot_service::chain_spec::{get_account_id_from_seed, get_from_seed, Extensions}; use polkadot_service::chain_spec::{get_account_id_from_seed, get_from_seed, Extensions};
use polkadot_test_runtime::BABE_GENESIS_EPOCH_CONFIG; use polkadot_test_runtime::BABE_GENESIS_EPOCH_CONFIG;
use sc_chain_spec::{ChainSpec, ChainType}; use sc_chain_spec::{ChainSpec, ChainType};
@@ -165,11 +167,14 @@ fn polkadot_testnet_genesis(
max_code_size: MAX_CODE_SIZE, max_code_size: MAX_CODE_SIZE,
max_pov_size: MAX_POV_SIZE, max_pov_size: MAX_POV_SIZE,
max_head_data_size: 32 * 1024, max_head_data_size: 32 * 1024,
group_rotation_frequency: 20,
paras_availability_period: 4,
no_show_slots: 10, no_show_slots: 10,
minimum_validation_upgrade_delay: 5, minimum_validation_upgrade_delay: 5,
max_downward_message_size: 1024, max_downward_message_size: 1024,
scheduler_params: SchedulerParams {
group_rotation_frequency: 20,
paras_availability_period: 4,
..Default::default()
},
..Default::default() ..Default::default()
}, },
} }
+76
View File
@@ -23,6 +23,7 @@ use sp_std::prelude::*;
use parity_scale_codec::{Decode, Encode}; use parity_scale_codec::{Decode, Encode};
use primitives::RuntimeDebug; use primitives::RuntimeDebug;
use scale_info::TypeInfo; use scale_info::TypeInfo;
use sp_arithmetic::Perbill;
/// Approval voting configuration parameters /// Approval voting configuration parameters
#[derive( #[derive(
@@ -50,6 +51,81 @@ impl Default for ApprovalVotingParams {
} }
} }
/// Scheduler configuration parameters. All coretime/ondemand parameters are here.
#[derive(
RuntimeDebug,
Copy,
Clone,
PartialEq,
Encode,
Decode,
TypeInfo,
serde::Serialize,
serde::Deserialize,
)]
pub struct SchedulerParams<BlockNumber> {
/// How often parachain groups should be rotated across parachains.
///
/// Must be non-zero.
pub group_rotation_frequency: BlockNumber,
/// Availability timeout for a block on a core, measured in blocks.
///
/// This is the maximum amount of blocks after a core became occupied that validators have time
/// to make the block available.
///
/// This value only has effect on group rotations. If backers backed something at the end of
/// their rotation, the occupied core affects the backing group that comes afterwards. We limit
/// the effect one backing group can have on the next to `paras_availability_period` blocks.
///
/// Within a group rotation there is no timeout as backers are only affecting themselves.
///
/// Must be at least 1. With a value of 1, the previous group will not be able to negatively
/// affect the following group at the expense of a tight availability timeline at group
/// rotation boundaries.
pub paras_availability_period: BlockNumber,
/// The maximum number of validators to have per core.
///
/// `None` means no maximum.
pub max_validators_per_core: Option<u32>,
/// The amount of blocks ahead to schedule paras.
pub lookahead: u32,
/// How many cores are managed by the coretime chain.
pub num_cores: u32,
/// The max number of times a claim can time out in availability.
pub max_availability_timeouts: u32,
/// The maximum queue size of the pay as you go module.
pub on_demand_queue_max_size: u32,
/// The target utilization of the spot price queue in percentages.
pub on_demand_target_queue_utilization: Perbill,
/// How quickly the fee rises in reaction to increased utilization.
/// The lower the number the slower the increase.
pub on_demand_fee_variability: Perbill,
/// The minimum amount needed to claim a slot in the spot pricing queue.
pub on_demand_base_fee: Balance,
/// The number of blocks a claim stays in the scheduler's claimqueue before getting cleared.
/// This number should go reasonably higher than the number of blocks in the async backing
/// lookahead.
pub ttl: BlockNumber,
}
impl<BlockNumber: Default + From<u32>> Default for SchedulerParams<BlockNumber> {
fn default() -> Self {
Self {
group_rotation_frequency: 1u32.into(),
paras_availability_period: 1u32.into(),
max_validators_per_core: Default::default(),
lookahead: 1,
num_cores: Default::default(),
max_availability_timeouts: Default::default(),
on_demand_queue_max_size: ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
on_demand_target_queue_utilization: Perbill::from_percent(25),
on_demand_fee_variability: Perbill::from_percent(3),
on_demand_base_fee: 10_000_000u128,
ttl: 5u32.into(),
}
}
}
use bitvec::vec::BitVec; use bitvec::vec::BitVec;
/// Bit indices in the `HostConfiguration.node_features` that correspond to different node features. /// Bit indices in the `HostConfiguration.node_features` that correspond to different node features.
@@ -4,106 +4,24 @@ Types used within the runtime exclusively and pervasively.
## Host Configuration ## Host Configuration
The internal-to-runtime configuration of the parachain host. This is expected to be altered only by governance procedures. The internal-to-runtime configuration of the parachain host is kept in `struct HostConfiguration`. This is expected to
be altered only by governance procedures or via migrations from the Polkadot-SDK codebase. The latest definition of
`HostConfiguration` can be found in the project repo
[here](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/runtime/parachains/src/configuration.rs). Each
parameter has got a doc comment so for any details please refer to the code.
```rust Some related parameters in `HostConfiguration` are grouped together so that they can be managed easily. These are:
struct HostConfiguration { * `async_backing_params` in `struct AsyncBackingParams`
/// The minimum period, in blocks, between which parachains can update their validation code. * `executor_params` in `struct ExecutorParams`
pub validation_upgrade_cooldown: BlockNumber, * `approval_voting_params` in `struct ApprovalVotingParams`
/// The delay, in blocks, before a validation upgrade is applied. * `scheduler_params` in `struct SchedulerParams`
pub validation_upgrade_delay: BlockNumber,
/// How long to keep code on-chain, in blocks. This should be sufficiently long that disputes Check the definitions of these structs for further details.
/// have concluded.
pub code_retention_period: BlockNumber, ### Configuration migrations
/// The maximum validation code size, in bytes. Modifying `HostConfiguration` requires a storage migration. These migrations are located in the
pub max_code_size: u32, [`migrations`](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/runtime/parachains/src/configuration.rs)
/// The maximum head-data size, in bytes. subfolder of Polkadot-SDK repo.
pub max_head_data_size: u32,
/// The amount of availability cores to dedicate to parathreads (on-demand parachains).
pub parathread_cores: u32,
/// The number of retries that a parathread (on-demand parachain) author has to submit their block.
pub parathread_retries: u32,
/// How often parachain groups should be rotated across parachains.
pub group_rotation_frequency: BlockNumber,
/// The availability period, in blocks, for parachains. This is the amount of blocks
/// after inclusion that validators have to make the block available and signal its availability to
/// the chain. Must be at least 1.
pub chain_availability_period: BlockNumber,
/// The availability period, in blocks, for parathreads (on-demand parachains). Same as the `chain_availability_period`,
/// but a differing timeout due to differing requirements. Must be at least 1.
pub thread_availability_period: BlockNumber,
/// The amount of blocks ahead to schedule on-demand parachains.
pub scheduling_lookahead: u32,
/// The maximum number of validators to have per core. `None` means no maximum.
pub max_validators_per_core: Option<u32>,
/// The maximum number of validators to use for parachains, in total. `None` means no maximum.
pub max_validators: Option<u32>,
/// The amount of sessions to keep for disputes.
pub dispute_period: SessionIndex,
/// How long after dispute conclusion to accept statements.
pub dispute_post_conclusion_acceptance_period: BlockNumber,
/// The maximum number of dispute spam slots
pub dispute_max_spam_slots: u32,
/// The amount of consensus slots that must pass between submitting an assignment and
/// submitting an approval vote before a validator is considered a no-show.
/// Must be at least 1.
pub no_show_slots: u32,
/// The number of delay tranches in total.
pub n_delay_tranches: u32,
/// The width of the zeroth delay tranche for approval assignments. This many delay tranches
/// beyond 0 are all consolidated to form a wide 0 tranche.
pub zeroth_delay_tranche_width: u32,
/// The number of validators needed to approve a block.
pub needed_approvals: u32,
/// The number of samples to use in `RelayVRFModulo` or `RelayVRFModuloCompact` approval assignment criterions.
pub relay_vrf_modulo_samples: u32,
/// Total number of individual messages allowed in the parachain -> relay-chain message queue.
pub max_upward_queue_count: u32,
/// Total size of messages allowed in the parachain -> relay-chain message queue before which
/// no further messages may be added to it. If it exceeds this then the queue may contain only
/// a single message.
pub max_upward_queue_size: u32,
/// The maximum size of an upward message that can be sent by a candidate.
///
/// This parameter affects the upper bound of size of `CandidateCommitments`.
pub max_upward_message_size: u32,
/// The maximum number of messages that a candidate can contain.
///
/// This parameter affects the upper bound of size of `CandidateCommitments`.
pub max_upward_message_num_per_candidate: u32,
/// The maximum size of a message that can be put in a downward message queue.
///
/// Since we require receiving at least one DMP message the obvious upper bound of the size is
/// the PoV size. Of course, there is a lot of other different things that a parachain may
/// decide to do with its PoV so this value in practice will be picked as a fraction of the PoV
/// size.
pub max_downward_message_size: u32,
/// The deposit that the sender should provide for opening an HRMP channel.
pub hrmp_sender_deposit: u32,
/// The deposit that the recipient should provide for accepting opening an HRMP channel.
pub hrmp_recipient_deposit: u32,
/// The maximum number of messages allowed in an HRMP channel at once.
pub hrmp_channel_max_capacity: u32,
/// The maximum total size of messages in bytes allowed in an HRMP channel at once.
pub hrmp_channel_max_total_size: u32,
/// The maximum number of inbound HRMP channels a parachain is allowed to accept.
pub hrmp_max_parachain_inbound_channels: u32,
/// The maximum number of inbound HRMP channels a parathread (on-demand parachain) is allowed to accept.
pub hrmp_max_parathread_inbound_channels: u32,
/// The maximum size of a message that could ever be put into an HRMP channel.
///
/// This parameter affects the upper bound of size of `CandidateCommitments`.
pub hrmp_channel_max_message_size: u32,
/// The maximum number of outbound HRMP channels a parachain is allowed to open.
pub hrmp_max_parachain_outbound_channels: u32,
/// The maximum number of outbound HRMP channels a parathread (on-demand parachain) is allowed to open.
pub hrmp_max_parathread_outbound_channels: u32,
/// The maximum number of outbound HRMP messages can be sent by a candidate.
///
/// This parameter affects the upper bound of size of `CandidateCommitments`.
pub hrmp_max_message_num_per_candidate: u32,
}
```
## ParaInherentData ## ParaInherentData
@@ -64,11 +64,12 @@ impl GenesisConfigBuilder {
pub(super) fn build(self) -> MockGenesisConfig { pub(super) fn build(self) -> MockGenesisConfig {
let mut genesis = default_genesis_config(); let mut genesis = default_genesis_config();
let config = &mut genesis.configuration.config; let config = &mut genesis.configuration.config;
config.coretime_cores = self.on_demand_cores; config.scheduler_params.num_cores = self.on_demand_cores;
config.on_demand_base_fee = self.on_demand_base_fee; config.scheduler_params.on_demand_base_fee = self.on_demand_base_fee;
config.on_demand_fee_variability = self.on_demand_fee_variability; config.scheduler_params.on_demand_fee_variability = self.on_demand_fee_variability;
config.on_demand_queue_max_size = self.on_demand_max_queue_size; config.scheduler_params.on_demand_queue_max_size = self.on_demand_max_queue_size;
config.on_demand_target_queue_utilization = self.on_demand_target_queue_utilization; config.scheduler_params.on_demand_target_queue_utilization =
self.on_demand_target_queue_utilization;
let paras = &mut genesis.paras.paras; let paras = &mut genesis.paras.paras;
for para_id in self.onboarded_on_demand_chains { for para_id in self.onboarded_on_demand_chains {
@@ -30,7 +30,7 @@ mod tests;
use crate::{ use crate::{
assigner_on_demand, configuration, assigner_on_demand, configuration,
paras::AssignCoretime, paras::AssignCoretime,
scheduler::common::{Assignment, AssignmentProvider, AssignmentProviderConfig}, scheduler::common::{Assignment, AssignmentProvider},
ParaId, ParaId,
}; };
@@ -316,14 +316,6 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pallet<T> {
} }
} }
fn get_provider_config(_core_idx: CoreIndex) -> AssignmentProviderConfig<BlockNumberFor<T>> {
let config = <configuration::Pallet<T>>::config();
AssignmentProviderConfig {
max_availability_timeouts: config.on_demand_retries,
ttl: config.on_demand_ttl,
}
}
#[cfg(any(feature = "runtime-benchmarks", test))] #[cfg(any(feature = "runtime-benchmarks", test))]
fn get_mock_assignment(_: CoreIndex, para_id: primitives::Id) -> Assignment { fn get_mock_assignment(_: CoreIndex, para_id: primitives::Id) -> Assignment {
// Given that we are not tracking anything in `Bulk` assignments, it is safe to always // Given that we are not tracking anything in `Bulk` assignments, it is safe to always
@@ -333,7 +325,7 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pallet<T> {
fn session_core_count() -> u32 { fn session_core_count() -> u32 {
let config = <configuration::Pallet<T>>::config(); let config = <configuration::Pallet<T>>::config();
config.coretime_cores config.scheduler_params.num_cores
} }
} }
@@ -482,8 +474,8 @@ impl<T: Config> AssignCoretime for Pallet<T> {
// Add a new core and assign the para to it. // Add a new core and assign the para to it.
let mut config = <configuration::Pallet<T>>::config(); let mut config = <configuration::Pallet<T>>::config();
let core = config.coretime_cores; let core = config.scheduler_params.num_cores;
config.coretime_cores.saturating_inc(); config.scheduler_params.num_cores.saturating_inc();
// `assign_coretime` is only called at genesis or by root, so setting the active // `assign_coretime` is only called at genesis or by root, so setting the active
// config here is fine. // config here is fine.
@@ -43,7 +43,7 @@ where
{ {
ParasShared::<T>::set_session_index(SESSION_INDEX); ParasShared::<T>::set_session_index(SESSION_INDEX);
let mut config = HostConfiguration::default(); let mut config = HostConfiguration::default();
config.coretime_cores = 1; config.scheduler_params.num_cores = 1;
ConfigurationPallet::<T>::force_set_active_config(config); ConfigurationPallet::<T>::force_set_active_config(config);
let mut parachains = ParachainsCache::new(); let mut parachains = ParachainsCache::new();
ParasPallet::<T>::initialize_para_now( ParasPallet::<T>::initialize_para_now(
@@ -63,11 +63,12 @@ impl GenesisConfigBuilder {
pub(super) fn build(self) -> MockGenesisConfig { pub(super) fn build(self) -> MockGenesisConfig {
let mut genesis = default_genesis_config(); let mut genesis = default_genesis_config();
let config = &mut genesis.configuration.config; let config = &mut genesis.configuration.config;
config.coretime_cores = self.on_demand_cores; config.scheduler_params.num_cores = self.on_demand_cores;
config.on_demand_base_fee = self.on_demand_base_fee; config.scheduler_params.on_demand_base_fee = self.on_demand_base_fee;
config.on_demand_fee_variability = self.on_demand_fee_variability; config.scheduler_params.on_demand_fee_variability = self.on_demand_fee_variability;
config.on_demand_queue_max_size = self.on_demand_max_queue_size; config.scheduler_params.on_demand_queue_max_size = self.on_demand_max_queue_size;
config.on_demand_target_queue_utilization = self.on_demand_target_queue_utilization; config.scheduler_params.on_demand_target_queue_utilization =
self.on_demand_target_queue_utilization;
let paras = &mut genesis.paras.paras; let paras = &mut genesis.paras.paras;
for para_id in self.onboarded_on_demand_chains { for para_id in self.onboarded_on_demand_chains {
@@ -201,10 +201,10 @@ pub mod pallet {
let old_traffic = SpotTraffic::<T>::get(); let old_traffic = SpotTraffic::<T>::get();
match Self::calculate_spot_traffic( match Self::calculate_spot_traffic(
old_traffic, old_traffic,
config.on_demand_queue_max_size, config.scheduler_params.on_demand_queue_max_size,
Self::queue_size(), Self::queue_size(),
config.on_demand_target_queue_utilization, config.scheduler_params.on_demand_target_queue_utilization,
config.on_demand_fee_variability, config.scheduler_params.on_demand_fee_variability,
) { ) {
Ok(new_traffic) => { Ok(new_traffic) => {
// Only update storage on change // Only update storage on change
@@ -330,8 +330,9 @@ where
let traffic = SpotTraffic::<T>::get(); let traffic = SpotTraffic::<T>::get();
// Calculate spot price // Calculate spot price
let spot_price: BalanceOf<T> = let spot_price: BalanceOf<T> = traffic.saturating_mul_int(
traffic.saturating_mul_int(config.on_demand_base_fee.saturated_into::<BalanceOf<T>>()); config.scheduler_params.on_demand_base_fee.saturated_into::<BalanceOf<T>>(),
);
// Is the current price higher than `max_amount` // Is the current price higher than `max_amount`
ensure!(spot_price.le(&max_amount), Error::<T>::SpotPriceHigherThanMaxAmount); ensure!(spot_price.le(&max_amount), Error::<T>::SpotPriceHigherThanMaxAmount);
@@ -450,7 +451,10 @@ where
OnDemandQueue::<T>::try_mutate(|queue| { OnDemandQueue::<T>::try_mutate(|queue| {
// Abort transaction if queue is too large // Abort transaction if queue is too large
ensure!(Self::queue_size() < config.on_demand_queue_max_size, Error::<T>::QueueFull); ensure!(
Self::queue_size() < config.scheduler_params.on_demand_queue_max_size,
Error::<T>::QueueFull
);
match location { match location {
QueuePushDirection::Back => queue.push_back(order), QueuePushDirection::Back => queue.push_back(order),
QueuePushDirection::Front => queue.push_front(order), QueuePushDirection::Front => queue.push_front(order),
@@ -472,7 +476,7 @@ where
target: LOG_TARGET, target: LOG_TARGET,
"Failed to fetch the on demand queue size, returning the max size." "Failed to fetch the on demand queue size, returning the max size."
); );
return config.on_demand_queue_max_size return config.scheduler_params.on_demand_queue_max_size
}, },
} }
} }
@@ -27,7 +27,7 @@ use primitives::CoreIndex;
use crate::{ use crate::{
configuration, paras, configuration, paras,
scheduler::common::{Assignment, AssignmentProvider, AssignmentProviderConfig}, scheduler::common::{Assignment, AssignmentProvider},
}; };
pub use pallet::*; pub use pallet::*;
@@ -58,16 +58,6 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pallet<T> {
/// this is a no-op in the case of a bulk assignment slot. /// this is a no-op in the case of a bulk assignment slot.
fn push_back_assignment(_: Assignment) {} fn push_back_assignment(_: Assignment) {}
fn get_provider_config(_core_idx: CoreIndex) -> AssignmentProviderConfig<BlockNumberFor<T>> {
AssignmentProviderConfig {
// The next assignment already goes to the same [`ParaId`], no timeout tracking needed.
max_availability_timeouts: 0,
// The next assignment already goes to the same [`ParaId`], this can be any number
// that's high enough to clear the time it takes to clear backing/availability.
ttl: 10u32.into(),
}
}
#[cfg(any(feature = "runtime-benchmarks", test))] #[cfg(any(feature = "runtime-benchmarks", test))]
fn get_mock_assignment(_: CoreIndex, para_id: primitives::Id) -> Assignment { fn get_mock_assignment(_: CoreIndex, para_id: primitives::Id) -> Assignment {
Assignment::Bulk(para_id) Assignment::Bulk(para_id)
@@ -60,11 +60,12 @@ impl GenesisConfigBuilder {
pub(super) fn build(self) -> MockGenesisConfig { pub(super) fn build(self) -> MockGenesisConfig {
let mut genesis = default_genesis_config(); let mut genesis = default_genesis_config();
let config = &mut genesis.configuration.config; let config = &mut genesis.configuration.config;
config.coretime_cores = self.on_demand_cores; config.scheduler_params.num_cores = self.on_demand_cores;
config.on_demand_base_fee = self.on_demand_base_fee; config.scheduler_params.on_demand_base_fee = self.on_demand_base_fee;
config.on_demand_fee_variability = self.on_demand_fee_variability; config.scheduler_params.on_demand_fee_variability = self.on_demand_fee_variability;
config.on_demand_queue_max_size = self.on_demand_max_queue_size; config.scheduler_params.on_demand_queue_max_size = self.on_demand_max_queue_size;
config.on_demand_target_queue_utilization = self.on_demand_target_queue_utilization; config.scheduler_params.on_demand_target_queue_utilization =
self.on_demand_target_queue_utilization;
let paras = &mut genesis.paras.paras; let paras = &mut genesis.paras.paras;
for para_id in self.onboarded_on_demand_chains { for para_id in self.onboarded_on_demand_chains {
+8 -11
View File
@@ -18,11 +18,7 @@ use crate::{
configuration, inclusion, initializer, paras, configuration, inclusion, initializer, paras,
paras::ParaKind, paras::ParaKind,
paras_inherent, paras_inherent,
scheduler::{ scheduler::{self, common::AssignmentProvider, CoreOccupied, ParasEntry},
self,
common::{AssignmentProvider, AssignmentProviderConfig},
CoreOccupied, ParasEntry,
},
session_info, shared, session_info, shared,
}; };
use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec}; use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
@@ -197,7 +193,10 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
/// Maximum number of validators per core (a.k.a. max validators per group). This value is used /// Maximum number of validators per core (a.k.a. max validators per group). This value is used
/// if none is explicitly set on the builder. /// if none is explicitly set on the builder.
pub(crate) fn fallback_max_validators_per_core() -> u32 { pub(crate) fn fallback_max_validators_per_core() -> u32 {
configuration::Pallet::<T>::config().max_validators_per_core.unwrap_or(5) configuration::Pallet::<T>::config()
.scheduler_params
.max_validators_per_core
.unwrap_or(5)
} }
/// Specify a mapping of core index/ para id to the number of dispute statements for the /// Specify a mapping of core index/ para id to the number of dispute statements for the
@@ -684,7 +683,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
// We are currently in Session 0, so these changes will take effect in Session 2. // We are currently in Session 0, so these changes will take effect in Session 2.
Self::setup_para_ids(used_cores); Self::setup_para_ids(used_cores);
configuration::ActiveConfig::<T>::mutate(|c| { configuration::ActiveConfig::<T>::mutate(|c| {
c.coretime_cores = used_cores; c.scheduler_params.num_cores = used_cores;
}); });
let validator_ids = Self::generate_validator_pairs(self.max_validators()); let validator_ids = Self::generate_validator_pairs(self.max_validators());
@@ -715,8 +714,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
let cores = (0..used_cores) let cores = (0..used_cores)
.into_iter() .into_iter()
.map(|i| { .map(|i| {
let AssignmentProviderConfig { ttl, .. } = let ttl = configuration::Pallet::<T>::config().scheduler_params.ttl;
scheduler::Pallet::<T>::assignment_provider_config(CoreIndex(i));
// Load an assignment into provider so that one is present to pop // Load an assignment into provider so that one is present to pop
let assignment = <T as scheduler::Config>::AssignmentProvider::get_mock_assignment( let assignment = <T as scheduler::Config>::AssignmentProvider::get_mock_assignment(
CoreIndex(i), CoreIndex(i),
@@ -731,8 +729,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
let cores = (0..used_cores) let cores = (0..used_cores)
.into_iter() .into_iter()
.map(|i| { .map(|i| {
let AssignmentProviderConfig { ttl, .. } = let ttl = configuration::Pallet::<T>::config().scheduler_params.ttl;
scheduler::Pallet::<T>::assignment_provider_config(CoreIndex(i));
// Load an assignment into provider so that one is present to pop // Load an assignment into provider so that one is present to pop
let assignment = let assignment =
<T as scheduler::Config>::AssignmentProvider::get_mock_assignment( <T as scheduler::Config>::AssignmentProvider::get_mock_assignment(
@@ -29,7 +29,6 @@ use primitives::{
vstaging::{ApprovalVotingParams, NodeFeatures}, vstaging::{ApprovalVotingParams, NodeFeatures},
AsyncBackingParams, Balance, ExecutorParamError, ExecutorParams, SessionIndex, AsyncBackingParams, Balance, ExecutorParamError, ExecutorParams, SessionIndex,
LEGACY_MIN_BACKING_VOTES, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE, LEGACY_MIN_BACKING_VOTES, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE,
ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
}; };
use sp_runtime::{traits::Zero, Perbill}; use sp_runtime::{traits::Zero, Perbill};
use sp_std::prelude::*; use sp_std::prelude::*;
@@ -43,6 +42,7 @@ mod benchmarking;
pub mod migration; pub mod migration;
pub use pallet::*; pub use pallet::*;
use primitives::vstaging::SchedulerParams;
const LOG_TARGET: &str = "runtime::configuration"; const LOG_TARGET: &str = "runtime::configuration";
@@ -118,9 +118,9 @@ pub struct HostConfiguration<BlockNumber> {
/// been completed. /// been completed.
/// ///
/// Note, there are situations in which `expected_at` in the past. For example, if /// Note, there are situations in which `expected_at` in the past. For example, if
/// [`paras_availability_period`](Self::paras_availability_period) is less than the delay set /// [`paras_availability_period`](SchedulerParams::paras_availability_period) is less than the
/// by this field or if PVF pre-check took more time than the delay. In such cases, the upgrade /// delay set by this field or if PVF pre-check took more time than the delay. In such cases,
/// is further at the earliest possible time determined by /// the upgrade is further at the earliest possible time determined by
/// [`minimum_validation_upgrade_delay`](Self::minimum_validation_upgrade_delay). /// [`minimum_validation_upgrade_delay`](Self::minimum_validation_upgrade_delay).
/// ///
/// The rationale for this delay has to do with relay-chain reversions. In case there is an /// The rationale for this delay has to do with relay-chain reversions. In case there is an
@@ -172,48 +172,7 @@ pub struct HostConfiguration<BlockNumber> {
/// How long to keep code on-chain, in blocks. This should be sufficiently long that disputes /// How long to keep code on-chain, in blocks. This should be sufficiently long that disputes
/// have concluded. /// have concluded.
pub code_retention_period: BlockNumber, pub code_retention_period: BlockNumber,
/// How many cores are managed by the coretime chain.
pub coretime_cores: u32,
/// The number of retries that a on demand author has to submit their block.
pub on_demand_retries: u32,
/// The maximum queue size of the pay as you go module.
pub on_demand_queue_max_size: u32,
/// The target utilization of the spot price queue in percentages.
pub on_demand_target_queue_utilization: Perbill,
/// How quickly the fee rises in reaction to increased utilization.
/// The lower the number the slower the increase.
pub on_demand_fee_variability: Perbill,
/// The minimum amount needed to claim a slot in the spot pricing queue.
pub on_demand_base_fee: Balance,
/// The number of blocks an on demand claim stays in the scheduler's claimqueue before getting
/// cleared. This number should go reasonably higher than the number of blocks in the async
/// backing lookahead.
pub on_demand_ttl: BlockNumber,
/// How often parachain groups should be rotated across parachains.
///
/// Must be non-zero.
pub group_rotation_frequency: BlockNumber,
/// The minimum availability period, in blocks.
///
/// This is the minimum amount of blocks after a core became occupied that validators have time
/// to make the block available.
///
/// This value only has effect on group rotations. If backers backed something at the end of
/// their rotation, the occupied core affects the backing group that comes afterwards. We limit
/// the effect one backing group can have on the next to `paras_availability_period` blocks.
///
/// Within a group rotation there is no timeout as backers are only affecting themselves.
///
/// Must be at least 1. With a value of 1, the previous group will not be able to negatively
/// affect the following group at the expense of a tight availability timeline at group
/// rotation boundaries.
pub paras_availability_period: BlockNumber,
/// The amount of blocks ahead to schedule paras.
pub scheduling_lookahead: u32,
/// The maximum number of validators to have per core.
///
/// `None` means no maximum.
pub max_validators_per_core: Option<u32>,
/// The maximum number of validators to use for parachain consensus, period. /// The maximum number of validators to use for parachain consensus, period.
/// ///
/// `None` means no maximum. /// `None` means no maximum.
@@ -257,7 +216,7 @@ pub struct HostConfiguration<BlockNumber> {
/// scheduled. This number is controlled by this field. /// scheduled. This number is controlled by this field.
/// ///
/// This value should be greater than /// This value should be greater than
/// [`paras_availability_period`](Self::paras_availability_period). /// [`paras_availability_period`](SchedulerParams::paras_availability_period).
pub minimum_validation_upgrade_delay: BlockNumber, pub minimum_validation_upgrade_delay: BlockNumber,
/// The minimum number of valid backing statements required to consider a parachain candidate /// The minimum number of valid backing statements required to consider a parachain candidate
/// backable. /// backable.
@@ -266,6 +225,8 @@ pub struct HostConfiguration<BlockNumber> {
pub node_features: NodeFeatures, pub node_features: NodeFeatures,
/// Params used by approval-voting /// Params used by approval-voting
pub approval_voting_params: ApprovalVotingParams, pub approval_voting_params: ApprovalVotingParams,
/// Scheduler parameters
pub scheduler_params: SchedulerParams<BlockNumber>,
} }
impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber> { impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber> {
@@ -275,8 +236,6 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
max_candidate_depth: 0, max_candidate_depth: 0,
allowed_ancestry_len: 0, allowed_ancestry_len: 0,
}, },
group_rotation_frequency: 1u32.into(),
paras_availability_period: 1u32.into(),
no_show_slots: 1u32.into(), no_show_slots: 1u32.into(),
validation_upgrade_cooldown: Default::default(), validation_upgrade_cooldown: Default::default(),
validation_upgrade_delay: 2u32.into(), validation_upgrade_delay: 2u32.into(),
@@ -284,10 +243,6 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
max_code_size: MAX_CODE_SIZE, max_code_size: MAX_CODE_SIZE,
max_pov_size: Default::default(), max_pov_size: Default::default(),
max_head_data_size: Default::default(), max_head_data_size: Default::default(),
coretime_cores: Default::default(),
on_demand_retries: Default::default(),
scheduling_lookahead: 1,
max_validators_per_core: Default::default(),
max_validators: None, max_validators: None,
dispute_period: 6, dispute_period: 6,
dispute_post_conclusion_acceptance_period: 100.into(), dispute_post_conclusion_acceptance_period: 100.into(),
@@ -312,13 +267,9 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
minimum_validation_upgrade_delay: 2.into(), minimum_validation_upgrade_delay: 2.into(),
executor_params: Default::default(), executor_params: Default::default(),
approval_voting_params: ApprovalVotingParams { max_approval_coalesce_count: 1 }, approval_voting_params: ApprovalVotingParams { max_approval_coalesce_count: 1 },
on_demand_queue_max_size: ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
on_demand_base_fee: 10_000_000u128,
on_demand_fee_variability: Perbill::from_percent(3),
on_demand_target_queue_utilization: Perbill::from_percent(25),
on_demand_ttl: 5u32.into(),
minimum_backing_votes: LEGACY_MIN_BACKING_VOTES, minimum_backing_votes: LEGACY_MIN_BACKING_VOTES,
node_features: NodeFeatures::EMPTY, node_features: NodeFeatures::EMPTY,
scheduler_params: Default::default(),
} }
} }
} }
@@ -359,6 +310,8 @@ pub enum InconsistentError<BlockNumber> {
ZeroMinimumBackingVotes, ZeroMinimumBackingVotes,
/// `executor_params` are inconsistent. /// `executor_params` are inconsistent.
InconsistentExecutorParams { inner: ExecutorParamError }, InconsistentExecutorParams { inner: ExecutorParamError },
/// TTL should be bigger than lookahead
LookaheadExceedsTTL,
} }
impl<BlockNumber> HostConfiguration<BlockNumber> impl<BlockNumber> HostConfiguration<BlockNumber>
@@ -373,11 +326,11 @@ where
pub fn check_consistency(&self) -> Result<(), InconsistentError<BlockNumber>> { pub fn check_consistency(&self) -> Result<(), InconsistentError<BlockNumber>> {
use InconsistentError::*; use InconsistentError::*;
if self.group_rotation_frequency.is_zero() { if self.scheduler_params.group_rotation_frequency.is_zero() {
return Err(ZeroGroupRotationFrequency) return Err(ZeroGroupRotationFrequency)
} }
if self.paras_availability_period.is_zero() { if self.scheduler_params.paras_availability_period.is_zero() {
return Err(ZeroParasAvailabilityPeriod) return Err(ZeroParasAvailabilityPeriod)
} }
@@ -399,10 +352,11 @@ where
return Err(MaxPovSizeExceedHardLimit { max_pov_size: self.max_pov_size }) return Err(MaxPovSizeExceedHardLimit { max_pov_size: self.max_pov_size })
} }
if self.minimum_validation_upgrade_delay <= self.paras_availability_period { if self.minimum_validation_upgrade_delay <= self.scheduler_params.paras_availability_period
{
return Err(MinimumValidationUpgradeDelayLessThanChainAvailabilityPeriod { return Err(MinimumValidationUpgradeDelayLessThanChainAvailabilityPeriod {
minimum_validation_upgrade_delay: self.minimum_validation_upgrade_delay.clone(), minimum_validation_upgrade_delay: self.minimum_validation_upgrade_delay.clone(),
paras_availability_period: self.paras_availability_period.clone(), paras_availability_period: self.scheduler_params.paras_availability_period.clone(),
}) })
} }
@@ -447,6 +401,10 @@ where
return Err(InconsistentExecutorParams { inner }) return Err(InconsistentExecutorParams { inner })
} }
if self.scheduler_params.ttl < self.scheduler_params.lookahead.into() {
return Err(LookaheadExceedsTTL)
}
Ok(()) Ok(())
} }
@@ -471,6 +429,7 @@ pub trait WeightInfo {
fn set_config_with_executor_params() -> Weight; fn set_config_with_executor_params() -> Weight;
fn set_config_with_perbill() -> Weight; fn set_config_with_perbill() -> Weight;
fn set_node_feature() -> Weight; fn set_node_feature() -> Weight;
fn set_config_with_scheduler_params() -> Weight;
} }
pub struct TestWeightInfo; pub struct TestWeightInfo;
@@ -499,6 +458,9 @@ impl WeightInfo for TestWeightInfo {
fn set_node_feature() -> Weight { fn set_node_feature() -> Weight {
Weight::MAX Weight::MAX
} }
fn set_config_with_scheduler_params() -> Weight {
Weight::MAX
}
} }
#[frame_support::pallet] #[frame_support::pallet]
@@ -520,7 +482,8 @@ pub mod pallet {
/// v8-v9: <https://github.com/paritytech/polkadot/pull/7577> /// v8-v9: <https://github.com/paritytech/polkadot/pull/7577>
/// v9-v10: <https://github.com/paritytech/polkadot-sdk/pull/2177> /// v9-v10: <https://github.com/paritytech/polkadot-sdk/pull/2177>
/// v10-11: <https://github.com/paritytech/polkadot-sdk/pull/1191> /// v10-11: <https://github.com/paritytech/polkadot-sdk/pull/1191>
const STORAGE_VERSION: StorageVersion = StorageVersion::new(11); /// v11-12: <https://github.com/paritytech/polkadot-sdk/pull/3181>
const STORAGE_VERSION: StorageVersion = StorageVersion::new(12);
#[pallet::pallet] #[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)] #[pallet::storage_version(STORAGE_VERSION)]
@@ -679,16 +642,16 @@ pub mod pallet {
Self::set_coretime_cores_unchecked(new) Self::set_coretime_cores_unchecked(new)
} }
/// Set the number of retries for a particular on demand. /// Set the max number of times a claim may timeout on a core before it is abandoned
#[pallet::call_index(7)] #[pallet::call_index(7)]
#[pallet::weight(( #[pallet::weight((
T::WeightInfo::set_config_with_u32(), T::WeightInfo::set_config_with_u32(),
DispatchClass::Operational, DispatchClass::Operational,
))] ))]
pub fn set_on_demand_retries(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_max_availability_timeouts(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
config.on_demand_retries = new; config.scheduler_params.max_availability_timeouts = new;
}) })
} }
@@ -704,7 +667,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
config.group_rotation_frequency = new; config.scheduler_params.group_rotation_frequency = new;
}) })
} }
@@ -720,7 +683,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
config.paras_availability_period = new; config.scheduler_params.paras_availability_period = new;
}) })
} }
@@ -733,7 +696,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::schedule_config_update(|config| { Self::schedule_config_update(|config| {
config.scheduling_lookahead = new; config.scheduler_params.lookahead = new;
}) })
} }
@@ -749,7 +712,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
config.max_validators_per_core = new; config.scheduler_params.max_validators_per_core = new;
}) })
} }
@@ -1141,7 +1104,7 @@ pub mod pallet {
pub fn set_on_demand_base_fee(origin: OriginFor<T>, new: Balance) -> DispatchResult { pub fn set_on_demand_base_fee(origin: OriginFor<T>, new: Balance) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
config.on_demand_base_fee = new; config.scheduler_params.on_demand_base_fee = new;
}) })
} }
@@ -1154,7 +1117,7 @@ pub mod pallet {
pub fn set_on_demand_fee_variability(origin: OriginFor<T>, new: Perbill) -> DispatchResult { pub fn set_on_demand_fee_variability(origin: OriginFor<T>, new: Perbill) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
config.on_demand_fee_variability = new; config.scheduler_params.on_demand_fee_variability = new;
}) })
} }
@@ -1167,7 +1130,7 @@ pub mod pallet {
pub fn set_on_demand_queue_max_size(origin: OriginFor<T>, new: u32) -> DispatchResult { pub fn set_on_demand_queue_max_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
config.on_demand_queue_max_size = new; config.scheduler_params.on_demand_queue_max_size = new;
}) })
} }
/// Set the on demand (parathreads) fee variability. /// Set the on demand (parathreads) fee variability.
@@ -1182,7 +1145,7 @@ pub mod pallet {
) -> DispatchResult { ) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
config.on_demand_target_queue_utilization = new; config.scheduler_params.on_demand_target_queue_utilization = new;
}) })
} }
/// Set the on demand (parathreads) ttl in the claimqueue. /// Set the on demand (parathreads) ttl in the claimqueue.
@@ -1194,7 +1157,7 @@ pub mod pallet {
pub fn set_on_demand_ttl(origin: OriginFor<T>, new: BlockNumberFor<T>) -> DispatchResult { pub fn set_on_demand_ttl(origin: OriginFor<T>, new: BlockNumberFor<T>) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
config.on_demand_ttl = new; config.scheduler_params.ttl = new;
}) })
} }
@@ -1244,6 +1207,22 @@ pub mod pallet {
config.approval_voting_params = new; config.approval_voting_params = new;
}) })
} }
/// Set scheduler-params.
#[pallet::call_index(55)]
#[pallet::weight((
T::WeightInfo::set_config_with_scheduler_params(),
DispatchClass::Operational,
))]
pub fn set_scheduler_params(
origin: OriginFor<T>,
new: SchedulerParams<BlockNumberFor<T>>,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.scheduler_params = new;
})
}
} }
impl<T: Config> Pallet<T> { impl<T: Config> Pallet<T> {
@@ -1252,7 +1231,7 @@ pub mod pallet {
/// To be used if authorization is checked otherwise. /// To be used if authorization is checked otherwise.
pub fn set_coretime_cores_unchecked(new: u32) -> DispatchResult { pub fn set_coretime_cores_unchecked(new: u32) -> DispatchResult {
Self::schedule_config_update(|config| { Self::schedule_config_update(|config| {
config.coretime_cores = new; config.scheduler_params.num_cores = new;
}) })
} }
} }
@@ -1393,7 +1372,7 @@ impl<T: Config> Pallet<T> {
let base_config_consistent = base_config.check_consistency().is_ok(); let base_config_consistent = base_config.check_consistency().is_ok();
// Now, we need to decide what the new configuration should be. // Now, we need to decide what the new configuration should be.
// We also move the `base_config` to `new_config` to empahsize that the base config was // We also move the `base_config` to `new_config` to emphasize that the base config was
// destroyed by the `updater`. // destroyed by the `updater`.
updater(&mut base_config); updater(&mut base_config);
let new_config = base_config; let new_config = base_config;
@@ -51,6 +51,8 @@ benchmarks! {
set_node_feature{}: set_node_feature(RawOrigin::Root, 255, true) set_node_feature{}: set_node_feature(RawOrigin::Root, 255, true)
set_config_with_scheduler_params {} : set_scheduler_params(RawOrigin::Root, SchedulerParams::default())
impl_benchmark_test_suite!( impl_benchmark_test_suite!(
Pallet, Pallet,
crate::mock::new_test_ext(Default::default()), crate::mock::new_test_ext(Default::default()),
@@ -18,6 +18,7 @@
pub mod v10; pub mod v10;
pub mod v11; pub mod v11;
pub mod v12;
pub mod v6; pub mod v6;
pub mod v7; pub mod v7;
pub mod v8; pub mod v8;
@@ -21,13 +21,122 @@ use frame_support::{
migrations::VersionedMigration, pallet_prelude::*, traits::Defensive, weights::Weight, migrations::VersionedMigration, pallet_prelude::*, traits::Defensive, weights::Weight,
}; };
use frame_system::pallet_prelude::BlockNumberFor; use frame_system::pallet_prelude::BlockNumberFor;
use primitives::{vstaging::ApprovalVotingParams, SessionIndex}; use primitives::{
vstaging::ApprovalVotingParams, AsyncBackingParams, ExecutorParams, SessionIndex,
LEGACY_MIN_BACKING_VOTES, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
};
use sp_std::vec::Vec; use sp_std::vec::Vec;
use frame_support::traits::OnRuntimeUpgrade; use frame_support::traits::OnRuntimeUpgrade;
use polkadot_core_primitives::Balance;
use primitives::vstaging::NodeFeatures;
use sp_arithmetic::Perbill;
use super::v10::V10HostConfiguration; use super::v10::V10HostConfiguration;
type V11HostConfiguration<BlockNumber> = configuration::HostConfiguration<BlockNumber>;
#[derive(Clone, Encode, PartialEq, Decode, Debug)]
pub struct V11HostConfiguration<BlockNumber> {
pub max_code_size: u32,
pub max_head_data_size: u32,
pub max_upward_queue_count: u32,
pub max_upward_queue_size: u32,
pub max_upward_message_size: u32,
pub max_upward_message_num_per_candidate: u32,
pub hrmp_max_message_num_per_candidate: u32,
pub validation_upgrade_cooldown: BlockNumber,
pub validation_upgrade_delay: BlockNumber,
pub async_backing_params: AsyncBackingParams,
pub max_pov_size: u32,
pub max_downward_message_size: u32,
pub hrmp_max_parachain_outbound_channels: u32,
pub hrmp_sender_deposit: Balance,
pub hrmp_recipient_deposit: Balance,
pub hrmp_channel_max_capacity: u32,
pub hrmp_channel_max_total_size: u32,
pub hrmp_max_parachain_inbound_channels: u32,
pub hrmp_channel_max_message_size: u32,
pub executor_params: ExecutorParams,
pub code_retention_period: BlockNumber,
pub coretime_cores: u32,
pub on_demand_retries: u32,
pub on_demand_queue_max_size: u32,
pub on_demand_target_queue_utilization: Perbill,
pub on_demand_fee_variability: Perbill,
pub on_demand_base_fee: Balance,
pub on_demand_ttl: BlockNumber,
pub group_rotation_frequency: BlockNumber,
pub paras_availability_period: BlockNumber,
pub scheduling_lookahead: u32,
pub max_validators_per_core: Option<u32>,
pub max_validators: Option<u32>,
pub dispute_period: SessionIndex,
pub dispute_post_conclusion_acceptance_period: BlockNumber,
pub no_show_slots: u32,
pub n_delay_tranches: u32,
pub zeroth_delay_tranche_width: u32,
pub needed_approvals: u32,
pub relay_vrf_modulo_samples: u32,
pub pvf_voting_ttl: SessionIndex,
pub minimum_validation_upgrade_delay: BlockNumber,
pub minimum_backing_votes: u32,
pub node_features: NodeFeatures,
pub approval_voting_params: ApprovalVotingParams,
}
impl<BlockNumber: Default + From<u32>> Default for V11HostConfiguration<BlockNumber> {
fn default() -> Self {
Self {
async_backing_params: AsyncBackingParams {
max_candidate_depth: 0,
allowed_ancestry_len: 0,
},
group_rotation_frequency: 1u32.into(),
paras_availability_period: 1u32.into(),
no_show_slots: 1u32.into(),
validation_upgrade_cooldown: Default::default(),
validation_upgrade_delay: 2u32.into(),
code_retention_period: Default::default(),
max_code_size: Default::default(),
max_pov_size: Default::default(),
max_head_data_size: Default::default(),
coretime_cores: Default::default(),
on_demand_retries: Default::default(),
scheduling_lookahead: 1,
max_validators_per_core: Default::default(),
max_validators: None,
dispute_period: 6,
dispute_post_conclusion_acceptance_period: 100.into(),
n_delay_tranches: Default::default(),
zeroth_delay_tranche_width: Default::default(),
needed_approvals: Default::default(),
relay_vrf_modulo_samples: Default::default(),
max_upward_queue_count: Default::default(),
max_upward_queue_size: Default::default(),
max_downward_message_size: Default::default(),
max_upward_message_size: Default::default(),
max_upward_message_num_per_candidate: Default::default(),
hrmp_sender_deposit: Default::default(),
hrmp_recipient_deposit: Default::default(),
hrmp_channel_max_capacity: Default::default(),
hrmp_channel_max_total_size: Default::default(),
hrmp_max_parachain_inbound_channels: Default::default(),
hrmp_channel_max_message_size: Default::default(),
hrmp_max_parachain_outbound_channels: Default::default(),
hrmp_max_message_num_per_candidate: Default::default(),
pvf_voting_ttl: 2u32.into(),
minimum_validation_upgrade_delay: 2.into(),
executor_params: Default::default(),
approval_voting_params: ApprovalVotingParams { max_approval_coalesce_count: 1 },
on_demand_queue_max_size: ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
on_demand_base_fee: 10_000_000u128,
on_demand_fee_variability: Perbill::from_percent(3),
on_demand_target_queue_utilization: Perbill::from_percent(25),
on_demand_ttl: 5u32.into(),
minimum_backing_votes: LEGACY_MIN_BACKING_VOTES,
node_features: NodeFeatures::EMPTY,
}
}
}
mod v10 { mod v10 {
use super::*; use super::*;
@@ -0,0 +1,349 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! A module that is responsible for migration of storage.
use crate::configuration::{self, migration::v11::V11HostConfiguration, Config, Pallet};
use frame_support::{
migrations::VersionedMigration,
pallet_prelude::*,
traits::{Defensive, OnRuntimeUpgrade},
};
use frame_system::pallet_prelude::BlockNumberFor;
use primitives::vstaging::SchedulerParams;
use sp_core::Get;
use sp_staking::SessionIndex;
use sp_std::vec::Vec;
type V12HostConfiguration<BlockNumber> = configuration::HostConfiguration<BlockNumber>;
mod v11 {
use super::*;
#[frame_support::storage_alias]
pub(crate) type ActiveConfig<T: Config> =
StorageValue<Pallet<T>, V11HostConfiguration<BlockNumberFor<T>>, OptionQuery>;
#[frame_support::storage_alias]
pub(crate) type PendingConfigs<T: Config> = StorageValue<
Pallet<T>,
Vec<(SessionIndex, V11HostConfiguration<BlockNumberFor<T>>)>,
OptionQuery,
>;
}
mod v12 {
use super::*;
#[frame_support::storage_alias]
pub(crate) type ActiveConfig<T: Config> =
StorageValue<Pallet<T>, V12HostConfiguration<BlockNumberFor<T>>, OptionQuery>;
#[frame_support::storage_alias]
pub(crate) type PendingConfigs<T: Config> = StorageValue<
Pallet<T>,
Vec<(SessionIndex, V12HostConfiguration<BlockNumberFor<T>>)>,
OptionQuery,
>;
}
pub type MigrateToV12<T> = VersionedMigration<
11,
12,
UncheckedMigrateToV12<T>,
Pallet<T>,
<T as frame_system::Config>::DbWeight,
>;
pub struct UncheckedMigrateToV12<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for UncheckedMigrateToV12<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
log::trace!(target: crate::configuration::LOG_TARGET, "Running pre_upgrade() for HostConfiguration MigrateToV12");
Ok(Vec::new())
}
fn on_runtime_upgrade() -> Weight {
log::info!(target: configuration::LOG_TARGET, "HostConfiguration MigrateToV12 started");
let weight_consumed = migrate_to_v12::<T>();
log::info!(target: configuration::LOG_TARGET, "HostConfiguration MigrateToV12 executed successfully");
weight_consumed
}
#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
log::trace!(target: crate::configuration::LOG_TARGET, "Running post_upgrade() for HostConfiguration MigrateToV12");
ensure!(
StorageVersion::get::<Pallet<T>>() >= 12,
"Storage version should be >= 12 after the migration"
);
Ok(())
}
}
fn migrate_to_v12<T: Config>() -> Weight {
// Unusual formatting is justified:
// - make it easier to verify that fields assign what they supposed to assign.
// - this code is transient and will be removed after all migrations are done.
// - this code is important enough to optimize for legibility sacrificing consistency.
#[rustfmt::skip]
let translate =
|pre: V11HostConfiguration<BlockNumberFor<T>>| ->
V12HostConfiguration<BlockNumberFor<T>>
{
V12HostConfiguration {
max_code_size : pre.max_code_size,
max_head_data_size : pre.max_head_data_size,
max_upward_queue_count : pre.max_upward_queue_count,
max_upward_queue_size : pre.max_upward_queue_size,
max_upward_message_size : pre.max_upward_message_size,
max_upward_message_num_per_candidate : pre.max_upward_message_num_per_candidate,
hrmp_max_message_num_per_candidate : pre.hrmp_max_message_num_per_candidate,
validation_upgrade_cooldown : pre.validation_upgrade_cooldown,
validation_upgrade_delay : pre.validation_upgrade_delay,
max_pov_size : pre.max_pov_size,
max_downward_message_size : pre.max_downward_message_size,
hrmp_sender_deposit : pre.hrmp_sender_deposit,
hrmp_recipient_deposit : pre.hrmp_recipient_deposit,
hrmp_channel_max_capacity : pre.hrmp_channel_max_capacity,
hrmp_channel_max_total_size : pre.hrmp_channel_max_total_size,
hrmp_max_parachain_inbound_channels : pre.hrmp_max_parachain_inbound_channels,
hrmp_max_parachain_outbound_channels : pre.hrmp_max_parachain_outbound_channels,
hrmp_channel_max_message_size : pre.hrmp_channel_max_message_size,
code_retention_period : pre.code_retention_period,
max_validators : pre.max_validators,
dispute_period : pre.dispute_period,
dispute_post_conclusion_acceptance_period: pre.dispute_post_conclusion_acceptance_period,
no_show_slots : pre.no_show_slots,
n_delay_tranches : pre.n_delay_tranches,
zeroth_delay_tranche_width : pre.zeroth_delay_tranche_width,
needed_approvals : pre.needed_approvals,
relay_vrf_modulo_samples : pre.relay_vrf_modulo_samples,
pvf_voting_ttl : pre.pvf_voting_ttl,
minimum_validation_upgrade_delay : pre.minimum_validation_upgrade_delay,
async_backing_params : pre.async_backing_params,
executor_params : pre.executor_params,
minimum_backing_votes : pre.minimum_backing_votes,
node_features : pre.node_features,
approval_voting_params : pre.approval_voting_params,
scheduler_params: SchedulerParams {
group_rotation_frequency : pre.group_rotation_frequency,
paras_availability_period : pre.paras_availability_period,
max_validators_per_core : pre.max_validators_per_core,
lookahead : pre.scheduling_lookahead,
num_cores : pre.coretime_cores,
max_availability_timeouts : pre.on_demand_retries,
on_demand_queue_max_size : pre.on_demand_queue_max_size,
on_demand_target_queue_utilization : pre.on_demand_target_queue_utilization,
on_demand_fee_variability : pre.on_demand_fee_variability,
on_demand_base_fee : pre.on_demand_base_fee,
ttl : pre.on_demand_ttl,
}
}
};
let v11 = v11::ActiveConfig::<T>::get()
.defensive_proof("Could not decode old config")
.unwrap_or_default();
let v12 = translate(v11);
v12::ActiveConfig::<T>::set(Some(v12));
// Allowed to be empty.
let pending_v11 = v11::PendingConfigs::<T>::get().unwrap_or_default();
let mut pending_v12 = Vec::new();
for (session, v11) in pending_v11.into_iter() {
let v12 = translate(v11);
pending_v12.push((session, v12));
}
v12::PendingConfigs::<T>::set(Some(pending_v12.clone()));
let num_configs = (pending_v12.len() + 1) as u64;
T::DbWeight::get().reads_writes(num_configs, num_configs)
}
#[cfg(test)]
mod tests {
use primitives::LEGACY_MIN_BACKING_VOTES;
use sp_arithmetic::Perbill;
use super::*;
use crate::mock::{new_test_ext, Test};
#[test]
fn v12_deserialized_from_actual_data() {
// Example how to get new `raw_config`:
// We'll obtain the raw_config at a specified a block
// Steps:
// 1. Go to Polkadot.js -> Developer -> Chain state -> Storage: https://polkadot.js.org/apps/#/chainstate
// 2. Set these parameters:
// 2.1. selected state query: configuration; activeConfig():
// PolkadotRuntimeParachainsConfigurationHostConfiguration
// 2.2. blockhash to query at:
// 0xf89d3ab5312c5f70d396dc59612f0aa65806c798346f9db4b35278baed2e0e53 (the hash of
// the block)
// 2.3. Note the value of encoded storage key ->
// 0x06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385 for the
// referenced block.
// 2.4. You'll also need the decoded values to update the test.
// 3. Go to Polkadot.js -> Developer -> Chain state -> Raw storage
// 3.1 Enter the encoded storage key and you get the raw config.
// This exceeds the maximal line width length, but that's fine, since this is not code and
// doesn't need to be read and also leaving it as one line allows to easily copy it.
let raw_config =
hex_literal::hex![
"0000300000800000080000000000100000c8000005000000050000000200000002000000000000000000000000005000000010000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000000100000b004000000060000006400000002000000190000000000000002000000020000000200000005000000020000000001000000140000000400000001010000000100000001000000000000001027000080b2e60e80c3c9018096980000000000000000000000000005000000"
];
let v12 =
V12HostConfiguration::<primitives::BlockNumber>::decode(&mut &raw_config[..]).unwrap();
// We check only a sample of the values here. If we missed any fields or messed up data
// types that would skew all the fields coming after.
assert_eq!(v12.max_code_size, 3_145_728);
assert_eq!(v12.validation_upgrade_cooldown, 2);
assert_eq!(v12.max_pov_size, 5_242_880);
assert_eq!(v12.hrmp_channel_max_message_size, 1_048_576);
assert_eq!(v12.n_delay_tranches, 25);
assert_eq!(v12.minimum_validation_upgrade_delay, 5);
assert_eq!(v12.minimum_backing_votes, LEGACY_MIN_BACKING_VOTES);
assert_eq!(v12.approval_voting_params.max_approval_coalesce_count, 1);
assert_eq!(v12.scheduler_params.group_rotation_frequency, 20);
assert_eq!(v12.scheduler_params.paras_availability_period, 4);
assert_eq!(v12.scheduler_params.lookahead, 1);
assert_eq!(v12.scheduler_params.num_cores, 1);
assert_eq!(v12.scheduler_params.max_availability_timeouts, 0);
assert_eq!(v12.scheduler_params.on_demand_queue_max_size, 10_000);
assert_eq!(
v12.scheduler_params.on_demand_target_queue_utilization,
Perbill::from_percent(25)
);
assert_eq!(v12.scheduler_params.on_demand_fee_variability, Perbill::from_percent(3));
assert_eq!(v12.scheduler_params.on_demand_base_fee, 10_000_000);
assert_eq!(v12.scheduler_params.ttl, 5);
}
#[test]
fn test_migrate_to_v12() {
// Host configuration has lots of fields. However, in this migration we only add one
// field. The most important part to check are a couple of the last fields. We also pick
// extra fields to check arbitrarily, e.g. depending on their position (i.e. the middle) and
// also their type.
//
// We specify only the picked fields and the rest should be provided by the `Default`
// implementation. That implementation is copied over between the two types and should work
// fine.
let v11 = V11HostConfiguration::<primitives::BlockNumber> {
needed_approvals: 69,
paras_availability_period: 55,
hrmp_recipient_deposit: 1337,
max_pov_size: 1111,
minimum_validation_upgrade_delay: 20,
on_demand_ttl: 3,
on_demand_retries: 10,
..Default::default()
};
let mut pending_configs = Vec::new();
pending_configs.push((100, v11.clone()));
pending_configs.push((300, v11.clone()));
new_test_ext(Default::default()).execute_with(|| {
// Implant the v10 version in the state.
v11::ActiveConfig::<Test>::set(Some(v11.clone()));
v11::PendingConfigs::<Test>::set(Some(pending_configs));
migrate_to_v12::<Test>();
let v12 = v12::ActiveConfig::<Test>::get().unwrap();
assert_eq!(v12.approval_voting_params.max_approval_coalesce_count, 1);
let mut configs_to_check = v12::PendingConfigs::<Test>::get().unwrap();
configs_to_check.push((0, v12.clone()));
for (_, v12) in configs_to_check {
#[rustfmt::skip]
{
assert_eq!(v11.max_code_size , v12.max_code_size);
assert_eq!(v11.max_head_data_size , v12.max_head_data_size);
assert_eq!(v11.max_upward_queue_count , v12.max_upward_queue_count);
assert_eq!(v11.max_upward_queue_size , v12.max_upward_queue_size);
assert_eq!(v11.max_upward_message_size , v12.max_upward_message_size);
assert_eq!(v11.max_upward_message_num_per_candidate , v12.max_upward_message_num_per_candidate);
assert_eq!(v11.hrmp_max_message_num_per_candidate , v12.hrmp_max_message_num_per_candidate);
assert_eq!(v11.validation_upgrade_cooldown , v12.validation_upgrade_cooldown);
assert_eq!(v11.validation_upgrade_delay , v12.validation_upgrade_delay);
assert_eq!(v11.max_pov_size , v12.max_pov_size);
assert_eq!(v11.max_downward_message_size , v12.max_downward_message_size);
assert_eq!(v11.hrmp_max_parachain_outbound_channels , v12.hrmp_max_parachain_outbound_channels);
assert_eq!(v11.hrmp_sender_deposit , v12.hrmp_sender_deposit);
assert_eq!(v11.hrmp_recipient_deposit , v12.hrmp_recipient_deposit);
assert_eq!(v11.hrmp_channel_max_capacity , v12.hrmp_channel_max_capacity);
assert_eq!(v11.hrmp_channel_max_total_size , v12.hrmp_channel_max_total_size);
assert_eq!(v11.hrmp_max_parachain_inbound_channels , v12.hrmp_max_parachain_inbound_channels);
assert_eq!(v11.hrmp_channel_max_message_size , v12.hrmp_channel_max_message_size);
assert_eq!(v11.code_retention_period , v12.code_retention_period);
assert_eq!(v11.max_validators , v12.max_validators);
assert_eq!(v11.dispute_period , v12.dispute_period);
assert_eq!(v11.no_show_slots , v12.no_show_slots);
assert_eq!(v11.n_delay_tranches , v12.n_delay_tranches);
assert_eq!(v11.zeroth_delay_tranche_width , v12.zeroth_delay_tranche_width);
assert_eq!(v11.needed_approvals , v12.needed_approvals);
assert_eq!(v11.relay_vrf_modulo_samples , v12.relay_vrf_modulo_samples);
assert_eq!(v11.pvf_voting_ttl , v12.pvf_voting_ttl);
assert_eq!(v11.minimum_validation_upgrade_delay , v12.minimum_validation_upgrade_delay);
assert_eq!(v11.async_backing_params.allowed_ancestry_len, v12.async_backing_params.allowed_ancestry_len);
assert_eq!(v11.async_backing_params.max_candidate_depth , v12.async_backing_params.max_candidate_depth);
assert_eq!(v11.executor_params , v12.executor_params);
assert_eq!(v11.minimum_backing_votes , v12.minimum_backing_votes);
assert_eq!(v11.group_rotation_frequency , v12.scheduler_params.group_rotation_frequency);
assert_eq!(v11.paras_availability_period , v12.scheduler_params.paras_availability_period);
assert_eq!(v11.max_validators_per_core , v12.scheduler_params.max_validators_per_core);
assert_eq!(v11.scheduling_lookahead , v12.scheduler_params.lookahead);
assert_eq!(v11.coretime_cores , v12.scheduler_params.num_cores);
assert_eq!(v11.on_demand_retries , v12.scheduler_params.max_availability_timeouts);
assert_eq!(v11.on_demand_queue_max_size , v12.scheduler_params.on_demand_queue_max_size);
assert_eq!(v11.on_demand_target_queue_utilization , v12.scheduler_params.on_demand_target_queue_utilization);
assert_eq!(v11.on_demand_fee_variability , v12.scheduler_params.on_demand_fee_variability);
assert_eq!(v11.on_demand_base_fee , v12.scheduler_params.on_demand_base_fee);
assert_eq!(v11.on_demand_ttl , v12.scheduler_params.ttl);
}; // ; makes this a statement. `rustfmt::skip` cannot be put on an expression.
}
});
}
// Test that migration doesn't panic in case there are no pending configurations upgrades in
// pallet's storage.
#[test]
fn test_migrate_to_v12_no_pending() {
let v11 = V11HostConfiguration::<primitives::BlockNumber>::default();
new_test_ext(Default::default()).execute_with(|| {
// Implant the v10 version in the state.
v11::ActiveConfig::<Test>::set(Some(v11));
// Ensure there are no pending configs.
v12::PendingConfigs::<Test>::set(None);
// Shouldn't fail.
migrate_to_v12::<Test>();
});
}
}
@@ -226,8 +226,11 @@ fn invariants() {
); );
ActiveConfig::<Test>::put(HostConfiguration { ActiveConfig::<Test>::put(HostConfiguration {
paras_availability_period: 10,
minimum_validation_upgrade_delay: 11, minimum_validation_upgrade_delay: 11,
scheduler_params: SchedulerParams {
paras_availability_period: 10,
..Default::default()
},
..Default::default() ..Default::default()
}); });
assert_err!( assert_err!(
@@ -283,12 +286,6 @@ fn setting_pending_config_members() {
max_code_size: 100_000, max_code_size: 100_000,
max_pov_size: 1024, max_pov_size: 1024,
max_head_data_size: 1_000, max_head_data_size: 1_000,
coretime_cores: 2,
on_demand_retries: 5,
group_rotation_frequency: 20,
paras_availability_period: 10,
scheduling_lookahead: 3,
max_validators_per_core: None,
max_validators: None, max_validators: None,
dispute_period: 239, dispute_period: 239,
dispute_post_conclusion_acceptance_period: 10, dispute_post_conclusion_acceptance_period: 10,
@@ -314,13 +311,21 @@ fn setting_pending_config_members() {
minimum_validation_upgrade_delay: 20, minimum_validation_upgrade_delay: 20,
executor_params: Default::default(), executor_params: Default::default(),
approval_voting_params: ApprovalVotingParams { max_approval_coalesce_count: 1 }, approval_voting_params: ApprovalVotingParams { max_approval_coalesce_count: 1 },
on_demand_queue_max_size: 10_000u32,
on_demand_base_fee: 10_000_000u128,
on_demand_fee_variability: Perbill::from_percent(3),
on_demand_target_queue_utilization: Perbill::from_percent(25),
on_demand_ttl: 5u32,
minimum_backing_votes: 5, minimum_backing_votes: 5,
node_features: bitvec![u8, Lsb0; 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1], node_features: bitvec![u8, Lsb0; 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
scheduler_params: SchedulerParams {
group_rotation_frequency: 20,
paras_availability_period: 10,
max_validators_per_core: None,
lookahead: 3,
num_cores: 2,
max_availability_timeouts: 5,
on_demand_queue_max_size: 10_000u32,
on_demand_base_fee: 10_000_000u128,
on_demand_fee_variability: Perbill::from_percent(3),
on_demand_target_queue_utilization: Perbill::from_percent(25),
ttl: 5u32,
},
}; };
Configuration::set_validation_upgrade_cooldown( Configuration::set_validation_upgrade_cooldown(
@@ -342,13 +347,19 @@ fn setting_pending_config_members() {
Configuration::set_max_pov_size(RuntimeOrigin::root(), new_config.max_pov_size).unwrap(); Configuration::set_max_pov_size(RuntimeOrigin::root(), new_config.max_pov_size).unwrap();
Configuration::set_max_head_data_size(RuntimeOrigin::root(), new_config.max_head_data_size) Configuration::set_max_head_data_size(RuntimeOrigin::root(), new_config.max_head_data_size)
.unwrap(); .unwrap();
Configuration::set_coretime_cores(RuntimeOrigin::root(), new_config.coretime_cores) Configuration::set_coretime_cores(
.unwrap(); RuntimeOrigin::root(),
Configuration::set_on_demand_retries(RuntimeOrigin::root(), new_config.on_demand_retries) new_config.scheduler_params.num_cores,
.unwrap(); )
.unwrap();
Configuration::set_max_availability_timeouts(
RuntimeOrigin::root(),
new_config.scheduler_params.max_availability_timeouts,
)
.unwrap();
Configuration::set_group_rotation_frequency( Configuration::set_group_rotation_frequency(
RuntimeOrigin::root(), RuntimeOrigin::root(),
new_config.group_rotation_frequency, new_config.scheduler_params.group_rotation_frequency,
) )
.unwrap(); .unwrap();
// This comes out of order to satisfy the validity criteria for the chain and thread // This comes out of order to satisfy the validity criteria for the chain and thread
@@ -360,17 +371,17 @@ fn setting_pending_config_members() {
.unwrap(); .unwrap();
Configuration::set_paras_availability_period( Configuration::set_paras_availability_period(
RuntimeOrigin::root(), RuntimeOrigin::root(),
new_config.paras_availability_period, new_config.scheduler_params.paras_availability_period,
) )
.unwrap(); .unwrap();
Configuration::set_scheduling_lookahead( Configuration::set_scheduling_lookahead(
RuntimeOrigin::root(), RuntimeOrigin::root(),
new_config.scheduling_lookahead, new_config.scheduler_params.lookahead,
) )
.unwrap(); .unwrap();
Configuration::set_max_validators_per_core( Configuration::set_max_validators_per_core(
RuntimeOrigin::root(), RuntimeOrigin::root(),
new_config.max_validators_per_core, new_config.scheduler_params.max_validators_per_core,
) )
.unwrap(); .unwrap();
Configuration::set_max_validators(RuntimeOrigin::root(), new_config.max_validators) Configuration::set_max_validators(RuntimeOrigin::root(), new_config.max_validators)
@@ -114,7 +114,7 @@ mod v_coretime {
let legacy_paras = paras::Parachains::<T>::get(); let legacy_paras = paras::Parachains::<T>::get();
let config = <configuration::Pallet<T>>::config(); let config = <configuration::Pallet<T>>::config();
let total_core_count = config.coretime_cores + legacy_paras.len() as u32; let total_core_count = config.scheduler_params.num_cores + legacy_paras.len() as u32;
let dmp_queue_size = let dmp_queue_size =
crate::dmp::Pallet::<T>::dmq_contents(T::BrokerId::get().into()).len() as u32; crate::dmp::Pallet::<T>::dmq_contents(T::BrokerId::get().into()).len() as u32;
@@ -150,7 +150,7 @@ mod v_coretime {
// Migrate to Coretime. // Migrate to Coretime.
// //
// NOTE: Also migrates coretime_cores config value in configuration::ActiveConfig. // NOTE: Also migrates `num_cores` config value in configuration::ActiveConfig.
fn migrate_to_coretime< fn migrate_to_coretime<
T: Config, T: Config,
SendXcm: xcm::v4::SendXcm, SendXcm: xcm::v4::SendXcm,
@@ -176,8 +176,8 @@ mod v_coretime {
} }
let config = <configuration::Pallet<T>>::config(); let config = <configuration::Pallet<T>>::config();
// coretime_cores was on_demand_cores until now: // num_cores was on_demand_cores until now:
for on_demand in 0..config.coretime_cores { for on_demand in 0..config.scheduler_params.num_cores {
let core = CoreIndex(legacy_count.saturating_add(on_demand as _)); let core = CoreIndex(legacy_count.saturating_add(on_demand as _));
let r = assigner_coretime::Pallet::<T>::assign_core( let r = assigner_coretime::Pallet::<T>::assign_core(
core, core,
@@ -189,9 +189,9 @@ mod v_coretime {
log::error!("Creating assignment for existing on-demand core, failed: {:?}", err); log::error!("Creating assignment for existing on-demand core, failed: {:?}", err);
} }
} }
let total_cores = config.coretime_cores + legacy_count; let total_cores = config.scheduler_params.num_cores + legacy_count;
configuration::ActiveConfig::<T>::mutate(|c| { configuration::ActiveConfig::<T>::mutate(|c| {
c.coretime_cores = total_cores; c.scheduler_params.num_cores = total_cores;
}); });
if let Err(err) = migrate_send_assignments_to_coretime_chain::<T, SendXcm, LegacyLease>() { if let Err(err) = migrate_send_assignments_to_coretime_chain::<T, SendXcm, LegacyLease>() {
@@ -200,7 +200,9 @@ mod v_coretime {
let single_weight = <T as Config>::WeightInfo::assign_core(1); let single_weight = <T as Config>::WeightInfo::assign_core(1);
single_weight single_weight
.saturating_mul(u64::from(legacy_count.saturating_add(config.coretime_cores))) .saturating_mul(u64::from(
legacy_count.saturating_add(config.scheduler_params.num_cores),
))
// Second read from sending assignments to the coretime chain. // Second read from sending assignments to the coretime chain.
.saturating_add(T::DbWeight::get().reads_writes(2, 1)) .saturating_add(T::DbWeight::get().reads_writes(2, 1))
} }
@@ -244,7 +246,8 @@ mod v_coretime {
Some(mk_coretime_call(crate::coretime::CoretimeCalls::SetLease(p.into(), time_slice))) Some(mk_coretime_call(crate::coretime::CoretimeCalls::SetLease(p.into(), time_slice)))
}); });
let core_count: u16 = configuration::Pallet::<T>::config().coretime_cores.saturated_into(); let core_count: u16 =
configuration::Pallet::<T>::config().scheduler_params.num_cores.saturated_into();
let set_core_count = iter::once(mk_coretime_call( let set_core_count = iter::once(mk_coretime_call(
crate::coretime::CoretimeCalls::NotifyCoreCount(core_count), crate::coretime::CoretimeCalls::NotifyCoreCount(core_count),
)); ));
@@ -214,8 +214,8 @@ impl<T: Config> Pallet<T> {
} }
pub fn initializer_on_new_session(notification: &SessionChangeNotification<BlockNumberFor<T>>) { pub fn initializer_on_new_session(notification: &SessionChangeNotification<BlockNumberFor<T>>) {
let old_core_count = notification.prev_config.coretime_cores; let old_core_count = notification.prev_config.scheduler_params.num_cores;
let new_core_count = notification.new_config.coretime_cores; let new_core_count = notification.new_config.scheduler_params.num_cores;
if new_core_count != old_core_count { if new_core_count != old_core_count {
let core_count: u16 = new_core_count.saturated_into(); let core_count: u16 = new_core_count.saturated_into();
let message = Xcm(vec![ let message = Xcm(vec![
@@ -47,10 +47,10 @@ use test_helpers::{dummy_collator, dummy_collator_signature, dummy_validation_co
fn default_config() -> HostConfiguration<BlockNumber> { fn default_config() -> HostConfiguration<BlockNumber> {
let mut config = HostConfiguration::default(); let mut config = HostConfiguration::default();
config.coretime_cores = 1; config.scheduler_params.num_cores = 1;
config.max_code_size = 0b100000; config.max_code_size = 0b100000;
config.max_head_data_size = 0b100000; config.max_head_data_size = 0b100000;
config.group_rotation_frequency = u32::MAX; config.scheduler_params.group_rotation_frequency = u32::MAX;
config config
} }
@@ -224,7 +224,7 @@ pub(crate) fn run_to_block(
} }
pub(crate) fn expected_bits() -> usize { pub(crate) fn expected_bits() -> usize {
Paras::parachains().len() + Configuration::config().coretime_cores as usize Paras::parachains().len() + Configuration::config().scheduler_params.num_cores as usize
} }
fn default_bitfield() -> AvailabilityBitfield { fn default_bitfield() -> AvailabilityBitfield {
@@ -386,7 +386,7 @@ fn collect_pending_cleans_up_pending() {
(thread_a, ParaKind::Parathread), (thread_a, ParaKind::Parathread),
]; ];
let mut config = genesis_config(paras); let mut config = genesis_config(paras);
config.configuration.config.group_rotation_frequency = 3; config.configuration.config.scheduler_params.group_rotation_frequency = 3;
new_test_ext(config).execute_with(|| { new_test_ext(config).execute_with(|| {
let default_candidate = TestCandidateBuilder::default().build(); let default_candidate = TestCandidateBuilder::default().build();
<PendingAvailability<Test>>::insert( <PendingAvailability<Test>>::insert(
@@ -2062,7 +2062,7 @@ fn check_allowed_relay_parents() {
} }
let validator_public = validator_pubkeys(&validators); let validator_public = validator_pubkeys(&validators);
let mut config = genesis_config(paras); let mut config = genesis_config(paras);
config.configuration.config.group_rotation_frequency = 1; config.configuration.config.scheduler_params.group_rotation_frequency = 1;
new_test_ext(config).execute_with(|| { new_test_ext(config).execute_with(|| {
shared::Pallet::<Test>::set_active_validators_ascending(validator_public.clone()); shared::Pallet::<Test>::set_active_validators_ascending(validator_public.clone());
+1 -22
View File
@@ -23,7 +23,7 @@ use crate::{
initializer, origin, paras, initializer, origin, paras,
paras::ParaKind, paras::ParaKind,
paras_inherent, scheduler, paras_inherent, scheduler,
scheduler::common::{AssignmentProvider, AssignmentProviderConfig}, scheduler::common::AssignmentProvider,
session_info, shared, ParaId, session_info, shared, ParaId,
}; };
use frame_support::pallet_prelude::*; use frame_support::pallet_prelude::*;
@@ -463,10 +463,6 @@ pub mod mock_assigner {
pub(super) type MockAssignmentQueue<T: Config> = pub(super) type MockAssignmentQueue<T: Config> =
StorageValue<_, VecDeque<Assignment>, ValueQuery>; StorageValue<_, VecDeque<Assignment>, ValueQuery>;
#[pallet::storage]
pub(super) type MockProviderConfig<T: Config> =
StorageValue<_, AssignmentProviderConfig<BlockNumber>, OptionQuery>;
#[pallet::storage] #[pallet::storage]
pub(super) type MockCoreCount<T: Config> = StorageValue<_, u32, OptionQuery>; pub(super) type MockCoreCount<T: Config> = StorageValue<_, u32, OptionQuery>;
} }
@@ -478,12 +474,6 @@ pub mod mock_assigner {
MockAssignmentQueue::<T>::mutate(|queue| queue.push_back(assignment)); MockAssignmentQueue::<T>::mutate(|queue| queue.push_back(assignment));
} }
// This configuration needs to be customized to service `get_provider_config` in
// scheduler tests.
pub fn set_assignment_provider_config(config: AssignmentProviderConfig<BlockNumber>) {
MockProviderConfig::<T>::set(Some(config));
}
// Allows for customized core count in scheduler tests, rather than a core count // Allows for customized core count in scheduler tests, rather than a core count
// derived from on-demand config + parachain count. // derived from on-demand config + parachain count.
pub fn set_core_count(count: u32) { pub fn set_core_count(count: u32) {
@@ -512,17 +502,6 @@ pub mod mock_assigner {
// in the mock assigner. // in the mock assigner.
fn push_back_assignment(_assignment: Assignment) {} fn push_back_assignment(_assignment: Assignment) {}
// Gets the provider config we set earlier using `set_assignment_provider_config`, falling
// back to the on demand parachain configuration if none was set.
fn get_provider_config(_core_idx: CoreIndex) -> AssignmentProviderConfig<BlockNumber> {
match MockProviderConfig::<T>::get() {
Some(config) => config,
None => AssignmentProviderConfig {
max_availability_timeouts: 1,
ttl: BlockNumber::from(5u32),
},
}
}
#[cfg(any(feature = "runtime-benchmarks", test))] #[cfg(any(feature = "runtime-benchmarks", test))]
fn get_mock_assignment(_: CoreIndex, para_id: ParaId) -> Assignment { fn get_mock_assignment(_: CoreIndex, para_id: ParaId) -> Assignment {
Assignment::Bulk(para_id) Assignment::Bulk(para_id)
@@ -17,7 +17,7 @@
use super::*; use super::*;
use frame_support::{assert_err, assert_ok, assert_storage_noop}; use frame_support::{assert_err, assert_ok, assert_storage_noop};
use keyring::Sr25519Keyring; use keyring::Sr25519Keyring;
use primitives::{BlockNumber, PARACHAIN_KEY_TYPE_ID}; use primitives::{vstaging::SchedulerParams, BlockNumber, PARACHAIN_KEY_TYPE_ID};
use sc_keystore::LocalKeystore; use sc_keystore::LocalKeystore;
use sp_keystore::{Keystore, KeystorePtr}; use sp_keystore::{Keystore, KeystorePtr};
use std::sync::Arc; use std::sync::Arc;
@@ -909,7 +909,10 @@ fn full_parachain_cleanup_storage() {
minimum_validation_upgrade_delay: 2, minimum_validation_upgrade_delay: 2,
// Those are not relevant to this test. However, HostConfiguration is still a // Those are not relevant to this test. However, HostConfiguration is still a
// subject for the consistency check. // subject for the consistency check.
paras_availability_period: 1, scheduler_params: SchedulerParams {
paras_availability_period: 1,
..Default::default()
},
..Default::default() ..Default::default()
}, },
}, },
@@ -27,13 +27,14 @@ mod enter {
builder::{Bench, BenchBuilder}, builder::{Bench, BenchBuilder},
mock::{mock_assigner, new_test_ext, BlockLength, BlockWeights, MockGenesisConfig, Test}, mock::{mock_assigner, new_test_ext, BlockLength, BlockWeights, MockGenesisConfig, Test},
scheduler::{ scheduler::{
common::{Assignment, AssignmentProvider, AssignmentProviderConfig}, common::{Assignment, AssignmentProvider},
ParasEntry, ParasEntry,
}, },
}; };
use assert_matches::assert_matches; use assert_matches::assert_matches;
use frame_support::assert_ok; use frame_support::assert_ok;
use frame_system::limits; use frame_system::limits;
use primitives::vstaging::SchedulerParams;
use sp_runtime::Perbill; use sp_runtime::Perbill;
use sp_std::collections::btree_map::BTreeMap; use sp_std::collections::btree_map::BTreeMap;
@@ -87,7 +88,7 @@ mod enter {
// `create_inherent` and will not cause `enter` to early. // `create_inherent` and will not cause `enter` to early.
fn include_backed_candidates() { fn include_backed_candidates() {
let config = MockGenesisConfig::default(); let config = MockGenesisConfig::default();
assert!(config.configuration.config.scheduling_lookahead > 0); assert!(config.configuration.config.scheduler_params.lookahead > 0);
new_test_ext(config).execute_with(|| { new_test_ext(config).execute_with(|| {
let dispute_statements = BTreeMap::new(); let dispute_statements = BTreeMap::new();
@@ -625,7 +626,7 @@ mod enter {
#[test] #[test]
fn limit_candidates_over_weight_1() { fn limit_candidates_over_weight_1() {
let config = MockGenesisConfig::default(); let config = MockGenesisConfig::default();
assert!(config.configuration.config.scheduling_lookahead > 0); assert!(config.configuration.config.scheduler_params.lookahead > 0);
new_test_ext(config).execute_with(|| { new_test_ext(config).execute_with(|| {
// Create the inherent data for this block // Create the inherent data for this block
@@ -706,8 +707,8 @@ mod enter {
let cores = (0..used_cores) let cores = (0..used_cores)
.into_iter() .into_iter()
.map(|i| { .map(|i| {
let AssignmentProviderConfig { ttl, .. } = let SchedulerParams { ttl, .. } =
scheduler::Pallet::<Test>::assignment_provider_config(CoreIndex(i)); <configuration::Pallet<Test>>::config().scheduler_params;
// Load an assignment into provider so that one is present to pop // Load an assignment into provider so that one is present to pop
let assignment = let assignment =
<Test as scheduler::Config>::AssignmentProvider::get_mock_assignment( <Test as scheduler::Config>::AssignmentProvider::get_mock_assignment(
+17 -26
View File
@@ -51,7 +51,7 @@ use sp_std::{
pub mod common; pub mod common;
use common::{Assignment, AssignmentProvider, AssignmentProviderConfig}; use common::{Assignment, AssignmentProvider};
pub use pallet::*; pub use pallet::*;
@@ -222,7 +222,7 @@ impl<T: Config> Pallet<T> {
let n_cores = core::cmp::max( let n_cores = core::cmp::max(
T::AssignmentProvider::session_core_count(), T::AssignmentProvider::session_core_count(),
match config.max_validators_per_core { match config.scheduler_params.max_validators_per_core {
Some(x) if x != 0 => validators.len() as u32 / x, Some(x) if x != 0 => validators.len() as u32 / x,
_ => 0, _ => 0,
}, },
@@ -350,6 +350,7 @@ impl<T: Config> Pallet<T> {
fn drop_expired_claims_from_claimqueue() { fn drop_expired_claims_from_claimqueue() {
let now = <frame_system::Pallet<T>>::block_number(); let now = <frame_system::Pallet<T>>::block_number();
let availability_cores = AvailabilityCores::<T>::get(); let availability_cores = AvailabilityCores::<T>::get();
let ttl = <configuration::Pallet<T>>::config().scheduler_params.ttl;
ClaimQueue::<T>::mutate(|cq| { ClaimQueue::<T>::mutate(|cq| {
for (idx, _) in (0u32..).zip(availability_cores) { for (idx, _) in (0u32..).zip(availability_cores) {
@@ -382,8 +383,6 @@ impl<T: Config> Pallet<T> {
if let Some(assignment) = if let Some(assignment) =
T::AssignmentProvider::pop_assignment_for_core(core_idx) T::AssignmentProvider::pop_assignment_for_core(core_idx)
{ {
let AssignmentProviderConfig { ttl, .. } =
T::AssignmentProvider::get_provider_config(core_idx);
core_claimqueue.push_back(ParasEntry::new(assignment, now + ttl)); core_claimqueue.push_back(ParasEntry::new(assignment, now + ttl));
} }
} }
@@ -428,7 +427,7 @@ impl<T: Config> Pallet<T> {
} }
let rotations_since_session_start: BlockNumberFor<T> = let rotations_since_session_start: BlockNumberFor<T> =
(at - session_start_block) / config.group_rotation_frequency; (at - session_start_block) / config.scheduler_params.group_rotation_frequency;
let rotations_since_session_start = let rotations_since_session_start =
<BlockNumberFor<T> as TryInto<u32>>::try_into(rotations_since_session_start) <BlockNumberFor<T> as TryInto<u32>>::try_into(rotations_since_session_start)
@@ -460,9 +459,9 @@ impl<T: Config> Pallet<T> {
// Note: blocks backed in this rotation will never time out here as backed_in + // Note: blocks backed in this rotation will never time out here as backed_in +
// config.paras_availability_period will always be > now for these blocks, as // config.paras_availability_period will always be > now for these blocks, as
// otherwise above condition would not be true. // otherwise above condition would not be true.
pending_since + config.paras_availability_period pending_since + config.scheduler_params.paras_availability_period
} else { } else {
next_rotation + config.paras_availability_period next_rotation + config.scheduler_params.paras_availability_period
}; };
AvailabilityTimeoutStatus { timed_out: time_out_at <= now, live_until: time_out_at } AvailabilityTimeoutStatus { timed_out: time_out_at <= now, live_until: time_out_at }
@@ -478,7 +477,8 @@ impl<T: Config> Pallet<T> {
let now = <frame_system::Pallet<T>>::block_number() + One::one(); let now = <frame_system::Pallet<T>>::block_number() + One::one();
let rotation_info = Self::group_rotation_info(now); let rotation_info = Self::group_rotation_info(now);
let current_window = rotation_info.last_rotation_at() + config.paras_availability_period; let current_window =
rotation_info.last_rotation_at() + config.scheduler_params.paras_availability_period;
now < current_window now < current_window
} }
@@ -488,7 +488,7 @@ impl<T: Config> Pallet<T> {
) -> GroupRotationInfo<BlockNumberFor<T>> { ) -> GroupRotationInfo<BlockNumberFor<T>> {
let session_start_block = Self::session_start_block(); let session_start_block = Self::session_start_block();
let group_rotation_frequency = let group_rotation_frequency =
<configuration::Pallet<T>>::config().group_rotation_frequency; <configuration::Pallet<T>>::config().scheduler_params.group_rotation_frequency;
GroupRotationInfo { session_start_block, now, group_rotation_frequency } GroupRotationInfo { session_start_block, now, group_rotation_frequency }
} }
@@ -508,6 +508,8 @@ impl<T: Config> Pallet<T> {
/// Return the next thing that will be scheduled on this core assuming it is currently /// Return the next thing that will be scheduled on this core assuming it is currently
/// occupied and the candidate occupying it times out. /// occupied and the candidate occupying it times out.
pub(crate) fn next_up_on_time_out(core: CoreIndex) -> Option<ScheduledCore> { pub(crate) fn next_up_on_time_out(core: CoreIndex) -> Option<ScheduledCore> {
let max_availability_timeouts =
<configuration::Pallet<T>>::config().scheduler_params.max_availability_timeouts;
Self::next_up_on_available(core).or_else(|| { Self::next_up_on_available(core).or_else(|| {
// Or, if none, the claim currently occupying the core, // Or, if none, the claim currently occupying the core,
// as it would be put back on the queue after timing out if number of retries is not at // as it would be put back on the queue after timing out if number of retries is not at
@@ -515,16 +517,12 @@ impl<T: Config> Pallet<T> {
let cores = AvailabilityCores::<T>::get(); let cores = AvailabilityCores::<T>::get();
cores.get(core.0 as usize).and_then(|c| match c { cores.get(core.0 as usize).and_then(|c| match c {
CoreOccupied::Free => None, CoreOccupied::Free => None,
CoreOccupied::Paras(pe) => { CoreOccupied::Paras(pe) =>
let AssignmentProviderConfig { max_availability_timeouts, .. } =
T::AssignmentProvider::get_provider_config(core);
if pe.availability_timeouts < max_availability_timeouts { if pe.availability_timeouts < max_availability_timeouts {
Some(Self::paras_entry_to_scheduled_core(pe)) Some(Self::paras_entry_to_scheduled_core(pe))
} else { } else {
None None
} },
},
}) })
}) })
} }
@@ -566,7 +564,7 @@ impl<T: Config> Pallet<T> {
// ClaimQueue related functions // ClaimQueue related functions
// //
fn claimqueue_lookahead() -> u32 { fn claimqueue_lookahead() -> u32 {
<configuration::Pallet<T>>::config().scheduling_lookahead <configuration::Pallet<T>>::config().scheduler_params.lookahead
} }
/// Frees cores and fills the free claimqueue spots by popping from the `AssignmentProvider`. /// Frees cores and fills the free claimqueue spots by popping from the `AssignmentProvider`.
@@ -585,15 +583,15 @@ impl<T: Config> Pallet<T> {
let n_lookahead = Self::claimqueue_lookahead().max(1); let n_lookahead = Self::claimqueue_lookahead().max(1);
let n_session_cores = T::AssignmentProvider::session_core_count(); let n_session_cores = T::AssignmentProvider::session_core_count();
let cq = ClaimQueue::<T>::get(); let cq = ClaimQueue::<T>::get();
let ttl = <configuration::Pallet<T>>::config().on_demand_ttl; let config = <configuration::Pallet<T>>::config();
let max_availability_timeouts = config.scheduler_params.max_availability_timeouts;
let ttl = config.scheduler_params.ttl;
for core_idx in 0..n_session_cores { for core_idx in 0..n_session_cores {
let core_idx = CoreIndex::from(core_idx); let core_idx = CoreIndex::from(core_idx);
// add previously timedout paras back into the queue // add previously timedout paras back into the queue
if let Some(mut entry) = timedout_paras.remove(&core_idx) { if let Some(mut entry) = timedout_paras.remove(&core_idx) {
let AssignmentProviderConfig { max_availability_timeouts, .. } =
T::AssignmentProvider::get_provider_config(core_idx);
if entry.availability_timeouts < max_availability_timeouts { if entry.availability_timeouts < max_availability_timeouts {
// Increment the timeout counter. // Increment the timeout counter.
entry.availability_timeouts += 1; entry.availability_timeouts += 1;
@@ -668,13 +666,6 @@ impl<T: Config> Pallet<T> {
.filter_map(|(core_idx, v)| v.front().map(|e| (core_idx, e.assignment.para_id()))) .filter_map(|(core_idx, v)| v.front().map(|e| (core_idx, e.assignment.para_id())))
} }
#[cfg(any(feature = "runtime-benchmarks", test))]
pub(crate) fn assignment_provider_config(
core_idx: CoreIndex,
) -> AssignmentProviderConfig<BlockNumberFor<T>> {
T::AssignmentProvider::get_provider_config(core_idx)
}
#[cfg(any(feature = "try-runtime", test))] #[cfg(any(feature = "try-runtime", test))]
fn claimqueue_len() -> usize { fn claimqueue_len() -> usize {
ClaimQueue::<T>::get().iter().map(|la_vec| la_vec.1.len()).sum() ClaimQueue::<T>::get().iter().map(|la_vec| la_vec.1.len()).sum()
@@ -48,22 +48,10 @@ impl Assignment {
} }
} }
#[derive(Encode, Decode, TypeInfo)]
/// A set of variables required by the scheduler in order to operate.
pub struct AssignmentProviderConfig<BlockNumber> {
/// How many times a collation can time out on availability.
/// Zero timeouts still means that a collation can be provided as per the slot auction
/// assignment provider.
pub max_availability_timeouts: u32,
/// How long the collator has to provide a collation to the backing group before being dropped.
pub ttl: BlockNumber,
}
pub trait AssignmentProvider<BlockNumber> { pub trait AssignmentProvider<BlockNumber> {
/// Pops an [`Assignment`] from the provider for a specified [`CoreIndex`]. /// Pops an [`Assignment`] from the provider for a specified [`CoreIndex`].
/// ///
/// This is where assignments come into existance. /// This is where assignments come into existence.
fn pop_assignment_for_core(core_idx: CoreIndex) -> Option<Assignment>; fn pop_assignment_for_core(core_idx: CoreIndex) -> Option<Assignment>;
/// A previously popped `Assignment` has been fully processed. /// A previously popped `Assignment` has been fully processed.
@@ -77,14 +65,11 @@ pub trait AssignmentProvider<BlockNumber> {
/// Push back a previously popped assignment. /// Push back a previously popped assignment.
/// ///
/// If the assignment could not be processed within the current session, it can be pushed back /// If the assignment could not be processed within the current session, it can be pushed back
/// to the assignment provider in order to be poppped again later. /// to the assignment provider in order to be popped again later.
/// ///
/// This is the second way the life of an assignment can come to an end. /// This is the second way the life of an assignment can come to an end.
fn push_back_assignment(assignment: Assignment); fn push_back_assignment(assignment: Assignment);
/// Returns a set of variables needed by the scheduler
fn get_provider_config(core_idx: CoreIndex) -> AssignmentProviderConfig<BlockNumber>;
/// Push some assignment for mocking/benchmarks purposes. /// Push some assignment for mocking/benchmarks purposes.
/// ///
/// Useful for benchmarks and testing. The returned assignment is "valid" and can if need be /// Useful for benchmarks and testing. The returned assignment is "valid" and can if need be
@@ -18,7 +18,9 @@ use super::*;
use frame_support::assert_ok; use frame_support::assert_ok;
use keyring::Sr25519Keyring; use keyring::Sr25519Keyring;
use primitives::{BlockNumber, SessionIndex, ValidationCode, ValidatorId}; use primitives::{
vstaging::SchedulerParams, BlockNumber, SessionIndex, ValidationCode, ValidatorId,
};
use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet}; use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
use crate::{ use crate::{
@@ -103,15 +105,19 @@ fn run_to_end_of_block(
fn default_config() -> HostConfiguration<BlockNumber> { fn default_config() -> HostConfiguration<BlockNumber> {
HostConfiguration { HostConfiguration {
coretime_cores: 3,
group_rotation_frequency: 10,
paras_availability_period: 3,
scheduling_lookahead: 2,
// This field does not affect anything that scheduler does. However, `HostConfiguration` // This field does not affect anything that scheduler does. However, `HostConfiguration`
// is still a subject to consistency test. It requires that // is still a subject to consistency test. It requires that
// `minimum_validation_upgrade_delay` is greater than `chain_availability_period` and // `minimum_validation_upgrade_delay` is greater than `chain_availability_period` and
// `thread_availability_period`. // `thread_availability_period`.
minimum_validation_upgrade_delay: 6, minimum_validation_upgrade_delay: 6,
scheduler_params: SchedulerParams {
group_rotation_frequency: 10,
paras_availability_period: 3,
lookahead: 2,
num_cores: 3,
max_availability_timeouts: 1,
..Default::default()
},
..Default::default() ..Default::default()
} }
} }
@@ -155,7 +161,7 @@ fn scheduled_entries() -> impl Iterator<Item = (CoreIndex, ParasEntry<BlockNumbe
#[test] #[test]
fn claimqueue_ttl_drop_fn_works() { fn claimqueue_ttl_drop_fn_works() {
let mut config = default_config(); let mut config = default_config();
config.scheduling_lookahead = 3; config.scheduler_params.lookahead = 3;
let genesis_config = genesis_config(&config); let genesis_config = genesis_config(&config);
let para_id = ParaId::from(100); let para_id = ParaId::from(100);
@@ -163,8 +169,7 @@ fn claimqueue_ttl_drop_fn_works() {
let mut now = 10; let mut now = 10;
new_test_ext(genesis_config).execute_with(|| { new_test_ext(genesis_config).execute_with(|| {
let assignment_provider_ttl = MockAssigner::get_provider_config(CoreIndex::from(0)).ttl; assert!(config.scheduler_params.ttl == 5);
assert!(assignment_provider_ttl == 5);
// Register and run to a blockheight where the para is in a valid state. // Register and run to a blockheight where the para is in a valid state.
schedule_blank_para(para_id); schedule_blank_para(para_id);
run_to_block(now, |n| if n == now { Some(Default::default()) } else { None }); run_to_block(now, |n| if n == now { Some(Default::default()) } else { None });
@@ -290,7 +295,7 @@ fn session_change_shuffles_validators() {
fn session_change_takes_only_max_per_core() { fn session_change_takes_only_max_per_core() {
let config = { let config = {
let mut config = default_config(); let mut config = default_config();
config.max_validators_per_core = Some(1); config.scheduler_params.max_validators_per_core = Some(1);
config config
}; };
@@ -330,7 +335,8 @@ fn session_change_takes_only_max_per_core() {
#[test] #[test]
fn fill_claimqueue_fills() { fn fill_claimqueue_fills() {
let genesis_config = genesis_config(&default_config()); let config = default_config();
let genesis_config = genesis_config(&config);
let para_a = ParaId::from(3_u32); let para_a = ParaId::from(3_u32);
let para_b = ParaId::from(4_u32); let para_b = ParaId::from(4_u32);
@@ -342,8 +348,7 @@ fn fill_claimqueue_fills() {
new_test_ext(genesis_config).execute_with(|| { new_test_ext(genesis_config).execute_with(|| {
MockAssigner::set_core_count(2); MockAssigner::set_core_count(2);
let AssignmentProviderConfig { ttl: config_ttl, .. } = let coretime_ttl = config.scheduler_params.ttl;
MockAssigner::get_provider_config(CoreIndex(0));
// Add 3 paras // Add 3 paras
schedule_blank_para(para_a); schedule_blank_para(para_a);
@@ -381,7 +386,7 @@ fn fill_claimqueue_fills() {
&ParasEntry { &ParasEntry {
assignment: assignment_a.clone(), assignment: assignment_a.clone(),
availability_timeouts: 0, availability_timeouts: 0,
ttl: 2 + config_ttl ttl: 2 + coretime_ttl
}, },
); );
// Sits on the same core as `para_a` // Sits on the same core as `para_a`
@@ -390,7 +395,7 @@ fn fill_claimqueue_fills() {
ParasEntry { ParasEntry {
assignment: assignment_b.clone(), assignment: assignment_b.clone(),
availability_timeouts: 0, availability_timeouts: 0,
ttl: 2 + config_ttl ttl: 2 + coretime_ttl
} }
); );
assert_eq!( assert_eq!(
@@ -398,7 +403,7 @@ fn fill_claimqueue_fills() {
&ParasEntry { &ParasEntry {
assignment: assignment_c.clone(), assignment: assignment_c.clone(),
availability_timeouts: 0, availability_timeouts: 0,
ttl: 2 + config_ttl ttl: 2 + coretime_ttl
}, },
); );
} }
@@ -410,7 +415,7 @@ fn schedule_schedules_including_just_freed() {
let mut config = default_config(); let mut config = default_config();
// NOTE: This test expects on demand cores to each get slotted on to a different core // NOTE: This test expects on demand cores to each get slotted on to a different core
// and not fill up the claimqueue of each core first. // and not fill up the claimqueue of each core first.
config.scheduling_lookahead = 1; config.scheduler_params.lookahead = 1;
let genesis_config = genesis_config(&config); let genesis_config = genesis_config(&config);
let para_a = ParaId::from(3_u32); let para_a = ParaId::from(3_u32);
@@ -479,7 +484,7 @@ fn schedule_schedules_including_just_freed() {
// All `core_queue`s should be empty // All `core_queue`s should be empty
Scheduler::claimqueue() Scheduler::claimqueue()
.iter() .iter()
.for_each(|(_core_idx, core_queue)| assert!(core_queue.len() == 0)) .for_each(|(_core_idx, core_queue)| assert_eq!(core_queue.len(), 0))
} }
// add a couple more para claims - the claim on `b` will go to the 3rd core // add a couple more para claims - the claim on `b` will go to the 3rd core
@@ -557,7 +562,7 @@ fn schedule_schedules_including_just_freed() {
#[test] #[test]
fn schedule_clears_availability_cores() { fn schedule_clears_availability_cores() {
let mut config = default_config(); let mut config = default_config();
config.scheduling_lookahead = 1; config.scheduler_params.lookahead = 1;
let genesis_config = genesis_config(&config); let genesis_config = genesis_config(&config);
let para_a = ParaId::from(1_u32); let para_a = ParaId::from(1_u32);
@@ -659,11 +664,11 @@ fn schedule_clears_availability_cores() {
fn schedule_rotates_groups() { fn schedule_rotates_groups() {
let config = { let config = {
let mut config = default_config(); let mut config = default_config();
config.scheduling_lookahead = 1; config.scheduler_params.lookahead = 1;
config config
}; };
let rotation_frequency = config.group_rotation_frequency; let rotation_frequency = config.scheduler_params.group_rotation_frequency;
let on_demand_cores = 2; let on_demand_cores = 2;
let genesis_config = genesis_config(&config); let genesis_config = genesis_config(&config);
@@ -742,9 +747,12 @@ fn schedule_rotates_groups() {
#[test] #[test]
fn on_demand_claims_are_pruned_after_timing_out() { fn on_demand_claims_are_pruned_after_timing_out() {
let max_retries = 20; let max_timeouts = 20;
let mut config = default_config(); let mut config = default_config();
config.scheduling_lookahead = 1; config.scheduler_params.lookahead = 1;
// Need more timeouts for this test
config.scheduler_params.max_availability_timeouts = max_timeouts;
config.scheduler_params.ttl = BlockNumber::from(5u32);
let genesis_config = genesis_config(&config); let genesis_config = genesis_config(&config);
let para_a = ParaId::from(1_u32); let para_a = ParaId::from(1_u32);
@@ -753,11 +761,6 @@ fn on_demand_claims_are_pruned_after_timing_out() {
new_test_ext(genesis_config).execute_with(|| { new_test_ext(genesis_config).execute_with(|| {
MockAssigner::set_core_count(2); MockAssigner::set_core_count(2);
// Need more timeouts for this test
MockAssigner::set_assignment_provider_config(AssignmentProviderConfig {
max_availability_timeouts: max_retries,
ttl: BlockNumber::from(5u32),
});
schedule_blank_para(para_a); schedule_blank_para(para_a);
// #1 // #1
@@ -794,7 +797,7 @@ fn on_demand_claims_are_pruned_after_timing_out() {
// Run to block #n over the max_retries value. // Run to block #n over the max_retries value.
// In this case, both validator groups with time out on availability and // In this case, both validator groups with time out on availability and
// the assignment will be dropped. // the assignment will be dropped.
for n in now..=(now + max_retries + 1) { for n in now..=(now + max_timeouts + 1) {
// #n // #n
run_to_block(n, |_| None); run_to_block(n, |_| None);
// Time out on core 0. // Time out on core 0.
@@ -806,7 +809,7 @@ fn on_demand_claims_are_pruned_after_timing_out() {
Scheduler::free_cores_and_fill_claimqueue(just_updated, now); Scheduler::free_cores_and_fill_claimqueue(just_updated, now);
// ParaId a exists in the claim queue until max_retries is reached. // ParaId a exists in the claim queue until max_retries is reached.
if n < max_retries + now { if n < max_timeouts + now {
assert!(claimqueue_contains_para_ids::<Test>(vec![para_a])); assert!(claimqueue_contains_para_ids::<Test>(vec![para_a]));
} else { } else {
assert!(!claimqueue_contains_para_ids::<Test>(vec![para_a])); assert!(!claimqueue_contains_para_ids::<Test>(vec![para_a]));
@@ -822,7 +825,7 @@ fn on_demand_claims_are_pruned_after_timing_out() {
assert!(!availability_cores_contains_para_ids::<Test>(vec![para_a])); assert!(!availability_cores_contains_para_ids::<Test>(vec![para_a]));
// #25 // #25
now += max_retries + 2; now += max_timeouts + 2;
// Add assignment back to the mix. // Add assignment back to the mix.
MockAssigner::add_test_assignment(assignment_a.clone()); MockAssigner::add_test_assignment(assignment_a.clone());
@@ -833,7 +836,7 @@ fn on_demand_claims_are_pruned_after_timing_out() {
// #26 // #26
now += 1; now += 1;
// Run to block #n but this time have group 1 conclude the availabilty. // Run to block #n but this time have group 1 conclude the availabilty.
for n in now..=(now + max_retries + 1) { for n in now..=(now + max_timeouts + 1) {
// #n // #n
run_to_block(n, |_| None); run_to_block(n, |_| None);
// Time out core 0 if group 0 is assigned to it, if group 1 is assigned, conclude. // Time out core 0 if group 0 is assigned to it, if group 1 is assigned, conclude.
@@ -874,10 +877,8 @@ fn on_demand_claims_are_pruned_after_timing_out() {
fn availability_predicate_works() { fn availability_predicate_works() {
let genesis_config = genesis_config(&default_config()); let genesis_config = genesis_config(&default_config());
let HostConfiguration { group_rotation_frequency, paras_availability_period, .. } = let SchedulerParams { group_rotation_frequency, paras_availability_period, .. } =
default_config(); default_config().scheduler_params;
assert!(paras_availability_period < group_rotation_frequency);
new_test_ext(genesis_config).execute_with(|| { new_test_ext(genesis_config).execute_with(|| {
run_to_block(1 + paras_availability_period, |_| None); run_to_block(1 + paras_availability_period, |_| None);
@@ -1044,7 +1045,7 @@ fn next_up_on_time_out_reuses_claim_if_nothing_queued() {
#[test] #[test]
fn session_change_requires_reschedule_dropping_removed_paras() { fn session_change_requires_reschedule_dropping_removed_paras() {
let mut config = default_config(); let mut config = default_config();
config.scheduling_lookahead = 1; config.scheduler_params.lookahead = 1;
let genesis_config = genesis_config(&config); let genesis_config = genesis_config(&config);
let para_a = ParaId::from(1_u32); let para_a = ParaId::from(1_u32);
@@ -1056,7 +1057,7 @@ fn session_change_requires_reschedule_dropping_removed_paras() {
new_test_ext(genesis_config).execute_with(|| { new_test_ext(genesis_config).execute_with(|| {
// Setting explicit core count // Setting explicit core count
MockAssigner::set_core_count(5); MockAssigner::set_core_count(5);
let assignment_provider_ttl = MockAssigner::get_provider_config(CoreIndex::from(0)).ttl; let coretime_ttl = <configuration::Pallet<Test>>::config().scheduler_params.ttl;
schedule_blank_para(para_a); schedule_blank_para(para_a);
schedule_blank_para(para_b); schedule_blank_para(para_b);
@@ -1120,7 +1121,7 @@ fn session_change_requires_reschedule_dropping_removed_paras() {
vec![ParasEntry::new( vec![ParasEntry::new(
Assignment::Bulk(para_a), Assignment::Bulk(para_a),
// At end of block 2 // At end of block 2
assignment_provider_ttl + 2 coretime_ttl + 2
)] )]
.into_iter() .into_iter()
.collect() .collect()
@@ -1169,7 +1170,7 @@ fn session_change_requires_reschedule_dropping_removed_paras() {
vec![ParasEntry::new( vec![ParasEntry::new(
Assignment::Bulk(para_a), Assignment::Bulk(para_a),
// At block 3 // At block 3
assignment_provider_ttl + 3 coretime_ttl + 3
)] )]
.into_iter() .into_iter()
.collect() .collect()
@@ -1179,7 +1180,7 @@ fn session_change_requires_reschedule_dropping_removed_paras() {
vec![ParasEntry::new( vec![ParasEntry::new(
Assignment::Bulk(para_b), Assignment::Bulk(para_b),
// At block 3 // At block 3
assignment_provider_ttl + 3 coretime_ttl + 3
)] )]
.into_iter() .into_iter()
.collect() .collect()
@@ -25,7 +25,7 @@ use crate::{
util::take_active_subset, util::take_active_subset,
}; };
use keyring::Sr25519Keyring; use keyring::Sr25519Keyring;
use primitives::{BlockNumber, ValidatorId, ValidatorIndex}; use primitives::{vstaging::SchedulerParams, BlockNumber, ValidatorId, ValidatorIndex};
fn run_to_block( fn run_to_block(
to: BlockNumber, to: BlockNumber,
@@ -62,9 +62,9 @@ fn run_to_block(
fn default_config() -> HostConfiguration<BlockNumber> { fn default_config() -> HostConfiguration<BlockNumber> {
HostConfiguration { HostConfiguration {
coretime_cores: 1,
dispute_period: 2, dispute_period: 2,
needed_approvals: 3, needed_approvals: 3,
scheduler_params: SchedulerParams { num_cores: 1, ..Default::default() },
..Default::default() ..Default::default()
} }
} }
+1
View File
@@ -1658,6 +1658,7 @@ pub mod migrations {
parachains_configuration::migration::v11::MigrateToV11<Runtime>, parachains_configuration::migration::v11::MigrateToV11<Runtime>,
// This needs to come after the `parachains_configuration` above as we are reading the configuration. // This needs to come after the `parachains_configuration` above as we are reading the configuration.
coretime::migration::MigrateToCoretime<Runtime, crate::xcm_config::XcmRouter, GetLegacyLeaseImpl>, coretime::migration::MigrateToCoretime<Runtime, crate::xcm_config::XcmRouter, GetLegacyLeaseImpl>,
parachains_configuration::migration::v12::MigrateToV12<Runtime>,
// permanent // permanent
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>, pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
@@ -16,10 +16,10 @@
//! 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 32.0.0
//! DATE: 2023-11-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! DATE: 2024-02-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000` //! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-yprdrvc7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("rococo-dev")`, DB CACHE: 1024 //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("rococo-dev")`, DB CACHE: 1024
// Executed Command: // Executed Command:
@@ -58,8 +58,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 7_793_000 picoseconds. // Minimum execution time: 7_789_000 picoseconds.
Weight::from_parts(8_192_000, 0) Weight::from_parts(8_269_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -74,8 +74,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 7_819_000 picoseconds. // Minimum execution time: 7_851_000 picoseconds.
Weight::from_parts(8_004_000, 0) Weight::from_parts(8_152_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -90,8 +90,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 7_760_000 picoseconds. // Minimum execution time: 7_960_000 picoseconds.
Weight::from_parts(8_174_000, 0) Weight::from_parts(8_276_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -116,8 +116,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 7_814_000 picoseconds. // Minimum execution time: 7_912_000 picoseconds.
Weight::from_parts(8_098_000, 0) Weight::from_parts(8_164_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -132,8 +132,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 10_028_000 picoseconds. // Minimum execution time: 9_782_000 picoseconds.
Weight::from_parts(10_386_000, 0) Weight::from_parts(10_373_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -148,8 +148,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 7_867_000 picoseconds. // Minimum execution time: 7_870_000 picoseconds.
Weight::from_parts(8_191_000, 0) Weight::from_parts(8_274_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -164,8 +164,24 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 10_158_000 picoseconds. // Minimum execution time: 9_960_000 picoseconds.
Weight::from_parts(10_430_000, 0) Weight::from_parts(10_514_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Configuration::PendingConfigs` (r:1 w:1)
/// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0)
/// Proof: `Configuration::BypassConsistencyCheck` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn set_config_with_scheduler_params() -> Weight {
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 7_913_000 picoseconds.
Weight::from_parts(8_338_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
+1
View File
@@ -1699,6 +1699,7 @@ pub mod migrations {
// Migrate Identity pallet for Usernames // Migrate Identity pallet for Usernames
pallet_identity::migration::versioned::V0ToV1<Runtime, IDENTITY_MIGRATION_KEY_LIMIT>, pallet_identity::migration::versioned::V0ToV1<Runtime, IDENTITY_MIGRATION_KEY_LIMIT>,
parachains_configuration::migration::v11::MigrateToV11<Runtime>, parachains_configuration::migration::v11::MigrateToV11<Runtime>,
parachains_configuration::migration::v12::MigrateToV12<Runtime>,
// permanent // permanent
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>, pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
// Migrate from legacy lease to coretime. Needs to run after configuration v11 // Migrate from legacy lease to coretime. Needs to run after configuration v11
@@ -16,10 +16,10 @@
//! 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 32.0.0
//! DATE: 2023-11-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! DATE: 2024-02-08, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000` //! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-yprdrvc7-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("westend-dev")`, DB CACHE: 1024 //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("westend-dev")`, DB CACHE: 1024
// Executed Command: // Executed Command:
@@ -58,8 +58,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 8_065_000 picoseconds. // Minimum execution time: 7_775_000 picoseconds.
Weight::from_parts(8_389_000, 0) Weight::from_parts(8_036_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -74,8 +74,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 8_038_000 picoseconds. // Minimum execution time: 7_708_000 picoseconds.
Weight::from_parts(8_463_000, 0) Weight::from_parts(7_971_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -90,8 +90,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 7_843_000 picoseconds. // Minimum execution time: 7_746_000 picoseconds.
Weight::from_parts(8_216_000, 0) Weight::from_parts(8_028_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -116,8 +116,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 7_969_000 picoseconds. // Minimum execution time: 7_729_000 picoseconds.
Weight::from_parts(8_362_000, 0) Weight::from_parts(7_954_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -132,8 +132,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 10_084_000 picoseconds. // Minimum execution time: 9_871_000 picoseconds.
Weight::from_parts(10_451_000, 0) Weight::from_parts(10_075_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -148,8 +148,8 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 7_948_000 picoseconds. // Minimum execution time: 7_869_000 picoseconds.
Weight::from_parts(8_268_000, 0) Weight::from_parts(8_000_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -164,8 +164,24 @@ impl<T: frame_system::Config> runtime_parachains::configuration::WeightInfo for
// Proof Size summary in bytes: // Proof Size summary in bytes:
// Measured: `151` // Measured: `151`
// Estimated: `1636` // Estimated: `1636`
// Minimum execution time: 10_257_000 picoseconds. // Minimum execution time: 9_797_000 picoseconds.
Weight::from_parts(10_584_000, 0) Weight::from_parts(10_373_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Configuration::PendingConfigs` (r:1 w:1)
/// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0)
/// Proof: `Configuration::BypassConsistencyCheck` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn set_config_with_scheduler_params() -> Weight {
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 7_718_000 picoseconds.
Weight::from_parts(7_984_000, 0)
.saturating_add(Weight::from_parts(0, 1636)) .saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1)) .saturating_add(T::DbWeight::get().writes(1))
@@ -2,9 +2,11 @@
timeout = 1000 timeout = 1000
[relaychain.genesis.runtimeGenesis.patch.configuration.config] [relaychain.genesis.runtimeGenesis.patch.configuration.config]
max_validators_per_core = 5
needed_approvals = 8 needed_approvals = 8
[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 5
[relaychain.genesis.runtimeGenesis.patch.configuration.config.approval_voting_params] [relaychain.genesis.runtimeGenesis.patch.configuration.config.approval_voting_params]
max_approval_coalesce_count = 5 max_approval_coalesce_count = 5
@@ -2,8 +2,10 @@
timeout = 1000 timeout = 1000
bootnode = true bootnode = true
[relaychain.genesis.runtimeGenesis.patch.configuration.config] [relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 1 max_validators_per_core = 1
[relaychain.genesis.runtimeGenesis.patch.configuration.config]
needed_approvals = 2 needed_approvals = 2
[relaychain] [relaychain]
@@ -3,8 +3,10 @@ timeout = 1000
bootnode = true bootnode = true
[relaychain.genesis.runtimeGenesis.patch.configuration.config] [relaychain.genesis.runtimeGenesis.patch.configuration.config]
max_validators_per_core = 1
needed_approvals = 2 needed_approvals = 2
[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 1
group_rotation_frequency = 2 group_rotation_frequency = 2
[relaychain] [relaychain]
@@ -3,10 +3,12 @@ timeout = 1000
bootnode = true bootnode = true
[relaychain.genesis.runtimeGenesis.patch.configuration.config] [relaychain.genesis.runtimeGenesis.patch.configuration.config]
max_validators_per_core = 1
needed_approvals = 7 needed_approvals = 7
relay_vrf_modulo_samples = 5 relay_vrf_modulo_samples = 5
[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 1
[relaychain] [relaychain]
default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}"
chain = "rococo-local" chain = "rococo-local"
@@ -2,9 +2,11 @@
timeout = 1000 timeout = 1000
[relaychain.genesis.runtimeGenesis.patch.configuration.config] [relaychain.genesis.runtimeGenesis.patch.configuration.config]
max_validators_per_core = 1
needed_approvals = 1 needed_approvals = 1
[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 1
[relaychain] [relaychain]
default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}"
chain = "rococo-local" chain = "rococo-local"
@@ -2,9 +2,11 @@
timeout = 1000 timeout = 1000
[relaychain.genesis.runtimeGenesis.patch.configuration.config] [relaychain.genesis.runtimeGenesis.patch.configuration.config]
max_validators_per_core = 1
needed_approvals = 1 needed_approvals = 1
[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 1
[relaychain] [relaychain]
default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}"
chain = "rococo-local" chain = "rococo-local"
@@ -3,8 +3,10 @@ timeout = 1000
bootnode = true bootnode = true
[relaychain.genesis.runtimeGenesis.patch.configuration.config] [relaychain.genesis.runtimeGenesis.patch.configuration.config]
max_validators_per_core = 1
needed_approvals = 2 needed_approvals = 2
[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 1
group_rotation_frequency = 10 group_rotation_frequency = 10
[relaychain] [relaychain]
@@ -8,13 +8,16 @@ chain = "rococo-local"
[relaychain.genesis.runtimeGenesis.patch.configuration.config] [relaychain.genesis.runtimeGenesis.patch.configuration.config]
needed_approvals = 4 needed_approvals = 4
relay_vrf_modulo_samples = 6 relay_vrf_modulo_samples = 6
scheduling_lookahead = 2
group_rotation_frequency = 4
[relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params] [relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params]
max_candidate_depth = 3 max_candidate_depth = 3
allowed_ancestry_len = 2 allowed_ancestry_len = 2
[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
lookahead = 2
group_rotation_frequency = 4
[relaychain.default_resources] [relaychain.default_resources]
limits = { memory = "4G", cpu = "2" } limits = { memory = "4G", cpu = "2" }
requests = { memory = "2G", cpu = "1" } requests = { memory = "2G", cpu = "1" }
@@ -3,9 +3,11 @@ timeout = 1000
bootnode = true bootnode = true
[relaychain.genesis.runtimeGenesis.patch.configuration.config] [relaychain.genesis.runtimeGenesis.patch.configuration.config]
max_validators_per_core = 2
needed_approvals = 4 needed_approvals = 4
coretime_cores = 2
[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 2
num_cores = 2
[relaychain] [relaychain]
default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}"
@@ -3,9 +3,11 @@ timeout = 1000
bootnode = true bootnode = true
[relaychain.genesis.runtimeGenesis.patch.configuration.config] [relaychain.genesis.runtimeGenesis.patch.configuration.config]
max_validators_per_core = 1
needed_approvals = 3 needed_approvals = 3
[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 1
[relaychain] [relaychain]
default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}" default_image = "{{ZOMBIENET_INTEGRATION_TEST_IMAGE}}"
chain = "rococo-local" chain = "rococo-local"