Skip to content

Commit

Permalink
remove fields from configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
alindima committed Sep 17, 2024
1 parent d0a42c8 commit d31e0a0
Show file tree
Hide file tree
Showing 8 changed files with 486 additions and 48 deletions.
8 changes: 0 additions & 8 deletions polkadot/primitives/src/v8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2093,8 +2093,6 @@ pub struct SchedulerParams<BlockNumber> {
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.
Expand All @@ -2104,10 +2102,6 @@ pub struct SchedulerParams<BlockNumber> {
pub on_demand_fee_variability: Perbill,
/// The minimum amount needed to claim a slot in the spot pricing queue.
pub on_demand_base_fee: Balance,
/// The number of blocks a claim stays in the scheduler's claim queue before getting cleared.
/// This number should go reasonably higher than the number of blocks in the async backing
/// lookahead.
pub ttl: BlockNumber,
}

impl<BlockNumber: Default + From<u32>> Default for SchedulerParams<BlockNumber> {
Expand All @@ -2118,12 +2112,10 @@ impl<BlockNumber: Default + From<u32>> Default for SchedulerParams<BlockNumber>
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(),
}
}
}
Expand Down
33 changes: 3 additions & 30 deletions polkadot/runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,6 @@ pub enum InconsistentError<BlockNumber> {
ZeroMinimumBackingVotes,
/// `executor_params` are inconsistent.
InconsistentExecutorParams { inner: ExecutorParamError },
/// TTL should be bigger than lookahead
LookaheadExceedsTTL,
/// Lookahead is zero, while it must be at least 1 for parachains to work.
LookaheadZero,
/// Passed in queue size for on-demand was too large.
Expand Down Expand Up @@ -430,10 +428,6 @@ where
return Err(InconsistentExecutorParams { inner })
}

if self.scheduler_params.ttl < self.scheduler_params.lookahead.into() {
return Err(LookaheadExceedsTTL)
}

if self.scheduler_params.lookahead == 0 {
return Err(LookaheadZero)
}
Expand Down Expand Up @@ -682,18 +676,7 @@ pub mod pallet {
Self::set_coretime_cores_unchecked(new)
}

/// Set the max number of times a claim may timeout on a core before it is abandoned
#[pallet::call_index(7)]
#[pallet::weight((
T::WeightInfo::set_config_with_u32(),
DispatchClass::Operational,
))]
pub fn set_max_availability_timeouts(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.scheduler_params.max_availability_timeouts = new;
})
}
// Call index 7 used to be `set_max_availability_timeouts`, which was removed.

/// Set the parachain validator-group rotation frequency
#[pallet::call_index(8)]
Expand Down Expand Up @@ -1189,18 +1172,8 @@ pub mod pallet {
config.scheduler_params.on_demand_target_queue_utilization = new;
})
}
/// Set the on demand (parathreads) ttl in the claimqueue.
#[pallet::call_index(51)]
#[pallet::weight((
T::WeightInfo::set_config_with_block_number(),
DispatchClass::Operational
))]
pub fn set_on_demand_ttl(origin: OriginFor<T>, new: BlockNumberFor<T>) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.scheduler_params.ttl = new;
})
}

// Call index 51 used to be `set_on_demand_ttl`, which was removed.

/// Set the minimum backing votes threshold.
#[pallet::call_index(52)]
Expand Down
1 change: 1 addition & 0 deletions polkadot/runtime/parachains/src/configuration/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
pub mod v10;
pub mod v11;
pub mod v12;
pub mod v13;
pub mod v6;
pub mod v7;
pub mod v8;
Expand Down
125 changes: 122 additions & 3 deletions polkadot/runtime/parachains/src/configuration/migration/v12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,130 @@ use frame_support::{
traits::{Defensive, UncheckedOnRuntimeUpgrade},
};
use frame_system::pallet_prelude::BlockNumberFor;
use polkadot_primitives::SchedulerParams;
use polkadot_primitives::{
ApprovalVotingParams, AsyncBackingParams, Balance, ExecutorParams, NodeFeatures,
LEGACY_MIN_BACKING_VOTES, MAX_CODE_SIZE, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
};
use sp_arithmetic::Perbill;
use sp_core::Get;
use sp_staking::SessionIndex;

