Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves XCM barrier for DescendOrigin #2335

Merged
merged 4 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 0 additions & 83 deletions primitives/xcm/src/barriers.rs

This file was deleted.

3 changes: 0 additions & 3 deletions primitives/xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
mod asset_id_conversions;
pub use asset_id_conversions::*;

mod barriers;
pub use barriers::*;

mod constants;
pub use constants::*;

Expand Down
19 changes: 13 additions & 6 deletions runtime/moonbase/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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<Everything>,
AllowTopLevelPaidExecutionFrom<Everything>,
// Expected responses are OK.
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
),
UniversalLocation,
ConstU32<8>,
>,
);

parameter_types! {
Expand Down
21 changes: 14 additions & 7 deletions runtime/moonbase/tests/xcm_mock/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -284,14 +284,21 @@ pub type AssetTransactors = (

pub type XcmRouter = super::ParachainXcmRouter<MsgQueue>;

pub type Barrier = (
pub type XcmBarrier = (
// Weight that is paid for may be consumed.
TakeWeightCredit,
xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst<Everything>,
AllowTopLevelPaidExecutionFrom<Everything>,
// Expected responses are OK.
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
),
UniversalLocation,
ConstU32<8>,
>,
);

parameter_types! {
Expand Down Expand Up @@ -367,7 +374,7 @@ impl Config for XcmConfig {
>;
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Barrier = XcmBarrier;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
// We use three traders
// When we receive either representation of the self-reserve asset,
Expand Down
22 changes: 15 additions & 7 deletions runtime/moonbase/tests/xcm_mock/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Everything>,
AllowTopLevelPaidExecutionFrom<Everything>,
// Expected responses are OK.
AllowKnownQueryResponses<XcmPallet>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
),
UniversalLocation,
ConstU32<8>,
>,
);

pub struct XcmConfig;
Expand All @@ -159,7 +167,7 @@ impl Config for XcmConfig {
type IsReserve = ();
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Barrier = XcmBarrier;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type Trader = FixedRateOfFungible<KsmPerSecond, ()>;
type ResponseHandler = XcmPallet;
Expand Down
18 changes: 12 additions & 6 deletions runtime/moonbeam/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -230,15 +230,21 @@ pub type XcmWeigher = WeightInfoBounds<
MaxInstructions,
>;

// Allow paid executions
pub type XcmBarrier = (
// Weight that is paid for may be consumed.
TakeWeightCredit,
xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst<Everything>,
AllowTopLevelPaidExecutionFrom<Everything>,
// Expected responses are OK.
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
),
UniversalLocation,
ConstU32<8>,
>,
);

parameter_types! {
Expand Down
21 changes: 14 additions & 7 deletions runtime/moonbeam/tests/xcm_mock/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -280,14 +280,21 @@ pub type AssetTransactors = (
);
pub type XcmRouter = super::ParachainXcmRouter<MsgQueue>;

pub type Barrier = (
pub type XcmBarrier = (
// Weight that is paid for may be consumed.
TakeWeightCredit,
xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst<Everything>,
AllowTopLevelPaidExecutionFrom<Everything>,
// Expected responses are OK.
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
),
UniversalLocation,
ConstU32<8>,
>,
);

parameter_types! {
Expand Down Expand Up @@ -354,7 +361,7 @@ impl Config for XcmConfig {
>;
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Barrier = XcmBarrier;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
// We use two traders
// When we receive the self-reserve asset,
Expand Down
22 changes: 15 additions & 7 deletions runtime/moonbeam/tests/xcm_mock/relay_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Everything>,
AllowTopLevelPaidExecutionFrom<Everything>,
// Expected responses are OK.
AllowKnownQueryResponses<XcmPallet>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
),
UniversalLocation,
ConstU32<8>,
>,
);

pub struct XcmConfig;
Expand All @@ -159,7 +167,7 @@ impl Config for XcmConfig {
type IsReserve = ();
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Barrier = XcmBarrier;
type Weigher = FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
type Trader = FixedRateOfFungible<KsmPerSecond, ()>;
type ResponseHandler = XcmPallet;
Expand Down
18 changes: 12 additions & 6 deletions runtime/moonriver/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -238,15 +238,21 @@ pub type XcmWeigher = WeightInfoBounds<
MaxInstructions,
>;

// Allow paid executions
pub type XcmBarrier = (
// Weight that is paid for may be consumed.
TakeWeightCredit,
xcm_primitives::AllowTopLevelPaidExecutionDescendOriginFirst<Everything>,
AllowTopLevelPaidExecutionFrom<Everything>,
// Expected responses are OK.
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
),
UniversalLocation,
ConstU32<8>,
>,
);

parameter_types! {
Expand Down
Loading