Skip to content

Commit cbe5476

Browse files
rphmeierpepyakin
authored andcommitted
kusama runtime: reserve, not teleport
1 parent 6a23681 commit cbe5476

File tree

1 file changed

+30
-39
lines changed

1 file changed

+30
-39
lines changed

sugondat-chain/runtimes/sugondat-kusama/src/xcm_config.rs

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::{
22
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
33
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
44
};
5-
use cumulus_primitives_core::{IsSystem, ParaId};
65
use frame_support::{
76
match_types, parameter_types,
87
traits::{ConstU32, ContainsPair, Everything, Nothing},
@@ -15,11 +14,11 @@ use polkadot_runtime_common::impls::ToAuthor;
1514
use xcm::latest::prelude::*;
1615
use xcm_builder::{
1716
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowSubscriptionsFrom,
18-
AllowTopLevelPaidExecutionFrom, CurrencyAdapter, DenyReserveTransferToRelayChain, DenyThenTry,
19-
EnsureXcmOrigin, FixedWeightBounds, IsConcrete, ParentAsSuperuser, ParentIsPreset,
20-
RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
21-
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
22-
TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic,
17+
AllowTopLevelPaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds,
18+
IsConcrete, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
19+
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
20+
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
21+
WithComputedOrigin, WithUniqueTopic,
2322
};
2423
use xcm_executor::XcmExecutor;
2524

@@ -105,25 +104,20 @@ match_types! {
105104
};
106105
}
107106

108-
pub type Barrier = TrailingSetTopicAsId<
109-
DenyThenTry<
110-
DenyReserveTransferToRelayChain,
107+
pub type Barrier = TrailingSetTopicAsId<(
108+
TakeWeightCredit,
109+
WithComputedOrigin<
111110
(
112-
TakeWeightCredit,
113-
WithComputedOrigin<
114-
(
115-
AllowTopLevelPaidExecutionFrom<Everything>,
116-
// Parents or their pluralities (governnace) get free execution.
117-
AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
118-
// Subscriptions for version tracking are OK.
119-
AllowSubscriptionsFrom<ParentOrSiblings>,
120-
),
121-
UniversalLocation,
122-
ConstU32<8>,
123-
>,
111+
AllowTopLevelPaidExecutionFrom<Everything>,
112+
// Parents or their pluralities (governnace) get free execution.
113+
AllowExplicitUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
114+
// Subscriptions for version tracking are OK.
115+
AllowSubscriptionsFrom<ParentOrSiblings>,
124116
),
117+
UniversalLocation,
118+
ConstU32<8>,
125119
>,
126-
>;
120+
)>;
127121

128122
pub struct XcmConfig;
129123
impl xcm_executor::Config for XcmConfig {
@@ -132,10 +126,10 @@ impl xcm_executor::Config for XcmConfig {
132126
// How to withdraw and deposit an asset.
133127
type AssetTransactor = CurrencyTransactor;
134128
type OriginConverter = XcmOriginToTransactDispatchOrigin;
135-
// Sugondat does not recognize a reserve location for any asset. Users must teleport KSM
136-
// where allowed (e.g. with the Relay Chain).
137-
type IsReserve = ();
138-
type IsTeleporter = TrustedTeleporters;
129+
// Sugondat recognizes the relay chain as a reserve asset.
130+
type IsReserve = TrustedReserve;
131+
// Sugondat is not formally part of the system and therefore should not be used for teleportation.
132+
type IsTeleporter = ();
139133
type UniversalLocation = UniversalLocation;
140134
type Barrier = Barrier;
141135
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
@@ -170,32 +164,29 @@ pub type XcmRouter = WithUniqueTopic<(
170164
XcmpQueue,
171165
)>;
172166

173-
/// Accepts an asset if it is a concrete asset from the system (Relay Chain or system parachain).
174-
pub struct KusamaAndSystemAsset;
175-
impl ContainsPair<MultiAsset, MultiLocation> for KusamaAndSystemAsset {
167+
/// Accepts an asset if it is a concrete asset from the system using the relay chain as a reserve.
168+
pub struct ParentRelayChainAndAsset;
169+
impl ContainsPair<MultiAsset, MultiLocation> for ParentRelayChainAndAsset {
176170
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
177-
log::trace!(target: "xcm::contains", "KusamaAndSystemAsset asset: {:?}, origin: {:?}", asset, origin);
171+
log::trace!(target: "xcm::contains", "ParentRelayChain asset: {:?}, origin: {:?}", asset, origin);
178172
let is_system = match origin {
179173
// The Relay Chain
180174
MultiLocation {
181175
parents: 1,
182176
interior: Here,
183177
} => true,
184-
// System parachain
185-
MultiLocation {
186-
parents: 1,
187-
interior: X1(Parachain(id)),
188-
} => ParaId::from(*id).is_system(),
189178
// Others
190179
_ => false,
191180
};
192181
matches!(asset.id, Concrete(id) if id == KusamaLocation::get()) && is_system
193182
}
194183
}
195184

196-
/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
197-
/// - Kusama with the parent Relay Chain and system parachains.
198-
pub type TrustedTeleporters = KusamaAndSystemAsset;
185+
/// As this is not a system parachain, there are no trusted teleporters.
186+
pub type TrustedTeleporters = ();
187+
188+
/// The parent relay chain is the accepted reserve for the native asset.
189+
pub type TrustedReserve = ParentRelayChainAndAsset;
199190

200191
#[cfg(feature = "runtime-benchmarks")]
201192
parameter_types! {
@@ -212,7 +203,7 @@ impl pallet_xcm::Config for Runtime {
212203
// Needs to be `Everything` for local testing.
213204
type XcmExecutor = XcmExecutor<XcmConfig>;
214205
type XcmTeleportFilter = Everything;
215-
type XcmReserveTransferFilter = Nothing;
206+
type XcmReserveTransferFilter = Everything;
216207
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;
217208
type UniversalLocation = UniversalLocation;
218209
type RuntimeOrigin = RuntimeOrigin;

0 commit comments

Comments
 (0)