-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add HrmpChannelManagementHooks #2661
Changes from 5 commits
c5a5cb0
ed0e939
8d223a3
08ef5b7
5eb7e16
bd06574
c16f724
80edf1b
1d56ac5
f66b1a3
8faf033
0ba6d88
af66d5b
164dcb3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,6 +262,52 @@ pub enum Xcm<Call> { | |
recipient: u32, | ||
}, | ||
|
||
/// A message to propose opening a channel on the relay-chain between the | ||
/// sender para to the recipient para. | ||
/// | ||
/// - `recipient`: The recipient in the to-be opened channel. | ||
/// - `max_message_size`: The maximum size of a message proposed by the sender. | ||
/// - `max_capacity`: The maximum number of messages that can be queued in the channel. | ||
/// | ||
/// Safety: The message should originate directly from the sender para. | ||
/// | ||
/// Kind: *Instruction*. | ||
/// | ||
/// Errors: | ||
HrmpInitOpenChannel { | ||
#[codec(compact)] recipient: u32, | ||
#[codec(compact)] max_message_size: u32, | ||
#[codec(compact)] max_capacity: u32, | ||
}, | ||
|
||
/// A message to accept opening a channel on the relay-chain. | ||
/// | ||
/// - `sender`: The sender in the to-be opened channel. | ||
/// | ||
/// Safety: The message should originate directly from the recipient para. | ||
/// | ||
/// Kind: *Instruction*. | ||
/// | ||
/// Errors: | ||
HrmpAcceptOpenChannel { | ||
#[codec(compact)] sender: u32, | ||
}, | ||
|
||
/// A message to close a channel on the relay-chain. | ||
/// | ||
/// - `sender`: The sender in the to-be closed channel. | ||
/// - `recipient`: The recipient in the to-be closed channel. | ||
/// | ||
/// Safety: The message should originate directly from the sender or | ||
/// recipient para (either member of the channel). | ||
/// | ||
/// Kind: *Instruction*. | ||
/// | ||
/// Errors: | ||
HrmpCloseChannel { | ||
#[codec(compact)] sender: u32, | ||
#[codec(compact)] recipient: u32, | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recalling an open channel request is upcoming in #3543 I think it's worth to reconsider these messages in the light of that PR. |
||
/// A message to indicate that the embedded XCM is actually arriving on behalf of some consensus | ||
/// location within the origin. | ||
/// | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,3 +259,21 @@ impl SendXcm for Tuple { | |
Err(Error::CannotReachDestination(destination, message)) | ||
} | ||
} | ||
|
||
pub trait ExecuteHrmp { | ||
4meta5 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fn hrmp_init_open_channel(sender: u32, recipient: u32, max_message_size: u32, max_capacity: u32) -> Result; | ||
fn hrmp_accept_open_channel(recipient: u32, sender: u32) -> Result; | ||
fn hrmp_close_channel(initiator: u32, sender: u32, recipient: u32) -> Result; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DQ: why are all parameters u32 all across the place? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I presumed it's the same reason why we use u32 within XCM definitions. The alternative you are thinking of is |
||
} | ||
|
||
impl ExecuteHrmp for () { | ||
fn hrmp_init_open_channel(_sender: u32, _recipient: u32, _max_message_size: u32, _max_capacity: u32) -> Result { | ||
Err(().into()) | ||
} | ||
fn hrmp_accept_open_channel(_recipient: u32, _sender: u32) -> Result { | ||
Err(().into()) | ||
} | ||
fn hrmp_close_channel(_initiator: u32, _sender: u32, _recipient: u32) -> Result { | ||
Err(().into()) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ use frame_support::{ | |
dispatch::{Dispatchable, Parameter}, | ||
weights::{GetDispatchInfo, PostDispatchInfo}, | ||
}; | ||
use xcm::v0::SendXcm; | ||
use xcm::v0::{SendXcm, ExecuteHrmp}; | ||
|
||
/// The trait to parameterize the `XcmExecutor`. | ||
pub trait Config { | ||
|
@@ -35,6 +35,9 @@ pub trait Config { | |
/// How to withdraw and deposit an asset. | ||
type AssetTransactor: TransactAsset; | ||
|
||
/// How to execute HRMP-related actions | ||
type HrmpExecutor: ExecuteHrmp; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this could be improved by specifying what exactly actions are (i.e. the channel management). It is also better to take into account how the developers will approach it. I think this is mostly relevant for relay-chains which is a way less common case. Thus it would be good to guide a typical implementer of this to use the |
||
|
||
/// How to get a call origin from a `OriginKind` value. | ||
type OriginConverter: ConvertOrigin<<Self::Call as Dispatchable>::Origin>; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, this is returning the XcmError::Undefined if a runtime error is returned. What error should it be?