[testnet] Align testnet system parachain runtimes using RelayTreasuryLocation and SystemParachains in the same way (#2023)

This PR addresses several issues:
- simplify referencing `RelayTreasuryLocation` without needing
additional `RelayTreasury` struct
- fix for referencing `SystemParachains` from parachain with `parents:
1` instead of `parents: 0`
- removed hard-coded constants and fix tests for `asset-hub-rococo`
which was merged to master after
https://github.com/paritytech/polkadot-sdk/pull/1726

---------

Co-authored-by: command-bot <>
This commit is contained in:
Branislav Kontur
2023-10-25 17:35:15 +02:00
committed by GitHub
parent c86b633695
commit f6560c2b72
12 changed files with 198 additions and 155 deletions
@@ -20,7 +20,7 @@ use super::{
use crate::common::rococo::currency::CENTS;
use frame_support::{
match_types, parameter_types,
traits::{ConstU32, EitherOfDiverse, Everything, Nothing},
traits::{ConstU32, EitherOfDiverse, Equals, Everything, Nothing},
weights::Weight,
};
use frame_system::EnsureRoot;
@@ -31,7 +31,7 @@ use parachains_common::{
};
use polkadot_parachain_primitives::primitives::Sibling;
use polkadot_runtime_common::xcm_sender::ExponentialPrice;
use rococo_runtime_constants::system_parachain::SystemParachains;
use rococo_runtime_constants::system_parachain;
use sp_runtime::traits::AccountIdConversion;
use xcm::latest::prelude::*;
use xcm_builder::{
@@ -52,6 +52,7 @@ parameter_types! {
pub UniversalLocation: InteriorMultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
pub const ExecutiveBody: BodyId = BodyId::Executive;
pub TreasuryAccount: Option<AccountId> = Some(TREASURY_PALLET_ID.into_account_truncating());
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
}
/// We allow root and the Relay Chain council to execute privileged collator selection operations.
@@ -140,8 +141,12 @@ pub type Barrier = TrailingSetTopicAsId<
// If the message is one that immediately attempts to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its pluralities (i.e. governance bodies) get free execution.
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
// Parent, its pluralities (i.e. governance bodies) and relay treasury pallet
// get free execution.
AllowExplicitUnpaidExecutionFrom<(
ParentOrParentsPlurality,
Equals<RelayTreasuryLocation>,
)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
),
@@ -152,6 +157,26 @@ 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 |
system_parachain::CONTRACTS_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 TrustedTeleporter = ConcreteAssetFromSystem<RelayLocation>;
pub struct XcmConfig;
@@ -174,12 +199,7 @@ impl xcm_executor::Config for XcmConfig {
type MaxAssetsIntoHolding = ConstU32<8>;
type AssetLocker = ();
type AssetExchanger = ();
type FeeManager = XcmFeesToAccount<
Self,
RelayOrOtherSystemParachains<SystemParachains, Runtime>,
AccountId,
TreasuryAccount,
>;
type FeeManager = XcmFeesToAccount<Self, WaivedLocations, AccountId, TreasuryAccount>;
type MessageExporter = ();
type UniversalAliases = Nothing;
type CallDispatcher = RuntimeCall;