From 15204f690ee3ae485384df4ed3f598091190a67b Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Wed, 24 Nov 2021 17:06:37 +0100 Subject: [PATCH 1/2] configure pallet-xcm to allow teleports but forbid generic sends --- polkadot-parachains/statemine/src/lib.rs | 13 +++++++++---- polkadot-parachains/statemint/src/lib.rs | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/polkadot-parachains/statemine/src/lib.rs b/polkadot-parachains/statemine/src/lib.rs index 8246070cf0f..c193ae2b419 100644 --- a/polkadot-parachains/statemine/src/lib.rs +++ b/polkadot-parachains/statemine/src/lib.rs @@ -75,7 +75,8 @@ use xcm_builder::{ ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocationInverter, NativeAsset, ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + UsingComponents, }; use xcm_executor::{traits::JustTry, Config, XcmExecutor}; @@ -560,8 +561,9 @@ parameter_types! { pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10; } -/// No local origins on this chain are allowed to dispatch XCM sends/executions. -pub type LocalOriginToLocation = (); +/// Converts a local signed origin into an XCM multilocation. +/// Forms the basis for local origins sending/executing XCMs. +pub type LocalOriginToLocation = SignedToAccountId32; /// The means for routing XCM messages which are not for local execution into the right message /// queues. @@ -574,9 +576,12 @@ pub type XcmRouter = ( impl pallet_xcm::Config for Runtime { type Event = Event; - type SendXcmOrigin = EnsureXcmOrigin; + // We want to disallow users sending (arbitrary) XCMs from this chain. + type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; + // We support local origins dispatching XCM executions in principle... type ExecuteXcmOrigin = EnsureXcmOrigin; + // ... but disallow generic XCM execution. As a result only teleports and reserve transfers are allowed. type XcmExecuteFilter = Nothing; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; diff --git a/polkadot-parachains/statemint/src/lib.rs b/polkadot-parachains/statemint/src/lib.rs index 6d3574da4d9..ba4bbb3ed6b 100644 --- a/polkadot-parachains/statemint/src/lib.rs +++ b/polkadot-parachains/statemint/src/lib.rs @@ -75,7 +75,8 @@ use xcm_builder::{ ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocationInverter, NativeAsset, ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, + UsingComponents, }; use xcm_executor::{traits::JustTry, Config, XcmExecutor}; @@ -572,8 +573,9 @@ parameter_types! { pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10; } -/// No local origins on this chain are allowed to dispatch XCM sends/executions. -pub type LocalOriginToLocation = (); +/// Converts a local signed origin into an XCM multilocation. +/// Forms the basis for local origins sending/executing XCMs. +pub type LocalOriginToLocation = SignedToAccountId32; /// The means for routing XCM messages which are not for local execution into the right message /// queues. @@ -586,9 +588,12 @@ pub type XcmRouter = ( impl pallet_xcm::Config for Runtime { type Event = Event; - type SendXcmOrigin = EnsureXcmOrigin; + // We want to disallow users sending (arbitrary) XCMs from this chain. + type SendXcmOrigin = EnsureXcmOrigin; type XcmRouter = XcmRouter; + // We support local origins dispatching XCM executions in principle... type ExecuteXcmOrigin = EnsureXcmOrigin; + // ... but disallow generic XCM execution. As a result only teleports and reserve transfers are allowed. type XcmExecuteFilter = Nothing; type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; From 4204a393cca419dca7dc866330a1f8f94bce6016 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Wed, 24 Nov 2021 17:11:18 +0100 Subject: [PATCH 2/2] bump spec_version --- polkadot-parachains/statemine/src/lib.rs | 2 +- polkadot-parachains/statemint/src/lib.rs | 2 +- polkadot-parachains/westmint/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/polkadot-parachains/statemine/src/lib.rs b/polkadot-parachains/statemine/src/lib.rs index c193ae2b419..cff9f270603 100644 --- a/polkadot-parachains/statemine/src/lib.rs +++ b/polkadot-parachains/statemine/src/lib.rs @@ -91,7 +91,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("statemine"), impl_name: create_runtime_str!("statemine"), authoring_version: 1, - spec_version: 600, + spec_version: 601, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 4, diff --git a/polkadot-parachains/statemint/src/lib.rs b/polkadot-parachains/statemint/src/lib.rs index ba4bbb3ed6b..6a1735ecd79 100644 --- a/polkadot-parachains/statemint/src/lib.rs +++ b/polkadot-parachains/statemint/src/lib.rs @@ -91,7 +91,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("statemint"), impl_name: create_runtime_str!("statemint"), authoring_version: 1, - spec_version: 600, + spec_version: 601, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 4, diff --git a/polkadot-parachains/westmint/src/lib.rs b/polkadot-parachains/westmint/src/lib.rs index b934d2cea82..a982a527b06 100644 --- a/polkadot-parachains/westmint/src/lib.rs +++ b/polkadot-parachains/westmint/src/lib.rs @@ -91,7 +91,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("westmint"), impl_name: create_runtime_str!("westmint"), authoring_version: 1, - spec_version: 600, + spec_version: 601, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 4,