type V12HostConfiguration<BlockNumber> = configuration::HostConfiguration<BlockNumber>;
#[derive(Clone, Encode, PartialEq, Decode, Debug)]
pub struct V12SchedulerParams<BlockNumber> {
pub group_rotation_frequency: BlockNumber,
pub paras_availability_period: BlockNumber,
pub max_validators_per_core: Option<u32>,
pub lookahead: u32,
pub num_cores: u32,
pub max_availability_timeouts: u32,
pub on_demand_queue_max_size: u32,
pub on_demand_target_queue_utilization: Perbill,
pub on_demand_fee_variability: Perbill,
pub on_demand_base_fee: Balance,
pub ttl: BlockNumber,
}

impl<BlockNumber: Default + From<u32>> Default for V12SchedulerParams<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(),
}
}
}

#[derive(Clone, Encode, PartialEq, Decode, Debug)]
pub struct V12HostConfiguration<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 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,
pub scheduler_params: V12SchedulerParams<BlockNumber>,
}

impl<BlockNumber: Default + From<u32>> Default for V12HostConfiguration<BlockNumber> {
fn default() -> Self {
Self {
async_backing_params: AsyncBackingParams {
max_candidate_depth: 0,
allowed_ancestry_len: 0,
},
no_show_slots: 1u32.into(),
validation_upgrade_cooldown: Default::default(),
validation_upgrade_delay: 2u32.into(),
code_retention_period: Default::default(),
max_code_size: MAX_CODE_SIZE,
max_pov_size: Default::default(),
max_head_data_size: Default::default(),
max_validators: None,
dispute_period: 6,
dispute_post_conclusion_acceptance_period: 100.into(),
n_delay_tranches: 1,
zeroth_delay_tranche_width: Default::default(),
needed_approvals: Default::default(),
relay_vrf_modulo_samples: Default::default(),
max_upward_queue_count: Default::default(),
max_upward_queue_size: Default::default(),
max_downward_message_size: Default::default(),
max_upward_message_size: Default::default(),
max_upward_message_num_per_candidate: Default::default(),
hrmp_sender_deposit: Default::default(),
hrmp_recipient_deposit: Default::default(),
hrmp_channel_max_capacity: Default::default(),
hrmp_channel_max_total_size: Default::default(),
hrmp_max_parachain_inbound_channels: Default::default(),
hrmp_channel_max_message_size: Default::default(),
hrmp_max_parachain_outbound_channels: Default::default(),
hrmp_max_message_num_per_candidate: Default::default(),
pvf_voting_ttl: 2u32.into(),
minimum_validation_upgrade_delay: 2.into(),
executor_params: Default::default(),
approval_voting_params: ApprovalVotingParams { max_approval_coalesce_count: 1 },
minimum_backing_votes: LEGACY_MIN_BACKING_VOTES,
node_features: NodeFeatures::EMPTY,
scheduler_params: Default::default(),
}
}
}

mod v11 {
use super::*;
Expand Down Expand Up @@ -143,7 +262,7 @@ fn migrate_to_v12<T: Config>() -> Weight {
minimum_backing_votes : pre.minimum_backing_votes,
node_features : pre.node_features,
approval_voting_params : pre.approval_voting_params,
scheduler_params: SchedulerParams {
scheduler_params: V12SchedulerParams {
group_rotation_frequency : pre.group_rotation_frequency,
paras_availability_period : pre.paras_availability_period,
max_validators_per_core : pre.max_validators_per_core,
Expand Down
Loading

0 comments on commit d31e0a0

Please sign in to comment.