Skip to content

Commit

Permalink
[xcm] adapt paritytech/polkadot-sdk#2422 (IsChildSystemParachain)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Feb 15, 2024
1 parent ba739cb commit 349fb52
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 117 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions relay/kusama/constants/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sp-runtime = { default-features = false , version = "32.0.0" }
sp-weights = { default-features = false , version = "28.0.0" }
sp-core = { default-features = false , version = "29.0.0" }

xcm = { package = "staging-xcm", default-features = false , version = "8.0.0" }
xcm-builder = { package = "staging-xcm-builder", default-features = false , version = "8.0.0" }

[features]
default = [ "std" ]
Expand All @@ -27,5 +27,5 @@ std = [
"sp-core/std",
"sp-runtime/std",
"sp-weights/std",
"xcm/std"
"xcm-builder/std"
]
18 changes: 4 additions & 14 deletions relay/kusama/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ pub mod fee {

/// System Parachains.
pub mod system_parachain {
use xcm::latest::prelude::*;
use primitives::Id;
use xcm_builder::IsChildSystemParachain;

/// Asset Hub parachain ID.
pub const ASSET_HUB_ID: u32 = 1000;
Expand All @@ -108,19 +109,8 @@ pub mod system_parachain {
/// Bridge Hub parachain ID.
pub const BRIDGE_HUB_ID: u32 = 1002;

frame_support::match_types! {
// System parachains from Kusama point of view.
pub type SystemParachains: impl Contains<MultiLocation> = {
MultiLocation {
parents: 0,
interior: X1(Parachain(
ASSET_HUB_ID |
ENCOINTER_ID |
BRIDGE_HUB_ID
)),
}
};
}
// System parachains from Kusama point of view.
pub type SystemParachains = IsChildSystemParachain<Id>;
}

/// Kusama Treasury pallet instance.
Expand Down
4 changes: 2 additions & 2 deletions relay/polkadot/constants/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sp-runtime = { default-features = false , version = "32.0.0" }
sp-weights = { default-features = false , version = "28.0.0" }
sp-core = { default-features = false , version = "29.0.0" }

xcm = { package = "staging-xcm", default-features = false , version = "8.0.0" }
xcm-builder = { package = "staging-xcm-builder", default-features = false , version = "8.0.0" }

[features]
default = [ "std" ]
Expand All @@ -27,5 +27,5 @@ std = [
"sp-core/std",
"sp-runtime/std",
"sp-weights/std",
"xcm/std"
"xcm-builder/std"
]
18 changes: 4 additions & 14 deletions relay/polkadot/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ pub mod xcm {

/// System Parachains.
pub mod system_parachain {
use xcm::latest::prelude::*;
use primitives::Id;
use xcm_builder::IsChildSystemParachain;

/// Asset Hub parachain ID.
pub const ASSET_HUB_ID: u32 = 1000;
Expand All @@ -124,19 +125,8 @@ pub mod system_parachain {
/// Bridge Hub parachain ID.
pub const BRIDGE_HUB_ID: u32 = 1002;

frame_support::match_types! {
// System parachains from Polkadot point of view.
pub type SystemParachains: impl Contains<MultiLocation> = {
MultiLocation {
parents: 0,
interior: X1(Parachain(
ASSET_HUB_ID |
COLLECTIVES_ID |
BRIDGE_HUB_ID
)),
}
};
}
// System parachains from Polkadot point of view.
pub type SystemParachains = IsChildSystemParachain<Id>;
}

/// Polkadot Treasury pallet instance.
Expand Down
27 changes: 8 additions & 19 deletions system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ use frame_support::{
traits::{ConstU32, Contains, Equals, Everything, Nothing, PalletInfoAccess},
};
use frame_system::EnsureRoot;
use kusama_runtime_constants::system_parachain;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{
AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem,
RelayOrOtherSystemParachains,
AllSiblingSystemParachains, AssetFeeAsExistentialDepositMultiplier,
ConcreteAssetFromSystem, RelayOrOtherSystemParachains,
},
};
use polkadot_parachain_primitives::primitives::Sibling;
Expand Down Expand Up @@ -130,8 +129,8 @@ pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConverte
// Ignore `TrustBackedAssets` explicitly
StartsWith<TrustBackedAssetsPalletLocation>,
// Ignore assets that start explicitly with our `GlobalConsensus(NetworkId)`, means:
// - foreign assets from our consensus should be: `MultiLocation {parents: 1,
// X*(Parachain(xyz), ..)}`
// - foreign assets from our consensus should be: `Location {parents: 1, X*(Parachain(xyz),
// ..)}`
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` won't
// be accepted here
StartsWithExplicitGlobalConsensus<UniversalLocationNetworkId>,
Expand Down Expand Up @@ -479,23 +478,13 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia
TrustBackedAssetsInstance,
>;

match_types! {
pub type SystemParachains: impl Contains<MultiLocation> = {
MultiLocation {
parents: 1,
interior: X1(Parachain(
system_parachain::ENCOINTER_ID |
system_parachain::BRIDGE_HUB_ID
)),
}
};
}

/// Locations that will not be charged fees in the executor,
/// either execution or delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations =
(RelayOrOtherSystemParachains<SystemParachains, Runtime>, Equals<RelayTreasuryLocation>);
pub type WaivedLocations = (
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
Equals<RelayTreasuryLocation>,
);

/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
///
Expand Down
23 changes: 5 additions & 18 deletions system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{
AssetFeeAsExistentialDepositMultiplier, ConcreteAssetFromSystem,
RelayOrOtherSystemParachains,
AllSiblingSystemParachains, AssetFeeAsExistentialDepositMultiplier,
ConcreteAssetFromSystem, RelayOrOtherSystemParachains,
},
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_constants::system_parachain;
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
use system_parachains_constants::TREASURY_PALLET_ID;
use xcm::latest::prelude::*;
Expand Down Expand Up @@ -126,8 +125,8 @@ pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConverte
// Ignore `TrustBackedAssets` explicitly
StartsWith<TrustBackedAssetsPalletLocation>,
// Ignore assets that start explicitly with our `GlobalConsensus(NetworkId)`, means:
// - foreign assets from our consensus should be: `MultiLocation {parents: 1,
// X*(Parachain(xyz), ..)}`
// - foreign assets from our consensus should be: `Location {parents: 1, X*(Parachain(xyz),
// ..)}`
// - foreign assets outside our consensus with the same `GlobalConsensus(NetworkId)` won't
// be accepted here
StartsWithExplicitGlobalConsensus<UniversalLocationNetworkId>,
Expand Down Expand Up @@ -422,23 +421,11 @@ pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentia
TrustBackedAssetsInstance,
>;

match_types! {
pub type SystemParachains: impl Contains<MultiLocation> = {
MultiLocation {
parents: 1,
interior: X1(Parachain(
system_parachain::COLLECTIVES_ID |
system_parachain::BRIDGE_HUB_ID
)),
}
};
}

/// Locations that will not be charged fees in the executor,
/// either execution or delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations = (
RelayOrOtherSystemParachains<SystemParachains, Runtime>,
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
Equals<RelayTreasuryLocation>,
FellowshipEntities,
);
Expand Down
23 changes: 7 additions & 16 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ use frame_support::{
traits::{ConstU32, Contains, Equals, Everything, Nothing},
};
use frame_system::EnsureRoot;
use kusama_runtime_constants::system_parachain;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{ConcreteAssetFromSystem, RelayOrOtherSystemParachains},
xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, RelayOrOtherSystemParachains,
},
};
use polkadot_parachain_primitives::primitives::Sibling;
use sp_runtime::traits::AccountIdConversion;
Expand Down Expand Up @@ -226,23 +227,13 @@ pub type Barrier = TrailingSetTopicAsId<
>,
>;

match_types! {
pub type SystemParachains: impl Contains<MultiLocation> = {
MultiLocation {
parents: 1,
interior: X1(Parachain(
system_parachain::ASSET_HUB_ID |
system_parachain::ENCOINTER_ID
)),
}
};
}

/// Locations that will not be charged fees in the executor,
/// either execution or delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations =
(RelayOrOtherSystemParachains<SystemParachains, Runtime>, Equals<RelayTreasuryLocation>);
pub type WaivedLocations = (
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{ConcreteAssetFromSystem, RelayOrOtherSystemParachains},
xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, RelayOrOtherSystemParachains,
},
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_constants::system_parachain;
use sp_runtime::traits::AccountIdConversion;
use system_parachains_constants::TREASURY_PALLET_ID;
use xcm::latest::prelude::*;
Expand Down Expand Up @@ -230,23 +231,11 @@ pub type Barrier = TrailingSetTopicAsId<
>,
>;

match_types! {
pub type SystemParachains: impl Contains<MultiLocation> = {
MultiLocation {
parents: 1,
interior: X1(Parachain(
system_parachain::ASSET_HUB_ID |
system_parachain::COLLECTIVES_ID
)),
}
};
}

/// Locations that will not be charged fees in the executor,
/// either execution or delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations = (
RelayOrOtherSystemParachains<SystemParachains, Runtime>,
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
Equals<RelayTreasuryLocation>,
FellowsPlurality,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
use parachains_common::{
impls::ToStakingPot,
xcm_config::{ConcreteAssetFromSystem, RelayOrOtherSystemParachains},
xcm_config::{
AllSiblingSystemParachains, ConcreteAssetFromSystem, RelayOrOtherSystemParachains,
},
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_constants::{system_parachain, xcm as xcm_constants};
use polkadot_runtime_constants::xcm as xcm_constants;
use sp_runtime::traits::AccountIdConversion;
use system_parachains_constants::TREASURY_PALLET_ID;
use xcm::latest::prelude::*;
Expand Down Expand Up @@ -253,23 +255,11 @@ pub type Barrier = TrailingSetTopicAsId<
>,
>;

match_types! {
pub type SystemParachains: impl Contains<MultiLocation> = {
MultiLocation {
parents: 1,
interior: X1(Parachain(
system_parachain::ASSET_HUB_ID |
system_parachain::BRIDGE_HUB_ID
)),
}
};
}

/// Locations that will not be charged fees in the executor,
/// either execution or delivery.
/// We only waive fees for system functions, which these locations represent.
pub type WaivedLocations = (
RelayOrOtherSystemParachains<SystemParachains, Runtime>,
RelayOrOtherSystemParachains<AllSiblingSystemParachains, Runtime>,
Equals<RelayTreasuryLocation>,
Equals<RootLocation>,
LocalPlurality,
Expand Down

0 comments on commit 349fb52

Please sign in to comment.