From 57fe885ac345e9cc5dd623e9b6ee4f096a24f302 Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Thu, 23 Nov 2023 09:28:25 +0200 Subject: [PATCH] Parameterize message origin --- .../assets/asset-hub-rococo/src/lib.rs | 1 + .../assets/asset-hub-wococo/src/lib.rs | 1 + .../bridges/bridge-hub-rococo/src/lib.rs | 1 + .../bridges/bridge-hub-wococo/src/lib.rs | 1 + .../parachains/testing/penpal/src/lib.rs | 2 ++ cumulus/xcm/xcm-emulator/src/lib.rs | 24 ++++++++++--------- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/lib.rs index f94c4c3d2558..33b13a8a3e31 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-rococo/src/lib.rs @@ -37,6 +37,7 @@ decl_test_parachains! { XcmpMessageHandler: asset_hub_rococo_runtime::XcmpQueue, LocationToAccountId: asset_hub_rococo_runtime::xcm_config::LocationToAccountId, ParachainInfo: asset_hub_rococo_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, }, pallets = { PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm, diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-wococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-wococo/src/lib.rs index 38a6ece3472e..946290164ee0 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-wococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/assets/asset-hub-wococo/src/lib.rs @@ -35,6 +35,7 @@ decl_test_parachains! { XcmpMessageHandler: asset_hub_rococo_runtime::XcmpQueue, LocationToAccountId: asset_hub_rococo_runtime::xcm_config::LocationToAccountId, ParachainInfo: asset_hub_rococo_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, }, pallets = { PolkadotXcm: asset_hub_rococo_runtime::PolkadotXcm, diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/lib.rs index 0d7fa53a0ad4..5bd4abdfb6b0 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/src/lib.rs @@ -36,6 +36,7 @@ decl_test_parachains! { XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue, LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId, ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, }, pallets = { PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm, diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-wococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-wococo/src/lib.rs index e643f104aa31..8958c43763cc 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-wococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-wococo/src/lib.rs @@ -34,6 +34,7 @@ decl_test_parachains! { XcmpMessageHandler: bridge_hub_rococo_runtime::XcmpQueue, LocationToAccountId: bridge_hub_rococo_runtime::xcm_config::LocationToAccountId, ParachainInfo: bridge_hub_rococo_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, }, pallets = { PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm, diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs index ec23257eae53..38efbcdccb43 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/testing/penpal/src/lib.rs @@ -38,6 +38,7 @@ decl_test_parachains! { XcmpMessageHandler: penpal_runtime::XcmpQueue, LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId, ParachainInfo: penpal_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, }, pallets = { PolkadotXcm: penpal_runtime::PolkadotXcm, @@ -56,6 +57,7 @@ decl_test_parachains! { XcmpMessageHandler: penpal_runtime::XcmpQueue, LocationToAccountId: penpal_runtime::xcm_config::LocationToAccountId, ParachainInfo: penpal_runtime::ParachainInfo, + MessageOrigin: cumulus_primitives_core::AggregateMessageOrigin, }, pallets = { PolkadotXcm: penpal_runtime::PolkadotXcm, diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index f2e4ff397c45..1ad4cd05b74e 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Polkadot. If not, see . -pub use codec::{Decode, Encode, EncodeLike}; +pub use codec::{Decode, Encode, EncodeLike, MaxEncodedLen}; pub use lazy_static::lazy_static; pub use log; pub use paste; @@ -576,7 +576,7 @@ macro_rules! decl_test_parachains { XcmpMessageHandler: $xcmp_message_handler:path, LocationToAccountId: $location_to_account:path, ParachainInfo: $parachain_info:path, - // MessageProcessor: $message_processor:path, + MessageOrigin: $message_origin:path, }, pallets = { $($pallet_name:ident: $pallet_path:path,)* @@ -615,7 +615,7 @@ macro_rules! decl_test_parachains { type LocationToAccountId = $location_to_account; type ParachainSystem = $crate::ParachainSystemPallet<::Runtime>; type ParachainInfo = $parachain_info; - type MessageProcessor = $crate::DefaultParaMessageProcessor<$name>; + type MessageProcessor = $crate::DefaultParaMessageProcessor<$name, $message_origin>; // We run an empty block during initialisation to open HRMP channels // and have them ready for the next block @@ -1313,17 +1313,18 @@ macro_rules! decl_test_sender_receiver_accounts_parameter_types { }; } -pub struct DefaultParaMessageProcessor(PhantomData); +pub struct DefaultParaMessageProcessor(PhantomData<(T, M)>); // Process HRMP messages from sibling paraids -impl ProcessMessage for DefaultParaMessageProcessor +impl ProcessMessage for DefaultParaMessageProcessor where + M: codec::FullCodec + MaxEncodedLen + Clone + Eq + PartialEq + frame_support::pallet_prelude::TypeInfo + Debug, T: Parachain, T::Runtime: MessageQueueConfig, <::MessageProcessor as ProcessMessage>::Origin: - PartialEq, - MessageQueuePallet: EnqueueMessage + ServiceQueues, + PartialEq, + MessageQueuePallet: EnqueueMessage + ServiceQueues, { - type Origin = CumulusAggregateMessageOrigin; + type Origin = M; fn process_message( msg: &[u8], @@ -1340,13 +1341,14 @@ where Ok(true) } } -impl ServiceQueues for DefaultParaMessageProcessor +impl ServiceQueues for DefaultParaMessageProcessor where + M: MaxEncodedLen, T: Parachain, T::Runtime: MessageQueueConfig, <::MessageProcessor as ProcessMessage>::Origin: - PartialEq, - MessageQueuePallet: EnqueueMessage + ServiceQueues, + PartialEq, + MessageQueuePallet: EnqueueMessage + ServiceQueues, { type OverweightMessageAddress = ();