Make System Parachains trusted Teleporters (#1368)

Make System Parachain trusted Teleporters of each other.

Migration of https://github.com/paritytech/cumulus/pull/2842

---------

Co-authored-by: command-bot <>
Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
This commit is contained in:
Ignacio Palacios
2023-10-16 19:52:33 +02:00
committed by GitHub
parent 4145902f1c
commit e0065cb81b
24 changed files with 465 additions and 84 deletions
@@ -31,7 +31,10 @@ use frame_support::{
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier};
use parachains_common::{
impls::ToStakingPot,
xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem},
};
use polkadot_parachain_primitives::primitives::Sibling;
use sp_runtime::traits::ConvertInto;
use xcm::latest::prelude::*;
@@ -39,8 +42,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, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
@@ -470,6 +473,15 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia
TrustBackedAssetsInstance,
>;
/// 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;
@@ -480,13 +492,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<
@@ -27,7 +27,10 @@ use frame_support::{
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier};
use parachains_common::{
impls::ToStakingPot,
xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem},
};
use polkadot_parachain_primitives::primitives::Sibling;
use sp_runtime::traits::ConvertInto;
use xcm::latest::prelude::*;
@@ -35,8 +38,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, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
@@ -394,6 +397,15 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia
TrustBackedAssetsInstance,
>;
/// 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;
@@ -404,13 +416,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<
@@ -31,7 +31,10 @@ use frame_support::{
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{impls::ToStakingPot, xcm_config::AssetFeeAsExistentialDepositMultiplier};
use parachains_common::{
impls::ToStakingPot,
xcm_config::{AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem},
};
use polkadot_parachain_primitives::primitives::Sibling;
use sp_runtime::traits::ConvertInto;
use xcm::latest::prelude::*;
@@ -39,8 +42,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, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic,
@@ -481,6 +484,15 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia
TrustBackedAssetsInstance,
>;
/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
///
/// - WND with the parent Relay Chain and sibling system parachains; and
/// - Sibling parachains' assets from where they originate (as `ForeignCreators`).
pub type TrustedTeleporters = (
ConcreteAssetFromSystem<WestendLocation>,
IsForeignConcreteAsset<FromSiblingParachain<parachain_info::Pallet<Runtime>>>,
);
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
@@ -491,13 +503,7 @@ impl xcm_executor::Config for XcmConfig {
// Asset Hub acting _as_ a reserve location for WND and assets created under `pallet-assets`.
// For WND, users must use teleport where allowed (e.g. with the Relay Chain).
type IsReserve = ();
// We allow:
// - teleportation of WND
// - 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<
@@ -24,7 +24,7 @@ use frame_support::{
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom};
use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteAssetFromSystem};
use polkadot_parachain_primitives::primitives::Sibling;
use xcm::latest::prelude::*;
use xcm_builder::{
@@ -177,6 +177,10 @@ pub type Barrier = TrailingSetTopicAsId<
>,
>;
/// 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;
@@ -186,8 +190,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<
@@ -24,7 +24,7 @@ use frame_support::{
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom};
use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteAssetFromSystem};
use polkadot_parachain_primitives::primitives::Sibling;
use xcm::latest::prelude::*;
use xcm_builder::{
@@ -181,6 +181,10 @@ pub type Barrier = TrailingSetTopicAsId<
>,
>;
/// 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;
@@ -190,8 +194,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<
@@ -30,7 +30,7 @@ use frame_support::{
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom};
use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteAssetFromSystem};
use polkadot_parachain_primitives::primitives::Sibling;
use sp_core::Get;
use xcm::latest::prelude::*;
@@ -224,6 +224,10 @@ pub type Barrier = TrailingSetTopicAsId<
>,
>;
/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
/// - NativeToken with the parent Relay Chain and sibling parachains.
pub type TrustedTeleporters = ConcreteAssetFromSystem<RelayLocation>;
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
@@ -233,8 +237,7 @@ impl xcm_executor::Config for XcmConfig {
// BridgeHub does not recognize a reserve location for any asset. Users must teleport Native
// token where allowed (e.g. with the Relay Chain).
type IsReserve = ();
/// Only allow teleportation of NativeToken of relay chain.
type IsTeleporter = ConcreteNativeAssetFrom<RelayLocation>;
type IsTeleporter = TrustedTeleporters;
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Weigher = WeightInfoBounds<
@@ -24,7 +24,7 @@ use frame_support::{
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteNativeAssetFrom};
use parachains_common::{impls::ToStakingPot, xcm_config::ConcreteAssetFromSystem};
use polkadot_parachain_primitives::primitives::Sibling;
use xcm::latest::prelude::*;
use xcm_builder::{
@@ -240,6 +240,10 @@ pub type Barrier = TrailingSetTopicAsId<
>,
>;
/// 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<DotLocation>;
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
@@ -249,8 +253,7 @@ impl xcm_executor::Config for XcmConfig {
// Collectives 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<DotLocation>;
type IsTeleporter = TrustedTeleporters;
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<TempFixedXcmWeight, RuntimeCall, MaxInstructions>;
@@ -24,6 +24,7 @@ use frame_support::{
};
use frame_system::EnsureRoot;
use pallet_xcm::{EnsureXcm, IsMajorityOfBody, XcmPassthrough};
use parachains_common::xcm_config::ConcreteAssetFromSystem;
use polkadot_parachain_primitives::primitives::Sibling;
use xcm::latest::prelude::*;
use xcm_builder::{
@@ -144,6 +145,8 @@ pub type Barrier = TrailingSetTopicAsId<
>,
>;
pub type TrustedTeleporter = ConcreteAssetFromSystem<RelayLocation>;
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type RuntimeCall = RuntimeCall;
@@ -151,7 +154,7 @@ impl xcm_executor::Config for XcmConfig {
type AssetTransactor = CurrencyTransactor;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
type IsReserve = NativeAsset;
type IsTeleporter = NativeAsset;
type IsTeleporter = TrustedTeleporter;
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;