Skip to content

Commit

Permalink
Add establish_channel_with_system to the HRMP pallet (#329)
Browse files Browse the repository at this point in the history
Allows any parachain to have bidirectional channel with any system
parachains.

Relates to: polkadot-fellows/RFCs#82
Relates to: paritytech/polkadot-sdk#3721
Relates to: paritytech/polkadot-sdk#4332

<!-- Remember that you can run `/merge` to enable auto-merge in the PR
-->

<!-- Remember to modify the changelog. If you don't need to modify it,
you can check the following box.
Instead, if you have already modified it, simply delete the following
line. -->

- [x] regenerate weights for `runtime_parachains::hrmp`
- [ ] Does not require a CHANGELOG entry

## Polkadot weights
(the threshold moved from the default 5 to 0.1 to see some differences)
```
subweight compare commits          --path-pattern "./relay/polkadot/**/weights/**/*.rs"          --format markdown --no-color           --change added changed          --method asymptotic --ignore-errors --threshold 0.1          remotes/polkadot-fellows/main          origin/bko-hrmp-patch
```
| File | Extrinsic | Old | New | Change [%] |

|-------------------------------------------------------|-------------------------------|----------|----------|------------|
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
poke_channel_deposits | 137.20us | 140.03us | +2.06 |
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
hrmp_accept_open_channel | 555.89us | 563.03us | +1.28 |
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
hrmp_close_channel | 556.97us | 563.79us | +1.22 |
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
hrmp_init_open_channel | 732.03us | 740.10us | +1.10 |
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
force_open_hrmp_channel | 1.16ms | 1.17ms | +0.98 |
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
establish_system_channel | 1.15ms | 1.16ms | +0.69 |
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
force_process_hrmp_open | 102.05ms | 102.47ms | +0.42 |
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
force_clean_hrmp | 91.52ms | 91.86ms | +0.37 |
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
clean_open_channel_requests | 16.56ms | 16.61ms | +0.35 |
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
force_process_hrmp_close | 75.41ms | 75.65ms | +0.33 |
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
hrmp_cancel_open_request | 422.12us | 415.03us | -1.68 |
| relay/polkadot/src/weights/runtime_parachains_hrmp.rs |
establish_channel_with_system | | 1.67ms | Added |

## Kusama weights
(the threshold moved from the default 5 to 0.1 to see some differences)
```
subweight compare commits          --path-pattern "./relay/kusama/**/weights/**/*.rs"          --format markdown --no-color           --change added changed          --method asymptotic --ignore-errors --threshold 0.1          remotes/polkadot-fellows/main          origin/bko-hrmp-patch
```
| File | Extrinsic | Old | New | Change [%] |

|-----------------------------------------------------|-------------------------------|----------|----------|------------|
| relay/kusama/src/weights/runtime_parachains_hrmp.rs |
poke_channel_deposits | 137.23us | 140.25us | +2.20 |
| relay/kusama/src/weights/runtime_parachains_hrmp.rs |
hrmp_close_channel | 557.39us | 564.18us | +1.22 |
| relay/kusama/src/weights/runtime_parachains_hrmp.rs |
hrmp_accept_open_channel | 556.49us | 563.23us | +1.21 |
| relay/kusama/src/weights/runtime_parachains_hrmp.rs |
hrmp_init_open_channel | 735.26us | 743.59us | +1.13 |
| relay/kusama/src/weights/runtime_parachains_hrmp.rs |
force_open_hrmp_channel | 1.16ms | 1.17ms | +0.97 |
| relay/kusama/src/weights/runtime_parachains_hrmp.rs |
establish_system_channel | 1.15ms | 1.16ms | +0.84 |
| relay/kusama/src/weights/runtime_parachains_hrmp.rs |
hrmp_cancel_open_request | 413.79us | 416.03us | +0.54 |
| relay/kusama/src/weights/runtime_parachains_hrmp.rs |
force_process_hrmp_open | 101.96ms | 102.43ms | +0.46 |
| relay/kusama/src/weights/runtime_parachains_hrmp.rs |
clean_open_channel_requests | 16.54ms | 16.61ms | +0.45 |
| relay/kusama/src/weights/runtime_parachains_hrmp.rs | force_clean_hrmp
| 91.43ms | 91.82ms | +0.43 |
| relay/kusama/src/weights/runtime_parachains_hrmp.rs |
force_process_hrmp_close | 75.34ms | 75.63ms | +0.40 |
| relay/kusama/src/weights/runtime_parachains_hrmp.rs |
establish_channel_with_system | | 1.67ms | Added |
  • Loading branch information
bkontur authored May 29, 2024
1 parent a611c19 commit 8f44f91
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 112 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added

- Staking runtime api to check if reward is pending for an era ([polkadot-fellows/runtimes#318](https://github.com/polkadot-fellows/runtimes/pull/318))
- Allow any parachain to have bidirectional channel with any system parachains ([polkadot-fellows/runtimes#329](https://github.com/polkadot-fellows/runtimes/pull/329))

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};
use runtime_parachains::{
assigner_coretime as parachains_assigner_coretime,
assigner_on_demand as parachains_assigner_on_demand, configuration as parachains_configuration,
configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio,
coretime, disputes as parachains_disputes,
disputes::slashing as parachains_slashing,
dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
Expand Down Expand Up @@ -1341,11 +1342,22 @@ impl pallet_message_queue::Config for Runtime {

impl parachains_dmp::Config for Runtime {}

parameter_types! {
pub const HrmpChannelSizeAndCapacityWithSystemRatio: Percent = Percent::from_percent(100);
}

impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type ChannelManager = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
type Currency = Balances;
// Use the `HrmpChannelSizeAndCapacityWithSystemRatio` ratio from the actual active
// `HostConfiguration` configuration for `hrmp_channel_max_message_size` and
// `hrmp_channel_max_capacity`.
type DefaultChannelSizeAndCapacityWithSystem = ActiveConfigHrmpChannelSizeAndCapacityRatio<
Runtime,
HrmpChannelSizeAndCapacityWithSystemRatio,
>;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
}

Expand Down
106 changes: 68 additions & 38 deletions relay/kusama/src/weights/runtime_parachains_hrmp.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion relay/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ use polkadot_runtime_common::{

use runtime_parachains::{
assigner_parachains as parachains_assigner_parachains,
configuration as parachains_configuration, disputes as parachains_disputes,
configuration as parachains_configuration,
configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio,
disputes as parachains_disputes,
disputes::slashing as parachains_slashing,
dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
inclusion::{AggregateMessageOrigin, UmpQueueId},
Expand Down Expand Up @@ -1365,11 +1367,22 @@ impl pallet_message_queue::Config for Runtime {

impl parachains_dmp::Config for Runtime {}

parameter_types! {
pub const HrmpChannelSizeAndCapacityWithSystemRatio: Percent = Percent::from_percent(100);
}

impl parachains_hrmp::Config for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type ChannelManager = EitherOf<EnsureRoot<Self::AccountId>, GeneralAdmin>;
type Currency = Balances;
// Use the `HrmpChannelSizeAndCapacityWithSystemRatio` ratio from the actual active
// `HostConfiguration` configuration for `hrmp_channel_max_message_size` and
// `hrmp_channel_max_capacity`.
type DefaultChannelSizeAndCapacityWithSystem = ActiveConfigHrmpChannelSizeAndCapacityRatio<
Runtime,
HrmpChannelSizeAndCapacityWithSystemRatio,
>;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
}

Expand Down
Loading

0 comments on commit 8f44f91

Please sign in to comment.