From c522c8733ae7ef0146707af096222f1c0311b698 Mon Sep 17 00:00:00 2001 From: agus Date: Wed, 7 Jun 2023 15:06:32 -0300 Subject: [PATCH 1/3] fix xcm barrier --- primitives/xcm/src/barriers.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/primitives/xcm/src/barriers.rs b/primitives/xcm/src/barriers.rs index 4c54ade8d4..6a95fdd6f8 100644 --- a/primitives/xcm/src/barriers.rs +++ b/primitives/xcm/src/barriers.rs @@ -25,7 +25,7 @@ use frame_support::{ /// Only allows for `DescendOrigin` + `WithdrawAsset`, + `BuyExecution` use sp_std::marker::PhantomData; use xcm::latest::{ - prelude::{BuyExecution, DescendOrigin, Instruction, WithdrawAsset}, + prelude::{BuyExecution, ClearOrigin, DescendOrigin, Instruction, WithdrawAsset}, MultiLocation, WeightLimit::{Limited, Unlimited}, }; @@ -35,9 +35,9 @@ use xcm_executor::traits::ShouldExecute; /// first pub struct AllowTopLevelPaidExecutionDescendOriginFirst(PhantomData); impl> ShouldExecute for AllowTopLevelPaidExecutionDescendOriginFirst { - fn should_execute( + fn should_execute( origin: &MultiLocation, - message: &mut [Instruction], + message: &mut [Instruction], max_weight: Weight, _weight_credit: &mut Weight, ) -> Result<(), ProcessMessageError> { @@ -48,7 +48,8 @@ impl> ShouldExecute for AllowTopLevelPaidExecutionDes origin, message, max_weight, _weight_credit, ); ensure!(T::contains(origin), ProcessMessageError::Unsupported); - let mut iter = message.iter_mut(); + // At most two ClearOrigin + let mut iter = message.iter_mut().take(5); // Make sure the first instruction is DescendOrigin iter.next() .filter(|instruction| matches!(instruction, DescendOrigin(_))) @@ -60,14 +61,16 @@ impl> ShouldExecute for AllowTopLevelPaidExecutionDes .ok_or(ProcessMessageError::BadFormat)?; // Then BuyExecution - let i = iter.next().ok_or(ProcessMessageError::BadFormat)?; + let mut i = iter.next().ok_or(ProcessMessageError::BadFormat)?; + while let ClearOrigin = i { + i = iter.next().ok_or(ProcessMessageError::BadFormat)?; + } match i { BuyExecution { weight_limit: Limited(ref mut weight), .. } if weight.all_gte(max_weight) => { - weight.set_ref_time(max_weight.ref_time()); - weight.set_proof_size(max_weight.proof_size()); + *weight = max_weight; Ok(()) } BuyExecution { From 15db0d3e85d3d7eafaf5e6acf8a641e29866f1fb Mon Sep 17 00:00:00 2001 From: agus Date: Wed, 7 Jun 2023 15:46:58 -0300 Subject: [PATCH 2/3] Call instead of RuntimeCall --- primitives/xcm/src/barriers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/primitives/xcm/src/barriers.rs b/primitives/xcm/src/barriers.rs index 6a95fdd6f8..20844c1bac 100644 --- a/primitives/xcm/src/barriers.rs +++ b/primitives/xcm/src/barriers.rs @@ -35,9 +35,9 @@ use xcm_executor::traits::ShouldExecute; /// first pub struct AllowTopLevelPaidExecutionDescendOriginFirst(PhantomData); impl> ShouldExecute for AllowTopLevelPaidExecutionDescendOriginFirst { - fn should_execute( + fn should_execute( origin: &MultiLocation, - message: &mut [Instruction], + message: &mut [Instruction], max_weight: Weight, _weight_credit: &mut Weight, ) -> Result<(), ProcessMessageError> { From 7666365e72bdd3c3f91e3b07af4056fe96612685 Mon Sep 17 00:00:00 2001 From: librelois Date: Thu, 8 Jun 2023 10:02:20 +0200 Subject: [PATCH 3/3] xcm: use WithComputedOrigin barrier --- primitives/xcm/src/barriers.rs | 86 ------------------- primitives/xcm/src/lib.rs | 3 - runtime/moonbase/src/xcm_config.rs | 19 ++-- runtime/moonbase/tests/xcm_mock/parachain.rs | 21 +++-- .../moonbase/tests/xcm_mock/relay_chain.rs | 22 +++-- runtime/moonbeam/src/xcm_config.rs | 18 ++-- runtime/moonbeam/tests/xcm_mock/parachain.rs | 21 +++-- .../moonbeam/tests/xcm_mock/relay_chain.rs | 22 +++-- runtime/moonriver/src/xcm_config.rs | 18 ++-- runtime/moonriver/tests/xcm_mock/parachain.rs | 21 +++-- .../moonriver/tests/xcm_mock/relay_chain.rs | 22 +++-- 11 files changed, 124 insertions(+), 149 deletions(-) delete mode 100644 primitives/xcm/src/barriers.rs diff --git a/primitives/xcm/src/barriers.rs b/primitives/xcm/src/barriers.rs deleted file mode 100644 index 20844c1bac..0000000000 --- a/primitives/xcm/src/barriers.rs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2019-2022 PureStake Inc. -// This file is part of Moonbeam. - -// Moonbeam is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Moonbeam is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Moonbeam. If not, see . - -use frame_support::{ - ensure, - pallet_prelude::Weight, - traits::{Contains, ProcessMessageError}, -}; -/// Allows execution from `origin` if it is contained in `T` (i.e. `T::Contains(origin)`) taking -/// payments into account and if it starts with DescendOrigin. -/// -/// Only allows for `DescendOrigin` + `WithdrawAsset`, + `BuyExecution` -use sp_std::marker::PhantomData; -use xcm::latest::{ - prelude::{BuyExecution, ClearOrigin, DescendOrigin, Instruction, WithdrawAsset}, - MultiLocation, - WeightLimit::{Limited, Unlimited}, -}; -use xcm_executor::traits::ShouldExecute; - -/// Barrier allowing a top level paid message with DescendOrigin instruction -/// first -pub struct AllowTopLevelPaidExecutionDescendOriginFirst(PhantomData); -impl> ShouldExecute for AllowTopLevelPaidExecutionDescendOriginFirst { - fn should_execute( - origin: &MultiLocation, - message: &mut [Instruction], - max_weight: Weight, - _weight_credit: &mut Weight, - ) -> Result<(), ProcessMessageError> { - log::trace!( - target: "xcm::barriers", - "AllowTopLevelPaidExecutionDescendOriginFirst origin: - {:?}, message: {:?}, max_weight: {:?}, weight_credit: {:?}", - origin, message, max_weight, _weight_credit, - ); - ensure!(T::contains(origin), ProcessMessageError::Unsupported); - // At most two ClearOrigin - let mut iter = message.iter_mut().take(5); - // Make sure the first instruction is DescendOrigin - iter.next() - .filter(|instruction| matches!(instruction, DescendOrigin(_))) - .ok_or(ProcessMessageError::BadFormat)?; - - // Then WithdrawAsset - iter.next() - .filter(|instruction| matches!(instruction, WithdrawAsset(_))) - .ok_or(ProcessMessageError::BadFormat)?; - - // Then BuyExecution - let mut i = iter.next().ok_or(ProcessMessageError::BadFormat)?; - while let ClearOrigin = i { - i = iter.next().ok_or(ProcessMessageError::BadFormat)?; - } - match i { - BuyExecution { - weight_limit: Limited(ref mut weight), - .. - } if weight.all_gte(max_weight) => { - *weight = max_weight; - Ok(()) - } - BuyExecution { - ref mut weight_limit, - .. - } if weight_limit == &Unlimited => { - *weight_limit = Limited(max_weight); - Ok(()) - } - _ => Err(ProcessMessageError::Overweight(max_weight)), - } - } -} diff --git a/primitives/xcm/src/lib.rs b/primitives/xcm/src/lib.rs index 5e275eaa6c..e5636a3cc6 100644 --- a/primitives/xcm/src/lib.rs +++ b/primitives/xcm/src/lib.rs @@ -21,9 +21,6 @@ mod asset_id_conversions; pub use asset_id_conversions::*; -mod barriers; -pub use barriers::*; - mod constants; pub use constants::*; diff --git a/runtime/moonbase/src/xcm_config.rs b/runtime/moonbase/src/xcm_config.rs index 146b019f44..aacea234f4 100644 --- a/runtime/moonbase/src/xcm_config.rs +++ b/runtime/moonbase/src/xcm_config.rs @@ -44,7 +44,7 @@ use xcm_builder::{ CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, NoChecking, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountKey20AsNative, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, - WeightInfoBounds, + WeightInfoBounds, WithComputedOrigin, }; use xcm::latest::prelude::*; @@ -239,14 +239,21 @@ pub type XcmWeigher = WeightInfoBounds< MaxInstructions, >; -// Allow paid executions pub type XcmBarrier = ( + // Weight that is paid for may be consumed. TakeWeightCredit, - xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst, - AllowTopLevelPaidExecutionFrom, + // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); parameter_types! { diff --git a/runtime/moonbase/tests/xcm_mock/parachain.rs b/runtime/moonbase/tests/xcm_mock/parachain.rs index 724ca93c3c..0230f5a829 100644 --- a/runtime/moonbase/tests/xcm_mock/parachain.rs +++ b/runtime/moonbase/tests/xcm_mock/parachain.rs @@ -54,7 +54,7 @@ use xcm_builder::{ CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter, IsConcrete, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountKey20AsNative, SovereignSignedViaLocation, TakeWeightCredit, + SignedAccountKey20AsNative, SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin, }; use xcm_executor::{traits::JustTry, Config, XcmExecutor}; @@ -284,14 +284,21 @@ pub type AssetTransactors = ( pub type XcmRouter = super::ParachainXcmRouter; -pub type Barrier = ( +pub type XcmBarrier = ( + // Weight that is paid for may be consumed. TakeWeightCredit, - xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst, - AllowTopLevelPaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); parameter_types! { @@ -367,7 +374,7 @@ impl Config for XcmConfig { >; type IsTeleporter = (); type UniversalLocation = UniversalLocation; - type Barrier = Barrier; + type Barrier = XcmBarrier; type Weigher = FixedWeightBounds; // We use three traders // When we receive either representation of the self-reserve asset, diff --git a/runtime/moonbase/tests/xcm_mock/relay_chain.rs b/runtime/moonbase/tests/xcm_mock/relay_chain.rs index 6f83328364..f4d9e136fa 100644 --- a/runtime/moonbase/tests/xcm_mock/relay_chain.rs +++ b/runtime/moonbase/tests/xcm_mock/relay_chain.rs @@ -37,7 +37,7 @@ use xcm_builder::{ AllowTopLevelPaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, + SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin, }; use xcm_executor::{Config, XcmExecutor}; pub type AccountId = AccountId32; @@ -140,14 +140,22 @@ parameter_types! { } pub type XcmRouter = super::RelayChainXcmRouter; -pub type Barrier = ( + +pub type XcmBarrier = ( + // Weight that is paid for may be consumed. TakeWeightCredit, - xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst, - AllowTopLevelPaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); pub struct XcmConfig; @@ -159,7 +167,7 @@ impl Config for XcmConfig { type IsReserve = (); type IsTeleporter = (); type UniversalLocation = UniversalLocation; - type Barrier = Barrier; + type Barrier = XcmBarrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; type ResponseHandler = XcmPallet; diff --git a/runtime/moonbeam/src/xcm_config.rs b/runtime/moonbeam/src/xcm_config.rs index 12184d73b4..cf7757c956 100644 --- a/runtime/moonbeam/src/xcm_config.rs +++ b/runtime/moonbeam/src/xcm_config.rs @@ -44,7 +44,7 @@ use xcm_builder::{ CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, NoChecking, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountKey20AsNative, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, - WeightInfoBounds, + WeightInfoBounds, WithComputedOrigin, }; use xcm::latest::prelude::*; @@ -229,15 +229,21 @@ pub type XcmWeigher = WeightInfoBounds< MaxInstructions, >; -// Allow paid executions pub type XcmBarrier = ( + // Weight that is paid for may be consumed. TakeWeightCredit, - xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst, - AllowTopLevelPaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); parameter_types! { diff --git a/runtime/moonbeam/tests/xcm_mock/parachain.rs b/runtime/moonbeam/tests/xcm_mock/parachain.rs index f760147049..80b5cb5452 100644 --- a/runtime/moonbeam/tests/xcm_mock/parachain.rs +++ b/runtime/moonbeam/tests/xcm_mock/parachain.rs @@ -54,7 +54,7 @@ use xcm_builder::{ CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter, IsConcrete, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountKey20AsNative, SovereignSignedViaLocation, TakeWeightCredit, + SignedAccountKey20AsNative, SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin, }; use xcm_executor::{traits::JustTry, Config, XcmExecutor}; @@ -280,14 +280,21 @@ pub type AssetTransactors = ( ); pub type XcmRouter = super::ParachainXcmRouter; -pub type Barrier = ( +pub type XcmBarrier = ( + // Weight that is paid for may be consumed. TakeWeightCredit, - xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst, - AllowTopLevelPaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); parameter_types! { @@ -354,7 +361,7 @@ impl Config for XcmConfig { >; type IsTeleporter = (); type UniversalLocation = UniversalLocation; - type Barrier = Barrier; + type Barrier = XcmBarrier; type Weigher = FixedWeightBounds; // We use two traders // When we receive the self-reserve asset, diff --git a/runtime/moonbeam/tests/xcm_mock/relay_chain.rs b/runtime/moonbeam/tests/xcm_mock/relay_chain.rs index 6f83328364..f4d9e136fa 100644 --- a/runtime/moonbeam/tests/xcm_mock/relay_chain.rs +++ b/runtime/moonbeam/tests/xcm_mock/relay_chain.rs @@ -37,7 +37,7 @@ use xcm_builder::{ AllowTopLevelPaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, + SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin, }; use xcm_executor::{Config, XcmExecutor}; pub type AccountId = AccountId32; @@ -140,14 +140,22 @@ parameter_types! { } pub type XcmRouter = super::RelayChainXcmRouter; -pub type Barrier = ( + +pub type XcmBarrier = ( + // Weight that is paid for may be consumed. TakeWeightCredit, - xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst, - AllowTopLevelPaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); pub struct XcmConfig; @@ -159,7 +167,7 @@ impl Config for XcmConfig { type IsReserve = (); type IsTeleporter = (); type UniversalLocation = UniversalLocation; - type Barrier = Barrier; + type Barrier = XcmBarrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; type ResponseHandler = XcmPallet; diff --git a/runtime/moonriver/src/xcm_config.rs b/runtime/moonriver/src/xcm_config.rs index 805d36076c..35cd865028 100644 --- a/runtime/moonriver/src/xcm_config.rs +++ b/runtime/moonriver/src/xcm_config.rs @@ -44,7 +44,7 @@ use xcm_builder::{ CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, NoChecking, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountKey20AsNative, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, - WeightInfoBounds, + WeightInfoBounds, WithComputedOrigin, }; use xcm::latest::prelude::*; @@ -237,15 +237,21 @@ pub type XcmWeigher = WeightInfoBounds< MaxInstructions, >; -// Allow paid executions pub type XcmBarrier = ( + // Weight that is paid for may be consumed. TakeWeightCredit, - xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst, - AllowTopLevelPaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); parameter_types! { diff --git a/runtime/moonriver/tests/xcm_mock/parachain.rs b/runtime/moonriver/tests/xcm_mock/parachain.rs index 0683728f4c..4315c3e8ac 100644 --- a/runtime/moonriver/tests/xcm_mock/parachain.rs +++ b/runtime/moonriver/tests/xcm_mock/parachain.rs @@ -53,7 +53,7 @@ use xcm_builder::{ CurrencyAdapter as XcmCurrencyAdapter, EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter, IsConcrete, NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountKey20AsNative, SovereignSignedViaLocation, TakeWeightCredit, + SignedAccountKey20AsNative, SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin, }; use xcm_executor::{traits::JustTry, Config, XcmExecutor}; @@ -280,14 +280,21 @@ pub type AssetTransactors = ( pub type XcmRouter = super::ParachainXcmRouter; -pub type Barrier = ( +pub type XcmBarrier = ( + // Weight that is paid for may be consumed. TakeWeightCredit, - xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst, - AllowTopLevelPaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); parameter_types! { @@ -361,7 +368,7 @@ impl Config for XcmConfig { >; type IsTeleporter = (); type UniversalLocation = UniversalLocation; - type Barrier = Barrier; + type Barrier = XcmBarrier; type Weigher = FixedWeightBounds; // We use three traders // When we receive either representation of the self-reserve asset, diff --git a/runtime/moonriver/tests/xcm_mock/relay_chain.rs b/runtime/moonriver/tests/xcm_mock/relay_chain.rs index 6f83328364..f4d9e136fa 100644 --- a/runtime/moonriver/tests/xcm_mock/relay_chain.rs +++ b/runtime/moonriver/tests/xcm_mock/relay_chain.rs @@ -37,7 +37,7 @@ use xcm_builder::{ AllowTopLevelPaidExecutionFrom, ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedRateOfFungible, FixedWeightBounds, IsConcrete, SignedAccountId32AsNative, SignedToAccountId32, - SovereignSignedViaLocation, TakeWeightCredit, + SovereignSignedViaLocation, TakeWeightCredit, WithComputedOrigin, }; use xcm_executor::{Config, XcmExecutor}; pub type AccountId = AccountId32; @@ -140,14 +140,22 @@ parameter_types! { } pub type XcmRouter = super::RelayChainXcmRouter; -pub type Barrier = ( + +pub type XcmBarrier = ( + // Weight that is paid for may be consumed. TakeWeightCredit, - xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst, - AllowTopLevelPaidExecutionFrom, // Expected responses are OK. AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, ); pub struct XcmConfig; @@ -159,7 +167,7 @@ impl Config for XcmConfig { type IsReserve = (); type IsTeleporter = (); type UniversalLocation = UniversalLocation; - type Barrier = Barrier; + type Barrier = XcmBarrier; type Weigher = FixedWeightBounds; type Trader = FixedRateOfFungible; type ResponseHandler = XcmPallet;