Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
56 changes: 56 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ members = [
"substrate/frame/grandpa",
"substrate/frame/honzon/oracle",
"substrate/frame/honzon/oracle/runtime-api",
"substrate/frame/hrmp/para",
"substrate/frame/hrmp/primitives",
"substrate/frame/hrmp/relay",
"substrate/frame/identity",
"substrate/frame/im-online",
"substrate/frame/indices",
Expand Down Expand Up @@ -428,6 +431,9 @@ members = [
"substrate/frame/ranked-collective",
"substrate/frame/recovery",
"substrate/frame/referenda",
"substrate/frame/registrar/para",
"substrate/frame/registrar/primitives",
"substrate/frame/registrar/relay",
"substrate/frame/remark",
"substrate/frame/revive",
"substrate/frame/revive/dev-node/node",
Expand Down
5 changes: 5 additions & 0 deletions substrate/frame/hrmp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# HRMP channels

- `para/` — `pallet-hrmp-para`: user facing control-plane, runs on a parachain.
- `relay/` — `pallet-hrmp-relay`: receives messages from the parachain, runs on the relay chain.
- `primitives/` — `hrmp-primitives`: shared parachain<->relay XCM message types.
38 changes: 38 additions & 0 deletions substrate/frame/hrmp/para/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "pallet-hrmp-para"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "User facing control plane for managing HRMP channels that are stored on the relay chain."

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { workspace = true, features = ["derive"] }
frame-support = { workspace = true }
frame-system = { workspace = true }
scale-info = { workspace = true, features = ["derive"] }

[features]
default = ["std"]
std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
]
58 changes: 58 additions & 0 deletions substrate/frame/hrmp/para/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! # Parachain HRMP pallet
//!
//! User-facing half of HRMP channel management. Runs on a parachain, holding channel deposits and
//! driving open / accept / close on the relay-chain counterpart ([`pallet-hrmp-relay`]) over XCM.

#![cfg_attr(not(feature = "std"), no_std)]

pub use pallet::*;

/// Used to send an XCM `Transact` to the HRMP pallet on the remote relay chain.
pub trait SendToRelay {}

#[frame_support::pallet]
pub mod pallet {
use super::*;

#[pallet::config]
pub trait Config: frame_system::Config {
/// Sends messages to the relay chain.
type SendToRelay: SendToRelay;
}

#[pallet::pallet]
pub struct Pallet<T>(_);

// - TODO: hrmp_init_open_channel — request to open a channel; holds the sender deposit, XCM to
// the relay.

// - TODO: hrmp_accept_open_channel — accept a pending open request; holds the recipient
// deposit.

// - TODO: hrmp_close_channel — close a channel; releases both deposits.

// - TODO: hrmp_cancel_open_request — cancel a pending open request; releases the sender
// deposit.

// - TODO: establish_channel_with_system — open a bidirectional channel with a system chain (no
// deposit).

// - TODO: poke_channel_deposits — re-sync a channel's deposits to the current config.
}
26 changes: 26 additions & 0 deletions substrate/frame/hrmp/primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "hrmp-primitives"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "Shared Para<->Relay message types."

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { workspace = true, features = ["derive"] }
scale-info = { workspace = true, features = ["derive"] }

[features]
default = ["std"]
std = [
"codec/std",
"scale-info/std",
]
62 changes: 62 additions & 0 deletions substrate/frame/hrmp/primitives/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! # HRMP-channel shared primitives
//!
//! Types shared by the parachain pallet ([`pallet-hrmp-para`]) and relay-chain pallet
//! ([`pallet-hrmp-relay`]). This crate is deliberately free of any FRAME, XCM, or network-specific
//! dependency, so a single version of the wire types serves Westend, Kusama and Polkadot, and so
//! both pallets can depend on it without forming a dependency cycle.

#![cfg_attr(not(feature = "std"), no_std)]

use codec::{Decode, Encode};
use scale_info::TypeInfo;

/// HRMP control-plane messages sent to the relay chain.
///
/// The variant's `#[codec(index)]` is the on-wire version tag.
#[derive(Encode, Decode, Clone, Eq, PartialEq, Debug, TypeInfo)]
pub enum MessageToRelay {
/// Version 1 of the HRMP control-plane messages to the relay chain.
#[codec(index = 0)]
V1(MessageToRelayV1),
}

/// Version 1 payloads for [`MessageToRelay`].
#[derive(Encode, Decode, Clone, Eq, PartialEq, Debug, TypeInfo)]
pub enum MessageToRelayV1 {
#[codec(index = 0)]
TODO,
}

/// HRMP report messages sent back to the parachain.
///
/// The variant's `#[codec(index)]` is the on-wire version tag.
#[derive(Encode, Decode, Clone, Eq, PartialEq, Debug, TypeInfo)]
pub enum MessageToPara {
/// Version 1 of the HRMP report messages to the parachain.
#[codec(index = 0)]
V1(MessageToParaV1),
}

/// Version 1 payloads for [`MessageToPara`].
#[derive(Encode, Decode, Clone, Eq, PartialEq, Debug, TypeInfo)]
pub enum MessageToParaV1 {
#[codec(index = 0)]
TODO,
}
38 changes: 38 additions & 0 deletions substrate/frame/hrmp/relay/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "pallet-hrmp-relay"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "Relay pallet as counter-part for the pallet-hrmp-para"

[package.metadata.polkadot-sdk]
exclude-from-umbrella = true

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { workspace = true, features = ["derive"] }
frame-support = { workspace = true }
frame-system = { workspace = true }
scale-info = { workspace = true, features = ["derive"] }

[features]
default = ["std"]
std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
]
45 changes: 45 additions & 0 deletions substrate/frame/hrmp/relay/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! # Relay-chain HRMP pallet
//!
//! Relay half of HRMP channel management. Runs on the relay chain, applying channel operations
//! received from a parachain ([`pallet-hrmp-para`]) to the relay's legacy `hrmp` routing table and
//! reporting back.

#![cfg_attr(not(feature = "std"), no_std)]

pub use pallet::*;

/// Used to send an XCM `Transact` to the HRMP pallet on the remote parachain.
pub trait SendToPara {}

#[frame_support::pallet]
pub mod pallet {
use super::*;

#[pallet::config]
pub trait Config: frame_system::Config {
/// Sends messages to the parachain.
type SendToPara: SendToPara;
}

#[pallet::pallet]
pub struct Pallet<T>(_);

// - TODO: Extrinsic to accept the messages from the para.
}
5 changes: 5 additions & 0 deletions substrate/frame/registrar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Parachain registrar

- `para/` — `pallet-registrar-para`: user facing control-plane, runs on a parachain.
- `relay/` — `pallet-registrar-relay`: receives messages from the parachain, runs on the relay chain.
- `primitives/` — `registrar-primitives`: shared parachain<->relay XCM message types.
Loading
Loading