From 5e480ddc18267dcc41aba82b6ab27907d30cc154 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Thu, 26 Oct 2023 15:36:35 +0200 Subject: [PATCH] fixes send token --- .../assets/asset-hub-rococo/src/xcm_config.rs | 23 +++++++++------- .../runtimes/assets/common/src/matching.rs | 27 ++++++++++++++++--- .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 8 +++--- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs index d7f2b5261bef..c124d49e8586 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs @@ -574,6 +574,7 @@ impl xcm_executor::Config for XcmConfig { type IsReserve = ( bridging::to_wococo::IsTrustedBridgedReserveLocationForConcreteAsset, bridging::to_rococo::IsTrustedBridgedReserveLocationForConcreteAsset, + bridging::to_rococo::IsTrustedBridgedReserveLocationForForeignAsset, ); type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; @@ -678,7 +679,7 @@ impl pallet_xcm::Config for Runtime { type XcmReserveTransferFilter = ( LocationWithAssetFilters, bridging::to_rococo::AllowedReserveTransferAssets, - bridging::to_rococo::AllowedReserveTransferAssetsEthereum, + //bridging::to_rococo::AllowedReserveTransferAssetsEthereum, bridging::to_wococo::AllowedReserveTransferAssets, ); @@ -872,6 +873,7 @@ pub mod bridging { pub mod to_rococo { use super::*; + use assets_common::matching::FromNetwork; parameter_types! { pub SiblingBridgeHubWithBridgeHubRococoInstance: MultiLocation = MultiLocation::new( @@ -903,10 +905,10 @@ pub mod bridging { AssetHubRococo::get() ); - pub EtherFromEthereum: (MultiAssetFilter, MultiLocation) = ( - Wild(AllOf { fun: WildFungible, id: Concrete(EthereumLocation::get()) }), - EthereumLocation::get() - ); + /*pub EtherFromEthereum: (MultiAssetFilter, MultiLocation) = ( + EthereumGatewayLocation::get().into(), + EthereumGatewayLocation::get() + );*/ /// Set up exporters configuration. /// `Option` represents static "base fee" which is used for total delivery fee calculation. @@ -941,14 +943,14 @@ pub mod bridging { ]; pub AllowedReserveTransferAssetsToEthereum: sp_std::vec::Vec = sp_std::vec![ - Wild(AllOf { fun: WildFungible, id: Concrete(EthereumGatewayLocation::get()) }), // TODO check + Wild(AllOf { fun: WildFungible, id: Concrete(EthereumGatewayLocation::get()) }), ]; /// Universal aliases pub UniversalAliases: BTreeSet<(MultiLocation, Junction)> = BTreeSet::from_iter( sp_std::vec![ (SiblingBridgeHubWithBridgeHubRococoInstance::get(), GlobalConsensus(RococoNetwork::get())), - (SiblingBridgeHub::get(), GlobalConsensus(EthereumNetwork::get())), // TODO check + (SiblingBridgeHub::get(), GlobalConsensus(EthereumNetwork::get())), ] ); } @@ -967,21 +969,24 @@ pub mod bridging { ( // allow receive ROC from AssetHubRococo xcm_builder::Case, - xcm_builder::Case, // and nothing else ), >; + pub type IsTrustedBridgedReserveLocationForForeignAsset = + matching::IsForeignConcreteAsset>; + /// Allows to reserve transfer assets to `AssetHubRococo`. pub type AllowedReserveTransferAssets = LocationWithAssetFilters< Equals, AllowedReserveTransferAssetsToAssetHubRococo, >; + /* pub type AllowedReserveTransferAssetsEthereum = LocationWithAssetFilters< StartsWithExplicitGlobalConsensus, // TODO check AllowedReserveTransferAssetsToEthereum, - >; + >;*/ impl Contains for ToRococoXcmRouter { fn contains(call: &RuntimeCall) -> bool { diff --git a/cumulus/parachains/runtimes/assets/common/src/matching.rs b/cumulus/parachains/runtimes/assets/common/src/matching.rs index 914972812521..ba0012b20cc1 100644 --- a/cumulus/parachains/runtimes/assets/common/src/matching.rs +++ b/cumulus/parachains/runtimes/assets/common/src/matching.rs @@ -46,18 +46,37 @@ impl> ContainsPair fn contains(&a: &MultiLocation, b: &MultiLocation) -> bool { // `a` needs to be from `b` at least if !a.starts_with(b) { - return false + return false; } // here we check if sibling match a { - MultiLocation { parents: 1, interior } => - matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get()))), + MultiLocation { parents: 1, interior } => { + matches!(interior.first(), Some(Parachain(sibling_para_id)) if sibling_para_id.ne(&u32::from(SelfParaId::get()))) + }, _ => false, } } } +pub struct FromNetwork(sp_std::marker::PhantomData); +impl> ContainsPair + for FromNetwork +{ + fn contains(&a: &MultiLocation, b: &MultiLocation) -> bool { + // `a` needs to be from `b` at least + if !a.starts_with(b) { + return false; + } + + match a { + MultiLocation { parents: 2, interior } => { + matches!(interior.first(), Some(GlobalConsensus(network)) if *network == SelfNetworkId::get()) + }, + _ => false, + } + } +} /// Adapter verifies if it is allowed to receive `MultiAsset` from `MultiLocation`. /// /// Note: `MultiLocation` has to be from a different global consensus. @@ -87,7 +106,7 @@ impl< "IsTrustedBridgedReserveLocationForConcreteAsset origin: {:?} is not remote to the universal_source: {:?}", origin, universal_source ); - return false + return false; }, }; 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 9c52962b4a4d..a257042233d9 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 @@ -480,16 +480,14 @@ impl pallet_utility::Config for Runtime { parameter_types! { /// Amount of weight that can be spent per block to service messages. - pub MessageQueueServiceWeight: Weight = Weight::from_parts(1_000_000_000, 1_000_000); - pub const MessageQueueHeapSize: u32 = 65_536; - pub const MessageQueueMaxStale: u32 = 16; + pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block; } impl pallet_message_queue::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Size = u32; - type HeapSize = MessageQueueHeapSize; - type MaxStale = MessageQueueMaxStale; + type HeapSize = ConstU32<{ 64 * 1024 }>; + type MaxStale = ConstU32<8>; type ServiceWeight = MessageQueueServiceWeight; type MessageProcessor = EthereumOutboundQueue; type QueueChangeHandler = ();