From fafe2722a1a015cf59ef7d09c13836a88ddbc621 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Tue, 30 Jan 2024 13:50:35 +0100 Subject: [PATCH] Revert "[Runtime] Bound XCMP queue" (#3117) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverts paritytech/polkadot-sdk#2302. 🤦‍♂️ should have checked the migration CI first. We either need to reduce the `max_message_size` for the open HRMP channels on the failing chains or increase the `PageSize` of the XCMP queue. Both would be fine on a test-net, but i assume this will also fail before the next SP runtime upgrade so first need to think what best to do. AFAIK its not possible currently to change the `max_message_size` of an open HRMP channel. --- cumulus/pallets/parachain-system/src/lib.rs | 9 +- cumulus/pallets/xcmp-queue/src/lib.rs | 105 ++++------------ cumulus/pallets/xcmp-queue/src/migration.rs | 26 ++-- .../pallets/xcmp-queue/src/migration/v5.rs | 115 ------------------ cumulus/pallets/xcmp-queue/src/mock.rs | 4 +- cumulus/pallets/xcmp-queue/src/tests.rs | 2 +- cumulus/parachain-template/runtime/src/lib.rs | 4 +- .../assets/asset-hub-rococo/src/lib.rs | 13 +- .../assets/asset-hub-westend/src/lib.rs | 13 +- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 12 +- .../bridge-hubs/bridge-hub-westend/src/lib.rs | 13 +- .../collectives-westend/src/lib.rs | 13 +- .../contracts/contracts-rococo/src/lib.rs | 3 +- .../contracts-rococo/src/xcm_config.rs | 9 +- .../coretime/coretime-rococo/src/lib.rs | 14 +-- .../coretime/coretime-westend/src/lib.rs | 9 +- .../runtimes/people/people-rococo/src/lib.rs | 9 +- .../runtimes/people/people-westend/src/lib.rs | 9 +- .../runtimes/testing/penpal/src/lib.rs | 4 +- .../testing/rococo-parachain/src/lib.rs | 4 +- cumulus/primitives/core/src/lib.rs | 8 -- polkadot/parachain/src/primitives.rs | 14 +-- prdoc/pr_2302.prdoc | 20 --- 23 files changed, 65 insertions(+), 367 deletions(-) delete mode 100644 cumulus/pallets/xcmp-queue/src/migration/v5.rs delete mode 100644 prdoc/pr_2302.prdoc diff --git a/cumulus/pallets/parachain-system/src/lib.rs b/cumulus/pallets/parachain-system/src/lib.rs index 05b9dd3c3b..5a0fa57fb1 100644 --- a/cumulus/pallets/parachain-system/src/lib.rs +++ b/cumulus/pallets/parachain-system/src/lib.rs @@ -30,7 +30,7 @@ use codec::{Decode, Encode}; use cumulus_primitives_core::{ relay_chain, AbridgedHostConfiguration, ChannelInfo, ChannelStatus, CollationInfo, - GetChannelInfo, InboundDownwardMessage, InboundHrmpMessage, ListChannelInfos, MessageSendError, + GetChannelInfo, InboundDownwardMessage, InboundHrmpMessage, MessageSendError, OutboundHrmpMessage, ParaId, PersistedValidationData, UpwardMessage, UpwardMessageSender, XcmpMessageHandler, XcmpMessageSource, }; @@ -1023,13 +1023,6 @@ impl FeeTracker for Pallet { } } -impl ListChannelInfos for Pallet { - fn outgoing_channels() -> Vec { - let Some(state) = Self::relevant_messaging_state() else { return Vec::new() }; - state.egress_channels.into_iter().map(|(id, _)| id).collect() - } -} - impl GetChannelInfo for Pallet { fn get_channel_status(id: ParaId) -> ChannelStatus { // Note, that we are using `relevant_messaging_state` which may be from the previous diff --git a/cumulus/pallets/xcmp-queue/src/lib.rs b/cumulus/pallets/xcmp-queue/src/lib.rs index 0460015da1..5b90076962 100644 --- a/cumulus/pallets/xcmp-queue/src/lib.rs +++ b/cumulus/pallets/xcmp-queue/src/lib.rs @@ -51,7 +51,7 @@ pub mod weights; pub use weights::WeightInfo; use bounded_collections::BoundedBTreeSet; -use codec::{Decode, DecodeLimit, Encode, MaxEncodedLen}; +use codec::{Decode, DecodeLimit, Encode}; use cumulus_primitives_core::{ relay_chain::BlockNumber as RelayBlockNumber, ChannelStatus, GetChannelInfo, MessageSendError, ParaId, XcmpMessageFormat, XcmpMessageHandler, XcmpMessageSource, @@ -105,6 +105,7 @@ pub mod pallet { #[pallet::pallet] #[pallet::storage_version(migration::STORAGE_VERSION)] + #[pallet::without_storage_info] pub struct Pallet(_); #[pallet::config] @@ -131,25 +132,6 @@ pub mod pallet { #[pallet::constant] type MaxInboundSuspended: Get; - /// Maximal number of outbound XCMP channels that can have messages queued at the same time. - /// - /// If this is reached, then no further messages can be sent to channels that do not yet - /// have a message queued. This should be set to the expected maximum of outbound channels - /// which is determined by [`Self::ChannelInfo`]. It is important to set this correctly, - /// since otherwise the congestion control protocol will not work as intended and messages - /// may be dropped. This value increases the PoV and should therefore not be picked too - /// high. - #[pallet::constant] - type MaxActiveOutboundChannels: Get; - - /// The maximal page size for HRMP message pages. - /// - /// A lower limit can be set dynamically, but this is the hard-limit for the PoV worst case - /// benchmarking. The limit for the size of a message is slightly below this, since some - /// overhead is incurred for encoding the format. - #[pallet::constant] - type MaxPageSize: Get; - /// The origin that is allowed to resume or suspend the XCMP queue. type ControllerOrigin: EnsureOrigin; @@ -294,10 +276,6 @@ pub mod pallet { AlreadySuspended, /// The execution is already resumed. AlreadyResumed, - /// There are too many active outbound channels. - TooManyOutboundChannels, - /// The message is too big. - TooBig, } /// The suspended inbound XCMP channels. All others are not suspended. @@ -319,28 +297,19 @@ pub mod pallet { /// case of the need to send a high-priority signal message this block. /// The bool is true if there is a signal message waiting to be sent. #[pallet::storage] - pub(super) type OutboundXcmpStatus = StorageValue< - _, - BoundedVec, - ValueQuery, - >; + pub(super) type OutboundXcmpStatus = + StorageValue<_, Vec, ValueQuery>; + // The new way of doing it: /// The messages outbound in a given XCMP channel. #[pallet::storage] - pub(super) type OutboundXcmpMessages = StorageDoubleMap< - _, - Blake2_128Concat, - ParaId, - Twox64Concat, - u16, - BoundedVec, - ValueQuery, - >; + pub(super) type OutboundXcmpMessages = + StorageDoubleMap<_, Blake2_128Concat, ParaId, Twox64Concat, u16, Vec, ValueQuery>; /// Any signal messages waiting to be sent. #[pallet::storage] pub(super) type SignalMessages = - StorageMap<_, Blake2_128Concat, ParaId, BoundedVec, ValueQuery>; + StorageMap<_, Blake2_128Concat, ParaId, Vec, ValueQuery>; /// The configuration which controls the dynamics of the outbound queue. #[pallet::storage] @@ -362,14 +331,15 @@ pub mod pallet { StorageMap<_, Twox64Concat, ParaId, FixedU128, ValueQuery, InitialFactor>; } -#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] +#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] pub enum OutboundState { Ok, Suspended, } /// Struct containing detailed information about the outbound channel. -#[derive(Clone, Eq, PartialEq, Encode, Decode, TypeInfo, RuntimeDebug, MaxEncodedLen)] +#[derive(Clone, Eq, PartialEq, Encode, Decode, TypeInfo)] +#[cfg_attr(feature = "std", derive(Debug))] pub struct OutboundChannelDetails { /// The `ParaId` of the parachain that this channel is connected with. recipient: ParaId, @@ -405,7 +375,7 @@ impl OutboundChannelDetails { } } -#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] +#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] pub struct QueueConfigData { /// The number of pages which must be in the queue for the other side to be told to suspend /// their sending. @@ -508,9 +478,7 @@ impl Pallet { { details } else { - all_channels - .try_push(OutboundChannelDetails::new(recipient)) - .map_err(|_| MessageSendError::TooManyChannels)?; + all_channels.push(OutboundChannelDetails::new(recipient)); all_channels .last_mut() .expect("can't be empty; a new element was just pushed; qed") @@ -535,7 +503,7 @@ impl Pallet { if page.len() + encoded_fragment.len() > max_message_size { return None } - page.try_extend(encoded_fragment.iter().cloned()).ok()?; + page.extend_from_slice(&encoded_fragment[..]); Some(page.len()) }, ) @@ -553,9 +521,7 @@ impl Pallet { new_page.extend_from_slice(&encoded_fragment[..]); let last_page_size = new_page.len(); let number_of_pages = (channel_details.last_index - channel_details.first_index) as u32; - let bounded_page = - BoundedVec::try_from(new_page).map_err(|_| MessageSendError::TooBig)?; - >::insert(recipient, page_index, bounded_page); + >::insert(recipient, page_index, new_page); >::put(all_channels); (number_of_pages, last_page_size) }; @@ -577,21 +543,17 @@ impl Pallet { /// Sends a signal to the `dest` chain over XCMP. This is guaranteed to be dispatched on this /// block. - fn send_signal(dest: ParaId, signal: ChannelSignal) -> Result<(), Error> { + fn send_signal(dest: ParaId, signal: ChannelSignal) { let mut s = >::get(); if let Some(details) = s.iter_mut().find(|item| item.recipient == dest) { details.signals_exist = true; } else { - s.try_push(OutboundChannelDetails::new(dest).with_signals()) - .map_err(|_| Error::::TooManyOutboundChannels)?; + s.push(OutboundChannelDetails::new(dest).with_signals()); } - - let page = BoundedVec::try_from((XcmpMessageFormat::Signals, signal).encode()) - .map_err(|_| Error::::TooBig)?; - - >::insert(dest, page); + >::mutate(dest, |page| { + *page = (XcmpMessageFormat::Signals, signal).encode(); + }); >::put(s); - Ok(()) } fn suspend_channel(target: ParaId) { @@ -601,13 +563,7 @@ impl Pallet { defensive_assert!(ok, "WARNING: Attempt to suspend channel that was not Ok."); details.state = OutboundState::Suspended; } else { - if s.try_push(OutboundChannelDetails::new(target).with_suspended_state()).is_err() { - // Nothing that we can do here. The outbound channel does not exist either, so - // there should be no message going out as well. The next time that the channel - // can be created it will again get the suspension from the remote side. It can - // therefore result in a few lost messages, but should eventually self-repair. - defensive!("Cannot pause channel; too many outbound channels"); - } + s.push(OutboundChannelDetails::new(target).with_suspended_state()); } }); } @@ -708,17 +664,13 @@ impl OnQueueChanged for Pallet { let suspended = suspended_channels.contains(¶); if suspended && fp.pages <= resume_threshold { - // If the resuming fails then it is not critical. We will retry in the future. - let _ = Self::send_signal(para, ChannelSignal::Resume); + Self::send_signal(para, ChannelSignal::Resume); suspended_channels.remove(¶); >::put(suspended_channels); } else if !suspended && fp.pages >= suspend_threshold { log::warn!("XCMP queue for sibling {:?} is full; suspending channel.", para); - if let Err(_) = Self::send_signal(para, ChannelSignal::Suspend) { - // It will retry if `drop_threshold` is not reached, but it could be too late. - defensive!("Could not send suspension signal; future messages may be dropped."); - } + Self::send_signal(para, ChannelSignal::Suspend); if let Err(err) = suspended_channels.try_insert(para) { log::error!("Too many channels suspended; cannot suspend sibling {:?}: {:?}; further messages may be dropped.", para, err); @@ -890,7 +842,7 @@ impl XcmpMessageSource for Pallet { // since it's so unlikely then for now we just drop it. defensive!("WARNING: oversize message in queue - dropping"); } else { - result.push((para_id, page.into_inner())); + result.push((para_id, page)); } let max_total_size = match T::ChannelInfo::get_channel_info(para_id) { @@ -938,14 +890,7 @@ impl XcmpMessageSource for Pallet { let pruned = old_statuses_len - statuses.len(); // removing an item from status implies a message being sent, so the result messages must // be no less than the pruned channels. - - // TODO - { - let mut statuses_inner = statuses.into_inner(); - statuses_inner.rotate_left(result.len().saturating_sub(pruned)); - statuses = BoundedVec::try_from(statuses_inner) - .expect("Rotating does not change the length; it still fits; qed"); - } + statuses.rotate_left(result.len().saturating_sub(pruned)); >::put(statuses); diff --git a/cumulus/pallets/xcmp-queue/src/migration.rs b/cumulus/pallets/xcmp-queue/src/migration.rs index 7d46ded57a..6c86c3011d 100644 --- a/cumulus/pallets/xcmp-queue/src/migration.rs +++ b/cumulus/pallets/xcmp-queue/src/migration.rs @@ -16,8 +16,6 @@ //! A module that is responsible for migration of storage. -pub mod v5; - use crate::{Config, OverweightIndex, Pallet, QueueConfig, QueueConfigData, DEFAULT_POV_SIZE}; use cumulus_primitives_core::XcmpMessageFormat; use frame_support::{ @@ -27,7 +25,7 @@ use frame_support::{ }; /// The current storage version. -pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(5); +pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); pub const LOG: &str = "runtime::xcmp-queue-migration"; @@ -266,9 +264,9 @@ pub mod v4 { /// Migrates `QueueConfigData` to v4, removing deprecated fields and bumping page /// thresholds to at least the default values. - pub struct UncheckedMigrateV3ToV4(PhantomData); + pub struct UncheckedMigrationToV4(PhantomData); - impl OnRuntimeUpgrade for UncheckedMigrateV3ToV4 { + impl OnRuntimeUpgrade for UncheckedMigrationToV4 { fn on_runtime_upgrade() -> Weight { let translate = |pre: v2::QueueConfigData| -> QueueConfigData { let pre_default = v2::QueueConfigData::default(); @@ -301,13 +299,13 @@ pub mod v4 { } } - /// [`UncheckedMigrateV3ToV4`] wrapped in a + /// [`UncheckedMigrationToV4`] wrapped in a /// [`VersionedMigration`](frame_support::migrations::VersionedMigration), ensuring the /// migration is only performed when on-chain version is 3. - pub type MigrateV3ToV4 = frame_support::migrations::VersionedMigration< + pub type MigrationToV4 = frame_support::migrations::VersionedMigration< 3, 4, - UncheckedMigrateV3ToV4, + UncheckedMigrationToV4, Pallet, ::DbWeight, >; @@ -374,10 +372,10 @@ mod tests { &v2.encode(), ); - let bytes = v4::MigrateV3ToV4::::pre_upgrade(); + let bytes = v4::MigrationToV4::::pre_upgrade(); assert!(bytes.is_ok()); - v4::MigrateV3ToV4::::on_runtime_upgrade(); - assert!(v4::MigrateV3ToV4::::post_upgrade(bytes.unwrap()).is_ok()); + v4::MigrationToV4::::on_runtime_upgrade(); + assert!(v4::MigrationToV4::::post_upgrade(bytes.unwrap()).is_ok()); let v4 = QueueConfig::::get(); @@ -403,10 +401,10 @@ mod tests { &v2.encode(), ); - let bytes = v4::MigrateV3ToV4::::pre_upgrade(); + let bytes = v4::MigrationToV4::::pre_upgrade(); assert!(bytes.is_ok()); - v4::MigrateV3ToV4::::on_runtime_upgrade(); - assert!(v4::MigrateV3ToV4::::post_upgrade(bytes.unwrap()).is_ok()); + v4::MigrationToV4::::on_runtime_upgrade(); + assert!(v4::MigrationToV4::::post_upgrade(bytes.unwrap()).is_ok()); let v4 = QueueConfig::::get(); diff --git a/cumulus/pallets/xcmp-queue/src/migration/v5.rs b/cumulus/pallets/xcmp-queue/src/migration/v5.rs deleted file mode 100644 index 789b82be33..0000000000 --- a/cumulus/pallets/xcmp-queue/src/migration/v5.rs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) Parity Technologies (UK) Ltd. -// This file is part of Polkadot. - -// Polkadot is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Polkadot is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Polkadot. If not, see . - -//! Migrates the storage to version 5. - -use crate::*; -use cumulus_primitives_core::ListChannelInfos; -use frame_support::{pallet_prelude::*, traits::OnRuntimeUpgrade}; - -/// Configs needed to run the V5 migration. -pub trait V5Config: Config { - /// List all outbound channels with their target `ParaId` and maximum message size. - type ChannelList: ListChannelInfos; -} - -/// Ensures that the storage migrates cleanly to V5. -/// -/// The migration itself is a no-op, but it checks that none of the `BoundedVec`s would truncate on -/// the next decode after the upgrade was applied. -pub type MigrateV4ToV5 = frame_support::migrations::VersionedMigration< - 4, - 5, - unversioned::UncheckedMigrateV4ToV5, - Pallet, - ::DbWeight, ->; - -// V4 storage aliases -mod v4 { - use super::*; - - #[frame_support::storage_alias] - pub(super) type OutboundXcmpStatus = - StorageValue, Vec, ValueQuery>; - - #[frame_support::storage_alias] - pub(super) type OutboundXcmpMessages = StorageDoubleMap< - Pallet, - Blake2_128Concat, - ParaId, - Twox64Concat, - u16, - Vec, - ValueQuery, - >; - - #[frame_support::storage_alias] - pub(super) type SignalMessages = - StorageMap, Blake2_128Concat, ParaId, Vec, ValueQuery>; -} - -// Private module to hide the migration. -mod unversioned { - /// Please use [`MigrateV4ToV5`] instead. - pub struct UncheckedMigrateV4ToV5(core::marker::PhantomData); -} - -impl OnRuntimeUpgrade for unversioned::UncheckedMigrateV4ToV5 { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - Default::default() - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(_: Vec) -> Result<(), sp_runtime::DispatchError> { - // We dont need any front-run protection for this since channels are opened by governance. - ensure!( - v4::OutboundXcmpStatus::::get().len() as u32 <= T::MaxActiveOutboundChannels::get(), - "Too many outbound channels. Close some channels or increase `MaxActiveOutboundChannels`." - ); - - // Check if any channels have a too large message max sizes. - let max_msg_len = T::MaxPageSize::get() - XcmpMessageFormat::max_encoded_len() as u32; - for channel in T::ChannelList::outgoing_channels() { - let info = T::ChannelInfo::get_channel_info(channel) - .expect("All listed channels must provide info"); - - ensure!( - info.max_message_size <= max_msg_len, - "Max message size for channel is too large. This means that the V5 migration can \ - be front-run and an attacker could place a large message just right before the \ - migration to make other messages un-decodable. Please either increase \ - `MaxPageSize` or decrease the `max_message_size` for this channel.", - ); - } - - // Now check that all pages still fit into the new `BoundedVec`s: - for page in v4::OutboundXcmpMessages::::iter_values() { - ensure!( - page.len() < T::MaxPageSize::get() as usize, - "Too long message in storage. Either manually truncate the pages or increase `MaxPageSize`." - ); - } - for page in v4::SignalMessages::::iter_values() { - ensure!( - page.len() < T::MaxPageSize::get() as usize, - "Too long signal in storage. Either manually truncate the pages or increase `MaxPageSize`." - ); - } - - Ok(()) - } -} diff --git a/cumulus/pallets/xcmp-queue/src/mock.rs b/cumulus/pallets/xcmp-queue/src/mock.rs index b47014a805..f8b89258f2 100644 --- a/cumulus/pallets/xcmp-queue/src/mock.rs +++ b/cumulus/pallets/xcmp-queue/src/mock.rs @@ -275,9 +275,7 @@ impl Config for Test { type ChannelInfo = MockedChannelInfo; type VersionWrapper = (); type XcmpQueue = EnqueueToLocalStorage>; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = SystemParachainAsSuperuser; type WeightInfo = (); diff --git a/cumulus/pallets/xcmp-queue/src/tests.rs b/cumulus/pallets/xcmp-queue/src/tests.rs index e1d7724564..0b41095828 100644 --- a/cumulus/pallets/xcmp-queue/src/tests.rs +++ b/cumulus/pallets/xcmp-queue/src/tests.rs @@ -520,7 +520,7 @@ fn hrmp_signals_are_prioritized() { }); // But a signal gets prioritized instead of the messages: - assert_ok!(XcmpQueue::send_signal(sibling_para_id.into(), ChannelSignal::Suspend)); + XcmpQueue::send_signal(sibling_para_id.into(), ChannelSignal::Suspend); let taken = XcmpQueue::take_outbound_messages(130); assert_eq!( diff --git a/cumulus/parachain-template/runtime/src/lib.rs b/cumulus/parachain-template/runtime/src/lib.rs index 980211a577..0ab36eba31 100644 --- a/cumulus/parachain-template/runtime/src/lib.rs +++ b/cumulus/parachain-template/runtime/src/lib.rs @@ -422,9 +422,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type VersionWrapper = (); // Enqueue XCMP messages from siblings for later processing. type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type WeightInfo = (); diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index df84a5f67e..d6f2f41ef3 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -716,19 +716,12 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = xcm_config::XcmOriginToTransactDispatchOrigin; type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; } -impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { - // This must be the same as the `ChannelInfo` from the `Config`: - type ChannelList = ParachainSystem; -} - parameter_types! { pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent; } @@ -1000,8 +993,8 @@ pub type UncheckedExtrinsic = pub type Migrations = ( pallet_collator_selection::migration::v1::MigrateToV1, InitStorageVersions, - cumulus_pallet_xcmp_queue::migration::v4::MigrateV3ToV4, - cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, + // unreleased + cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, ); /// Migration to initialize storage versions for pallets added after genesis. diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index f87798ff29..66d80fac83 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -668,20 +668,13 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type VersionWrapper = PolkadotXcm; // Enqueue XCMP messages from siblings for later processing. type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; } -impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { - // This must be the same as the `ChannelInfo` from the `Config`: - type ChannelList = ParachainSystem; -} - parameter_types! { pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent; } @@ -954,8 +947,8 @@ pub type Migrations = ( InitStorageVersions, // unreleased DeleteUndecodableStorage, - cumulus_pallet_xcmp_queue::migration::v4::MigrateV3ToV4, - cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, + // unreleased + cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, ); /// Asset Hub Westend has some undecodable storage, delete it. diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 895cb6e893..abe447a43b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -144,9 +144,8 @@ pub type Migrations = ( pallet_collator_selection::migration::v1::MigrateToV1, pallet_multisig::migrations::v1::MigrateToV1, InitStorageVersions, + cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, // unreleased - cumulus_pallet_xcmp_queue::migration::v4::MigrateV3ToV4, - cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, snowbridge_pallet_system::migration::v0::InitializeOnUpgrade< Runtime, ConstU32, @@ -406,20 +405,13 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type VersionWrapper = PolkadotXcm; // Enqueue XCMP messages from siblings for later processing. type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; } -impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { - // This must be the same as the `ChannelInfo` from the `Config`: - type ChannelList = ParachainSystem; -} - parameter_types! { pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent; } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 43c825383b..10058ef13b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -123,8 +123,8 @@ pub type Migrations = ( pallet_collator_selection::migration::v1::MigrateToV1, pallet_multisig::migrations::v1::MigrateToV1, InitStorageVersions, - cumulus_pallet_xcmp_queue::migration::v4::MigrateV3ToV4, - cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, + // unreleased + cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, ); /// Migration to initialize storage versions for pallets added after genesis. @@ -371,20 +371,13 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; } -impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { - // This must be the same as the `ChannelInfo` from the `Config`: - type ChannelList = ParachainSystem; -} - parameter_types! { pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent; } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index fb8e9ddf24..be7beafc89 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -445,20 +445,13 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type VersionWrapper = PolkadotXcm; // Enqueue XCMP messages from siblings for later processing. type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = EitherOfDiverse, Fellows>; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; } -impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { - // This must be the same as the `ChannelInfo` from the `Config`: - type ChannelList = ParachainSystem; -} - parameter_types! { pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent; } @@ -727,8 +720,8 @@ pub type UncheckedExtrinsic = type Migrations = ( // unreleased pallet_collator_selection::migration::v1::MigrateToV1, - cumulus_pallet_xcmp_queue::migration::v4::MigrateV3ToV4, - cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, + // unreleased + cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, ); /// Executive: handles dispatch to the various modules. diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs index 605fa72037..f1c5acb495 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs @@ -104,8 +104,7 @@ pub type Migrations = ( cumulus_pallet_xcmp_queue::migration::v3::MigrationToV3, pallet_contracts::Migration, // unreleased - cumulus_pallet_xcmp_queue::migration::v4::MigrateV3ToV4, - cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, + cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4, ); type EventRecord = frame_system::EventRecord< diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs index 9590f36e63..8c0d681361 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs @@ -281,9 +281,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { cumulus_primitives_core::ParaId, parachains_common::message_queue::ParaIdToSibling, >; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = EitherOfDiverse< EnsureRoot, EnsureXcm>, @@ -293,11 +291,6 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; } -impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { - // This must be the same as the `ChannelInfo` from the `Config`: - type ChannelList = ParachainSystem; -} - parameter_types! { pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent; } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index 06475849a5..531a0ffe4f 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -106,10 +106,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Migrations to apply on runtime upgrade. -pub type Migrations = ( - cumulus_pallet_xcmp_queue::migration::v4::MigrateV3ToV4, - cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5, -); +pub type Migrations = (cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4,); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -335,20 +332,13 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = RootOrFellows; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; } -impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { - // This must be the same as the `ChannelInfo` from the `Config`: - type ChannelList = ParachainSystem; -} - pub const PERIOD: u32 = 6 * HOURS; pub const OFFSET: u32 = 0; diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index 96b0d2b476..8924927241 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -323,20 +323,13 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = RootOrFellows; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; } -impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { - // This must be the same as the `ChannelInfo` from the `Config`: - type ChannelList = ParachainSystem; -} - pub const PERIOD: u32 = 6 * HOURS; pub const OFFSET: u32 = 0; diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs index c038f8b417..b21fdc6a68 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs @@ -301,20 +301,13 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = RootOrFellows; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; } -impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { - // This must be the same as the `ChannelInfo` from the `Config`: - type ChannelList = ParachainSystem; -} - pub const PERIOD: u32 = 6 * HOURS; pub const OFFSET: u32 = 0; diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index 4d1f82be97..20d8973417 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -301,20 +301,13 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type ChannelInfo = ParachainSystem; type VersionWrapper = PolkadotXcm; type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = RootOrFellows; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo; type PriceForSiblingDelivery = PriceForSiblingParachainDelivery; } -impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { - // This must be the same as the `ChannelInfo` from the `Config`: - type ChannelList = ParachainSystem; -} - pub const PERIOD: u32 = 6 * HOURS; pub const OFFSET: u32 = 0; diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index e38ef33821..d33f51df5a 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -549,9 +549,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type VersionWrapper = PolkadotXcm; // Enqueue XCMP messages from siblings for later processing. type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type WeightInfo = (); diff --git a/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs b/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs index 985cccdf53..253a492871 100644 --- a/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/rococo-parachain/src/lib.rs @@ -542,9 +542,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime { type VersionWrapper = (); // Enqueue XCMP messages from siblings for later processing. type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = ConstU32<1_000>; - type MaxActiveOutboundChannels = ConstU32<128>; - type MaxPageSize = ConstU32<{ 1 << 16 }>; + type MaxInboundSuspended = sp_core::ConstU32<1_000>; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; diff --git a/cumulus/primitives/core/src/lib.rs b/cumulus/primitives/core/src/lib.rs index 29216d5134..7f73536856 100644 --- a/cumulus/primitives/core/src/lib.rs +++ b/cumulus/primitives/core/src/lib.rs @@ -64,8 +64,6 @@ pub enum MessageSendError { TooBig, /// Some other error. Other, - /// There are too many channels open at once. - TooManyChannels, } impl From for &'static str { @@ -76,7 +74,6 @@ impl From for &'static str { NoChannel => "NoChannel", TooBig => "TooBig", Other => "Other", - TooManyChannels => "TooManyChannels", } } } @@ -138,11 +135,6 @@ pub trait GetChannelInfo { fn get_channel_info(id: ParaId) -> Option; } -/// List all open outgoing channels. -pub trait ListChannelInfos { - fn outgoing_channels() -> Vec; -} - /// Something that should be called when sending an upward message. pub trait UpwardMessageSender { /// Send the given UMP message; return the expected number of blocks before the message will diff --git a/polkadot/parachain/src/primitives.rs b/polkadot/parachain/src/primitives.rs index 2764384363..5a1efdf898 100644 --- a/polkadot/parachain/src/primitives.rs +++ b/polkadot/parachain/src/primitives.rs @@ -333,19 +333,7 @@ impl DmpMessageHandler for () { } /// The aggregate XCMP message format. -#[derive( - Copy, - Clone, - Eq, - PartialEq, - Ord, - PartialOrd, - Encode, - Decode, - TypeInfo, - RuntimeDebug, - MaxEncodedLen, -)] +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, TypeInfo, RuntimeDebug)] pub enum XcmpMessageFormat { /// Encoded `VersionedXcm` messages, all concatenated. ConcatenatedVersionedXcm, diff --git a/prdoc/pr_2302.prdoc b/prdoc/pr_2302.prdoc deleted file mode 100644 index b11129b9ed..0000000000 --- a/prdoc/pr_2302.prdoc +++ /dev/null @@ -1,20 +0,0 @@ -title: Storage bound the XCMP queue pallet - -doc: - - audience: Runtime Dev - description: | - Enforce upper limits for the number of suspended channels and on - the number of channels that have messages pending. This is needed to use - the worst-case PoV benchmarking. - -migrations: - db: [] - - runtime: - - reference: cumulus_pallet_xcmp_queue::migration::v5::MigrateV4ToV5 - description: A No-OP migration is deployed to ensure that all `BoundedVec`s` still decode as expected. - -crates: - - name: cumulus-pallet-xcmp-queue - -host_functions: []