From e1f432af67d4191f94a18d1a935794949dbacde5 Mon Sep 17 00:00:00 2001 From: Stanly Johnson Date: Sun, 27 Feb 2022 17:52:21 +0400 Subject: [PATCH 1/3] add sudo call to establish hrmp channel --- runtime/parachains/src/hrmp.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/runtime/parachains/src/hrmp.rs b/runtime/parachains/src/hrmp.rs index 025addbc9184..dc46cf758924 100644 --- a/runtime/parachains/src/hrmp.rs +++ b/runtime/parachains/src/hrmp.rs @@ -492,6 +492,29 @@ pub mod pallet { Ok(()) } + /// Sudo call to establish a channel from the sender to the recipient. + /// + /// This is equivalent to sending an `hrmp_init_open_channel` extrinsic followed by + /// `hrmp_accept_open_channel`. + #[pallet::weight(::WeightInfo::hrmp_init_open_channel() + ::WeightInfo::hrmp_accept_open_channel())] + pub fn sudo_establish_hrmp_channel( + origin: OriginFor, + sender: ParaId, + recipient: ParaId, + proposed_max_capacity: u32, + proposed_max_message_size: u32, + ) -> DispatchResult { + ensure_root(origin)?; + Self::init_open_channel( + sender, + recipient, + proposed_max_capacity, + proposed_max_message_size, + )?; + Self::accept_open_channel(recipient, sender)?; + Ok(()) + } + /// Initiate unilateral closing of a channel. The origin must be either the sender or the /// recipient in the channel being closed. /// From 9f8dcf3e6f1dbc5bcc1377eff5c7099bece8393f Mon Sep 17 00:00:00 2001 From: stanly Date: Mon, 28 Feb 2022 00:03:52 +0400 Subject: [PATCH 2/3] Update runtime/parachains/src/hrmp.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- runtime/parachains/src/hrmp.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/parachains/src/hrmp.rs b/runtime/parachains/src/hrmp.rs index dc46cf758924..8b3f696090a7 100644 --- a/runtime/parachains/src/hrmp.rs +++ b/runtime/parachains/src/hrmp.rs @@ -492,12 +492,14 @@ pub mod pallet { Ok(()) } - /// Sudo call to establish a channel from the sender to the recipient. + /// Call to establish a channel from the sender to the recipient. /// /// This is equivalent to sending an `hrmp_init_open_channel` extrinsic followed by /// `hrmp_accept_open_channel`. + /// + /// Origin must be Root. #[pallet::weight(::WeightInfo::hrmp_init_open_channel() + ::WeightInfo::hrmp_accept_open_channel())] - pub fn sudo_establish_hrmp_channel( + pub fn force_establish_hrmp_channel( origin: OriginFor, sender: ParaId, recipient: ParaId, From 53fec01d32a816c4c9835b8a72456690020bf6d0 Mon Sep 17 00:00:00 2001 From: stanly Date: Mon, 28 Feb 2022 00:03:58 +0400 Subject: [PATCH 3/3] Update runtime/parachains/src/hrmp.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- runtime/parachains/src/hrmp.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/parachains/src/hrmp.rs b/runtime/parachains/src/hrmp.rs index 8b3f696090a7..1895809c0e04 100644 --- a/runtime/parachains/src/hrmp.rs +++ b/runtime/parachains/src/hrmp.rs @@ -513,8 +513,7 @@ pub mod pallet { proposed_max_capacity, proposed_max_message_size, )?; - Self::accept_open_channel(recipient, sender)?; - Ok(()) + Self::accept_open_channel(recipient, sender) } /// Initiate unilateral closing of a channel. The origin must be either the sender or the