From 0a162d10a4db78e719ecd8c525f32cfdde996831 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Fri, 24 Nov 2023 14:55:32 +0200 Subject: [PATCH 01/11] update aggregate message origin --- .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 6 +- .../bridge-hub-polkadot/src/lib.rs | 6 +- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 7 +- .../bridge-hubs/bridge-hub-westend/src/lib.rs | 5 + .../runtimes/bridge-hubs/common/Cargo.toml | 7 +- .../runtimes/bridge-hubs/common/src/lib.rs | 2 +- .../bridge-hubs/common/src/message_queue.rs | 99 +++++++++++++++++-- 7 files changed, 116 insertions(+), 16 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index b37507000842..3b6ef76cfe13 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -41,7 +41,7 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; +use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, dispatch::DispatchClass, @@ -58,6 +58,10 @@ use frame_system::{ EnsureRoot, }; use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; +use bridge_hub_common::{ + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, + AggregateMessageOrigin, +}; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm_config::{FellowshipLocation, GovernanceLocation, XcmOriginToTransactDispatchOrigin}; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 841bb4ee8611..22bf8beb354b 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -41,7 +41,7 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; +use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, dispatch::DispatchClass, @@ -58,6 +58,10 @@ use frame_system::{ EnsureRoot, }; use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; +use bridge_hub_common::{ + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, + AggregateMessageOrigin, +}; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm_config::{FellowshipLocation, GovernanceLocation, XcmOriginToTransactDispatchOrigin}; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 38d009359aed..cf2068fe385d 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -50,7 +50,7 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; +use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, dispatch::DispatchClass, @@ -66,7 +66,10 @@ use frame_system::{ }; use pallet_xcm::EnsureXcm; -use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling}; +use bridge_hub_common::{ + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, + AggregateMessageOrigin, +}; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm::VersionedMultiLocation; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 9e8fd84e7125..54194fe7ff9c 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -49,6 +49,7 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; +use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, dispatch::DispatchClass, @@ -62,6 +63,10 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, }; +use bridge_hub_common::{ + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, + AggregateMessageOrigin, +}; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm_config::{XcmOriginToTransactDispatchOrigin, XcmRouter}; diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml index 46405f16dd5a..cb45735bbdcd 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml @@ -15,6 +15,7 @@ sp-runtime = { path = "../../../../../substrate/primitives/runtime", default-fea cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false } xcm = { package = "staging-xcm", path = "../../../../../polkadot/xcm", default-features = false} pallet-message-queue = { path = "../../../../../substrate/frame/message-queue", default-features = false} +snowbridge-core = { path = "../../../../../../parachain/primitives/core", default-features = false } [features] default = [ "std" ] @@ -26,12 +27,14 @@ std = [ "sp-runtime/std", "cumulus-primitives-core/std", "xcm/std", - "pallet-message-queue/std" + "pallet-message-queue/std", + "snowbridge-core/std" ] runtime-benchmarks = [ "frame-support/runtime-benchmarks", "cumulus-primitives-core/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "pallet-message-queue/runtime-benchmarks" + "pallet-message-queue/runtime-benchmarks", + "snowbridge-core/runtime-benchmarks" ] diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/common/src/lib.rs index 58e6264d1b70..eb02498448a1 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/common/src/lib.rs @@ -16,4 +16,4 @@ pub mod message_queue; -pub use message_queue::BridgeHubMessageRouter; +pub use message_queue::{AggregateMessageOrigin, BridgeHubMessageRouter}; diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs index 3d53d985af1d..65eaf807b918 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs @@ -13,23 +13,74 @@ // See the License for the specific language governing permissions and // limitations under the License. //! Runtime configuration for MessageQueue pallet -use cumulus_primitives_core::AggregateMessageOrigin; +use codec::{Decode, Encode, MaxEncodedLen}; +use cumulus_primitives_core::ParaId; use frame_support::{ - traits::{ProcessMessage, ProcessMessageError}, + traits::{ProcessMessage, ProcessMessageError, QueueFootprint, QueuePausedQuery}, weights::WeightMeter, }; -use sp_std::marker::PhantomData; +use pallet_message_queue::OnQueueChanged; +use scale_info::TypeInfo; +use sp_std::{marker::PhantomData, prelude::*}; +use xcm::v3::{Junction, MultiLocation}; +use snowbridge_core::ChannelId; + +/// The aggregate origin of an inbound message. +/// This is specialized for BridgeHub, as the snowbridge-outbound-queue pallet is also using +/// the shared MessageQueue pallet. +#[derive(Encode, Decode, Copy, MaxEncodedLen, Clone, Eq, PartialEq, TypeInfo, Debug)] +pub enum AggregateMessageOrigin { + /// The message came from the para-chain itself. + Here, + /// The message came from the relay-chain. + /// + /// This is used by the DMP queue. + Parent, + /// The message came from a sibling para-chain. + /// + /// This is used by the HRMP queue. + Sibling(ParaId), + Snowbridge(ChannelId), +} + +impl From for MultiLocation { + fn from(origin: AggregateMessageOrigin) -> Self { + use AggregateMessageOrigin::*; + match origin { + Here => MultiLocation::here(), + Parent => MultiLocation::parent(), + Sibling(id) => MultiLocation::new(1, Junction::Parachain(id.into())), + // NOTE: We don't need this conversion for Snowbridge. However we have to + // implement it anyway as xcm_builder::ProcessXcmMessage requires it. + Snowbridge(_) => MultiLocation::default(), + } + } +} + +#[cfg(feature = "runtime-benchmarks")] +impl From for AggregateMessageOrigin { + fn from(x: u32) -> Self { + match x { + 0 => Self::Here, + 1 => Self::Parent, + p => Self::Sibling(ParaId::from(p)), + } + } +} /// Routes messages to either the XCMP or Snowbridge processor. pub struct BridgeHubMessageRouter( PhantomData<(XcmpProcessor, SnowbridgeProcessor)>, -); +) + where + XcmpProcessor: ProcessMessage, + SnowbridgeProcessor: ProcessMessage; impl ProcessMessage - for BridgeHubMessageRouter -where - XcmpProcessor: ProcessMessage, - SnowbridgeProcessor: ProcessMessage, +for BridgeHubMessageRouter + where + XcmpProcessor: ProcessMessage, + SnowbridgeProcessor: ProcessMessage, { type Origin = AggregateMessageOrigin; @@ -43,7 +94,37 @@ where match origin { Here | Parent | Sibling(_) => XcmpProcessor::process_message(message, origin, meter, id), - GeneralKey(_) => SnowbridgeProcessor::process_message(message, origin, meter, id), + Snowbridge(_) => SnowbridgeProcessor::process_message(message, origin, meter, id), + } + } +} + +pub struct NarrowOriginToSibling(PhantomData); +impl> QueuePausedQuery +for NarrowOriginToSibling +{ + fn is_paused(origin: &AggregateMessageOrigin) -> bool { + match origin { + AggregateMessageOrigin::Sibling(id) => Inner::is_paused(id), + _ => false, } } } + +impl> OnQueueChanged +for NarrowOriginToSibling +{ + fn on_queue_changed(origin: AggregateMessageOrigin, fp: QueueFootprint) { + if let AggregateMessageOrigin::Sibling(id) = origin { + Inner::on_queue_changed(id, fp) + } + } +} + +/// Convert a sibling `ParaId` to an `AggregateMessageOrigin`. +pub struct ParaIdToSibling; +impl sp_runtime::traits::Convert for ParaIdToSibling { + fn convert(para_id: ParaId) -> AggregateMessageOrigin { + AggregateMessageOrigin::Sibling(para_id) + } +} From 52d4f62c8933e12ef68a9a22b4540a26824b4beb Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Fri, 24 Nov 2023 15:56:37 +0200 Subject: [PATCH 02/11] fix imports --- Cargo.lock | 4 +++- .../runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs | 1 - .../runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs | 1 - .../runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml | 4 +++- .../runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs | 4 +--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44629722defd..80e809310a18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2153,6 +2153,7 @@ dependencies = [ "pallet-message-queue", "parity-scale-codec", "scale-info", + "snowbridge-core", "sp-runtime", "sp-std 8.0.0", "staging-xcm", @@ -2533,6 +2534,7 @@ dependencies = [ "bp-rococo", "bp-runtime", "bp-westend", + "bridge-hub-common", "bridge-hub-test-utils", "bridge-runtime-common", "cumulus-pallet-aura-ext", @@ -17708,7 +17710,7 @@ dependencies = [ name = "snowbridge-outbound-queue" version = "0.1.1" dependencies = [ - "cumulus-primitives-core", + "bridge-hub-common", "ethabi-decode", "frame-benchmarking", "frame-support", diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index 3b6ef76cfe13..9d87cfd47501 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -76,7 +76,6 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use parachains_common::{ impls::DealWithFees, kusama::{consensus::*, currency::*, fee::WeightToFee}, - message_queue::{NarrowOriginToSibling, ParaIdToSibling}, AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 22bf8beb354b..a9299a3377f0 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -76,7 +76,6 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use parachains_common::{ impls::DealWithFees, - message_queue::{NarrowOriginToSibling, ParaIdToSibling}, polkadot::{consensus::*, currency::*, fee::WeightToFee}, AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml index 7e384126ab67..f6dff119949d 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml @@ -91,6 +91,7 @@ pallet-bridge-messages = { path = "../../../../../bridges/modules/messages", def pallet-bridge-parachains = { path = "../../../../../bridges/modules/parachains", default-features = false } pallet-bridge-relayers = { path = "../../../../../bridges/modules/relayers", 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" @@ -173,6 +174,7 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "bridge-hub-common/std", ] runtime-benchmarks = [ @@ -205,6 +207,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "bridge-hub-common/runtime-benchmarks", ] try-runtime = [ @@ -220,7 +223,6 @@ try-runtime = [ "pallet-aura/try-runtime", "pallet-authorship/try-runtime", "pallet-balances/try-runtime", - "pallet-bridge-grandpa/try-runtime", "pallet-bridge-messages/try-runtime", "pallet-bridge-parachains/try-runtime", "pallet-bridge-relayers/try-runtime", diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 54194fe7ff9c..6a58b2f794f2 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -33,8 +33,7 @@ mod weights; pub mod xcm_config; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; -use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling}; +use cumulus_primitives_core::ParaId; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ @@ -49,7 +48,6 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, dispatch::DispatchClass, From f26598d0c3984a9807eaa5271edcf12791109379 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Fri, 24 Nov 2023 16:08:42 +0200 Subject: [PATCH 03/11] fmt --- .../bridge-hubs/bridge-hub-kusama/src/lib.rs | 8 ++++---- .../bridge-hub-polkadot/src/lib.rs | 8 ++++---- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 2 +- .../bridge-hubs/bridge-hub-westend/src/lib.rs | 8 ++++---- .../bridge-hubs/common/src/message_queue.rs | 20 +++++++++---------- .../runtimes/testing/penpal/src/lib.rs | 1 - .../src/chain_head/subscription/inner.rs | 2 +- 7 files changed, 24 insertions(+), 25 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index 9d87cfd47501..4d66071d6cfc 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -41,6 +41,10 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; +use bridge_hub_common::{ + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, + AggregateMessageOrigin, +}; use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, @@ -58,10 +62,6 @@ use frame_system::{ EnsureRoot, }; use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; -use bridge_hub_common::{ - message_queue::{NarrowOriginToSibling, ParaIdToSibling}, - AggregateMessageOrigin, -}; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm_config::{FellowshipLocation, GovernanceLocation, XcmOriginToTransactDispatchOrigin}; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index a9299a3377f0..079b6f18eb65 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -41,6 +41,10 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; +use bridge_hub_common::{ + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, + AggregateMessageOrigin, +}; use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, @@ -58,10 +62,6 @@ use frame_system::{ EnsureRoot, }; use pallet_xcm::{EnsureXcm, IsVoiceOfBody}; -use bridge_hub_common::{ - message_queue::{NarrowOriginToSibling, ParaIdToSibling}, - AggregateMessageOrigin, -}; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm_config::{FellowshipLocation, GovernanceLocation, XcmOriginToTransactDispatchOrigin}; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index cf2068fe385d..0cb2ae9a307f 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -65,11 +65,11 @@ use frame_system::{ EnsureRoot, }; -use pallet_xcm::EnsureXcm; use bridge_hub_common::{ message_queue::{NarrowOriginToSibling, ParaIdToSibling}, AggregateMessageOrigin, }; +use pallet_xcm::EnsureXcm; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm::VersionedMultiLocation; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 6a58b2f794f2..90702e95533e 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -48,6 +48,10 @@ 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, dispatch::DispatchClass, @@ -61,10 +65,6 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, }; -use bridge_hub_common::{ - message_queue::{NarrowOriginToSibling, ParaIdToSibling}, - AggregateMessageOrigin, -}; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; pub use sp_runtime::{MultiAddress, Perbill, Permill}; use xcm_config::{XcmOriginToTransactDispatchOrigin, XcmRouter}; diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs index 65eaf807b918..76d6a122ee64 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs @@ -21,9 +21,9 @@ use frame_support::{ }; use pallet_message_queue::OnQueueChanged; use scale_info::TypeInfo; +use snowbridge_core::ChannelId; use sp_std::{marker::PhantomData, prelude::*}; use xcm::v3::{Junction, MultiLocation}; -use snowbridge_core::ChannelId; /// The aggregate origin of an inbound message. /// This is specialized for BridgeHub, as the snowbridge-outbound-queue pallet is also using @@ -72,15 +72,15 @@ impl From for AggregateMessageOrigin { pub struct BridgeHubMessageRouter( PhantomData<(XcmpProcessor, SnowbridgeProcessor)>, ) - where - XcmpProcessor: ProcessMessage, - SnowbridgeProcessor: ProcessMessage; +where + XcmpProcessor: ProcessMessage, + SnowbridgeProcessor: ProcessMessage; impl ProcessMessage -for BridgeHubMessageRouter - where - XcmpProcessor: ProcessMessage, - SnowbridgeProcessor: ProcessMessage, + for BridgeHubMessageRouter +where + XcmpProcessor: ProcessMessage, + SnowbridgeProcessor: ProcessMessage, { type Origin = AggregateMessageOrigin; @@ -101,7 +101,7 @@ for BridgeHubMessageRouter pub struct NarrowOriginToSibling(PhantomData); impl> QueuePausedQuery -for NarrowOriginToSibling + for NarrowOriginToSibling { fn is_paused(origin: &AggregateMessageOrigin) -> bool { match origin { @@ -112,7 +112,7 @@ for NarrowOriginToSibling } impl> OnQueueChanged -for NarrowOriginToSibling + for NarrowOriginToSibling { fn on_queue_changed(origin: AggregateMessageOrigin, fp: QueueFootprint) { if let AggregateMessageOrigin::Sibling(id) = origin { diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index 7e2992d832c0..09d236b717d7 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -458,7 +458,6 @@ impl pallet_assets::Config for Runtime { type BenchmarkHelper = (); } - parameter_types! { // we just reuse the same deposits pub const ForeignAssetsAssetDeposit: Balance = AssetDeposit::get(); diff --git a/substrate/client/rpc-spec-v2/src/chain_head/subscription/inner.rs b/substrate/client/rpc-spec-v2/src/chain_head/subscription/inner.rs index abd42ad96785..2b250f3dc2cf 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/subscription/inner.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/subscription/inner.rs @@ -763,7 +763,7 @@ impl> SubscriptionsInner { // blocks. for hash in hashes.clone() { if !sub.contains_block(hash) { - return Err(SubscriptionManagementError::BlockHashAbsent); + return Err(SubscriptionManagementError::BlockHashAbsent) } } From 78717452411b3f244e91459ab274f42ca65ae270 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Fri, 24 Nov 2023 21:24:20 +0200 Subject: [PATCH 04/11] revert non-rococo changes --- .../runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs | 7 ++----- .../runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs | 7 ++----- .../runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml | 4 +--- .../runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs | 7 ++----- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs index 4d66071d6cfc..b37507000842 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs @@ -41,11 +41,7 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use bridge_hub_common::{ - message_queue::{NarrowOriginToSibling, ParaIdToSibling}, - AggregateMessageOrigin, -}; -use cumulus_primitives_core::ParaId; +use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use frame_support::{ construct_runtime, dispatch::DispatchClass, @@ -76,6 +72,7 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use parachains_common::{ impls::DealWithFees, kusama::{consensus::*, currency::*, fee::WeightToFee}, + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs index 079b6f18eb65..841bb4ee8611 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-polkadot/src/lib.rs @@ -41,11 +41,7 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use bridge_hub_common::{ - message_queue::{NarrowOriginToSibling, ParaIdToSibling}, - AggregateMessageOrigin, -}; -use cumulus_primitives_core::ParaId; +use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; use frame_support::{ construct_runtime, dispatch::DispatchClass, @@ -76,6 +72,7 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; use parachains_common::{ impls::DealWithFees, + message_queue::{NarrowOriginToSibling, ParaIdToSibling}, polkadot::{consensus::*, currency::*, fee::WeightToFee}, AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml index f6dff119949d..7e384126ab67 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml @@ -91,7 +91,6 @@ pallet-bridge-messages = { path = "../../../../../bridges/modules/messages", def pallet-bridge-parachains = { path = "../../../../../bridges/modules/parachains", default-features = false } pallet-bridge-relayers = { path = "../../../../../bridges/modules/relayers", 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" @@ -174,7 +173,6 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", - "bridge-hub-common/std", ] runtime-benchmarks = [ @@ -207,7 +205,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "bridge-hub-common/runtime-benchmarks", ] try-runtime = [ @@ -223,6 +220,7 @@ try-runtime = [ "pallet-aura/try-runtime", "pallet-authorship/try-runtime", "pallet-balances/try-runtime", + "pallet-bridge-grandpa/try-runtime", "pallet-bridge-messages/try-runtime", "pallet-bridge-parachains/try-runtime", "pallet-bridge-relayers/try-runtime", diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 90702e95533e..9e8fd84e7125 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -33,7 +33,8 @@ mod weights; pub mod xcm_config; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -use cumulus_primitives_core::ParaId; +use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; +use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling}; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ @@ -48,10 +49,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, dispatch::DispatchClass, From 95b34b915254eec4d34ae99e5f4b9a26cb7f37b7 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Sat, 25 Nov 2023 13:52:14 +0200 Subject: [PATCH 05/11] adds log --- cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml | 4 +++- .../runtimes/bridge-hubs/common/src/message_queue.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml index cb45735bbdcd..868f35f4a366 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml @@ -16,6 +16,7 @@ cumulus-primitives-core = { path = "../../../../primitives/core", default-featur xcm = { package = "staging-xcm", path = "../../../../../polkadot/xcm", default-features = false} pallet-message-queue = { path = "../../../../../substrate/frame/message-queue", default-features = false} snowbridge-core = { path = "../../../../../../parachain/primitives/core", default-features = false } +log = { version = "0.4.20", default-features = false } [features] default = [ "std" ] @@ -28,7 +29,8 @@ std = [ "cumulus-primitives-core/std", "xcm/std", "pallet-message-queue/std", - "snowbridge-core/std" + "snowbridge-core/std", + "log/std" ] runtime-benchmarks = [ diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs index 76d6a122ee64..fc46323e6e29 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs @@ -91,6 +91,7 @@ where id: &mut [u8; 32], ) -> Result { use AggregateMessageOrigin::*; + log::info!(target: "xcm", "💫 in process message origin is {:?}.", origin); match origin { Here | Parent | Sibling(_) => XcmpProcessor::process_message(message, origin, meter, id), From 3af9a6b5063df21614c424c3b44606076334c9a3 Mon Sep 17 00:00:00 2001 From: Ron Date: Sat, 25 Nov 2023 19:55:40 +0800 Subject: [PATCH 06/11] Fix compile error & breaking tests (#39) --- Cargo.lock | 4 + .../bridges/bridge-hub-rococo/Cargo.toml | 1 + .../bridges/bridge-hub-rococo/src/lib.rs | 2 +- .../bridges/bridge-hub-westend/Cargo.toml | 1 + .../bridges/bridge-hub-westend/src/lib.rs | 2 +- .../bridges/bridge-hub-rococo/Cargo.toml | 2 + .../bridges/bridge-hub-rococo/src/lib.rs | 12 +- .../bridge-hub-rococo/src/tests/snowbridge.rs | 178 +++++++++--------- .../bridge-hubs/common/src/message_queue.rs | 12 +- cumulus/primitives/core/src/lib.rs | 7 - cumulus/xcm/xcm-emulator/src/lib.rs | 18 +- 11 files changed, 128 insertions(+), 111 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80e809310a18..c9b2265c1923 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2293,6 +2293,7 @@ dependencies = [ name = "bridge-hub-rococo-emulated-chain" version = "0.0.0" dependencies = [ + "bridge-hub-common", "bridge-hub-rococo-runtime", "cumulus-primitives-core", "emulated-integration-tests-common", @@ -2331,6 +2332,8 @@ dependencies = [ "parachains-common", "parity-scale-codec", "penpal-emulated-chain", + "penpal-runtime", + "rococo-system-emulated-network", "rococo-westend-system-emulated-network", "scale-info", "snowbridge-control", @@ -2486,6 +2489,7 @@ dependencies = [ name = "bridge-hub-westend-emulated-chain" version = "0.0.0" dependencies = [ + "bridge-hub-common", "bridge-hub-westend-runtime", "cumulus-primitives-core", "emulated-integration-tests-common", diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/Cargo.toml index 0efb2b199c1c..9ccc6b5ec335 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-rococo/Cargo.toml @@ -22,6 +22,7 @@ parachains-common = { path = "../../../../../../../parachains/common" } cumulus-primitives-core = { path = "../../../../../../../primitives/core", default-features = false } emulated-integration-tests-common = { path = "../../../../common", default-features = false } bridge-hub-rococo-runtime = { path = "../../../../../../runtimes/bridge-hubs/bridge-hub-rococo" } +bridge-hub-common = { path = "../../../../../../runtimes/bridge-hubs/common", default-features = false } # Snowbridge snowbridge-core = { path = "../../../../../../../../../parachain/primitives/core", default-features = false } 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 595329e85bb6..6eb14969eda9 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,7 +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, + MessageOrigin: bridge_hub_common::AggregateMessageOrigin, }, pallets = { PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm, diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/Cargo.toml index e5e6fd707393..191388e5f6df 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/Cargo.toml @@ -22,3 +22,4 @@ parachains-common = { path = "../../../../../../../parachains/common" } 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 } diff --git a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs index bb3536154f2e..dd1a2d835641 100644 --- a/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/chains/parachains/bridges/bridge-hub-westend/src/lib.rs @@ -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: cumulus_primitives_core::AggregateMessageOrigin, + MessageOrigin: bridge_hub_common::AggregateMessageOrigin, }, pallets = { PolkadotXcm: bridge_hub_westend_runtime::PolkadotXcm, diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml index 4866f2c3188c..24d1f1308b42 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/Cargo.toml @@ -40,6 +40,8 @@ rococo-westend-system-emulated-network = { path = "../../../networks/rococo-west bridge-hub-rococo-emulated-chain = { path = "../../../chains/parachains/bridges/bridge-hub-rococo"} asset-hub-rococo-emulated-chain = { path = "../../../chains/parachains/assets/asset-hub-rococo"} penpal-emulated-chain = { path = "../../../chains/parachains/testing/penpal" } +penpal-runtime = { path = "../../../../../runtimes/testing/penpal" } +rococo-system-emulated-network ={ path = "../../../networks/rococo-system" } # Snowbridge snowbridge-core = { path = "../../../../../../../../parachain/primitives/core", default-features = false } diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs index 86cf8e68d40d..b78cb140c3d6 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/lib.rs @@ -41,6 +41,11 @@ pub use emulated_integration_tests_common::{ PROOF_SIZE_THRESHOLD, REF_TIME_THRESHOLD, XCM_V3, }; pub use parachains_common::{AccountId, Balance}; +pub use rococo_system_emulated_network::{ + penpal_emulated_chain::PenpalAParaPallet as PenpalAPallet, + BridgeHubRococoParaReceiver as BridgeHubRococoReceiver, PenpalAPara as PenpalA, + PenpalAParaReceiver as PenpalAReceiver, PenpalAParaSender as PenpalASender, +}; pub use rococo_westend_system_emulated_network::{ asset_hub_rococo_emulated_chain::{ genesis::ED as ASSET_HUB_ROCOCO_ED, AssetHubRococoParaPallet as AssetHubRococoPallet, @@ -51,16 +56,13 @@ pub use rococo_westend_system_emulated_network::{ bridge_hub_rococo_emulated_chain::{ genesis::ED as BRIDGE_HUB_ROCOCO_ED, BridgeHubRococoParaPallet as BridgeHubRococoPallet, }, - penpal_emulated_chain::PenpalAParaPallet as PenpalAPallet, rococo_emulated_chain::{genesis::ED as ROCOCO_ED, RococoRelayPallet as RococoPallet}, AssetHubRococoPara as AssetHubRococo, AssetHubRococoParaReceiver as AssetHubRococoReceiver, AssetHubRococoParaSender as AssetHubRococoSender, AssetHubWestendPara as AssetHubWestend, AssetHubWestendParaReceiver as AssetHubWestendReceiver, BridgeHubRococoPara as BridgeHubRococo, - BridgeHubRococoParaReceiver as BridgeHubRococoReceiver, BridgeHubRococoParaSender as BridgeHubRococoSender, BridgeHubWestendPara as BridgeHubWestend, - PenpalAPara as PenpalA, PenpalAParaReceiver as PenpalAReceiver, - PenpalAParaSender as PenpalASender, RococoRelay as Rococo, - RococoRelayReceiver as RococoReceiver, RococoRelaySender as RococoSender, + RococoRelay as Rococo, RococoRelayReceiver as RococoReceiver, + RococoRelaySender as RococoSender, }; pub const ASSET_ID: u32 = 1; diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 21e63e81eb8b..ac3df173f0a4 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -230,95 +230,95 @@ fn register_token() { }); } -#[test] -fn send_token_to_penpal() { - let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation { - parents: 1, - interior: X1(Parachain(ASSETHUB_PARA_ID)), - }); - BridgeHubRococo::fund_accounts(vec![(asset_hub_sovereign.clone(), INITIAL_FUND)]); - - // Fund ethereum sovereign in asset hub - AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]); - - PenpalA::fund_accounts(vec![ - (PenpalAReceiver::get(), INITIAL_FUND), - (PenpalASender::get(), INITIAL_FUND), - ]); - - let weth_asset_id: MultiLocation = - (Parent, Parent, Ethereum { chain_id: 15 }, AccountKey20 { network: None, key: WETH }) - .into(); - - // Create asset on penpal. - PenpalA::execute_with(|| { - assert_ok!(::ForeignAssets::create( - ::RuntimeOrigin::signed(PenpalASender::get()), - weth_asset_id, - asset_hub_sovereign.into(), - 1000, - )); - - //assert!(::Assets::asset_exists(weth_asset_id)); - }); - - let message_id_: H256 = [1; 32].into(); - - BridgeHubRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - type EthereumInboundQueue = - ::EthereumInboundQueue; - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::RegisterToken { token: WETH.into() }, - }); - let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap(); - let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap(); - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::SendToken { - token: WETH.into(), - destination: Destination::ForeignAccountId32 { - para_id: 2000, - id: PenpalAReceiver::get().into(), - }, - amount: 1_000_000_000, - }, - }); - let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap(); - let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap(); - - assert_expected_events!( - BridgeHubRococo, - vec![ - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - AssetHubRococo::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - AssetHubRococo, - vec![ - RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, - ] - ); - }); - - PenpalA::execute_with(|| { - type RuntimeEvent = ::RuntimeEvent; - - assert_expected_events!( - PenpalA, - vec![ - RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, - ] - ); - }); -} +// #[test] +// fn send_token_to_penpal() { +// let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation { +// parents: 1, +// interior: X1(Parachain(ASSETHUB_PARA_ID)), +// }); +// BridgeHubRococo::fund_accounts(vec![(asset_hub_sovereign.clone(), INITIAL_FUND)]); +// +// // Fund ethereum sovereign in asset hub +// AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]); +// +// PenpalA::fund_accounts(vec![ +// (PenpalAReceiver::get(), INITIAL_FUND), +// (PenpalASender::get(), INITIAL_FUND), +// ]); +// +// let weth_asset_id: MultiLocation = +// (Parent, Parent, Ethereum { chain_id: 15 }, AccountKey20 { network: None, key: WETH }) +// .into(); +// +// // Create asset on penpal. +// PenpalA::execute_with(|| { +// assert_ok!(::ForeignAssets::create( +// ::RuntimeOrigin::signed(PenpalASender::get()), +// weth_asset_id, +// asset_hub_sovereign.into(), +// 1000, +// )); +// +// //assert!(::Assets::asset_exists(weth_asset_id)); +// }); +// +// let message_id_: H256 = [1; 32].into(); +// +// BridgeHubRococo::execute_with(|| { +// type RuntimeEvent = ::RuntimeEvent; +// type EthereumInboundQueue = +// ::EthereumInboundQueue; +// let message = VersionedMessage::V1(MessageV1 { +// chain_id: CHAIN_ID, +// command: Command::RegisterToken { token: WETH.into() }, +// }); +// let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap(); +// let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap(); +// let message = VersionedMessage::V1(MessageV1 { +// chain_id: CHAIN_ID, +// command: Command::SendToken { +// token: WETH.into(), +// destination: Destination::ForeignAccountId32 { +// para_id: 2000, +// id: PenpalAReceiver::get().into(), +// }, +// amount: 1_000_000_000, +// }, +// }); +// let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap(); +// let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap(); +// +// assert_expected_events!( +// BridgeHubRococo, +// vec![ +// RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, +// ] +// ); +// }); +// +// AssetHubRococo::execute_with(|| { +// type RuntimeEvent = ::RuntimeEvent; +// +// assert_expected_events!( +// AssetHubRococo, +// vec![ +// RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, +// RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, +// ] +// ); +// }); +// +// PenpalA::execute_with(|| { +// type RuntimeEvent = ::RuntimeEvent; +// +// assert_expected_events!( +// PenpalA, +// vec![ +// RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, +// ] +// ); +// }); +// } #[test] fn send_token() { diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs index fc46323e6e29..0cc8d4a0f0ff 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs @@ -14,7 +14,7 @@ // limitations under the License. //! Runtime configuration for MessageQueue pallet use codec::{Decode, Encode, MaxEncodedLen}; -use cumulus_primitives_core::ParaId; +use cumulus_primitives_core::{AggregateMessageOrigin as CumulusAggregateMessageOrigin, ParaId}; use frame_support::{ traits::{ProcessMessage, ProcessMessageError, QueueFootprint, QueuePausedQuery}, weights::WeightMeter, @@ -57,6 +57,16 @@ impl From for MultiLocation { } } +impl From for AggregateMessageOrigin { + fn from(origin: CumulusAggregateMessageOrigin) -> Self { + match origin { + CumulusAggregateMessageOrigin::Here => Self::Here, + CumulusAggregateMessageOrigin::Parent => Self::Parent, + CumulusAggregateMessageOrigin::Sibling(id) => Self::Sibling(id), + } + } +} + #[cfg(feature = "runtime-benchmarks")] impl From for AggregateMessageOrigin { fn from(x: u32) -> Self { diff --git a/cumulus/primitives/core/src/lib.rs b/cumulus/primitives/core/src/lib.rs index 2f972203ab54..835c9de649ea 100644 --- a/cumulus/primitives/core/src/lib.rs +++ b/cumulus/primitives/core/src/lib.rs @@ -91,11 +91,6 @@ pub enum AggregateMessageOrigin { /// /// This is used by the HRMP queue. Sibling(ParaId), - /// The message came from some origin identified by a 32-byte ID. - /// - /// Due to its generality, this is can be used by pallets - /// other than the DMP and HRMP queue. - GeneralKey([u8; 32]), } impl From for xcm::v3::MultiLocation { @@ -105,8 +100,6 @@ impl From for xcm::v3::MultiLocation { AggregateMessageOrigin::Parent => MultiLocation::parent(), AggregateMessageOrigin::Sibling(id) => MultiLocation::new(1, Junction::Parachain(id.into())), - AggregateMessageOrigin::GeneralKey(id) => - MultiLocation::new(0, Junction::GeneralKey { length: 32, data: id }), } } } diff --git a/cumulus/xcm/xcm-emulator/src/lib.rs b/cumulus/xcm/xcm-emulator/src/lib.rs index 1ad4cd05b74e..f5c6b88adce5 100644 --- a/cumulus/xcm/xcm-emulator/src/lib.rs +++ b/cumulus/xcm/xcm-emulator/src/lib.rs @@ -245,7 +245,7 @@ pub trait Parachain: Chain { type LocationToAccountId: ConvertLocation>; type ParachainInfo: Get; type ParachainSystem; - type MessageProcessor: ProcessMessage + ServiceQueues; + type MessageProcessor: ProcessMessage + ServiceQueues; fn init(); @@ -1007,7 +1007,7 @@ macro_rules! decl_test_networks { <$parachain>::ext_wrapper(|| { let _ = <$parachain as Parachain>::MessageProcessor::process_message( &msg[..], - $crate::CumulusAggregateMessageOrigin::Parent, + $crate::CumulusAggregateMessageOrigin::Parent.into(), &mut weight_meter, &mut msg.using_encoded($crate::blake2_256), ); @@ -1317,11 +1317,16 @@ pub struct DefaultParaMessageProcessor(PhantomData<(T, M)>); // Process HRMP messages from sibling paraids impl ProcessMessage for DefaultParaMessageProcessor where - M: codec::FullCodec + MaxEncodedLen + Clone + Eq + PartialEq + frame_support::pallet_prelude::TypeInfo + Debug, + M: codec::FullCodec + + MaxEncodedLen + + Clone + + Eq + + PartialEq + + frame_support::pallet_prelude::TypeInfo + + Debug, T: Parachain, T::Runtime: MessageQueueConfig, - <::MessageProcessor as ProcessMessage>::Origin: - PartialEq, + <::MessageProcessor as ProcessMessage>::Origin: PartialEq, MessageQueuePallet: EnqueueMessage + ServiceQueues, { type Origin = M; @@ -1346,8 +1351,7 @@ where M: MaxEncodedLen, T: Parachain, T::Runtime: MessageQueueConfig, - <::MessageProcessor as ProcessMessage>::Origin: - PartialEq, + <::MessageProcessor as ProcessMessage>::Origin: PartialEq, MessageQueuePallet: EnqueueMessage + ServiceQueues, { type OverweightMessageAddress = (); From e0e654287f0068a2a212cff3bf959b372a8fdc2b Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Sat, 25 Nov 2023 15:02:26 +0200 Subject: [PATCH 07/11] westend needs the same config --- .../runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml | 3 +++ .../runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml index 7e384126ab67..297fa2d7b038 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/Cargo.toml @@ -91,6 +91,7 @@ pallet-bridge-messages = { path = "../../../../../bridges/modules/messages", def pallet-bridge-parachains = { path = "../../../../../bridges/modules/parachains", default-features = false } pallet-bridge-relayers = { path = "../../../../../bridges/modules/relayers", 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" @@ -173,6 +174,7 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "bridge-hub-common/std", ] runtime-benchmarks = [ @@ -205,6 +207,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "bridge-hub-common/runtime-benchmarks", ] try-runtime = [ diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index 9e8fd84e7125..90702e95533e 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -33,8 +33,7 @@ mod weights; pub mod xcm_config; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -use cumulus_primitives_core::{AggregateMessageOrigin, ParaId}; -use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling}; +use cumulus_primitives_core::ParaId; use sp_api::impl_runtime_apis; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ @@ -49,6 +48,10 @@ 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, dispatch::DispatchClass, From cc582bd2e8bf99bc1476f47a3756ed7a6c192230 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Sat, 25 Nov 2023 20:23:24 +0200 Subject: [PATCH 08/11] revert log --- cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml | 4 +--- .../runtimes/bridge-hubs/common/src/message_queue.rs | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml b/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml index 868f35f4a366..cb45735bbdcd 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml +++ b/cumulus/parachains/runtimes/bridge-hubs/common/Cargo.toml @@ -16,7 +16,6 @@ cumulus-primitives-core = { path = "../../../../primitives/core", default-featur xcm = { package = "staging-xcm", path = "../../../../../polkadot/xcm", default-features = false} pallet-message-queue = { path = "../../../../../substrate/frame/message-queue", default-features = false} snowbridge-core = { path = "../../../../../../parachain/primitives/core", default-features = false } -log = { version = "0.4.20", default-features = false } [features] default = [ "std" ] @@ -29,8 +28,7 @@ std = [ "cumulus-primitives-core/std", "xcm/std", "pallet-message-queue/std", - "snowbridge-core/std", - "log/std" + "snowbridge-core/std" ] runtime-benchmarks = [ diff --git a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs index 0cc8d4a0f0ff..15b12ee785b8 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/common/src/message_queue.rs @@ -101,7 +101,6 @@ where id: &mut [u8; 32], ) -> Result { use AggregateMessageOrigin::*; - log::info!(target: "xcm", "💫 in process message origin is {:?}.", origin); match origin { Here | Parent | Sibling(_) => XcmpProcessor::process_message(message, origin, meter, id), From 34920103cbca1de2216f50ec77be8437fbd0efbc Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Sat, 25 Nov 2023 21:43:52 +0200 Subject: [PATCH 09/11] add test back in --- .../bridge-hub-rococo/src/tests/snowbridge.rs | 178 +++++++++--------- 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index ac3df173f0a4..21e63e81eb8b 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -230,95 +230,95 @@ fn register_token() { }); } -// #[test] -// fn send_token_to_penpal() { -// let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation { -// parents: 1, -// interior: X1(Parachain(ASSETHUB_PARA_ID)), -// }); -// BridgeHubRococo::fund_accounts(vec![(asset_hub_sovereign.clone(), INITIAL_FUND)]); -// -// // Fund ethereum sovereign in asset hub -// AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]); -// -// PenpalA::fund_accounts(vec![ -// (PenpalAReceiver::get(), INITIAL_FUND), -// (PenpalASender::get(), INITIAL_FUND), -// ]); -// -// let weth_asset_id: MultiLocation = -// (Parent, Parent, Ethereum { chain_id: 15 }, AccountKey20 { network: None, key: WETH }) -// .into(); -// -// // Create asset on penpal. -// PenpalA::execute_with(|| { -// assert_ok!(::ForeignAssets::create( -// ::RuntimeOrigin::signed(PenpalASender::get()), -// weth_asset_id, -// asset_hub_sovereign.into(), -// 1000, -// )); -// -// //assert!(::Assets::asset_exists(weth_asset_id)); -// }); -// -// let message_id_: H256 = [1; 32].into(); -// -// BridgeHubRococo::execute_with(|| { -// type RuntimeEvent = ::RuntimeEvent; -// type EthereumInboundQueue = -// ::EthereumInboundQueue; -// let message = VersionedMessage::V1(MessageV1 { -// chain_id: CHAIN_ID, -// command: Command::RegisterToken { token: WETH.into() }, -// }); -// let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap(); -// let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap(); -// let message = VersionedMessage::V1(MessageV1 { -// chain_id: CHAIN_ID, -// command: Command::SendToken { -// token: WETH.into(), -// destination: Destination::ForeignAccountId32 { -// para_id: 2000, -// id: PenpalAReceiver::get().into(), -// }, -// amount: 1_000_000_000, -// }, -// }); -// let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap(); -// let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap(); -// -// assert_expected_events!( -// BridgeHubRococo, -// vec![ -// RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, -// ] -// ); -// }); -// -// AssetHubRococo::execute_with(|| { -// type RuntimeEvent = ::RuntimeEvent; -// -// assert_expected_events!( -// AssetHubRococo, -// vec![ -// RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, -// RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, -// ] -// ); -// }); -// -// PenpalA::execute_with(|| { -// type RuntimeEvent = ::RuntimeEvent; -// -// assert_expected_events!( -// PenpalA, -// vec![ -// RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, -// ] -// ); -// }); -// } +#[test] +fn send_token_to_penpal() { + let asset_hub_sovereign = BridgeHubRococo::sovereign_account_id_of(MultiLocation { + parents: 1, + interior: X1(Parachain(ASSETHUB_PARA_ID)), + }); + BridgeHubRococo::fund_accounts(vec![(asset_hub_sovereign.clone(), INITIAL_FUND)]); + + // Fund ethereum sovereign in asset hub + AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]); + + PenpalA::fund_accounts(vec![ + (PenpalAReceiver::get(), INITIAL_FUND), + (PenpalASender::get(), INITIAL_FUND), + ]); + + let weth_asset_id: MultiLocation = + (Parent, Parent, Ethereum { chain_id: 15 }, AccountKey20 { network: None, key: WETH }) + .into(); + + // Create asset on penpal. + PenpalA::execute_with(|| { + assert_ok!(::ForeignAssets::create( + ::RuntimeOrigin::signed(PenpalASender::get()), + weth_asset_id, + asset_hub_sovereign.into(), + 1000, + )); + + //assert!(::Assets::asset_exists(weth_asset_id)); + }); + + let message_id_: H256 = [1; 32].into(); + + BridgeHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + type EthereumInboundQueue = + ::EthereumInboundQueue; + let message = VersionedMessage::V1(MessageV1 { + chain_id: CHAIN_ID, + command: Command::RegisterToken { token: WETH.into() }, + }); + let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap(); + let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap(); + let message = VersionedMessage::V1(MessageV1 { + chain_id: CHAIN_ID, + command: Command::SendToken { + token: WETH.into(), + destination: Destination::ForeignAccountId32 { + para_id: 2000, + id: PenpalAReceiver::get().into(), + }, + amount: 1_000_000_000, + }, + }); + let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap(); + let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap(); + + assert_expected_events!( + BridgeHubRococo, + vec![ + RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, + ] + ); + }); + + AssetHubRococo::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + AssetHubRococo, + vec![ + RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, + RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::XcmpMessageSent { .. }) => {}, + ] + ); + }); + + PenpalA::execute_with(|| { + type RuntimeEvent = ::RuntimeEvent; + + assert_expected_events!( + PenpalA, + vec![ + RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, + ] + ); + }); +} #[test] fn send_token() { From 315ab9708dba6815657902636787aec28a6f110f Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Sat, 25 Nov 2023 22:17:01 +0200 Subject: [PATCH 10/11] revert fmt --- .../client/rpc-spec-v2/src/chain_head/subscription/inner.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/substrate/client/rpc-spec-v2/src/chain_head/subscription/inner.rs b/substrate/client/rpc-spec-v2/src/chain_head/subscription/inner.rs index 2b250f3dc2cf..abd42ad96785 100644 --- a/substrate/client/rpc-spec-v2/src/chain_head/subscription/inner.rs +++ b/substrate/client/rpc-spec-v2/src/chain_head/subscription/inner.rs @@ -763,7 +763,7 @@ impl> SubscriptionsInner { // blocks. for hash in hashes.clone() { if !sub.contains_block(hash) { - return Err(SubscriptionManagementError::BlockHashAbsent) + return Err(SubscriptionManagementError::BlockHashAbsent); } } From 58f5dd9bcb593e32c29a7c672e9868917fe91073 Mon Sep 17 00:00:00 2001 From: ron Date: Mon, 27 Nov 2023 13:29:05 +0800 Subject: [PATCH 11/11] Fix breaking test --- .../bridge-hub-rococo/src/tests/snowbridge.rs | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 21e63e81eb8b..2849ca6045ca 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -238,17 +238,36 @@ fn send_token_to_penpal() { }); BridgeHubRococo::fund_accounts(vec![(asset_hub_sovereign.clone(), INITIAL_FUND)]); - // Fund ethereum sovereign in asset hub - AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]); - PenpalA::fund_accounts(vec![ (PenpalAReceiver::get(), INITIAL_FUND), (PenpalASender::get(), INITIAL_FUND), ]); - let weth_asset_id: MultiLocation = + let weth_asset_location: MultiLocation = (Parent, Parent, Ethereum { chain_id: 15 }, AccountKey20 { network: None, key: WETH }) .into(); + let weth_asset_id = weth_asset_location.into(); + + let origin_location = + MultiLocation { parents: 2, interior: weth_asset_location.interior.split_last().0 }; + + // Fund ethereum sovereign in asset hub + let ethereum_sovereign: AccountId = + hex!("da4d66c3651dc151264eee5460493210338e41a7bbfca91a520e438daf180bf5").into(); + AssetHubRococo::fund_accounts(vec![(ethereum_sovereign.clone(), INITIAL_FUND)]); + // Create asset on assethub. + AssetHubRococo::execute_with(|| { + assert_ok!(::ForeignAssets::create( + pallet_xcm::Origin::Xcm(origin_location).into(), + weth_asset_id, + asset_hub_sovereign.clone().into(), + 1000, + )); + + assert!(::ForeignAssets::asset_exists( + weth_asset_id + )); + }); // Create asset on penpal. PenpalA::execute_with(|| { @@ -259,7 +278,7 @@ fn send_token_to_penpal() { 1000, )); - //assert!(::Assets::asset_exists(weth_asset_id)); + assert!(::ForeignAssets::asset_exists(weth_asset_id)); }); let message_id_: H256 = [1; 32].into(); @@ -268,12 +287,6 @@ fn send_token_to_penpal() { type RuntimeEvent = ::RuntimeEvent; type EthereumInboundQueue = ::EthereumInboundQueue; - let message = VersionedMessage::V1(MessageV1 { - chain_id: CHAIN_ID, - command: Command::RegisterToken { token: WETH.into() }, - }); - let (xcm, _) = EthereumInboundQueue::do_convert(message_id_, message).unwrap(); - let _ = EthereumInboundQueue::send_xcm(xcm, ASSETHUB_PARA_ID.into()).unwrap(); let message = VersionedMessage::V1(MessageV1 { chain_id: CHAIN_ID, command: Command::SendToken {