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

* Backport async backing params primitive

* migration follow-up

* link pr

* parameters -> params

* rustfmt::skip block ident
This commit is contained in:
Chris Sosnin
2023-03-28 17:55:24 +03:00
committed by GitHub
parent 22f404f092
commit 16e4661446
4 changed files with 62 additions and 2 deletions
@@ -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::AsyncBackingParams, 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_params: AsyncBackingParams,
/// 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_params: AsyncBackingParams {
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_params(
origin: OriginFor<T>,
new: AsyncBackingParams,
) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.async_backing_params = new;
})
}
}
#[pallet::hooks]