Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
1 change: 1 addition & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,7 @@ impl parachains_dmp::Config for Runtime {}
impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type ChannelManager = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
type Currency = Balances;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
}
Expand Down
45 changes: 27 additions & 18 deletions runtime/parachains/src/hrmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ pub mod pallet {
+ From<<Self as frame_system::Config>::RuntimeOrigin>
+ Into<Result<crate::Origin, <Self as Config>::RuntimeOrigin>>;

/// The origin that can perform "force" actions on channels.
type ChannelManager: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;

/// An interface for reserving deposits for opening channels.
///
/// NOTE that this Currency instance will be charged with the amounts defined in the
Expand Down Expand Up @@ -511,13 +514,13 @@ pub mod pallet {
Ok(())
}

/// This extrinsic triggers the cleanup of all the HRMP storage items that
/// a para may have. Normally this happens once per session, but this allows
/// you to trigger the cleanup immediately for a specific parachain.
/// This extrinsic triggers the cleanup of all the HRMP storage items that a para may have.
/// Normally this happens once per session, but this allows you to trigger the cleanup
/// immediately for a specific parachain.
///
/// Origin must be Root.
/// Number of inbound and outbound channels for `para` must be provided as witness data.
///
/// Number of inbound and outbound channels for `para` must be provided as witness data of weighing.
/// Origin must be the `ChannelManager`.
#[pallet::call_index(3)]
#[pallet::weight(<T as Config>::WeightInfo::force_clean_hrmp(*_inbound, *_outbound))]
pub fn force_clean_hrmp(
Expand All @@ -526,36 +529,40 @@ pub mod pallet {
_inbound: u32,
_outbound: u32,
) -> DispatchResult {
ensure_root(origin)?;
T::ChannelManager::ensure_origin(origin)?;
Self::clean_hrmp_after_outgoing(&para);
Ok(())
}

/// Force process HRMP open channel requests.
///
/// If there are pending HRMP open channel requests, you can use this
/// function process all of those requests immediately.
/// If there are pending HRMP open channel requests, you can use this function to process
/// all of those requests immediately.
///
/// Total number of opening channels must be provided as witness data.
///
/// Total number of opening channels must be provided as witness data of weighing.
/// Origin must be the `ChannelManager`.
#[pallet::call_index(4)]
#[pallet::weight(<T as Config>::WeightInfo::force_process_hrmp_open(*_channels))]
pub fn force_process_hrmp_open(origin: OriginFor<T>, _channels: u32) -> DispatchResult {
ensure_root(origin)?;
T::ChannelManager::ensure_origin(origin)?;
let host_config = configuration::Pallet::<T>::config();
Self::process_hrmp_open_channel_requests(&host_config);
Ok(())
}

/// Force process HRMP close channel requests.
///
/// If there are pending HRMP close channel requests, you can use this
/// function process all of those requests immediately.
/// If there are pending HRMP close channel requests, you can use this function to process
/// all of those requests immediately.
///
/// Total number of closing channels must be provided as witness data of weighing.
/// Total number of closing channels must be provided as witness data.
///
/// Origin must be the `ChannelManager`.
#[pallet::call_index(5)]
#[pallet::weight(<T as Config>::WeightInfo::force_process_hrmp_close(*_channels))]
pub fn force_process_hrmp_close(origin: OriginFor<T>, _channels: u32) -> DispatchResult {
ensure_root(origin)?;
T::ChannelManager::ensure_origin(origin)?;
Self::process_hrmp_close_channel_requests();
Ok(())
}
Expand Down Expand Up @@ -586,12 +593,14 @@ pub mod pallet {
Ok(())
}

/// Open a channel from a `sender` to a `recipient` `ParaId` using the Root origin. Although
/// opened by Root, the `max_capacity` and `max_message_size` are still subject to the Relay
/// Chain's configured limits.
/// Open a channel from a `sender` to a `recipient` `ParaId`. Although opened by governance,
/// the `max_capacity` and `max_message_size` are still subject to the Relay Chain's
/// configured limits.
///
/// Expected use is when one of the `ParaId`s involved in the channel is governed by the
/// Relay Chain, e.g. a system parachain.
///
/// Origin must be the `ChannelManager`.
#[pallet::call_index(7)]
#[pallet::weight(<T as Config>::WeightInfo::force_open_hrmp_channel(1))]
pub fn force_open_hrmp_channel(
Expand All @@ -601,7 +610,7 @@ pub mod pallet {
max_capacity: u32,
max_message_size: u32,
) -> DispatchResultWithPostInfo {
ensure_root(origin)?;
T::ChannelManager::ensure_origin(origin)?;

// Guard against a common footgun where someone makes a channel request to a system
// parachain and then makes a proposal to open the channel via governance, which fails
Expand Down
1 change: 1 addition & 0 deletions runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ parameter_types! {
impl crate::hrmp::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type ChannelManager = frame_system::EnsureRoot<u64>;
type Currency = pallet_balances::Pallet<Test>;
type WeightInfo = crate::hrmp::TestWeightInfo;
}
Expand Down
1 change: 1 addition & 0 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,7 @@ impl parachains_dmp::Config for Runtime {}
impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type ChannelManager = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
type Currency = Balances;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
}
Expand Down
1 change: 1 addition & 0 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ impl parachains_dmp::Config for Runtime {}
impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type ChannelManager = EnsureRoot<AccountId>;
type Currency = Balances;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
}
Expand Down
1 change: 1 addition & 0 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ parameter_types! {
impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type ChannelManager = frame_system::EnsureRoot<AccountId>;
type Currency = Balances;
type WeightInfo = parachains_hrmp::TestWeightInfo;
}
Expand Down
1 change: 1 addition & 0 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ impl parachains_dmp::Config for Runtime {}
impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type ChannelManager = EnsureRoot<AccountId>;
type Currency = Balances;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
}
Expand Down