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

configuration: backport async backing parameters from the feature branch #6961

Merged
merged 5 commits into from
Mar 28, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
migration follow-up
slumber committed Mar 27, 2023
commit 352a607af5cec59e8d7fba9b2dca2eb677ef61bd
27 changes: 26 additions & 1 deletion runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,10 @@ use frame_support::{pallet_prelude::*, weights::constants::WEIGHT_REF_TIME_PER_M
use frame_system::pallet_prelude::*;
use parity_scale_codec::{Decode, Encode};
use polkadot_parachain::primitives::{MAX_HORIZONTAL_MESSAGE_NUM, MAX_UPWARD_MESSAGE_NUM};
use primitives::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE};
use primitives::{
vstaging::AsyncBackingParameters, Balance, SessionIndex, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE,
MAX_POV_SIZE,
};
use sp_runtime::traits::Zero;
use sp_std::prelude::*;

@@ -118,6 +121,8 @@ pub struct HostConfiguration<BlockNumber> {
* The parameters that are not essential, but still may be of interest for parachains.
*/

/// Asynchronous backing parameters.
pub async_backing_parameters: AsyncBackingParameters,
/// The maximum POV block size, in bytes.
pub max_pov_size: u32,
/// The maximum size of a message that can be put in a downward message queue.
@@ -243,6 +248,10 @@ pub struct HostConfiguration<BlockNumber> {
impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber> {
fn default() -> Self {
Self {
async_backing_parameters: AsyncBackingParameters {
max_candidate_depth: 0,
allowed_ancestry_len: 0,
},
group_rotation_frequency: 1u32.into(),
chain_availability_period: 1u32.into(),
thread_availability_period: 1u32.into(),
@@ -1138,6 +1147,22 @@ pub mod pallet {
BypassConsistencyCheck::<T>::put(new);
Ok(())
}

/// Set the asynchronous backing parameters.
#[pallet::call_index(45)]
#[pallet::weight((
T::WeightInfo::set_config_with_option_u32(), // The same size in bytes.
DispatchClass::Operational,
))]
pub fn set_async_backing_parameters(
origin: OriginFor<T>,
new: AsyncBackingParameters,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.async_backing_parameters = new;
})
}
}

#[pallet::hooks]
8 changes: 8 additions & 0 deletions runtime/parachains/src/configuration/migration.rs
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
use crate::configuration::{self, ActiveConfig, Config, Pallet, PendingConfigs, MAX_POV_SIZE};
use frame_support::{pallet_prelude::*, traits::StorageVersion, weights::Weight};
use frame_system::pallet_prelude::BlockNumberFor;
use primitives::vstaging::AsyncBackingParameters;
use sp_std::vec::Vec;

/// The current storage version.
@@ -226,6 +227,9 @@ ump_max_individual_weight : pre.ump_max_individual_weight,
pvf_checking_enabled : pre.pvf_checking_enabled,
pvf_voting_ttl : pre.pvf_voting_ttl,
minimum_validation_upgrade_delay : pre.minimum_validation_upgrade_delay,

// Default values are zeroes, thus it's ensured allowed ancestry never crosses the upgrade block.
async_backing_parameters : AsyncBackingParameters { max_candidate_depth: 0, allowed_ancestry_len: 0 },
}
};

@@ -383,6 +387,10 @@ mod tests {
assert_eq!(v4.pvf_voting_ttl , v5.pvf_voting_ttl);
assert_eq!(v4.minimum_validation_upgrade_delay , v5.minimum_validation_upgrade_delay);
}; // ; makes this a statement. `rustfmt::skip` cannot be put on an expression.

// additional checks for async backing.
assert_eq!(v5.async_backing_parameters.allowed_ancestry_len, 0);
assert_eq!(v5.async_backing_parameters.max_candidate_depth, 0);
}
});
}
4 changes: 4 additions & 0 deletions runtime/parachains/src/configuration/tests.rs
Original file line number Diff line number Diff line change
@@ -281,6 +281,10 @@ fn consistency_bypass_works() {
fn setting_pending_config_members() {
new_test_ext(Default::default()).execute_with(|| {
let new_config = HostConfiguration {
async_backing_parameters: primitives::vstaging::AsyncBackingParameters {
allowed_ancestry_len: 0,
max_candidate_depth: 0,
},
validation_upgrade_cooldown: 100,
validation_upgrade_delay: 10,
code_retention_period: 5,