Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Unify parathreads and parachains in HostConfig (take 2) #7452

Merged
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ fn default_parachains_host_configuration(
max_pov_size: MAX_POV_SIZE,
max_head_data_size: 32 * 1024,
group_rotation_frequency: 20,
chain_availability_period: 4,
thread_availability_period: 4,
paras_availability_period: 4,
max_upward_queue_count: 8,
max_upward_queue_size: 1024 * 1024,
max_downward_message_size: 1024 * 1024,
Expand All @@ -194,11 +193,9 @@ fn default_parachains_host_configuration(
hrmp_recipient_deposit: 0,
hrmp_channel_max_capacity: 8,
hrmp_channel_max_total_size: 8 * 1024,
hrmp_max_parachain_inbound_channels: 4,
hrmp_max_parathread_inbound_channels: 4,
hrmp_max_paras_inbound_channels: 4,
hrmp_channel_max_message_size: 1024 * 1024,
hrmp_max_parachain_outbound_channels: 4,
hrmp_max_parathread_outbound_channels: 4,
hrmp_max_paras_outbound_channels: 4,
hrmp_max_message_num_per_candidate: 5,
dispute_period: 6,
no_show_slots: 2,
Expand Down
3 changes: 1 addition & 2 deletions node/test/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ fn polkadot_testnet_genesis(
max_pov_size: MAX_POV_SIZE,
max_head_data_size: 32 * 1024,
group_rotation_frequency: 20,
chain_availability_period: 4,
thread_availability_period: 4,
paras_availability_period: 4,
no_show_slots: 10,
minimum_validation_upgrade_delay: 5,
..Default::default()
Expand Down
1 change: 1 addition & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,7 @@ pub mod migrations {
pub type Unreleased = (
pallet_society::migrations::MigrateToV2<Runtime, (), past_payouts::PastPayouts>,
pallet_im_online::migration::v1::Migration<Runtime>,
parachains_configuration::migration::v7::MigrateToV7<Runtime>,
);

/// Migrations that set `StorageVersion`s we missed to set.
Expand Down
2 changes: 1 addition & 1 deletion runtime/parachains/src/assigner_on_demand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ impl<T: Config> AssignmentProvider<T::BlockNumber> for Pallet<T> {

fn get_availability_period(_core_index: CoreIndex) -> T::BlockNumber {
let config = <configuration::Pallet<T>>::config();
config.thread_availability_period
config.paras_availability_period
}

fn get_max_retries(_core_idx: CoreIndex) -> u32 {
Expand Down
2 changes: 1 addition & 1 deletion runtime/parachains/src/assigner_parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<T: Config> AssignmentProvider<T::BlockNumber> for Pallet<T> {
fn push_assignment_for_core(_: CoreIndex, _: Assignment) {}

fn get_availability_period(_: CoreIndex) -> T::BlockNumber {
<configuration::Pallet<T>>::config().chain_availability_period
<configuration::Pallet<T>>::config().paras_availability_period
}

/// There are retries set up in bulk assignment as the next slot already goes to
Expand Down
141 changes: 32 additions & 109 deletions runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub use pallet::*;

const LOG_TARGET: &str = "runtime::configuration";

/// All configuration of the runtime with respect to parachains and parathreads.
/// All configuration of the runtime with respect to paras.
#[derive(
Clone,
Encode,
Expand Down Expand Up @@ -114,7 +114,7 @@ pub struct HostConfiguration<BlockNumber> {
/// been completed.
///
/// Note, there are situations in which `expected_at` in the past. For example, if
/// [`chain_availability_period`] or [`thread_availability_period`] is less than the delay set by
/// [`paras_availability_period`] is less than the delay set by
/// this field or if PVF pre-check took more time than the delay. In such cases, the upgrade is
/// further at the earliest possible time determined by [`minimum_validation_upgrade_delay`].
///
Expand All @@ -141,10 +141,8 @@ pub struct HostConfiguration<BlockNumber> {
/// 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 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 is allowed to open.
pub hrmp_max_parathread_outbound_channels: u32,
/// The maximum number of outbound HRMP channels a paras is allowed to open.
pub hrmp_max_paras_outbound_channels: u32,
/// The deposit that the sender should provide for opening an HRMP channel.
pub hrmp_sender_deposit: Balance,
/// The deposit that the recipient should provide for accepting opening an HRMP channel.
Expand All @@ -153,10 +151,8 @@ pub struct HostConfiguration<BlockNumber> {
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 is allowed to accept.
pub hrmp_max_parathread_inbound_channels: u32,
/// The maximum number of inbound HRMP channels a paras is allowed to accept.
pub hrmp_max_paras_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`.
Expand Down Expand Up @@ -191,18 +187,13 @@ pub struct HostConfiguration<BlockNumber> {
///
/// Must be non-zero.
pub group_rotation_frequency: BlockNumber,
/// The availability period, in blocks, for parachains. This is the amount of blocks
/// The availability period, in blocks. 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. 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 parachains and parathreads.
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.
///
Expand Down Expand Up @@ -255,8 +246,7 @@ pub struct HostConfiguration<BlockNumber> {
/// To prevent that, we introduce the minimum number of blocks after which the upgrade can be
/// scheduled. This number is controlled by this field.
///
/// This value should be greater than [`chain_availability_period`] and
/// [`thread_availability_period`].
/// This value should be greater than [`paras_availability_period`].
pub minimum_validation_upgrade_delay: BlockNumber,
}

Expand All @@ -268,8 +258,7 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
allowed_ancestry_len: 0,
},
group_rotation_frequency: 1u32.into(),
chain_availability_period: 1u32.into(),
thread_availability_period: 1u32.into(),
paras_availability_period: 1u32.into(),
no_show_slots: 1u32.into(),
validation_upgrade_cooldown: Default::default(),
validation_upgrade_delay: 2u32.into(),
Expand Down Expand Up @@ -297,11 +286,9 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
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_max_parathread_inbound_channels: Default::default(),
hrmp_max_paras_inbound_channels: Default::default(),
hrmp_channel_max_message_size: Default::default(),
hrmp_max_parachain_outbound_channels: Default::default(),
hrmp_max_parathread_outbound_channels: Default::default(),
hrmp_max_paras_outbound_channels: Default::default(),
hrmp_max_message_num_per_candidate: Default::default(),
pvf_checking_enabled: false,
pvf_voting_ttl: 2u32.into(),
Expand All @@ -322,9 +309,7 @@ pub enum InconsistentError<BlockNumber> {
/// `group_rotation_frequency` is set to zero.
ZeroGroupRotationFrequency,
/// `chain_availability_period` is set to zero.
ZeroChainAvailabilityPeriod,
/// `thread_availability_period` is set to zero.
ZeroThreadAvailabilityPeriod,
ZeroParasAvailabilityPeriod,
/// `no_show_slots` is set to zero.
ZeroNoShowSlots,
/// `max_code_size` exceeds the hard limit of `MAX_CODE_SIZE`.
Expand All @@ -333,15 +318,10 @@ pub enum InconsistentError<BlockNumber> {
MaxHeadDataSizeExceedHardLimit { max_head_data_size: u32 },
/// `max_pov_size` exceeds the hard limit of `MAX_POV_SIZE`.
MaxPovSizeExceedHardLimit { max_pov_size: u32 },
/// `minimum_validation_upgrade_delay` is less than `chain_availability_period`.
/// `minimum_validation_upgrade_delay` is less than `paras_availability_period`.
MinimumValidationUpgradeDelayLessThanChainAvailabilityPeriod {
minimum_validation_upgrade_delay: BlockNumber,
chain_availability_period: BlockNumber,
},
/// `minimum_validation_upgrade_delay` is less than `thread_availability_period`.
MinimumValidationUpgradeDelayLessThanThreadAvailabilityPeriod {
minimum_validation_upgrade_delay: BlockNumber,
thread_availability_period: BlockNumber,
paras_availability_period: BlockNumber,
},
/// `validation_upgrade_delay` is less than or equal 1.
ValidationUpgradeDelayIsTooLow { validation_upgrade_delay: BlockNumber },
Expand Down Expand Up @@ -373,12 +353,8 @@ where
return Err(ZeroGroupRotationFrequency)
}

if self.chain_availability_period.is_zero() {
return Err(ZeroChainAvailabilityPeriod)
}

if self.thread_availability_period.is_zero() {
return Err(ZeroThreadAvailabilityPeriod)
if self.paras_availability_period.is_zero() {
return Err(ZeroParasAvailabilityPeriod)
}

if self.no_show_slots.is_zero() {
Expand All @@ -399,15 +375,10 @@ where
return Err(MaxPovSizeExceedHardLimit { max_pov_size: self.max_pov_size })
}

if self.minimum_validation_upgrade_delay <= self.chain_availability_period {
if self.minimum_validation_upgrade_delay <= self.paras_availability_period {
return Err(MinimumValidationUpgradeDelayLessThanChainAvailabilityPeriod {
minimum_validation_upgrade_delay: self.minimum_validation_upgrade_delay.clone(),
chain_availability_period: self.chain_availability_period.clone(),
})
} else if self.minimum_validation_upgrade_delay <= self.thread_availability_period {
return Err(MinimumValidationUpgradeDelayLessThanThreadAvailabilityPeriod {
minimum_validation_upgrade_delay: self.minimum_validation_upgrade_delay.clone(),
thread_availability_period: self.thread_availability_period.clone(),
paras_availability_period: self.paras_availability_period.clone(),
})
}

Expand Down Expand Up @@ -435,12 +406,11 @@ where
})
}

if self.hrmp_max_parachain_outbound_channels > crate::hrmp::HRMP_MAX_OUTBOUND_CHANNELS_BOUND
{
if self.hrmp_max_paras_outbound_channels > crate::hrmp::HRMP_MAX_OUTBOUND_CHANNELS_BOUND {
return Err(MaxHrmpOutboundChannelsExceeded)
}

if self.hrmp_max_parachain_inbound_channels > crate::hrmp::HRMP_MAX_INBOUND_CHANNELS_BOUND {
if self.hrmp_max_paras_inbound_channels > crate::hrmp::HRMP_MAX_INBOUND_CHANNELS_BOUND {
return Err(MaxHrmpInboundChannelsExceeded)
}

Expand Down Expand Up @@ -508,7 +478,8 @@ pub mod pallet {
/// + <https://github.com/paritytech/polkadot/pull/6961>
/// + <https://github.com/paritytech/polkadot/pull/6934>
/// v5-v6: <https://github.com/paritytech/polkadot/pull/6271> (remove UMP dispatch queue)
const STORAGE_VERSION: StorageVersion = StorageVersion::new(6);
/// v6-v7: <https://github.com/paritytech/polkadot/pull/7265>
const STORAGE_VERSION: StorageVersion = StorageVersion::new(7);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
Expand Down Expand Up @@ -694,35 +665,19 @@ pub mod pallet {
})
}

/// Set the availability period for parachains.
/// Set the availability period for paras.
#[pallet::call_index(9)]
#[pallet::weight((
T::WeightInfo::set_config_with_block_number(),
DispatchClass::Operational,
))]
pub fn set_chain_availability_period(
pub fn set_paras_availability_period(
origin: OriginFor<T>,
new: T::BlockNumber,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.chain_availability_period = new;
})
}

/// Set the availability period for parathreads.
#[pallet::call_index(10)]
#[pallet::weight((
T::WeightInfo::set_config_with_block_number(),
DispatchClass::Operational,
))]
pub fn set_thread_availability_period(
origin: OriginFor<T>,
new: T::BlockNumber,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.thread_availability_period = new;
config.paras_availability_period = new;
})
}

Expand Down Expand Up @@ -998,35 +953,19 @@ pub mod pallet {
})
}

/// Sets the maximum number of inbound HRMP channels a parachain is allowed to accept.
/// Sets the maximum number of inbound HRMP channels a paras is allowed to accept.
#[pallet::call_index(34)]
#[pallet::weight((
T::WeightInfo::set_config_with_u32(),
DispatchClass::Operational,
))]
pub fn set_hrmp_max_parachain_inbound_channels(
pub fn set_hrmp_max_paras_inbound_channels(
origin: OriginFor<T>,
new: u32,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.hrmp_max_parachain_inbound_channels = new;
})
}

/// Sets the maximum number of inbound HRMP channels a parathread is allowed to accept.
#[pallet::call_index(35)]
#[pallet::weight((
T::WeightInfo::set_config_with_u32(),
DispatchClass::Operational,
))]
pub fn set_hrmp_max_parathread_inbound_channels(
origin: OriginFor<T>,
new: u32,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.hrmp_max_parathread_inbound_channels = new;
config.hrmp_max_paras_inbound_channels = new;
})
}

Expand All @@ -1049,29 +988,13 @@ pub mod pallet {
T::WeightInfo::set_config_with_u32(),
DispatchClass::Operational,
))]
pub fn set_hrmp_max_parachain_outbound_channels(
origin: OriginFor<T>,
new: u32,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.hrmp_max_parachain_outbound_channels = new;
})
}

/// Sets the maximum number of outbound HRMP channels a parathread is allowed to open.
#[pallet::call_index(38)]
#[pallet::weight((
T::WeightInfo::set_config_with_u32(),
DispatchClass::Operational,
))]
pub fn set_hrmp_max_parathread_outbound_channels(
pub fn set_hrmp_max_paras_outbound_channels(
origin: OriginFor<T>,
new: u32,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.hrmp_max_parathread_outbound_channels = new;
config.hrmp_max_paras_outbound_channels = new;
})
}

Expand Down
1 change: 1 addition & 0 deletions runtime/parachains/src/configuration/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ use primitives::ExecutorParams;

pub mod v5;
pub mod v6;
pub mod v7;
Loading
Loading