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 HRMP notification handlers to the xcm-executor #3696

Merged
merged 19 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = SafeCallFilter;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

/// Converts a local signed origin into an XCM location.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = SafeCallFilter;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

/// Local origins on this chain are allowed to dispatch XCM sends/executions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = SafeCallFilter;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

pub type PriceForParentDelivery =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = SafeCallFilter;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

pub type PriceForParentDelivery =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = SafeCallFilter;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

/// Converts a local signed origin into an XCM location.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

/// Converts a local signed origin into an XCM location.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = SafeCallFilter;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

/// Converts a local signed origin into an XCM location. Forms the basis for local origins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = SafeCallFilter;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

/// Converts a local signed origin into an XCM location. Forms the basis for local origins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

impl cumulus_pallet_xcm::Config for Runtime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = SafeCallFilter;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

/// Converts a local signed origin into an XCM location. Forms the basis for local origins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = SafeCallFilter;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

/// Converts a local signed origin into an XCM location. Forms the basis for local origins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = ();
type HrmpHandler = ();
}

impl cumulus_pallet_xcm::Config for Runtime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

/// Multiplier used for dedicated `TakeFirstAssetTrader` with `ForeignAssets` instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

/// Local origins on this chain are allowed to dispatch XCM sends/executions.
Expand Down
1 change: 1 addition & 0 deletions polkadot/runtime/rococo/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions polkadot/runtime/test-runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

impl pallet_xcm::Config for crate::Runtime {
Expand Down
1 change: 1 addition & 0 deletions polkadot/runtime/westend/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

parameter_types! {
Expand Down
9 changes: 4 additions & 5 deletions polkadot/xcm/xcm-executor/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use crate::traits::{
AssetExchange, AssetLock, CallDispatcher, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm,
FeeManager, OnResponse, ProcessTransaction, ShouldExecute, TransactAsset,
VersionChangeNotifier, WeightBounds, WeightTrader,
};
use crate::traits::{AssetExchange, AssetLock, CallDispatcher, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, HandleHrmp, OnResponse, ProcessTransaction, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader};
use frame_support::{
dispatch::{GetDispatchInfo, Parameter, PostDispatchInfo},
traits::{Contains, ContainsPair, Get, PalletsInfoAccess},
Expand Down Expand Up @@ -114,4 +110,7 @@ pub trait Config {

/// Transactional processor for XCM instructions.
type TransactionalProcessor: ProcessTransaction;

/// Handler for HRMP notification messages sent by the relay chain.
type HrmpHandler: HandleHrmp;
}
8 changes: 4 additions & 4 deletions polkadot/xcm/xcm-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use traits::{
validate_export, AssetExchange, AssetLock, CallDispatcher, ClaimAssets, ConvertOrigin,
DropAssets, Enact, ExportXcm, FeeManager, FeeReason, OnResponse, ProcessTransaction,
Properties, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader,
XcmAssetTransfers,
XcmAssetTransfers, HandleHrmp
};

mod assets;
Expand Down Expand Up @@ -1212,9 +1212,9 @@ impl<Config: config::Config> XcmExecutor<Config> {
);
Ok(())
},
HrmpNewChannelOpenRequest { .. } => Err(XcmError::Unimplemented),
HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented),
HrmpChannelClosing { .. } => Err(XcmError::Unimplemented),
HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } => Config::HrmpHandler::handle_new_channel_open_request(sender, max_message_size, max_capacity),
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
HrmpChannelAccepted { recipient } => Config::HrmpHandler::handle_channel_accepted(recipient),
HrmpChannelClosing { initiator, sender, recipient } => Config::HrmpHandler::handle_channel_closing(initiator, sender, recipient),
}
}
}
23 changes: 23 additions & 0 deletions polkadot/xcm/xcm-executor/src/traits/hrmp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use xcm::v3::{
prelude::{XcmError, XcmResult},
};

pub trait HandleHrmp {
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
fn handle_new_channel_open_request(sender: u32, max_message_size: u32, max_capacity: u32) -> XcmResult;
fn handle_channel_accepted(recipient: u32) -> XcmResult;
fn handle_channel_closing(initiator: u32, sender: u32, recipient: u32) -> XcmResult;
}

impl HandleHrmp for () {
fn handle_new_channel_open_request(_sender: u32, _max_message_size: u32, _max_capacity: u32) -> XcmResult {
Err(XcmError::Unimplemented)
}

fn handle_channel_accepted(_recipient: u32) -> XcmResult {
Err(XcmError::Unimplemented)
}

fn handle_channel_closing(_initiator: u32, _sender: u32, _recipient: u32) -> XcmResult {
Err(XcmError::Unimplemented)
}
}
2 changes: 2 additions & 0 deletions polkadot/xcm/xcm-executor/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ mod should_execute;
pub use should_execute::{CheckSuspension, Properties, ShouldExecute};
mod transact_asset;
pub use transact_asset::TransactAsset;
mod hrmp;
pub use hrmp::HandleHrmp;
mod weight;
#[deprecated = "Use `sp_runtime::traits::` instead"]
pub use sp_runtime::traits::{Identity, TryConvertInto as JustTry};
Expand Down
1 change: 1 addition & 0 deletions polkadot/xcm/xcm-simulator/example/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ impl Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

#[frame_support::pallet]
Expand Down
1 change: 1 addition & 0 deletions polkadot/xcm/xcm-simulator/example/src/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ impl Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
Expand Down
1 change: 1 addition & 0 deletions polkadot/xcm/xcm-simulator/fuzzer/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ impl Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

#[frame_support::pallet]
Expand Down
1 change: 1 addition & 0 deletions polkadot/xcm/xcm-simulator/fuzzer/src/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ impl Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>;
Expand Down
1 change: 1 addition & 0 deletions substrate/frame/contracts/mock-network/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ impl Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

impl mock_msg_queue::Config for Runtime {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ impl Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, RelayNetwork>;
Expand Down
1 change: 1 addition & 0 deletions templates/parachain/runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ impl xcm_executor::Config for XcmConfig {
type SafeCallFilter = Everything;
type Aliasers = Nothing;
type TransactionalProcessor = FrameTransactionalProcessor;
type HrmpHandler = ();
}

/// No local origins on this chain are allowed to dispatch XCM sends/executions.
Expand Down