Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Limit scope of SnowbridgeMwssageOrigin
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Dec 20, 2023
1 parent 89a79f5 commit 9db633e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ parachains-common = { path = "../../../../../../../parachains/common" }
# Cumulus
cumulus-primitives-core = { path = "../../../../../../../primitives/core", default-features = false }
emulated-integration-tests-common = { path = "../../../../common", default-features = false }
bridge-hub-westend-runtime = { path = "../../../../../../runtimes/bridge-hubs/bridge-hub-westend" }
bridge-hub-common = { path = "../../../../../../runtimes/bridge-hubs/common", default-features = false }
bridge-hub-westend-runtime = { path = "../../../../../../runtimes/bridge-hubs/bridge-hub-westend" }
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ decl_test_parachains! {
XcmpMessageHandler: bridge_hub_westend_runtime::XcmpQueue,
LocationToAccountId: bridge_hub_westend_runtime::xcm_config::LocationToAccountId,
ParachainInfo: bridge_hub_westend_runtime::ParachainInfo,
MessageOrigin: bridge_hub_common::AggregateMessageOrigin,
MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin,
},
pallets = {
PolkadotXcm: bridge_hub_westend_runtime::PolkadotXcm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use sp_std::prelude::*;
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use cumulus_primitives_core::ParaId;
use cumulus_primitives_core::{AggregateMessageOrigin as CumulusAggregateMessageOrigin, ParaId};
use frame_support::{
construct_runtime, derive_impl,
dispatch::DispatchClass,
Expand Down Expand Up @@ -371,7 +371,7 @@ impl pallet_message_queue::Config for Runtime {
#[cfg(not(feature = "runtime-benchmarks"))]
type MessageProcessor = BridgeHubMessageRouter<
xcm_builder::ProcessXcmMessage<
AggregateMessageOrigin,
CumulusAggregateMessageOrigin,
xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
RuntimeCall,
>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ pallet-bridge-parachains = { path = "../../../../../bridges/modules/parachains",
pallet-bridge-relayers = { path = "../../../../../bridges/modules/relayers", default-features = false }
pallet-xcm-bridge-hub = { path = "../../../../../bridges/modules/xcm-bridge-hub", default-features = false }
bridge-runtime-common = { path = "../../../../../bridges/bin/runtime-common", default-features = false }
bridge-hub-common = { path = "../../bridge-hubs/common", default-features = false }

[dev-dependencies]
static_assertions = "1.1"
Expand All @@ -118,7 +117,6 @@ std = [
"bp-rococo/std",
"bp-runtime/std",
"bp-westend/std",
"bridge-hub-common/std",
"bridge-runtime-common/std",
"codec/std",
"cumulus-pallet-aura-ext/std",
Expand Down Expand Up @@ -183,7 +181,6 @@ std = [
]

runtime-benchmarks = [
"bridge-hub-common/runtime-benchmarks",
"bridge-runtime-common/runtime-benchmarks",
"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod weights;
pub mod xcm_config;

use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_primitives_core::ParaId;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_runtime::{
Expand All @@ -48,10 +48,6 @@ use sp_std::prelude::*;
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use bridge_hub_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
AggregateMessageOrigin,
};
use frame_support::{
construct_runtime, derive_impl,
dispatch::DispatchClass,
Expand All @@ -65,6 +61,7 @@ use frame_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot,
};
use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm_config::{XcmOriginToTransactDispatchOrigin, XcmRouter};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub enum AggregateMessageOrigin {
/// This is used by the HRMP queue.
Sibling(ParaId),
/// The message came from a snowbridge channel.
///
///
/// This is used by Snowbridge inbound queue.
Snowbridge(ChannelId),
}
Expand Down Expand Up @@ -70,6 +70,17 @@ impl From<CumulusAggregateMessageOrigin> for AggregateMessageOrigin {
}
}

impl From<AggregateMessageOrigin> for CumulusAggregateMessageOrigin {
fn from(origin: AggregateMessageOrigin) -> Self {
match origin {
AggregateMessageOrigin::Here => Self::Here,
AggregateMessageOrigin::Parent => Self::Parent,
AggregateMessageOrigin::Sibling(id) => Self::Sibling(id),
AggregateMessageOrigin::Snowbridge(_) => Self::Here,
}
}
}

#[cfg(feature = "runtime-benchmarks")]
impl From<u32> for AggregateMessageOrigin {
fn from(x: u32) -> Self {
Expand All @@ -86,13 +97,13 @@ pub struct BridgeHubMessageRouter<XcmpProcessor, SnowbridgeProcessor>(
PhantomData<(XcmpProcessor, SnowbridgeProcessor)>,
)
where
XcmpProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
XcmpProcessor: ProcessMessage<Origin = CumulusAggregateMessageOrigin>,
SnowbridgeProcessor: ProcessMessage<Origin = AggregateMessageOrigin>;

impl<XcmpProcessor, SnowbridgeProcessor> ProcessMessage
for BridgeHubMessageRouter<XcmpProcessor, SnowbridgeProcessor>
where
XcmpProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
XcmpProcessor: ProcessMessage<Origin = CumulusAggregateMessageOrigin>,
SnowbridgeProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
{
type Origin = AggregateMessageOrigin;
Expand All @@ -106,7 +117,7 @@ where
use AggregateMessageOrigin::*;
match origin {
Here | Parent | Sibling(_) =>
XcmpProcessor::process_message(message, origin, meter, id),
XcmpProcessor::process_message(message, origin.into(), meter, id),
Snowbridge(_) => SnowbridgeProcessor::process_message(message, origin, meter, id),
}
}
Expand Down

0 comments on commit 9db633e

Please sign in to comment.