From a4a4d20d4c2a8a6e90985624a560786ab22cf2e3 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 7 Apr 2021 15:21:00 +0200 Subject: [PATCH] Add Root Functions to HRMP (#2785) * Update hrmp.rs * add root functions --- polkadot/runtime/parachains/src/hrmp.rs | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/polkadot/runtime/parachains/src/hrmp.rs b/polkadot/runtime/parachains/src/hrmp.rs index e7116ebecc..d7244fb2ab 100644 --- a/polkadot/runtime/parachains/src/hrmp.rs +++ b/polkadot/runtime/parachains/src/hrmp.rs @@ -24,6 +24,7 @@ use frame_support::{ decl_storage, decl_module, decl_error, decl_event, ensure, traits::{Get, ReservableCurrency}, weights::Weight, StorageMap, StorageValue, dispatch::DispatchResult, }; +use frame_system::ensure_root; use primitives::v1::{ Balance, Hash, HrmpChannelId, Id as ParaId, InboundHrmpMessage, OutboundHrmpMessage, SessionIndex, @@ -409,6 +410,41 @@ decl_module! { Self::deposit_event(Event::ChannelClosed(origin, channel_id)); 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. + /// + /// Origin must be Root. + #[weight = 0] + pub fn force_clean_hrmp(origin, para: ParaId) -> DispatchResult { + ensure_root(origin)?; + Self::clean_hrmp_after_outgoing(¶); + 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. + #[weight = 0] + pub fn force_process_hrmp_open(origin) -> DispatchResult { + ensure_root(origin)?; + let host_config = configuration::Module::::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. + #[weight = 0] + pub fn force_process_hrmp_close(origin) -> DispatchResult { + ensure_root(origin)?; + Self::process_hrmp_close_channel_requests(); + Ok(()) + } } }