Parachains configuration.rs FrameV2 (#3516)

* migration

* genesis build correctly

* migrate runtimes

* add genesis builds

* expose GenesisBuild

* chainspec migration

* fmt

* check before insert

* Reduce visibility of storage items to crate

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
ferrell-code
2021-07-28 00:56:35 -04:00
committed by GitHub
parent 3b87d363e9
commit 84ca3b2b3b
17 changed files with 194 additions and 160 deletions
+137 -109
View File
@@ -20,17 +20,14 @@
use sp_std::prelude::*;
use primitives::v1::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_POV_SIZE};
use frame_support::{
decl_storage, decl_module, decl_error,
ensure,
dispatch::DispatchResult,
weights::{DispatchClass, Weight},
};
use parity_scale_codec::{Encode, Decode};
use frame_system::ensure_root;
use frame_system::pallet_prelude::*;
use frame_support::pallet_prelude::*;
use sp_runtime::traits::Zero;
use crate::shared;
pub use pallet::*;
/// All configuration of the runtime with respect to parachains and parathreads.
#[derive(Clone, Encode, Decode, PartialEq, sp_core::RuntimeDebug)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
@@ -258,37 +255,68 @@ impl<BlockNumber: Zero> HostConfiguration<BlockNumber> {
}
}
pub trait Config: frame_system::Config + shared::Config { }
#[frame_support::pallet]
pub mod pallet {
use super::*;
decl_storage! {
trait Store for Module<T: Config> as Configuration {
/// The active configuration for the current session.
ActiveConfig get(fn config) config(): HostConfiguration<T::BlockNumber>;
/// Pending configuration (if any) for the next session.
PendingConfig: map hasher(twox_64_concat) SessionIndex => Option<HostConfiguration<T::BlockNumber>>;
}
add_extra_genesis {
build(|config: &Self| {
config.config.check_consistency();
})
}
}
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);
decl_error! {
pub enum Error for Module<T: Config> {
#[pallet::config]
pub trait Config: frame_system::Config + shared::Config {}
#[pallet::error]
pub enum Error<T> {
/// The new value for a configuration parameter is invalid.
InvalidNewValue,
}
}
decl_module! {
/// The parachains configuration module.
pub struct Module<T: Config> for enum Call where origin: <T as frame_system::Config>::Origin {
type Error = Error<T>;
/// The active configuration for the current session.
#[pallet::storage]
#[pallet::getter(fn config)]
pub(crate) type ActiveConfig<T: Config> = StorageValue<
_,
HostConfiguration<T::BlockNumber>,
ValueQuery
>;
/// Pending configuration (if any) for the next session.
#[pallet::storage]
pub(crate) type PendingConfig<T: Config> = StorageMap<
_,
Twox64Concat,
SessionIndex,
HostConfiguration<T::BlockNumber>
>;
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub config: HostConfiguration<T::BlockNumber>
}
#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
GenesisConfig {
config: Default::default()
}
}
}
#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
self.config.check_consistency();
ActiveConfig::<T>::put(&self.config);
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Set the validation upgrade frequency.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_validation_upgrade_frequency(origin, new: T::BlockNumber) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_validation_upgrade_frequency(origin: OriginFor<T>, new: T::BlockNumber) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.validation_upgrade_frequency, new) != new
@@ -297,8 +325,8 @@ decl_module! {
}
/// Set the validation upgrade delay.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_validation_upgrade_delay(origin, new: T::BlockNumber) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_validation_upgrade_delay(origin: OriginFor<T>, new: T::BlockNumber) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.validation_upgrade_delay, new) != new
@@ -307,8 +335,8 @@ decl_module! {
}
/// Set the acceptance period for an included candidate.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_code_retention_period(origin, new: T::BlockNumber) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_code_retention_period(origin: OriginFor<T>, new: T::BlockNumber) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.code_retention_period, new) != new
@@ -317,8 +345,8 @@ decl_module! {
}
/// Set the max validation code size for incoming upgrades.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_code_size(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_max_code_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
ensure!(new <= MAX_CODE_SIZE, Error::<T>::InvalidNewValue);
Self::update_config_member(|config| {
@@ -328,8 +356,8 @@ decl_module! {
}
/// Set the max POV block size for incoming upgrades.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_pov_size(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_max_pov_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
ensure!(new <= MAX_POV_SIZE, Error::<T>::InvalidNewValue);
Self::update_config_member(|config| {
@@ -339,8 +367,8 @@ decl_module! {
}
/// Set the max head data size for paras.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_head_data_size(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_max_head_data_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_head_data_size, new) != new
@@ -349,8 +377,8 @@ decl_module! {
}
/// Set the number of parathread execution cores.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_parathread_cores(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_parathread_cores(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.parathread_cores, new) != new
@@ -359,8 +387,8 @@ decl_module! {
}
/// Set the number of retries for a particular parathread.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_parathread_retries(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_parathread_retries(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.parathread_retries, new) != new
@@ -370,8 +398,8 @@ decl_module! {
/// Set the parachain validator-group rotation frequency
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_group_rotation_frequency(origin, new: T::BlockNumber) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_group_rotation_frequency(origin: OriginFor<T>, new: T::BlockNumber) -> DispatchResult {
ensure_root(origin)?;
ensure!(!new.is_zero(), Error::<T>::InvalidNewValue);
@@ -383,8 +411,8 @@ decl_module! {
}
/// Set the availability period for parachains.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_chain_availability_period(origin, new: T::BlockNumber) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_chain_availability_period(origin: OriginFor<T>, new: T::BlockNumber) -> DispatchResult {
ensure_root(origin)?;
ensure!(!new.is_zero(), Error::<T>::InvalidNewValue);
@@ -396,8 +424,8 @@ decl_module! {
}
/// Set the availability period for parathreads.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_thread_availability_period(origin, new: T::BlockNumber) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_thread_availability_period(origin: OriginFor<T>, new: T::BlockNumber) -> DispatchResult {
ensure_root(origin)?;
ensure!(!new.is_zero(), Error::<T>::InvalidNewValue);
@@ -409,8 +437,8 @@ decl_module! {
}
/// Set the scheduling lookahead, in expected number of blocks at peak throughput.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_scheduling_lookahead(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_scheduling_lookahead(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.scheduling_lookahead, new) != new
@@ -419,8 +447,8 @@ decl_module! {
}
/// Set the maximum number of validators to assign to any core.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_validators_per_core(origin, new: Option<u32>) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_max_validators_per_core(origin: OriginFor<T>, new: Option<u32>) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_validators_per_core, new) != new
@@ -429,8 +457,8 @@ decl_module! {
}
/// Set the maximum number of validators to use in parachain consensus.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_validators(origin, new: Option<u32>) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_max_validators(origin: OriginFor<T>, new: Option<u32>) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_validators, new) != new
@@ -439,8 +467,8 @@ decl_module! {
}
/// Set the dispute period, in number of sessions to keep for disputes.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_dispute_period(origin, new: SessionIndex) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_dispute_period(origin: OriginFor<T>, new: SessionIndex) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.dispute_period, new) != new
@@ -449,9 +477,9 @@ decl_module! {
}
/// Set the dispute post conclusion acceptance period.
#[weight = (1_000, DispatchClass::Operational)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_dispute_post_conclusion_acceptance_period(
origin,
origin: OriginFor<T>,
new: T::BlockNumber,
) -> DispatchResult {
ensure_root(origin)?;
@@ -462,8 +490,8 @@ decl_module! {
}
/// Set the maximum number of dispute spam slots.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_dispute_max_spam_slots(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_dispute_max_spam_slots(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.dispute_max_spam_slots, new) != new
@@ -472,8 +500,8 @@ decl_module! {
}
/// Set the dispute conclusion by time out period.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_dispute_conclusion_by_time_out_period(origin, new: T::BlockNumber)
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_dispute_conclusion_by_time_out_period(origin: OriginFor<T>, new: T::BlockNumber)
-> DispatchResult
{
ensure_root(origin)?;
@@ -485,8 +513,8 @@ decl_module! {
/// Set the no show slots, in number of number of consensus slots.
/// Must be at least 1.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_no_show_slots(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_no_show_slots(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
ensure!(!new.is_zero(), Error::<T>::InvalidNewValue);
@@ -498,8 +526,8 @@ decl_module! {
}
/// Set the total number of delay tranches.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_n_delay_tranches(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_n_delay_tranches(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.n_delay_tranches, new) != new
@@ -508,8 +536,8 @@ decl_module! {
}
/// Set the zeroth delay tranche width.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_zeroth_delay_tranche_width(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_zeroth_delay_tranche_width(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.zeroth_delay_tranche_width, new) != new
@@ -518,8 +546,8 @@ decl_module! {
}
/// Set the number of validators needed to approve a block.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_needed_approvals(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_needed_approvals(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.needed_approvals, new) != new
@@ -528,8 +556,8 @@ decl_module! {
}
/// Set the number of samples to do of the `RelayVRFModulo` approval assignment criterion.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_relay_vrf_modulo_samples(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_relay_vrf_modulo_samples(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.relay_vrf_modulo_samples, new) != new
@@ -538,8 +566,8 @@ decl_module! {
}
/// Sets the maximum items that can present in a upward dispatch queue at once.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_upward_queue_count(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_max_upward_queue_count(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_upward_queue_count, new) != new
@@ -548,8 +576,8 @@ decl_module! {
}
/// Sets the maximum total size of items that can present in a upward dispatch queue at once.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_upward_queue_size(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_max_upward_queue_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_upward_queue_size, new) != new
@@ -558,8 +586,8 @@ decl_module! {
}
/// Set the critical downward message size.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_downward_message_size(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_max_downward_message_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_downward_message_size, new) != new
@@ -568,8 +596,8 @@ decl_module! {
}
/// Sets the soft limit for the phase of dispatching dispatchable upward messages.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_ump_service_total_weight(origin, new: Weight) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_ump_service_total_weight(origin: OriginFor<T>, new: Weight) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.ump_service_total_weight, new) != new
@@ -578,8 +606,8 @@ decl_module! {
}
/// Sets the maximum size of an upward message that can be sent by a candidate.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_upward_message_size(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_max_upward_message_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_upward_message_size, new) != new
@@ -588,8 +616,8 @@ decl_module! {
}
/// Sets the maximum number of messages that a candidate can contain.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_max_upward_message_num_per_candidate(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_max_upward_message_num_per_candidate(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.max_upward_message_num_per_candidate, new) != new
@@ -598,8 +626,8 @@ decl_module! {
}
/// Sets the number of sessions after which an HRMP open channel request expires.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_hrmp_open_request_ttl(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_hrmp_open_request_ttl(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_open_request_ttl, new) != new
@@ -608,8 +636,8 @@ decl_module! {
}
/// Sets the amount of funds that the sender should provide for opening an HRMP channel.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_hrmp_sender_deposit(origin, new: Balance) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_hrmp_sender_deposit(origin: OriginFor<T>, new: Balance) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_sender_deposit, new) != new
@@ -619,8 +647,8 @@ decl_module! {
/// Sets the amount of funds that the recipient should provide for accepting opening an HRMP
/// channel.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_hrmp_recipient_deposit(origin, new: Balance) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_hrmp_recipient_deposit(origin: OriginFor<T>, new: Balance) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_recipient_deposit, new) != new
@@ -629,8 +657,8 @@ decl_module! {
}
/// Sets the maximum number of messages allowed in an HRMP channel at once.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_hrmp_channel_max_capacity(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_hrmp_channel_max_capacity(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_channel_max_capacity, new) != new
@@ -639,8 +667,8 @@ decl_module! {
}
/// Sets the maximum total size of messages in bytes allowed in an HRMP channel at once.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_hrmp_channel_max_total_size(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_hrmp_channel_max_total_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_channel_max_total_size, new) != new
@@ -649,8 +677,8 @@ decl_module! {
}
/// Sets the maximum number of inbound HRMP channels a parachain is allowed to accept.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_hrmp_max_parachain_inbound_channels(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_hrmp_max_parachain_inbound_channels(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_max_parachain_inbound_channels, new) != new
@@ -659,8 +687,8 @@ decl_module! {
}
/// Sets the maximum number of inbound HRMP channels a parathread is allowed to accept.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_hrmp_max_parathread_inbound_channels(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_hrmp_max_parathread_inbound_channels(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_max_parathread_inbound_channels, new) != new
@@ -669,8 +697,8 @@ decl_module! {
}
/// Sets the maximum size of a message that could ever be put into an HRMP channel.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_hrmp_channel_max_message_size(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_hrmp_channel_max_message_size(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_channel_max_message_size, new) != new
@@ -679,8 +707,8 @@ decl_module! {
}
/// Sets the maximum number of outbound HRMP channels a parachain is allowed to open.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_hrmp_max_parachain_outbound_channels(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_hrmp_max_parachain_outbound_channels(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_max_parachain_outbound_channels, new) != new
@@ -689,8 +717,8 @@ decl_module! {
}
/// Sets the maximum number of outbound HRMP channels a parathread is allowed to open.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_hrmp_max_parathread_outbound_channels(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_hrmp_max_parathread_outbound_channels(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_max_parathread_outbound_channels, new) != new
@@ -699,8 +727,8 @@ decl_module! {
}
/// Sets the maximum number of outbound HRMP messages can be sent by a candidate.
#[weight = (1_000, DispatchClass::Operational)]
pub fn set_hrmp_max_message_num_per_candidate(origin, new: u32) -> DispatchResult {
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_hrmp_max_message_num_per_candidate(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.hrmp_max_message_num_per_candidate, new) != new
@@ -710,7 +738,7 @@ decl_module! {
}
}
impl<T: Config> Module<T> {
impl<T: Config> Pallet<T> {
/// Called by the initializer to initialize the configuration module.
pub(crate) fn initializer_initialize(_now: T::BlockNumber) -> Weight {
0