[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
@@ -39,7 +39,7 @@ fn relay_origin_assertions(t: RelayToSystemParaTest) {
fn system_para_dest_assertions_incomplete(_t: RelayToSystemParaTest) {
AssetHubRococo::assert_dmp_queue_incomplete(
Some(Weight::from_parts(1_000_000_000, 0)),
Some(Weight::from_parts(57_185_000, 3504)),
Some(Error::UntrustedReserveLocation),
);
}
@@ -52,8 +52,8 @@ fn system_para_to_para_assertions(t: SystemParaToParaTest) {
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(
630_092_000,
6_196,
864_610_000,
8_799,
)));
assert_expected_events!(
@@ -77,8 +77,8 @@ fn system_para_to_para_assets_assertions(t: SystemParaToParaTest) {
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(
676_119_000,
6196,
864_610_000,
8799,
)));
assert_expected_events!(
@@ -83,7 +83,10 @@ fn send_xcm_from_para_to_system_para_paying_fee_with_assets_works() {
AssetHubRococo::execute_with(|| {
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
AssetHubRococo::assert_xcmp_queue_success(Some(Weight::from_parts(2_176_414_000, 203_593)));
AssetHubRococo::assert_xcmp_queue_success(Some(Weight::from_parts(
15_594_564_000,
562_893,
)));
assert_expected_events!(
AssetHubRococo,
@@ -68,7 +68,7 @@ fn relay_dest_assertions_fail(_t: SystemParaToRelayTest) {
Rococo::assert_ump_queue_processed(
false,
Some(AssetHubRococo::para_id()),
Some(Weight::from_parts(148_433_000, 3_593)),
Some(Weight::from_parts(157_718_000, 3_593)),
);
}
@@ -76,8 +76,8 @@ fn para_origin_assertions(t: SystemParaToRelayTest) {
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
AssetHubRococo::assert_xcm_pallet_attempted_complete(Some(Weight::from_parts(
534_872_000,
7_133,
720_053_000,
7_203,
)));
AssetHubRococo::assert_parachain_system_ump_sent();
@@ -97,7 +97,7 @@ fn para_origin_assertions(t: SystemParaToRelayTest) {
fn para_dest_assertions(t: RelayToSystemParaTest) {
type RuntimeEvent = <AssetHubRococo as Chain>::RuntimeEvent;
AssetHubRococo::assert_dmp_queue_complete(Some(Weight::from_parts(165_592_000, 0)));
AssetHubRococo::assert_dmp_queue_complete(Some(Weight::from_parts(157_718_000, 3593)));
assert_expected_events!(
AssetHubRococo,
@@ -1381,7 +1381,13 @@ impl_runtime_apis! {
MultiAsset { fun: Fungible(UNITS), id: Concrete(TokenLocation::get()) },
));
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
// AssetHubRococo trusts AssetHubWococo as reserve for WOCs
pub TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some(
(
xcm_config::bridging::to_wococo::AssetHubWococo::get(),
MultiAsset::from((xcm_config::bridging::to_wococo::WocLocation::get(), 1000000000000 as u128))
)
);
}
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
@@ -61,16 +61,8 @@ impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
fn withdraw_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
}
// Currently there is no trusted reserve (`IsReserve = ()`),
// but we need this hack for `pallet_xcm::reserve_transfer_assets`
// (TODO) fix https://github.com/paritytech/polkadot/pull/7424
// (TODO) fix https://github.com/paritytech/polkadot/pull/7546
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
// TODO: if we change `IsReserve = ...` then use this line...
// TODO: or if remote weight estimation is fixed, then remove
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
hardcoded_weight.min(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
}
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
@@ -125,12 +117,8 @@ impl<Call> XcmWeightInfo<Call> for AssetHubRococoXcmWeight<Call> {
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
XcmGeneric::<Runtime>::report_error()
}
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
// Hardcoded till the XCM pallet is fixed
let hardcoded_weight = Weight::from_parts(1_000_000_000_u64, 0);
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
hardcoded_weight.min(weight)
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
}
fn deposit_reserve_asset(
assets: &MultiAssetFilter,
@@ -17,28 +17,26 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-07-31, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-10-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-ynta1nyy-project-238-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-rococo-dev"), DB CACHE: 1024
//! HOSTNAME: `runner-ayothjw6-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: Compiled, CHAIN: Some("asset-hub-rococo-dev"), DB CACHE: 1024
// Executed Command:
// ./target/production/polkadot-parachain
// target/production/polkadot-parachain
// benchmark
// pallet
// --template=./templates/xcm-bench-template.hbs
// --chain=asset-hub-rococo-dev
// --wasm-execution=compiled
// --pallet=pallet_xcm_benchmarks::fungible
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --extrinsic=*
// --steps=50
// --repeat=20
// --json
// --header=./file_header.txt
// --output=./parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
// --pallet=pallet_xcm_benchmarks::fungible
// --chain=asset-hub-rococo-dev
// --header=./cumulus/file_header.txt
// --template=./cumulus/templates/xcm-bench-template.hbs
// --output=./cumulus/parachains/runtimes/assets/asset-hub-rococo/src/weights/xcm/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -56,8 +54,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `3593`
// Minimum execution time: 26_104_000 picoseconds.
Weight::from_parts(26_722_000, 3593)
// Minimum execution time: 20_408_000 picoseconds.
Weight::from_parts(21_066_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -67,15 +65,19 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `6196`
// Minimum execution time: 52_259_000 picoseconds.
Weight::from_parts(53_854_000, 6196)
// Minimum execution time: 42_449_000 picoseconds.
Weight::from_parts(43_065_000, 6196)
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: `System::Account` (r:2 w:2)
// Storage: `System::Account` (r:3 w:3)
// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
// Storage: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Proof: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0)
// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1)
@@ -88,49 +90,58 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn transfer_reserve_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `210`
// Estimated: `6196`
// Minimum execution time: 77_248_000 picoseconds.
Weight::from_parts(80_354_000, 6196)
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(4))
}
// Storage: `Benchmark::Override` (r:0 w:0)
// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`)
pub fn reserve_asset_deposited() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 500_000_000_000 picoseconds.
Weight::from_parts(500_000_000_000, 0)
// Measured: `246`
// Estimated: `8799`
// Minimum execution time: 85_637_000 picoseconds.
Weight::from_parts(86_550_000, 8799)
.saturating_add(T::DbWeight::get().reads(11))
.saturating_add(T::DbWeight::get().writes(5))
}
// Storage: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Proof: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
pub fn reserve_asset_deposited() -> Weight {
// Proof Size summary in bytes:
// Measured: `39`
// Estimated: `3504`
// Minimum execution time: 7_006_000 picoseconds.
Weight::from_parts(7_185_000, 3504)
.saturating_add(T::DbWeight::get().reads(2))
}
// Storage: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Proof: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0)
// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1)
// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0)
// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
// Storage: `System::Account` (r:2 w:2)
// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0)
// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1)
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn initiate_reserve_withdraw() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `3574`
// Minimum execution time: 482_070_000 picoseconds.
Weight::from_parts(490_269_000, 3574)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
// Measured: `246`
// Estimated: `6196`
// Minimum execution time: 185_307_000 picoseconds.
Weight::from_parts(189_716_000, 6196)
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(4))
}
pub fn receive_teleported_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_970_000 picoseconds.
Weight::from_parts(4_056_000, 0)
// Minimum execution time: 2_934_000 picoseconds.
Weight::from_parts(3_078_000, 0)
}
// Storage: `System::Account` (r:1 w:1)
// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
@@ -138,15 +149,19 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3593`
// Minimum execution time: 26_324_000 picoseconds.
Weight::from_parts(26_985_000, 3593)
// Minimum execution time: 18_701_000 picoseconds.
Weight::from_parts(19_221_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
// Storage: `System::Account` (r:1 w:1)
// Storage: `System::Account` (r:2 w:2)
// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
// Storage: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Proof: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0)
// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1)
@@ -159,32 +174,38 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn deposit_reserve_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `3593`
// Minimum execution time: 52_814_000 picoseconds.
Weight::from_parts(54_666_000, 3593)
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
// Measured: `145`
// Estimated: `6196`
// Minimum execution time: 57_182_000 picoseconds.
Weight::from_parts(58_877_000, 6196)
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(4))
}
// Storage: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Proof: UNKNOWN KEY `0x48297505634037ef48c848c99c0b1f1b` (r:1 w:0)
// Storage: `ParachainInfo::ParachainId` (r:1 w:0)
// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0)
// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0)
// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
// Storage: `PolkadotXcm::VersionDiscoveryQueue` (r:1 w:1)
// Proof: `PolkadotXcm::VersionDiscoveryQueue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
// Storage: `PolkadotXcm::SafeXcmVersion` (r:1 w:0)
// Proof: `PolkadotXcm::SafeXcmVersion` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
// Storage: `System::Account` (r:1 w:1)
// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0)
// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1)
// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
pub fn initiate_teleport() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `3574`
// Minimum execution time: 33_044_000 picoseconds.
Weight::from_parts(33_849_000, 3574)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
// Measured: `145`
// Estimated: `3610`
// Minimum execution time: 45_073_000 picoseconds.
Weight::from_parts(45_927_000, 3610)
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(3))
}
}
@@ -40,7 +40,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, ConvertInto};
use xcm::latest::prelude::*;
use xcm_builder::{
@@ -76,6 +76,7 @@ parameter_types! {
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
pub const GovernanceLocation: MultiLocation = MultiLocation::parent();
pub TreasuryAccount: Option<AccountId> = Some(TREASURY_PALLET_ID.into_account_truncating());
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
}
/// Adapter for resolving `NetworkId` based on `pub storage Flavor: RuntimeFlavor`.
@@ -497,10 +498,11 @@ pub type Barrier = TrailingSetTopicAsId<
// If the message is one that immediately attempts to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent, its pluralities (i.e. governance bodies) and BridgeHub get free
// execution.
// Parent, its pluralities (i.e. governance bodies), relay treasury pallet and
// BridgeHub get free execution.
AllowExplicitUnpaidExecutionFrom<(
ParentOrParentsPlurality,
Equals<RelayTreasuryLocation>,
Equals<bridging::SiblingBridgeHub>,
)>,
// Subscriptions for version tracking are OK.
@@ -530,22 +532,25 @@ pub type ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger =
ForeignAssetsInstance,
>;
parameter_types! {
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
}
pub struct RelayTreasury;
impl Contains<MultiLocation> for RelayTreasury {
fn contains(location: &MultiLocation) -> bool {
let relay_treasury_location = RelayTreasuryLocation::get();
*location == relay_treasury_location
}
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>, RelayTreasury);
pub type WaivedLocations =
(RelayOrOtherSystemParachains<SystemParachains, Runtime>, Equals<RelayTreasuryLocation>);
/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
///
@@ -26,7 +26,7 @@ use assets_common::{
};
use frame_support::{
match_types, parameter_types,
traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess},
traits::{ConstU32, Contains, Equals, Everything, Nothing, PalletInfoAccess},
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
@@ -74,6 +74,7 @@ parameter_types! {
PalletInstance(<PoolAssets as PalletInfoAccess>::index() as u8).into();
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
pub TreasuryAccount: Option<AccountId> = Some(TREASURY_PALLET_ID.into_account_truncating());
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
}
/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used
@@ -157,7 +158,7 @@ pub type ForeignFungiblesTransactor = FungiblesAdapter<
CheckingAccount,
>;
/// `AssetId/Balance` converter for `PoolAssets`
/// `AssetId`/`Balance` converter for `PoolAssets`.
pub type PoolAssetsConvertedConcreteId =
assets_common::PoolAssetsConvertedConcreteId<PoolAssetsPalletLocation, Balance>;
@@ -236,9 +237,6 @@ match_types! {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
};
pub type TreasuryPallet: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X1(PalletInstance(37)) }
};
}
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
@@ -466,9 +464,12 @@ pub type Barrier = TrailingSetTopicAsId<
// If the message is one that immediately attempts to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent, its pluralities (i.e. governance bodies) and treasury pallet get
// free execution.
AllowExplicitUnpaidExecutionFrom<(ParentOrParentsPlurality, TreasuryPallet)>,
// Parent, its pluralities (i.e. governance bodies), relay treasury pallet and
// BridgeHub get free execution.
AllowExplicitUnpaidExecutionFrom<(
ParentOrParentsPlurality,
Equals<RelayTreasuryLocation>,
)>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
),
@@ -504,22 +505,11 @@ match_types! {
};
}
parameter_types! {
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(westend_runtime_constants::TREASURY_PALLET_ID)).into();
}
pub struct RelayTreasury;
impl Contains<MultiLocation> for RelayTreasury {
fn contains(location: &MultiLocation) -> bool {
let relay_treasury_location = RelayTreasuryLocation::get();
*location == relay_treasury_location
}
}
/// 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>, RelayTreasury);
pub type WaivedLocations =
(RelayOrOtherSystemParachains<SystemParachains, Runtime>, Equals<RelayTreasuryLocation>);
/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
///
@@ -550,6 +540,8 @@ impl xcm_executor::Config for XcmConfig {
>;
type Trader = (
UsingComponents<WeightToFee, WestendLocation, AccountId, Balances, ToStakingPot<Runtime>>,
// This trader allows to pay with `is_sufficient=true` "Trust Backed" assets from dedicated
// `pallet_assets` instance - `Assets`.
cumulus_primitives_utility::TakeFirstAssetTrader<
AccountId,
AssetFeeAsExistentialDepositMultiplierFeeCharger,
@@ -93,6 +93,7 @@ pub fn teleports_for_native_asset_works<
.with_session_keys(collator_session_keys.session_keys())
.with_safe_xcm_version(XCM_VERSION)
.with_para_id(runtime_para_id.into())
.with_tracing()
.build()
.execute_with(|| {
let mut alice = [0u8; 32];
@@ -111,7 +112,7 @@ pub fn teleports_for_native_asset_works<
let native_asset_id = MultiLocation::parent();
let buy_execution_fee_amount_eta =
WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 0));
WeightToFee::weight_to_fee(&Weight::from_parts(90_000_000_000, 1024));
let native_asset_amount_unit = existential_deposit;
let native_asset_amount_received =
native_asset_amount_unit * 10.into() + buy_execution_fee_amount_eta.into();
@@ -128,7 +129,7 @@ pub fn teleports_for_native_asset_works<
id: Concrete(native_asset_id),
fun: Fungible(buy_execution_fee_amount_eta),
},
weight_limit: Limited(Weight::from_parts(303531000, 65536)),
weight_limit: Limited(Weight::from_parts(3035310000, 65536)),
},
DepositAsset {
assets: Wild(AllCounted(1)),
@@ -182,6 +182,14 @@ pub fn limited_reserve_transfer_assets_for_native_asset_works<
weight_limit,
));
// check pallet_xcm attempted
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::assert_pallet_xcm_event_outcome(
&unwrap_pallet_xcm_event,
|outcome| {
assert_ok!(outcome.ensure_complete());
},
);
// check alice account decreased by balance_to_transfer
// TODO:check-parameter: change and assert in tests when (https://github.com/paritytech/polkadot-sdk/pull/1234) merged
assert_eq!(
@@ -196,15 +204,6 @@ pub fn limited_reserve_transfer_assets_for_native_asset_works<
existential_deposit + balance_to_transfer.into()
);
// check events
// check pallet_xcm attempted
RuntimeHelper::<Runtime, AllPalletsWithoutSystem>::assert_pallet_xcm_event_outcome(
&unwrap_pallet_xcm_event,
|outcome| {
assert_ok!(outcome.ensure_complete());
},
);
// check that xcm was sent
let xcm_sent_message_hash = <frame_system::Pallet<Runtime>>::events()
.into_iter()
@@ -29,7 +29,7 @@ use crate::{
};
use frame_support::{
match_types, parameter_types,
traits::{ConstU32, Contains, Everything, Nothing},
traits::{ConstU32, Contains, Equals, Everything, Nothing},
};
use frame_system::EnsureRoot;
use pallet_xcm::XcmPassthrough;
@@ -40,7 +40,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_core::Get;
use sp_runtime::traits::AccountIdConversion;
use xcm::latest::prelude::*;
@@ -67,6 +67,7 @@ parameter_types! {
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
pub TreasuryAccount: Option<AccountId> = Some(TREASURY_PALLET_ID.into_account_truncating());
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
}
/// Adapter for resolving `NetworkId` based on `pub storage Flavor: RuntimeFlavor`.
@@ -222,8 +223,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>,
),
@@ -234,22 +239,25 @@ pub type Barrier = TrailingSetTopicAsId<
>,
>;
parameter_types! {
pub RelayTreasuryLocation: MultiLocation = (Parent, PalletInstance(rococo_runtime_constants::TREASURY_PALLET_ID)).into();
}
pub struct RelayTreasury;
impl Contains<MultiLocation> for RelayTreasury {
fn contains(location: &MultiLocation) -> bool {
let relay_treasury_location = RelayTreasuryLocation::get();
*location == relay_treasury_location
}
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>, RelayTreasury);
pub type WaivedLocations =
(RelayOrOtherSystemParachains<SystemParachains, Runtime>, Equals<RelayTreasuryLocation>);
/// Cases where a remote origin is accepted as trusted Teleporter for a given asset:
/// - NativeToken with the parent Relay Chain and sibling parachains.
@@ -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;