Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Allow explicit unpaid executions from the relay chains for system parachains #2060

Merged
merged 6 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 16 additions & 3 deletions parachains/runtimes/assets/statemine/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use xcm_builder::{
NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
WithComputedOrigin,
};
use xcm_executor::{
traits::{JustTry, WithOriginFilter},
Expand Down Expand Up @@ -134,12 +135,15 @@ pub type XcmOriginToTransactDispatchOrigin = (
parameter_types! {
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
pub const MaxPrefixes: u32 = 8;
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
pub XcmAssetFeesReceiver: Option<AccountId> = Authorship::author();
}

match_types! {
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
pub type ParentLocation: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here }
};
pub type ParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }
};
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
Expand Down Expand Up @@ -251,11 +255,20 @@ pub type Barrier = DenyThenTry<
TakeWeightCredit,
AllowTopLevelPaidExecutionFrom<Everything>,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
// Parent and its exec plurality get free execution
AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
AllowExplicitUnpaidExecutionFrom<ParentLocation>,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
// Expected responses are OK.
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
(
// Parent's executive plurality (i.e. governance) gets free execution.
AllowExplicitUnpaidExecutionFrom<ParentsExecutivePlurality>,
),
UniversalLocation,
MaxPrefixes,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
>,
),
>;

Expand Down
18 changes: 15 additions & 3 deletions parachains/runtimes/assets/statemint/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use xcm_builder::{
NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
WithComputedOrigin,
};
use xcm_executor::{
traits::{JustTry, WithOriginFilter},
Expand Down Expand Up @@ -138,8 +139,10 @@ parameter_types! {
}

match_types! {
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
pub type ParentLocation: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here }
};
pub type ParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }
};
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
Expand Down Expand Up @@ -251,11 +254,20 @@ pub type Barrier = DenyThenTry<
TakeWeightCredit,
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its exec plurality get free execution
AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
AllowExplicitUnpaidExecutionFrom<ParentLocation>,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
// Expected responses are OK.
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
(
// Parent's executive plurality (i.e. governance) gets free execution.
AllowExplicitUnpaidExecutionFrom<ParentsExecutivePlurality>,
),
UniversalLocation,
MaxPrefixes,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
>,
),
>;

Expand Down
21 changes: 17 additions & 4 deletions parachains/runtimes/assets/westmint/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use xcm_builder::{
NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
WithComputedOrigin,
};
use xcm_executor::{
traits::{JustTry, WithOriginFilter},
Expand Down Expand Up @@ -134,12 +135,15 @@ pub type XcmOriginToTransactDispatchOrigin = (
parameter_types! {
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
pub const MaxPrefixes: u32 = 8;
pub XcmAssetFeesReceiver: Option<AccountId> = Authorship::author();
}

match_types! {
pub type ParentOrParentsPlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
pub type ParentLocation: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here }
};
pub type ParentsPlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
};
}
Expand Down Expand Up @@ -245,12 +249,21 @@ pub type Barrier = DenyThenTry<
(
TakeWeightCredit,
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its plurality get free execution
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
// Parent gets free execution
AllowExplicitUnpaidExecutionFrom<ParentLocation>,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
// Expected responses are OK.
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
(
// Parent's plurality (i.e. governance bodies) gets free execution.
AllowExplicitUnpaidExecutionFrom<ParentsPlurality>,
),
UniversalLocation,
MaxPrefixes,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
>,
),
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use xcm_builder::{
FixedWeightBounds, IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
WithComputedOrigin,
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};

Expand Down Expand Up @@ -103,11 +104,14 @@ parameter_types! {
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
pub const MaxPrefixes: u32 = 8;
}

match_types! {
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: Here }
};
pub type ParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }
};
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
Expand Down Expand Up @@ -186,13 +190,22 @@ pub type Barrier = DenyThenTry<
// Allow local users to buy weight credit.
TakeWeightCredit,
// Parent and its exec plurality get free execution.
AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
AllowExplicitUnpaidExecutionFrom<ParentLocation>,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
// Expected responses are OK.
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
// Allow anything to pay for execution.
AllowTopLevelPaidExecutionFrom<Everything>,
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
(
// Parent's executive plurality (i.e. governance) gets free execution.
AllowExplicitUnpaidExecutionFrom<ParentsExecutivePlurality>,
),
UniversalLocation,
MaxPrefixes,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
>,
),
>;

Expand Down
20 changes: 16 additions & 4 deletions parachains/runtimes/contracts/contracts-rococo/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use xcm_builder::{
FixedWeightBounds, IsConcrete, NativeAsset, ParentAsSuperuser, ParentIsPreset,
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
UsingComponents,
UsingComponents, WithComputedOrigin,
};
use xcm_executor::XcmExecutor;

Expand Down Expand Up @@ -105,11 +105,14 @@ parameter_types! {
// One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate.
pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
pub const MaxInstructions: u32 = 100;
pub const MaxPrefixes: u32 = 8;
}

match_types! {
pub type ParentOrParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here } |
pub type ParentLocation: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: Here }
};
pub type ParentsExecutivePlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) }
};
pub type ParentOrSiblings: impl Contains<MultiLocation> = {
Expand All @@ -124,11 +127,20 @@ pub type Barrier = DenyThenTry<
TakeWeightCredit,
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its exec plurality get free execution
AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
AllowExplicitUnpaidExecutionFrom<ParentLocation>,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
// Expected responses are OK.
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
(
// Parent's executive plurality (i.e. governance) gets free execution.
AllowExplicitUnpaidExecutionFrom<ParentsExecutivePlurality>,
),
UniversalLocation,
MaxPrefixes,
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
>,
),
>;

Expand Down