Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik committed Nov 10, 2023
1 parent 3f6c2c7 commit 24395d7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 26 deletions.
26 changes: 16 additions & 10 deletions system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{AssetFeeAsExistentialDepositMultiplier, RelayOrOtherSystemParachains},
xcm_config::{
AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem,
RelayOrOtherSystemParachains,
},
TREASURY_PALLET_ID,
};
use polkadot_parachain_primitives::primitives::Sibling;
Expand All @@ -41,8 +44,8 @@ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily,
EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset,
NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
Expand Down Expand Up @@ -486,6 +489,15 @@ pub type WaivedLocations = (
Equals<RelayTreasuryLocation>,
);

/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
///
/// - KSM with the parent Relay Chain and sibling system parachains; and
/// - Sibling parachains' assets from where they originate (as `ForeignCreators`).
pub type TrustedTeleporters = (
ConcreteAssetFromSystem<KsmLocation>,
IsForeignConcreteAsset<FromSiblingParachain<parachain_info::Pallet<Runtime>>>,
);

pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
Expand All @@ -496,13 +508,7 @@ impl xcm_executor::Config for XcmConfig {
// Asset Hub acting _as_ a reserve location for KSM and assets created under `pallet-assets`.
// For KSM, users must use teleport where allowed (e.g. with the Relay Chain).
type IsReserve = ();
// We allow:
// - teleportation of KSM
// - teleportation of sibling parachain's assets (as ForeignCreators)
type IsTeleporter = (
NativeAsset,
IsForeignConcreteAsset<FromSiblingParachain<parachain_info::Pallet<Runtime>>>,
);
type IsTeleporter = TrustedTeleporters;
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Weigher = WeightInfoBounds<
Expand Down
26 changes: 16 additions & 10 deletions system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{AssetFeeAsExistentialDepositMultiplier, RelayOrOtherSystemParachains},
xcm_config::{
AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem,
RelayOrOtherSystemParachains,
},
TREASURY_PALLET_ID,
};
use polkadot_parachain_primitives::primitives::Sibling;
Expand All @@ -37,8 +40,8 @@ use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, CurrencyAdapter,
DenyReserveTransferToRelayChain, DenyThenTry, DescribeFamily, DescribePalletTerminal,
EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NativeAsset,
NoChecking, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
EnsureXcmOrigin, FungiblesAdapter, HashedDescription, IsConcrete, LocalMint, NoChecking,
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, StartsWith, StartsWithExplicitGlobalConsensus, TakeWeightCredit,
TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
Expand Down Expand Up @@ -406,6 +409,15 @@ pub type WaivedLocations = (
Equals<RelayTreasuryLocation>,
);

/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
///
/// - DOT with the parent Relay Chain and sibling system parachains; and
/// - Sibling parachains' assets from where they originate (as `ForeignCreators`).
pub type TrustedTeleporters = (
ConcreteAssetFromSystem<DotLocation>,
IsForeignConcreteAsset<FromSiblingParachain<parachain_info::Pallet<Runtime>>>,
);

pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
Expand All @@ -416,13 +428,7 @@ impl xcm_executor::Config for XcmConfig {
// Asset Hub acting _as_ a reserve location for DOT and assets created under `pallet-assets`.
// For DOT, users must use teleport where allowed (e.g. with the Relay Chain).
type IsReserve = ();
// We allow:
// - teleportation of DOT
// - teleportation of sibling parachain's assets (as ForeignCreators)
type IsTeleporter = (
NativeAsset,
IsForeignConcreteAsset<FromSiblingParachain<parachain_info::Pallet<Runtime>>>,
);
type IsTeleporter = TrustedTeleporters;
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Weigher = WeightInfoBounds<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{ConcreteNativeAssetFrom, RelayOrOtherSystemParachains},
xcm_config::{ConcreteAssetFromSystem, RelayOrOtherSystemParachains},
TREASURY_PALLET_ID,
};
use polkadot_parachain_primitives::primitives::Sibling;
Expand Down Expand Up @@ -197,6 +197,10 @@ pub type WaivedLocations = (
Equals<RelayTreasuryLocation>,
);

/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
/// - KSM with the parent Relay Chain and sibling parachains.
pub type TrustedTeleporters = ConcreteAssetFromSystem<KsmRelayLocation>;

pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
Expand All @@ -206,8 +210,7 @@ impl xcm_executor::Config for XcmConfig {
// BridgeHub does not recognize a reserve location for any asset. Users must teleport KSM
// where allowed (e.g. with the Relay Chain).
type IsReserve = ();
/// Only allow teleportation of KSM.
type IsTeleporter = ConcreteNativeAssetFrom<KsmRelayLocation>;
type IsTeleporter = TrustedTeleporters;
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Weigher = WeightInfoBounds<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{ConcreteNativeAssetFrom, RelayOrOtherSystemParachains},
xcm_config::{ConcreteAssetFromSystem, RelayOrOtherSystemParachains},
TREASURY_PALLET_ID,
};
use polkadot_parachain_primitives::primitives::Sibling;
Expand Down Expand Up @@ -201,6 +201,10 @@ pub type WaivedLocations = (
Equals<RelayTreasuryLocation>,
);

/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
/// - DOT with the parent Relay Chain and sibling parachains.
pub type TrustedTeleporters = ConcreteAssetFromSystem<DotRelayLocation>;

pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
Expand All @@ -210,8 +214,7 @@ impl xcm_executor::Config for XcmConfig {
// BridgeHub does not recognize a reserve location for any asset. Users must teleport DOT
// where allowed (e.g. with the Relay Chain).
type IsReserve = ();
/// Only allow teleportation of DOT.
type IsTeleporter = ConcreteNativeAssetFrom<DotRelayLocation>;
type IsTeleporter = TrustedTeleporters;
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Weigher = WeightInfoBounds<
Expand Down

0 comments on commit 24395d7

Please sign in to comment.