diff --git a/Cargo.lock b/Cargo.lock index f9c720cdebff..15a75f7279f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2372,6 +2372,11 @@ dependencies = [ "frame-support", "parachains-common", "serde_json", + "snowbridge-control", + "snowbridge-core", + "snowbridge-inbound-queue", + "snowbridge-outbound-queue", + "snowbridge-router-primitives", "sp-core", "sp-runtime", ] @@ -2380,19 +2385,32 @@ dependencies = [ name = "bridge-hub-rococo-integration-tests" version = "1.0.0" dependencies = [ + "asset-hub-rococo-emulated-chain", "asset-test-utils", "bp-messages", + "bridge-hub-rococo-emulated-chain", "bridge-hub-rococo-runtime", "cumulus-pallet-dmp-queue", "cumulus-pallet-xcmp-queue", "emulated-integration-tests-common", "frame-support", + "hex", + "hex-literal", + "pallet-assets", + "pallet-balances", "pallet-bridge-messages", "pallet-message-queue", "pallet-xcm", "parachains-common", "parity-scale-codec", "rococo-wococo-system-emulated-network", + "scale-info", + "snowbridge-control", + "snowbridge-core", + "snowbridge-inbound-queue", + "snowbridge-outbound-queue", + "snowbridge-router-primitives", + "sp-core", "staging-xcm", "staging-xcm-executor", ] 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 43c0f5fd14c9..0efb2b199c1c 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,3 +22,11 @@ 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" } + +# Snowbridge +snowbridge-core = { path = "../../../../../../../../../parachain/primitives/core", default-features = false } +snowbridge-router-primitives = { path = "../../../../../../../../../parachain/primitives/router", default-features = false } +snowbridge-control = { path = "../../../../../../../../../parachain/pallets/control", default-features = false } +snowbridge-inbound-queue = { path = "../../../../../../../../../parachain/pallets/inbound-queue", default-features = false } +snowbridge-outbound-queue = { path = "../../../../../../../../../parachain/pallets/outbound-queue", 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 f4557021f62b..0d7fa53a0ad4 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 @@ -40,6 +40,9 @@ decl_test_parachains! { pallets = { PolkadotXcm: bridge_hub_rococo_runtime::PolkadotXcm, Balances: bridge_hub_rococo_runtime::Balances, + EthereumControl: bridge_hub_rococo_runtime::EthereumControl, + EthereumInboundQueue: bridge_hub_rococo_runtime::EthereumInboundQueue, + EthereumOutboundQueue: bridge_hub_rococo_runtime::EthereumOutboundQueue, } }, } 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 035d9c107933..aad2807edde5 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 @@ -9,10 +9,16 @@ publish = false [dependencies] codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false } +scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } +hex = "0.4.3" +hex-literal = "0.4.1" # Substrate +sp-core = { path = "../../../../../../../substrate/primitives/core", default-features = false} frame-support = { path = "../../../../../../../substrate/frame/support", default-features = false} pallet-message-queue = { path = "../../../../../../../substrate/frame/message-queue" } +pallet-assets = { path = "../../../../../../../substrate/frame/assets", default-features = false } +pallet-balances = { path = "../../../../../../../substrate/frame/balances", default-features = false } # Polkadot xcm = { package = "staging-xcm", path = "../../../../../../../polkadot/xcm", default-features = false} @@ -30,4 +36,13 @@ cumulus-pallet-xcmp-queue = { path = "../../../../../../pallets/xcmp-queue", def cumulus-pallet-dmp-queue = { path = "../../../../../../pallets/dmp-queue", default-features = false} bridge-hub-rococo-runtime = { path = "../../../../../../parachains/runtimes/bridge-hubs/bridge-hub-rococo", default-features = false } emulated-integration-tests-common = { path = "../../../common", default-features = false} -rococo-wococo-system-emulated-network ={ path = "../../../networks/rococo-wococo-system" } +rococo-wococo-system-emulated-network = { path = "../../../networks/rococo-wococo-system" } +bridge-hub-rococo-emulated-chain = { path = "../../../chains/parachains/bridges/bridge-hub-rococo"} +asset-hub-rococo-emulated-chain = { path = "../../../chains/parachains/assets/asset-hub-rococo"} + +# Snowbridge +snowbridge-core = { path = "../../../../../../../../parachain/primitives/core", default-features = false } +snowbridge-router-primitives = { path = "../../../../../../../../parachain/primitives/router", default-features = false } +snowbridge-control = { path = "../../../../../../../../parachain/pallets/control", default-features = false } +snowbridge-inbound-queue = { path = "../../../../../../../../parachain/pallets/inbound-queue", default-features = false } +snowbridge-outbound-queue = { path = "../../../../../../../../parachain/pallets/outbound-queue", default-features = false } 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 fa697e5cc240..2ede961bf3c1 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 @@ -13,9 +13,11 @@ // See the License for the specific language governing permissions and // limitations under the License. use crate::*; -use codec::Encode; +use asset_hub_rococo_emulated_chain::AssetHubRococoParaPallet as AssetHubRococoPallet; +use bridge_hub_rococo_emulated_chain::BridgeHubRococoParaPallet as BridgeHubRococoPallet; +use codec::{Decode, Encode}; +use frame_support::pallet_prelude::TypeInfo; use hex_literal::hex; -use integration_tests_common::{AssetHubRococoPallet, BridgeHubRococoPallet}; use snowbridge_control; use snowbridge_core::outbound::OperatingMode; use snowbridge_router_primitives::inbound::{Command, Destination, MessageV1, VersionedMessage}; @@ -52,7 +54,7 @@ fn create_agent() { Transact { require_weight_at_most: 3000000000.into(), origin_kind: OriginKind::Xcm, - call: vec![51, 2].into(), + call: vec![63, 2].into(), }, ])); @@ -81,10 +83,6 @@ fn create_agent() { assert_expected_events!( BridgeHubRococo, vec![ - RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { - outcome: Outcome::Complete(_), - .. - }) => {}, RuntimeEvent::EthereumControl(snowbridge_control::Event::CreateAgent { .. }) => {}, @@ -93,6 +91,19 @@ fn create_agent() { }); } +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +pub enum CreateChannelCall { + #[codec(index = 3)] + CreateChannel { mode: OperatingMode, outbound_fee: u128 }, +} + +#[allow(clippy::large_enum_variant)] +#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] +pub enum SnowbridgeControl { + #[codec(index = 63)] + Control(CreateChannelCall), +} + #[test] fn create_channel() { let origin_para: u32 = 1001; @@ -114,17 +125,22 @@ fn create_channel() { Transact { require_weight_at_most: 3000000000.into(), origin_kind: OriginKind::Xcm, - call: vec![51, 2].into(), + call: vec![63, 2].into(), }, ])); + let create_channel_call = SnowbridgeControl::Control(CreateChannelCall::CreateChannel { + mode: OperatingMode::Normal, + outbound_fee: 1, + }); + let create_channel_xcm = VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, DescendOrigin(X1(Parachain(origin_para))), Transact { require_weight_at_most: 3000000000.into(), origin_kind: OriginKind::Xcm, - call: ([51u8, 3u8], OperatingMode::Normal, 1u128).encode().into(), + call: create_channel_call.encode().into(), }, ])); @@ -159,10 +175,6 @@ fn create_channel() { assert_expected_events!( BridgeHubRococo, vec![ - RuntimeEvent::DmpQueue(cumulus_pallet_dmp_queue::Event::ExecutedDownward { - outcome: Outcome::Complete(_), - .. - }) => {}, RuntimeEvent::EthereumControl(snowbridge_control::Event::CreateChannel { .. }) => {}, @@ -209,9 +221,6 @@ fn register_token() { AssetHubRococo, vec![ RuntimeEvent::ForeignAssets(pallet_assets::Event::Created { .. }) => {}, - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { message_id, .. }) => { - message_id: H256::from(*message_id) == message_id_, - }, ] ); }); @@ -271,9 +280,6 @@ fn send_token() { AssetHubRococo, vec![ RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { message_id, .. }) => { - message_id: H256::from(*message_id) == message_id_, - }, ] ); }); @@ -335,9 +341,6 @@ fn reserve_transfer_token() { AssetHubRococo, vec![ RuntimeEvent::ForeignAssets(pallet_assets::Event::Issued { .. }) => {}, - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { message_id, .. }) => { - message_id: H256::from(*message_id) == message_id_, - }, ] ); let assets = vec![MultiAsset { @@ -379,7 +382,6 @@ fn reserve_transfer_token() { BridgeHubRococo, vec![ RuntimeEvent::EthereumOutboundQueue(snowbridge_outbound_queue::Event::MessageQueued {..}) => {}, - RuntimeEvent::XcmpQueue(cumulus_pallet_xcmp_queue::Event::Success { .. }) => {}, ] ); let events = BridgeHubRococo::events(); 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 82e4bb50d895..7d46e6a02ed5 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 @@ -101,7 +101,7 @@ use parachains_common::{ }; #[cfg(feature = "runtime-benchmarks")] -use crate::xcm_config::benchmark_helper::DoNothingRouter; +use crate::xcm_config::DoNothingRouter; #[cfg(feature = "runtime-benchmarks")] use snowbridge_beacon_primitives::CompactExecutionHeader; #[cfg(feature = "runtime-benchmarks")] diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs index 96cd20c90a2b..048c5e60c2d3 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/xcm_config.rs @@ -221,9 +221,9 @@ impl Contains for SafeCallFilter { snowbridge_ethereum_beacon_client::Call::set_operating_mode { .. }, ) | RuntimeCall::EthereumInboundQueue( snowbridge_inbound_queue::Call::set_operating_mode { .. }, - ) /* | RuntimeCall::EthereumOutboundQueue( - snowbridge_outbound_queue::Call::set_operating_mode { .. }, - ) | RuntimeCall::EthereumControl(..) */ + ) | RuntimeCall::EthereumOutboundQueue( + snowbridge_outbound_queue::Call::set_operating_mode { .. }, + ) | RuntimeCall::EthereumControl(..) ) } } @@ -488,3 +488,14 @@ impl< fee } } + +pub struct DoNothingRouter; +impl SendXcm for DoNothingRouter { + type Ticket = (); + fn validate(_dest: &mut Option, _msg: &mut Option>) -> SendResult<()> { + Ok(((), MultiAssets::new())) + } + fn deliver(_: ()) -> Result { + Ok([0; 32]) + } +}