Skip to content

Commit

Permalink
Add Method to Establish HRMP Channels Among System Parachains (#1473)
Browse files Browse the repository at this point in the history
Solution to establish HRMP channels between system parachains.

---------

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>
  • Loading branch information
joepetrowski and muharem committed Sep 19, 2023
1 parent f3061c1 commit 2d96c8d
Show file tree
Hide file tree
Showing 9 changed files with 592 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,6 @@ fn force_open_hrmp_channel_for_system_para_works() {
// Parachain A init values
let para_a_id = PenpalKusamaA::para_id();

let fund_amount = KUSAMA_ED * 1000_000_000;

// Fund Parachain's Sovereign accounts to be able to reserve the deposit
let para_a_sovereign_account = Kusama::fund_para_sovereign(fund_amount, para_a_id);
let system_para_sovereign_account = Kusama::fund_para_sovereign(fund_amount, system_para_id);

Kusama::execute_with(|| {
assert_ok!(<Kusama as KusamaPallet>::Hrmp::force_open_hrmp_channel(
relay_root_origin,
Expand All @@ -179,14 +173,6 @@ fn force_open_hrmp_channel_for_system_para_works() {
assert_expected_events!(
Kusama,
vec![
// Sender deposit is reserved for System Parachain's Sovereign account
RuntimeEvent::Balances(pallet_balances::Event::Reserved { who, .. }) =>{
who: *who == system_para_sovereign_account,
},
// Recipient deposit is reserved for Parachain's Sovereign account
RuntimeEvent::Balances(pallet_balances::Event::Reserved { who, .. }) =>{
who: *who == para_a_sovereign_account,
},
// HRMP channel forced opened
RuntimeEvent::Hrmp(
polkadot_runtime_parachains::hrmp::Event::HrmpChannelForceOpened(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,6 @@ fn force_open_hrmp_channel_for_system_para_works() {
// Parachain A init values
let para_a_id = PenpalPolkadotA::para_id();

let fund_amount = POLKADOT_ED * 1000_000_000;

// Fund Parachain's Sovereign accounts to be able to reserve the deposit
let system_para_sovereign_account = Polkadot::fund_para_sovereign(fund_amount, system_para_id);
let para_a_sovereign_account = Polkadot::fund_para_sovereign(fund_amount, para_a_id);

Polkadot::execute_with(|| {
assert_ok!(<Polkadot as PolkadotPallet>::Hrmp::force_open_hrmp_channel(
relay_root_origin,
Expand All @@ -179,14 +173,6 @@ fn force_open_hrmp_channel_for_system_para_works() {
assert_expected_events!(
Polkadot,
vec![
// Sender deposit is reserved for System Parachain's Sovereign account
RuntimeEvent::Balances(pallet_balances::Event::Reserved { who, .. }) =>{
who: *who == system_para_sovereign_account,
},
// Recipient deposit is reserved for Parachain's Sovereign account
RuntimeEvent::Balances(pallet_balances::Event::Reserved { who, .. }) =>{
who: *who == para_a_sovereign_account,
},
// HRMP channel forced opened
RuntimeEvent::Hrmp(
polkadot_runtime_parachains::hrmp::Event::HrmpChannelForceOpened(
Expand Down
42 changes: 42 additions & 0 deletions polkadot/runtime/kusama/src/weights/runtime_parachains_hrmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,46 @@ impl<T: frame_system::Config> runtime_parachains::hrmp::WeightInfo for WeightInf
.saturating_add(T::DbWeight::get().reads(13))
.saturating_add(T::DbWeight::get().writes(8))
}
/// Storage: `Paras::ParaLifecycles` (r:1 w:0)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequests` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannels` (r:1 w:0)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpEgressChannelsIndex` (r:1 w:0)
/// Proof: `Hrmp::HrmpEgressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestCount` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestsList` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestsList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:2 w:2)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:2 w:2)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpIngressChannelsIndex` (r:1 w:0)
/// Proof: `Hrmp::HrmpIngressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpAcceptedChannelRequestCount` (r:1 w:1)
/// Proof: `Hrmp::HrmpAcceptedChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn establish_system_channel() -> Weight {
// Proof Size summary in bytes:
// Measured: `417`
// Estimated: `6357`
// Minimum execution time: 629_674_000 picoseconds.
Weight::from_parts(640_174_000, 0)
.saturating_add(Weight::from_parts(0, 6357))
.saturating_add(T::DbWeight::get().reads(12))
.saturating_add(T::DbWeight::get().writes(8))
}
/// Storage: `Hrmp::HrmpChannels` (r:1 w:1)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn poke_channel_deposits() -> Weight {
// Proof Size summary in bytes:
// Measured: `263`
// Estimated: `3728`
// Minimum execution time: 173_371_000 picoseconds.
Weight::from_parts(175_860_000, 0)
.saturating_add(Weight::from_parts(0, 3728))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}

0 comments on commit 2d96c8d

Please sign in to comment.