From 52494e6d4b14915dccf905275eecb612ae4521ff Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Tue, 12 Dec 2023 00:24:40 +0200 Subject: [PATCH 1/3] add basic filter --- .../bridge-hub-rococo/src/bridge_to_ethereum_config.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs index 02c85c06922d0..30074424b7699 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs @@ -18,6 +18,7 @@ use crate::{ xcm_config::{AgentIdOf, UniversalLocation}, Runtime, }; +use frame_support::traits::Everything; use snowbridge_rococo_common::EthereumNetwork; use snowbridge_router_primitives::outbound::EthereumBlobExporter; @@ -26,4 +27,5 @@ pub type SnowbridgeExporter = EthereumBlobExporter< EthereumNetwork, snowbridge_outbound_queue::Pallet, AgentIdOf, + Everything, >; From 4660ab498ffa140b3fcba6270e1e328fd19db59a Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Tue, 12 Dec 2023 01:29:12 +0200 Subject: [PATCH 2/3] add real filter --- .../src/bridge_to_ethereum_config.rs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs index 30074424b7699..2e4b52f15c9a9 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs @@ -18,14 +18,32 @@ use crate::{ xcm_config::{AgentIdOf, UniversalLocation}, Runtime, }; -use frame_support::traits::Everything; +use cumulus_primitives_core::{InteriorMultiLocation, Parachain, X1}; +use frame_support::traits::{ContainsPair, EverythingBut}; +use rococo_runtime_constants::system_parachain::ASSET_HUB_ID; +use snowbridge_core::outbound::{AgentExecuteCommand, Command, Message}; use snowbridge_rococo_common::EthereumNetwork; use snowbridge_router_primitives::outbound::EthereumBlobExporter; +pub struct NonAssetHubTokenTransfers; +impl ContainsPair for NonAssetHubTokenTransfers { + fn contains(origin: &InteriorMultiLocation, message: &Message) -> bool { + if let Command::AgentExecute { + command: AgentExecuteCommand::TransferToken { .. }, .. + } = message.command + { + return origin != &X1(Parachain(ASSET_HUB_ID)); + } + return false; + } +} + +type SnowbridgeExportFilter = EverythingBut; + pub type SnowbridgeExporter = EthereumBlobExporter< UniversalLocation, EthereumNetwork, snowbridge_outbound_queue::Pallet, AgentIdOf, - Everything, + SnowbridgeExportFilter, >; From 6252d96cb9555e8b407df8dd27b0b8ef359b74ef Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Tue, 12 Dec 2023 01:40:40 +0200 Subject: [PATCH 3/3] use matches! --- .../src/bridge_to_ethereum_config.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs index 2e4b52f15c9a9..d0f8f6d5c3eac 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/bridge_to_ethereum_config.rs @@ -28,13 +28,10 @@ use snowbridge_router_primitives::outbound::EthereumBlobExporter; pub struct NonAssetHubTokenTransfers; impl ContainsPair for NonAssetHubTokenTransfers { fn contains(origin: &InteriorMultiLocation, message: &Message) -> bool { - if let Command::AgentExecute { - command: AgentExecuteCommand::TransferToken { .. }, .. - } = message.command - { - return origin != &X1(Parachain(ASSET_HUB_ID)); - } - return false; + matches!( + message.command, + Command::AgentExecute { command: AgentExecuteCommand::TransferToken { .. }, .. } + ) && origin != &X1(Parachain(ASSET_HUB_ID)) } }