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

UMP: Support Overweight messages #3575

Merged
merged 26 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b0f1de0
Introduce new config: ump_max_individual_weight
pepyakin Aug 4, 2021
fe3ef6b
Implement overweight msg stashing
pepyakin Aug 4, 2021
be125f3
Test
pepyakin Aug 4, 2021
093455b
Add migration module.
pepyakin Aug 5, 2021
35deb5c
Integrate ExecuteOverweightOrigin to runtimes
pepyakin Aug 5, 2021
be55e53
Fix more stuff
pepyakin Aug 5, 2021
5a4de33
Add `yeet` into dictionary
pepyakin Aug 5, 2021
52f65da
Use suggested `Error` variant names
pepyakin Sep 1, 2021
bb1721d
typo
pepyakin Sep 1, 2021
88f458f
Use 20ms as the maximum individual message weight
pepyakin Sep 1, 2021
2824aa9
Update the test value
pepyakin Sep 1, 2021
14bf5ba
rustfmt
pepyakin Sep 9, 2021
5346161
Clean up
pepyakin Sep 9, 2021
c2c57c1
Merge branch 'master' into ser-ump-overweight
pepyakin Sep 9, 2021
5b77e2f
Remove deprecated field from host config
pepyakin Sep 9, 2021
213d60e
Remove missed _hrmp_open_request_ttl
pepyakin Sep 9, 2021
f75e7a8
Apply typo fix suggestion
pepyakin Sep 13, 2021
56f9a04
Rename `migration::migrate_to_latest`
pepyakin Sep 13, 2021
7bc31f0
Restore `_hrmp_open_request_ttl` in `v0::HostConfiguration`
pepyakin Sep 13, 2021
7236e5e
Apply suggestion for a rustdoc
pepyakin Sep 13, 2021
27a6a11
Apply the suggestion
pepyakin Sep 13, 2021
45295ca
Test v0 config with the raw production data fetched from Kusama
pepyakin Sep 13, 2021
ec2a02d
Update runtime/parachains/src/ump.rs
pepyakin Sep 13, 2021
f943546
Expose migration functions
pepyakin Sep 13, 2021
ec96365
Merge branch 'master' into ser-ump-overweight
shawntabrizi Sep 15, 2021
dff100f
Fix spellcheck
KiChjang Sep 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ fn default_parachains_host_configuration(
ump_service_total_weight: 4 * 1_000_000_000,
max_upward_message_size: 1024 * 1024,
max_upward_message_num_per_candidate: 5,
_hrmp_open_request_ttl: 5,
hrmp_sender_deposit: 0,
hrmp_recipient_deposit: 0,
hrmp_channel_max_capacity: 8,
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 @@ -1118,6 +1118,7 @@ impl parachains_ump::Config for Runtime {
type Event = Event;
type UmpSink = crate::parachains_ump::XcmSink<XcmExecutor<XcmConfig>, Runtime>;
type FirstMessageFactorPercent = FirstMessageFactorPercent;
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make sense to use sth like MoreThanHalfCouncil or similar? Otherwise we'd need a democracy proposal, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not feel confident answering this.

I am actually wondering why don't we allow for anyone to dispatch an overweight item given that the transaction supplies enough weight.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, you could probably relax it even more

}

impl parachains_dmp::Config for Runtime {}
Expand Down
37 changes: 30 additions & 7 deletions runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! Configuration can change only at session boundaries and is buffered until then.

use crate::shared;
use frame_support::pallet_prelude::*;
use frame_support::{pallet_prelude::*, weights::constants::WEIGHT_PER_MILLIS};
use frame_system::pallet_prelude::*;
use parity_scale_codec::{Decode, Encode};
use primitives::v1::{Balance, SessionIndex, MAX_CODE_SIZE, MAX_POV_SIZE};
Expand All @@ -28,6 +28,10 @@ use sp_std::prelude::*;

pub use pallet::*;

pub mod migration;

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

/// 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))]
Expand Down Expand Up @@ -91,10 +95,6 @@ pub struct HostConfiguration<BlockNumber> {
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,
/// NOTE: this field is deprecated. Channel open requests became non-expiring. Changing this value
/// doesn't have any effect. This field doesn't have a `deprecated` attribute because that would
/// trigger warnings coming from macros.
pub _hrmp_open_request_ttl: 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 Down Expand Up @@ -170,6 +170,9 @@ pub struct HostConfiguration<BlockNumber> {
pub needed_approvals: u32,
/// The number of samples to do of the `RelayVRFModulo` approval assignment criterion.
pub relay_vrf_modulo_samples: u32,
/// The maximum amount of weight any individual upward message may consume. Messages above this
/// weight go into the overweight queue and may only be serviced explicitly.
pub ump_max_individual_weight: Weight,
}

impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber> {
Expand Down Expand Up @@ -204,7 +207,6 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
ump_service_total_weight: Default::default(),
max_upward_message_size: Default::default(),
max_upward_message_num_per_candidate: Default::default(),
_hrmp_open_request_ttl: Default::default(),
hrmp_sender_deposit: Default::default(),
hrmp_recipient_deposit: Default::default(),
hrmp_channel_max_capacity: Default::default(),
Expand All @@ -215,6 +217,7 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
hrmp_max_parachain_outbound_channels: Default::default(),
hrmp_max_parathread_outbound_channels: Default::default(),
hrmp_max_message_num_per_candidate: Default::default(),
ump_max_individual_weight: 20 * WEIGHT_PER_MILLIS,
pepyakin marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down Expand Up @@ -261,6 +264,7 @@ pub mod pallet {

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
#[pallet::storage_version(migration::STORAGE_VERSION)]
pub struct Pallet<T>(_);

#[pallet::config]
Expand Down Expand Up @@ -764,10 +768,24 @@ pub mod pallet {
});
Ok(())
}

/// Sets the maximum amount of weight any individual upward message may consume.
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn set_ump_max_individual_weight(origin: OriginFor<T>, new: Weight) -> DispatchResult {
ensure_root(origin)?;
Self::update_config_member(|config| {
sp_std::mem::replace(&mut config.ump_max_individual_weight, new) != new
});
Ok(())
}
}

#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_runtime_upgrade() -> Weight {
migration::migrate_to_latest::<T>()
}

fn integrity_test() {
assert_eq!(
&ActiveConfig::<T>::hashed_key(),
Expand Down Expand Up @@ -888,7 +906,6 @@ mod tests {
ump_service_total_weight: 20000,
max_upward_message_size: 448,
max_upward_message_num_per_candidate: 5,
_hrmp_open_request_ttl: 0,
hrmp_sender_deposit: 22,
hrmp_recipient_deposit: 4905,
hrmp_channel_max_capacity: 3921,
Expand All @@ -899,6 +916,7 @@ mod tests {
hrmp_max_parachain_outbound_channels: 100,
hrmp_max_parathread_outbound_channels: 200,
hrmp_max_message_num_per_candidate: 20,
ump_max_individual_weight: 909,
};

assert!(<Configuration as Store>::PendingConfig::get(shared::SESSION_DELAY).is_none());
Expand Down Expand Up @@ -1060,6 +1078,11 @@ mod tests {
new_config.hrmp_max_message_num_per_candidate,
)
.unwrap();
Configuration::set_ump_max_individual_weight(
Origin::root(),
new_config.ump_max_individual_weight,
)
.unwrap();

assert_eq!(
<Configuration as Store>::PendingConfig::get(shared::SESSION_DELAY),
Expand Down