Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Method to Establish HRMP Channels Among System Parachains #1473

Merged
merged 23 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a03fd64
initial solution
joepetrowski Sep 8, 2023
88f73bd
Merge remote-tracking branch 'origin' into joe-system-hrmp-establishment
joepetrowski Sep 8, 2023
ffc4fdf
fix signatures in benchmarks
joepetrowski Sep 8, 2023
fd32120
add benchmark
joepetrowski Sep 8, 2023
5f0bfd9
add dummy to weight impl
joepetrowski Sep 8, 2023
8a4d579
fix and add tests
joepetrowski Sep 9, 2023
eb28866
Merge remote-tracking branch 'origin' into joe-system-hrmp-establishment
joepetrowski Sep 9, 2023
7cfd74e
fix benchmark
joepetrowski Sep 9, 2023
e3bc6ea
add poke fn to update deposits when config changes
joepetrowski Sep 10, 2023
71a387d
reasonable weights
joepetrowski Sep 10, 2023
e514265
missing brace
joepetrowski Sep 10, 2023
7bbaf66
do system checks in init/accept, not caller
joepetrowski Sep 10, 2023
c5e1621
add PR1407 change to identify system chains
joepetrowski Sep 11, 2023
b1be601
add test for poke
joepetrowski Sep 13, 2023
b236b53
Merge remote-tracking branch 'origin' into joe-system-hrmp-establishment
joepetrowski Sep 13, 2023
9fa4cbf
update comment
joepetrowski Sep 13, 2023
ae880f2
Merge branch 'master' into joe-system-hrmp-establishment
joepetrowski Sep 15, 2023
1275130
Merge branch 'master' into joe-system-hrmp-establishment
joepetrowski Sep 18, 2023
8b26281
Update polkadot/runtime/parachains/src/hrmp.rs
joepetrowski Sep 18, 2023
0b59b49
Merge branch 'master' into joe-system-hrmp-establishment
joepetrowski Sep 18, 2023
67815c0
don't saturate in conversion
joepetrowski Sep 18, 2023
6740c68
docs update
joepetrowski Sep 19, 2023
43809aa
Merge branch 'master' into joe-system-hrmp-establishment
joepetrowski Sep 19, 2023
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
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
9 changes: 5 additions & 4 deletions polkadot/parachain/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,14 @@ impl From<i32> for Id {
}
}

const USER_INDEX_START: u32 = 1000;
// System parachain ID is considered `< 2000`.
const SYSTEM_INDEX_END: u32 = 1999;
const PUBLIC_INDEX_START: u32 = 2000;

/// The ID of the first user (non-system) parachain.
pub const LOWEST_USER_ID: Id = Id(USER_INDEX_START);
pub const LOWEST_USER_ID: Id = Id(PUBLIC_INDEX_START);

/// The ID of the first publicly registerable parachain.
/// The ID of the first publicly registrable parachain.
pub const LOWEST_PUBLIC_ID: Id = Id(PUBLIC_INDEX_START);

impl Id {
Expand All @@ -223,7 +224,7 @@ pub trait IsSystem {

impl IsSystem for Id {
fn is_system(&self) -> bool {
self.0 < USER_INDEX_START
self.0 <= SYSTEM_INDEX_END
}
}

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))
}
}
Loading