XCM v3 Companion (#697)

* Fixes

* Undiener

* Undiener

* Undiener

* Lockfile

* Changes for send returning hash

* Include message ID as params to execute_xcm

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Companion fixes

* Formatting

* Fixes

* Formatting

* Bump

* Bump

* Fixes

* Formatting

* Make the price of UMP/XCMP message sending configurable

* cargo fmt

* Remove InvertLocation

* Formatting

* Use ConstantPrice from polkadot-runtime-common

* Fix naming

* cargo fmt

* Fixes

* Fixes

* Fixes

* Add CallDispatcher

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Remove unused import

* Remove unused import

* XCMv3 fixes (#1710)

* Fixes XCMv3 related
Fixes XCMv3 (removed query_holding)
Fixes XCMv3 - should use _depositable_count?
Fixes XCMv3 - removed TrustedReserve
Fixes - missing weights for statemine/statemint/westmint
[DO-NOT-CHERRY-PICK] tmp return query_holding to aviod conficts to master
Fixes - missing functions for pallet_xcm_benchmarks::generic::Config
Fixes for XCMv3 benchmarking
Fix xcm - removed query_holding

* ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic

* ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic

* ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic

* Fix imports

* Avoid consuming XCM message for NotApplicable scenario (#1787)

* Avoid consuming message for NotApplicable scenario

* Avoid consuming message for NotApplicable scenario tests

* Add 10 message processing limit to DMP queue

* Add 10 message limit to XCMP queue

* Always increment the message_processed count whenever a message is processed

* Fix formatting

* Set an upper limit to the overweight message DMP queue

* Add upper limit to XCMP overweight message queue

* Fix for missing weight for `fn unpaid_execution()`

* Fix - usage of `messages_processed`

* Fixes

* Fixes

* Fixes

* cargo fmt

* Fixes

* Fixes

* Fixes

* Fixes

* Remove unused import

* Fixes for gav-xcm-v3 (#1835)

* Fix for FungiblesAdapter - trait changes: Contains -> AssetChecking

* Fix for missing weight for `fn unpaid_execution()`

* Used NonLocalMint for all NonZeroIssuance

* Fix

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fix tests

* Fixes

* Add SafeCallFilter

* Add missing config items

* Add TODO

* Use () as the PriceForParentDelivery

* Fixes

* Fixes

* Fixes

* Fixes

* Update transact_origin to transact_origin_and_runtime_call

* Add ReachableDest config item to XCM pallet

* Update SafeCallFilter to allow remark_with_event in runtime benchmarks

* cargo fmt

* Update substrate

* Fix worst_case_holding

* Fix DMQ queue unit tests

* Remove unused label

* cargo fmt

* Actually process incoming XCMs

* Fixes

* Fixes

* Fixes

* Fixes - return back Weightless

* Added measured benchmarks for `pallet_xcm` (#1968)

* Fix

Fix

Fix

* Fix

* Fixes for transact benchmark

* Fixes add pallet_xcm to benchmarks

* Revert remark_with_event

* ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic

* Fixes

* TMP

* Fix for reserve_asset_deposited

* ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm

* Fix

* ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm

* Fix

* ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm

* Fix westmint

* ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic

* Fix

* ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic

* ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic

* ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm

* Fix for collectives

* ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm

* ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm

* Fixes for bridge-hubs

* Fixes - return back Weightless

* Fix - removed MigrateToTrackInactive for contracts-rococo

Co-authored-by: command-bot <>

* cargo fmt

* Fix benchmarks

* Bko gav xcm v3 (#1993)

* Fix

* ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::fungible

* ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::fungible

* ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::fungible

* ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic

* ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic

* ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic

* ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm

* ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm

* ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm

* ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm

* ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm

* ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm

Co-authored-by: command-bot <>

* Change AllowUnpaidExecutionFrom to be explicit

* xcm-v3 benchmarks, weights, fixes for bridge-hubs (#2035)

* Dumy weights to get compile

* Change UniversalLocation according to https://github.com/paritytech/polkadot/pull/4097 (Location Inversion Removed)

* Fix bridge-hubs weights

* ".git/.scripts/bench-bot.sh" pallet statemine assets pallet_xcm

* ".git/.scripts/bench-bot.sh" pallet statemint assets pallet_xcm

* ".git/.scripts/bench-bot.sh" pallet collectives-polkadot collectives pallet_xcm

* ".git/.scripts/bench-bot.sh" pallet westmint assets pallet_xcm

* ".git/.scripts/bench-bot.sh" xcm bridge-hub-kusama bridge-hubs pallet_xcm_benchmarks::generic

* ".git/.scripts/bench-bot.sh" xcm bridge-hub-kusama bridge-hubs pallet_xcm_benchmarks::fungible

* ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_xcm

* ".git/.scripts/bench-bot.sh" pallet bridge-hub-rococo bridge-hubs pallet_xcm

* ".git/.scripts/bench-bot.sh" xcm bridge-hub-rococo bridge-hubs pallet_xcm_benchmarks::fungible

* ".git/.scripts/bench-bot.sh" xcm bridge-hub-rococo bridge-hubs pallet_xcm_benchmarks::generic

* Change NetworkId to Option<NetworkId>

Co-authored-by: command-bot <>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

* Add event for showing the hash of an UMP sent message (#1228)

* Add UpwardMessageSent event in parachain-system

* additional fixes

* Message Id

* Fix errors from merge

* fmt

* more fmt

* Remove todo

* more formatting

* Fixes

* Fixes

* Fixes

* Fixes

* Allow explicit unpaid executions from the relay chains for system parachains (#2060)

* Allow explicit unpaid executions from the relay chains for system parachains

* Put origin-filtering barriers into WithComputedOrigin

* Use ConstU32<8>

* Small nits

* formatting

* cargo fmt

* Allow receiving XCMs from any relay chain plurality

* Fixes

* update lockfile for {"polkadot", "substrate"}

* Update polkadot

* Add runtime-benchmarks feature

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Branislav Kontur <bkontur@gmail.com>
Co-authored-by: girazoki <gorka.irazoki@gmail.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Gavin Wood
2023-01-17 06:26:34 -03:00
committed by GitHub
parent aae4731d38
commit 3aae882437
73 changed files with 4328 additions and 1487 deletions
+28 -16
View File
@@ -460,6 +460,7 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type ControllerOrigin = EnsureRoot<AccountId>;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
type PriceForSiblingDelivery = ();
}
impl cumulus_pallet_dmp_queue::Config for Runtime {
@@ -694,6 +695,7 @@ mod benches {
[pallet_collator_selection, CollatorSelection]
[cumulus_pallet_xcmp_queue, XcmpQueue]
// XCM
[pallet_xcm, PolkadotXcm]
// NOTE: Make sure you point to the individual modules below.
[pallet_xcm_benchmarks::fungible, XcmBalances]
[pallet_xcm_benchmarks::generic, XcmGeneric]
@@ -879,7 +881,7 @@ impl_runtime_apis! {
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
use xcm::latest::prelude::*;
use xcm_config::WestendLocation;
use xcm_config::{MaxAssetsIntoHolding, WestendLocation};
use pallet_xcm_benchmarks::asset_instance_from;
impl pallet_xcm_benchmarks::Config for Runtime {
@@ -888,12 +890,12 @@ impl_runtime_apis! {
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
Ok(WestendLocation::get())
}
fn worst_case_holding() -> MultiAssets {
fn worst_case_holding(depositable_count: u32) -> MultiAssets {
// A mix of fungible, non-fungible, and concrete assets.
const HOLDING_FUNGIBLES: u32 = 100;
const HOLDING_NON_FUNGIBLES: u32 = 100;
let holding_non_fungibles = MaxAssetsIntoHolding::get() / 2 - depositable_count;
let holding_fungibles = holding_non_fungibles - 1;
let fungibles_amount: u128 = 100;
let mut assets = (0..HOLDING_FUNGIBLES)
let mut assets = (0..holding_fungibles)
.map(|i| {
MultiAsset {
id: Concrete(GeneralIndex(i as u128).into()),
@@ -902,17 +904,17 @@ impl_runtime_apis! {
.into()
})
.chain(core::iter::once(MultiAsset { id: Concrete(Here.into()), fun: Fungible(u128::MAX) }))
.chain((0..HOLDING_NON_FUNGIBLES).map(|i| MultiAsset {
.chain((0..holding_non_fungibles).map(|i| MultiAsset {
id: Concrete(GeneralIndex(i as u128).into()),
fun: NonFungible(asset_instance_from(i)),
}))
.collect::<Vec<_>>();
assets.push(MultiAsset{
id: Concrete(WestendLocation::get()),
fun: Fungible(1_000_000 * UNITS),
});
assets.into()
assets.push(MultiAsset {
id: Concrete(WestendLocation::get()),
fun: Fungible(1_000_000 * UNITS),
});
assets.into()
}
}
@@ -921,8 +923,7 @@ impl_runtime_apis! {
WestendLocation::get(),
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WestendLocation::get()) },
));
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
pub const CheckedAccount: Option<AccountId> = None;
pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None;
}
@@ -931,7 +932,6 @@ impl_runtime_apis! {
type CheckedAccount = CheckedAccount;
type TrustedTeleporter = TrustedTeleporter;
type TrustedReserve = TrustedReserve;
fn get_multi_asset() -> MultiAsset {
MultiAsset {
@@ -948,8 +948,16 @@ impl_runtime_apis! {
(0u64, Response::Version(Default::default()))
}
fn transact_origin() -> Result<MultiLocation, BenchmarkError> {
Ok(WestendLocation::get())
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
Err(BenchmarkError::Skip)
}
fn universal_alias() -> Result<Junction, BenchmarkError> {
Err(BenchmarkError::Skip)
}
fn transact_origin_and_runtime_call() -> Result<(MultiLocation, RuntimeCall), BenchmarkError> {
Ok((WestendLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into()))
}
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
@@ -962,6 +970,10 @@ impl_runtime_apis! {
let ticket = MultiLocation { parents: 0, interior: Here };
Ok((origin, ticket, assets))
}
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
Err(BenchmarkError::Skip)
}
}
type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
@@ -12,6 +12,7 @@ pub mod pallet_session;
pub mod pallet_timestamp;
pub mod pallet_uniques;
pub mod pallet_utility;
pub mod pallet_xcm;
pub mod paritydb_weights;
pub mod rocksdb_weights;
pub mod xcm;
@@ -0,0 +1,173 @@
// Copyright 2021 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.
// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_xcm`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-12-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024
// Executed Command:
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
// benchmark
// pallet
// --steps=50
// --repeat=20
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
// --pallet=pallet_xcm
// --chain=westmint-dev
// --header=./file_header.txt
// --output=./parachains/runtimes/assets/westmint/src/weights/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;
/// Weight functions for `pallet_xcm`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
fn send() -> Weight {
// Minimum execution time: 27_623 nanoseconds.
Weight::from_ref_time(28_375_000)
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: ParachainInfo ParachainId (r:1 w:0)
fn teleport_assets() -> Weight {
// Minimum execution time: 33_363 nanoseconds.
Weight::from_ref_time(33_942_000)
.saturating_add(T::DbWeight::get().reads(1))
}
// Storage: ParachainInfo ParachainId (r:1 w:0)
fn reserve_transfer_assets() -> Weight {
// Minimum execution time: 25_113 nanoseconds.
Weight::from_ref_time(25_549_000)
.saturating_add(T::DbWeight::get().reads(1))
}
fn execute() -> Weight {
// Minimum execution time: 15_464 nanoseconds.
Weight::from_ref_time(15_772_000)
}
// Storage: PolkadotXcm SupportedVersion (r:0 w:1)
fn force_xcm_version() -> Weight {
// Minimum execution time: 15_375 nanoseconds.
Weight::from_ref_time(15_631_000)
.saturating_add(T::DbWeight::get().writes(1))
}
// Storage: PolkadotXcm SafeXcmVersion (r:0 w:1)
fn force_default_xcm_version() -> Weight {
// Minimum execution time: 4_575 nanoseconds.
Weight::from_ref_time(4_708_000)
.saturating_add(T::DbWeight::get().writes(1))
}
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
// Storage: PolkadotXcm QueryCounter (r:1 w:1)
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
// Storage: PolkadotXcm Queries (r:0 w:1)
fn force_subscribe_version_notify() -> Weight {
// Minimum execution time: 31_521 nanoseconds.
Weight::from_ref_time(32_350_000)
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(5))
}
// Storage: PolkadotXcm VersionNotifiers (r:1 w:1)
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
// Storage: PolkadotXcm Queries (r:0 w:1)
fn force_unsubscribe_version_notify() -> Weight {
// Minimum execution time: 32_589 nanoseconds.
Weight::from_ref_time(33_282_000)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
}
// Storage: PolkadotXcm SupportedVersion (r:4 w:2)
fn migrate_supported_version() -> Weight {
// Minimum execution time: 13_642 nanoseconds.
Weight::from_ref_time(13_969_000)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: PolkadotXcm VersionNotifiers (r:4 w:2)
fn migrate_version_notifiers() -> Weight {
// Minimum execution time: 13_569 nanoseconds.
Weight::from_ref_time(14_168_000)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: PolkadotXcm VersionNotifyTargets (r:5 w:0)
fn already_notified_target() -> Weight {
// Minimum execution time: 15_406 nanoseconds.
Weight::from_ref_time(15_731_000)
.saturating_add(T::DbWeight::get().reads(5))
}
// Storage: PolkadotXcm VersionNotifyTargets (r:2 w:1)
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
fn notify_current_targets() -> Weight {
// Minimum execution time: 27_357 nanoseconds.
Weight::from_ref_time(27_804_000)
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
// Storage: PolkadotXcm VersionNotifyTargets (r:3 w:0)
fn notify_target_migration_fail() -> Weight {
// Minimum execution time: 6_940 nanoseconds.
Weight::from_ref_time(7_147_000)
.saturating_add(T::DbWeight::get().reads(3))
}
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
fn migrate_version_notify_targets() -> Weight {
// Minimum execution time: 14_204 nanoseconds.
Weight::from_ref_time(14_529_000)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: PolkadotXcm VersionNotifyTargets (r:4 w:2)
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
fn migrate_and_notify_old_targets() -> Weight {
// Minimum execution time: 32_809 nanoseconds.
Weight::from_ref_time(33_346_000)
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(4))
}
}
@@ -21,168 +21,220 @@ use crate::Runtime;
use frame_support::weights::Weight;
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
use sp_std::{cmp, prelude::*};
use xcm::{
latest::{prelude::*, Weight as XCMWeight},
DoubleEncoded,
};
use sp_std::prelude::*;
use xcm::{latest::prelude::*, DoubleEncoded};
trait WeighMultiAssets {
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight;
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
}
const MAX_ASSETS: u32 = 100;
impl WeighMultiAssets for MultiAssetFilter {
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
let weight = match self {
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
match self {
Self::Definite(assets) =>
weight.saturating_mul(assets.inner().into_iter().count() as u64),
Self::Wild(_) => weight.saturating_mul(MAX_ASSETS as u64),
};
weight.ref_time()
}
}
}
impl WeighMultiAssets for MultiAssets {
fn weigh_multi_assets(&self, weight: Weight) -> XCMWeight {
weight.saturating_mul(self.inner().into_iter().count() as u64).ref_time()
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
weight.saturating_mul(self.inner().into_iter().count() as u64)
}
}
pub struct WestmintXcmWeight<Call>(core::marker::PhantomData<Call>);
impl<Call> XcmWeightInfo<Call> for WestmintXcmWeight<Call> {
fn withdraw_asset(assets: &MultiAssets) -> XCMWeight {
fn withdraw_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
}
// Currently there is no trusted reserve
fn reserve_asset_deposited(_assets: &MultiAssets) -> XCMWeight {
u64::MAX
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
// TODO: hardcoded - fix https://github.com/paritytech/cumulus/issues/1974
Weight::from_ref_time(1_000_000_000 as u64)
}
fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight {
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
}
fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> XCMWeight {
XcmGeneric::<Runtime>::query_response().ref_time()
fn query_response(
_query_id: &u64,
_response: &Response,
_max_weight: &Weight,
_querier: &Option<MultiLocation>,
) -> Weight {
XcmGeneric::<Runtime>::query_response()
}
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight {
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
}
fn transfer_reserve_asset(
assets: &MultiAssets,
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> XCMWeight {
) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
}
fn transact(
_origin_type: &OriginKind,
_require_weight_at_most: &u64,
_require_weight_at_most: &Weight,
_call: &DoubleEncoded<Call>,
) -> XCMWeight {
XcmGeneric::<Runtime>::transact().ref_time()
) -> Weight {
XcmGeneric::<Runtime>::transact()
}
fn hrmp_new_channel_open_request(
_sender: &u32,
_max_message_size: &u32,
_max_capacity: &u32,
) -> XCMWeight {
) -> Weight {
// XCM Executor does not currently support HRMP channel operations
Weight::MAX.ref_time()
Weight::MAX
}
fn hrmp_channel_accepted(_recipient: &u32) -> XCMWeight {
fn hrmp_channel_accepted(_recipient: &u32) -> Weight {
// XCM Executor does not currently support HRMP channel operations
Weight::MAX.ref_time()
Weight::MAX
}
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> XCMWeight {
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight {
// XCM Executor does not currently support HRMP channel operations
Weight::MAX.ref_time()
Weight::MAX
}
fn clear_origin() -> XCMWeight {
XcmGeneric::<Runtime>::clear_origin().ref_time()
fn clear_origin() -> Weight {
XcmGeneric::<Runtime>::clear_origin()
}
fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight {
XcmGeneric::<Runtime>::descend_origin().ref_time()
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
XcmGeneric::<Runtime>::descend_origin()
}
fn report_error(
_query_id: &QueryId,
_dest: &MultiLocation,
_max_response_weight: &u64,
) -> XCMWeight {
XcmGeneric::<Runtime>::report_error().ref_time()
fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
XcmGeneric::<Runtime>::report_error()
}
fn deposit_asset(
assets: &MultiAssetFilter,
_max_assets: &u32,
_dest: &MultiLocation,
) -> XCMWeight {
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> Weight {
// Hardcoded till the XCM pallet is fixed
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64).ref_time();
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64);
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
cmp::min(hardcoded_weight, weight)
hardcoded_weight.min(weight)
}
fn deposit_reserve_asset(
assets: &MultiAssetFilter,
_max_assets: &u32,
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> XCMWeight {
) -> Weight {
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
}
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> XCMWeight {
Weight::MAX.ref_time()
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets, _maximal: &bool) -> Weight {
Weight::MAX
}
fn initiate_reserve_withdraw(
assets: &MultiAssetFilter,
_reserve: &MultiLocation,
_xcm: &Xcm<()>,
) -> XCMWeight {
) -> Weight {
assets.weigh_multi_assets(XcmGeneric::<Runtime>::initiate_reserve_withdraw())
}
fn initiate_teleport(
assets: &MultiAssetFilter,
_dest: &MultiLocation,
_xcm: &Xcm<()>,
) -> XCMWeight {
) -> Weight {
// Hardcoded till the XCM pallet is fixed
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64).ref_time();
let hardcoded_weight = Weight::from_ref_time(200_000_000 as u64);
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
cmp::min(hardcoded_weight, weight)
hardcoded_weight.min(weight)
}
fn query_holding(
_query_id: &u64,
_dest: &MultiLocation,
_assets: &MultiAssetFilter,
_max_response_weight: &u64,
) -> XCMWeight {
XcmGeneric::<Runtime>::query_holding().ref_time()
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> Weight {
XcmGeneric::<Runtime>::report_holding()
}
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight {
XcmGeneric::<Runtime>::buy_execution().ref_time()
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
XcmGeneric::<Runtime>::buy_execution()
}
fn refund_surplus() -> XCMWeight {
XcmGeneric::<Runtime>::refund_surplus().ref_time()
fn refund_surplus() -> Weight {
XcmGeneric::<Runtime>::refund_surplus()
}
fn set_error_handler(_xcm: &Xcm<Call>) -> XCMWeight {
XcmGeneric::<Runtime>::set_error_handler().ref_time()
fn set_error_handler(_xcm: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::set_error_handler()
}
fn set_appendix(_xcm: &Xcm<Call>) -> XCMWeight {
XcmGeneric::<Runtime>::set_appendix().ref_time()
fn set_appendix(_xcm: &Xcm<Call>) -> Weight {
XcmGeneric::<Runtime>::set_appendix()
}
fn clear_error() -> XCMWeight {
XcmGeneric::<Runtime>::clear_error().ref_time()
fn clear_error() -> Weight {
XcmGeneric::<Runtime>::clear_error()
}
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> XCMWeight {
XcmGeneric::<Runtime>::claim_asset().ref_time()
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
XcmGeneric::<Runtime>::claim_asset()
}
fn trap(_code: &u64) -> XCMWeight {
XcmGeneric::<Runtime>::trap().ref_time()
fn trap(_code: &u64) -> Weight {
XcmGeneric::<Runtime>::trap()
}
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> XCMWeight {
XcmGeneric::<Runtime>::subscribe_version().ref_time()
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight {
XcmGeneric::<Runtime>::subscribe_version()
}
fn unsubscribe_version() -> XCMWeight {
XcmGeneric::<Runtime>::unsubscribe_version().ref_time()
fn unsubscribe_version() -> Weight {
XcmGeneric::<Runtime>::unsubscribe_version()
}
fn burn_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
}
fn expect_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
}
fn expect_origin(_origin: &Option<MultiLocation>) -> Weight {
XcmGeneric::<Runtime>::expect_origin()
}
fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
XcmGeneric::<Runtime>::expect_error()
}
fn query_pallet(_module_name: &Vec<u8>, _response_info: &QueryResponseInfo) -> Weight {
XcmGeneric::<Runtime>::query_pallet()
}
fn expect_pallet(
_index: &u32,
_name: &Vec<u8>,
_module_name: &Vec<u8>,
_crate_major: &u32,
_min_crate_minor: &u32,
) -> Weight {
XcmGeneric::<Runtime>::expect_pallet()
}
fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight {
XcmGeneric::<Runtime>::report_transact_status()
}
fn clear_transact_status() -> Weight {
XcmGeneric::<Runtime>::clear_transact_status()
}
fn universal_origin(_: &Junction) -> Weight {
Weight::MAX
}
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
Weight::MAX
}
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
Weight::MAX
}
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> Weight {
Weight::MAX
}
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> Weight {
Weight::MAX
}
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> Weight {
Weight::MAX
}
fn set_fees_mode(_: &bool) -> Weight {
XcmGeneric::<Runtime>::set_fees_mode()
}
fn set_topic(_topic: &[u8; 32]) -> Weight {
XcmGeneric::<Runtime>::set_topic()
}
fn clear_topic() -> Weight {
XcmGeneric::<Runtime>::clear_topic()
}
fn alias_origin(_: &MultiLocation) -> Weight {
// XCM Executor does not currently support alias origin operations
Weight::MAX
}
fn unpaid_execution(_: &WeightLimit, _: &Option<MultiLocation>) -> Weight {
XcmGeneric::<Runtime>::unpaid_execution()
}
}
@@ -18,25 +18,26 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! DATE: 2022-12-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024
// Executed Command:
// ./artifacts/polkadot-parachain
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
// benchmark
// pallet
// --template=./templates/xcm-bench-template.hbs
// --chain=westmint-dev
// --execution=wasm
// --wasm-execution=compiled
// --pallet=pallet_xcm_benchmarks::fungible
// --extrinsic=*
// --steps=50
// --repeat=20
// --json
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
// --pallet=pallet_xcm_benchmarks::fungible
// --chain=westmint-dev
// --header=./file_header.txt
// --output=./parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
// --template=./templates/xcm-bench-template.hbs
// --output=./parachains/runtimes/assets/westmint/src/weights/xcm/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -50,13 +51,13 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo<T> {
// Storage: System Account (r:1 w:1)
pub(crate) fn withdraw_asset() -> Weight {
Weight::from_ref_time(32_238_000 as u64)
Weight::from_ref_time(30_986_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: System Account (r:2 w:2)
pub(crate) fn transfer_asset() -> Weight {
Weight::from_ref_time(37_145_000 as u64)
Weight::from_ref_time(39_149_000 as u64)
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
@@ -68,16 +69,16 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
pub(crate) fn transfer_reserve_asset() -> Weight {
Weight::from_ref_time(52_803_000 as u64)
Weight::from_ref_time(56_235_000 as u64)
.saturating_add(T::DbWeight::get().reads(8 as u64))
.saturating_add(T::DbWeight::get().writes(4 as u64))
}
pub(crate) fn receive_teleported_asset() -> Weight {
Weight::from_ref_time(6_248_000 as u64)
Weight::from_ref_time(7_616_000 as u64)
}
// Storage: System Account (r:1 w:1)
pub(crate) fn deposit_asset() -> Weight {
Weight::from_ref_time(33_168_000 as u64)
Weight::from_ref_time(34_864_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
@@ -89,7 +90,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
pub(crate) fn deposit_reserve_asset() -> Weight {
Weight::from_ref_time(53_662_000 as u64)
Weight::from_ref_time(55_915_000 as u64)
.saturating_add(T::DbWeight::get().reads(7 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
@@ -100,7 +101,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
pub(crate) fn initiate_teleport() -> Weight {
Weight::from_ref_time(29_189_000 as u64)
Weight::from_ref_time(30_050_000 as u64)
.saturating_add(T::DbWeight::get().reads(6 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
@@ -18,25 +18,26 @@
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-12-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm4`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! DATE: 2022-12-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westmint-dev"), DB CACHE: 1024
// Executed Command:
// ./artifacts/polkadot-parachain
// /home/benchbot/cargo_target_dir/production/polkadot-parachain
// benchmark
// pallet
// --template=./templates/xcm-bench-template.hbs
// --chain=westmint-dev
// --execution=wasm
// --wasm-execution=compiled
// --pallet=pallet_xcm_benchmarks::generic
// --extrinsic=*
// --steps=50
// --repeat=20
// --json
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
// --pallet=pallet_xcm_benchmarks::generic
// --chain=westmint-dev
// --header=./file_header.txt
// --output=./parachains/runtimes/assets/westmint/src/weights/xcm/pallet_xcm_benchmarks_generic.rs
// --template=./templates/xcm-bench-template.hbs
// --output=./parachains/runtimes/assets/westmint/src/weights/xcm/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -54,58 +55,59 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
pub(crate) fn query_holding() -> Weight {
Weight::from_ref_time(710_352_000 as u64)
pub(crate) fn report_holding() -> Weight {
Weight::from_ref_time(337_762_000 as u64)
.saturating_add(T::DbWeight::get().reads(6 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
pub(crate) fn buy_execution() -> Weight {
Weight::from_ref_time(8_924_000 as u64)
Weight::from_ref_time(6_682_000 as u64)
}
// Storage: PolkadotXcm Queries (r:1 w:0)
pub(crate) fn query_response() -> Weight {
Weight::from_ref_time(17_278_000 as u64)
Weight::from_ref_time(17_801_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
}
pub(crate) fn transact() -> Weight {
Weight::from_ref_time(20_214_000 as u64)
Weight::from_ref_time(21_889_000 as u64)
}
pub(crate) fn refund_surplus() -> Weight {
Weight::from_ref_time(9_218_000 as u64)
Weight::from_ref_time(7_081_000 as u64)
}
pub(crate) fn set_error_handler() -> Weight {
Weight::from_ref_time(5_175_000 as u64)
Weight::from_ref_time(6_050_000 as u64)
}
pub(crate) fn set_appendix() -> Weight {
Weight::from_ref_time(5_145_000 as u64)
Weight::from_ref_time(5_982_000 as u64)
}
pub(crate) fn clear_error() -> Weight {
Weight::from_ref_time(5_298_000 as u64)
Weight::from_ref_time(5_948_000 as u64)
}
pub(crate) fn descend_origin() -> Weight {
Weight::from_ref_time(6_134_000 as u64)
Weight::from_ref_time(7_022_000 as u64)
}
pub(crate) fn clear_origin() -> Weight {
Weight::from_ref_time(5_277_000 as u64)
Weight::from_ref_time(6_019_000 as u64)
}
// Storage: ParachainInfo ParachainId (r:1 w:0)
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
pub(crate) fn report_error() -> Weight {
Weight::from_ref_time(15_270_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
Weight::from_ref_time(21_836_000 as u64)
.saturating_add(T::DbWeight::get().reads(6 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
// Storage: PolkadotXcm AssetTraps (r:1 w:1)
pub(crate) fn claim_asset() -> Weight {
Weight::from_ref_time(21_147_000 as u64)
Weight::from_ref_time(21_512_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
pub(crate) fn trap() -> Weight {
Weight::from_ref_time(5_429_000 as u64)
Weight::from_ref_time(5_971_000 as u64)
}
// Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1)
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
@@ -114,13 +116,13 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
pub(crate) fn subscribe_version() -> Weight {
Weight::from_ref_time(18_098_000 as u64)
Weight::from_ref_time(27_912_000 as u64)
.saturating_add(T::DbWeight::get().reads(6 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
// Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1)
pub(crate) fn unsubscribe_version() -> Weight {
Weight::from_ref_time(7_527_000 as u64)
Weight::from_ref_time(7_870_000 as u64)
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: ParachainInfo ParachainId (r:1 w:0)
@@ -130,8 +132,60 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
pub(crate) fn initiate_reserve_withdraw() -> Weight {
Weight::from_ref_time(927_560_000 as u64)
Weight::from_ref_time(390_638_000 as u64)
.saturating_add(T::DbWeight::get().reads(6 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
pub(crate) fn burn_asset() -> Weight {
Weight::from_ref_time(128_254_000 as u64)
}
pub(crate) fn expect_asset() -> Weight {
Weight::from_ref_time(15_386_000 as u64)
}
pub(crate) fn expect_origin() -> Weight {
Weight::from_ref_time(6_071_000 as u64)
}
pub(crate) fn expect_error() -> Weight {
Weight::from_ref_time(6_044_000 as u64)
}
// Storage: ParachainInfo ParachainId (r:1 w:0)
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
pub(crate) fn query_pallet() -> Weight {
Weight::from_ref_time(24_744_000 as u64)
.saturating_add(T::DbWeight::get().reads(6 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
pub(crate) fn expect_pallet() -> Weight {
Weight::from_ref_time(7_558_000 as u64)
}
// Storage: ParachainInfo ParachainId (r:1 w:0)
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
pub(crate) fn report_transact_status() -> Weight {
Weight::from_ref_time(22_068_000 as u64)
.saturating_add(T::DbWeight::get().reads(6 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
pub(crate) fn clear_transact_status() -> Weight {
Weight::from_ref_time(5_945_000 as u64)
}
pub(crate) fn set_topic() -> Weight {
Weight::from_ref_time(5_863_000 as u64)
}
pub(crate) fn clear_topic() -> Weight {
Weight::from_ref_time(5_807_000 as u64)
}
pub(crate) fn set_fees_mode() -> Weight {
Weight::from_ref_time(5_825_000 as u64)
}
pub(crate) fn unpaid_execution() -> Weight {
Weight::from_ref_time(5_920_000 as u64)
}
}
@@ -14,12 +14,13 @@
// limitations under the License.
use super::{
AccountId, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo, ParachainSystem,
PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
AccountId, AllPalletsWithSystem, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo,
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee,
XcmpQueue,
};
use frame_support::{
match_types, parameter_types,
traits::{Everything, PalletInfoAccess},
traits::{ConstU32, Contains, Everything, Nothing, PalletInfoAccess},
};
use pallet_xcm::XcmPassthrough;
use parachains_common::{
@@ -32,23 +33,26 @@ use polkadot_parachain::primitives::Sibling;
use sp_runtime::traits::ConvertInto;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, AsPrefixedGeneralIndex,
ConvertedConcreteAssetId, CurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, IsConcrete,
LocationInverter, NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative,
SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
WeightInfoBounds,
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex,
ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FungiblesAdapter, IsConcrete, LocalMint,
NativeAsset, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
WithComputedOrigin,
};
use xcm_executor::{
traits::{JustTry, WithOriginFilter},
XcmExecutor,
};
use xcm_executor::{traits::JustTry, XcmExecutor};
parameter_types! {
pub const WestendLocation: MultiLocation = MultiLocation::parent();
pub RelayNetwork: NetworkId =
NetworkId::Named(b"Westend".to_vec().try_into().expect("less than length limit; qed"));
pub RelayNetwork: Option<NetworkId> = Some(NetworkId::Westend);
pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into();
pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();
pub const Local: MultiLocation = Here.into();
pub UniversalLocation: InteriorMultiLocation =
X2(GlobalConsensus(RelayNetwork::get().unwrap()), Parachain(ParachainInfo::parachain_id().into()));
pub const Local: MultiLocation = Here.into_location();
pub AssetsPalletLocation: MultiLocation =
PalletInstance(<Assets as PalletInfoAccess>::index() as u8).into();
pub CheckingAccount: AccountId = PolkadotXcm::check_account();
@@ -85,7 +89,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
// Use this fungibles implementation:
Assets,
// Use this currency when it is a fungible asset matching the given location or name:
ConvertedConcreteAssetId<
ConvertedConcreteId<
AssetId,
Balance,
AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>,
@@ -97,7 +101,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
AccountId,
// We only want to allow teleports of known assets. We use non-zero issuance as an indication
// that this asset is known.
parachains_common::impls::NonZeroIssuance<AccountId, Assets>,
LocalMint<parachains_common::impls::NonZeroIssuance<AccountId, Assets>>,
// The account to use for tracking teleports.
CheckingAccount,
>;
@@ -130,6 +134,7 @@ pub type XcmOriginToTransactDispatchOrigin = (
parameter_types! {
pub const MaxInstructions: u32 = 100;
pub const MaxAssetsIntoHolding: u32 = 64;
pub XcmAssetFeesReceiver: Option<AccountId> = Authorship::author();
}
@@ -139,18 +144,122 @@ match_types! {
MultiLocation { parents: 1, interior: X1(Plurality { .. }) }
};
}
/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
/// account for proof size weights.
///
/// Calls that are allowed through this filter must:
/// 1. Have a fixed weight;
/// 2. Cannot lead to another call being made;
/// 3. Have a defined proof size weight, e.g. no unbounded vecs in call parameters.
pub struct SafeCallFilter;
impl Contains<RuntimeCall> for SafeCallFilter {
fn contains(call: &RuntimeCall) -> bool {
#[cfg(feature = "runtime-benchmarks")]
{
if matches!(call, RuntimeCall::System(frame_system::Call::remark_with_event { .. })) {
return true
}
}
match call {
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) |
RuntimeCall::ParachainSystem(..) |
RuntimeCall::Timestamp(..) |
RuntimeCall::Balances(..) |
RuntimeCall::CollatorSelection(
pallet_collator_selection::Call::set_desired_candidates { .. } |
pallet_collator_selection::Call::set_candidacy_bond { .. } |
pallet_collator_selection::Call::register_as_candidate { .. } |
pallet_collator_selection::Call::leave_intent { .. },
) |
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
RuntimeCall::XcmpQueue(..) |
RuntimeCall::DmpQueue(..) |
RuntimeCall::Utility(pallet_utility::Call::as_derivative { .. }) |
RuntimeCall::Assets(
pallet_assets::Call::create { .. } |
pallet_assets::Call::force_create { .. } |
pallet_assets::Call::start_destroy { .. } |
pallet_assets::Call::destroy_accounts { .. } |
pallet_assets::Call::destroy_approvals { .. } |
pallet_assets::Call::finish_destroy { .. } |
pallet_assets::Call::mint { .. } |
pallet_assets::Call::burn { .. } |
pallet_assets::Call::transfer { .. } |
pallet_assets::Call::transfer_keep_alive { .. } |
pallet_assets::Call::force_transfer { .. } |
pallet_assets::Call::freeze { .. } |
pallet_assets::Call::thaw { .. } |
pallet_assets::Call::freeze_asset { .. } |
pallet_assets::Call::thaw_asset { .. } |
pallet_assets::Call::transfer_ownership { .. } |
pallet_assets::Call::set_team { .. } |
pallet_assets::Call::clear_metadata { .. } |
pallet_assets::Call::force_clear_metadata { .. } |
pallet_assets::Call::force_asset_status { .. } |
pallet_assets::Call::approve_transfer { .. } |
pallet_assets::Call::cancel_approval { .. } |
pallet_assets::Call::force_cancel_approval { .. } |
pallet_assets::Call::transfer_approved { .. } |
pallet_assets::Call::touch { .. } |
pallet_assets::Call::refund { .. },
) |
RuntimeCall::Uniques(
pallet_uniques::Call::create { .. } |
pallet_uniques::Call::force_create { .. } |
pallet_uniques::Call::destroy { .. } |
pallet_uniques::Call::mint { .. } |
pallet_uniques::Call::burn { .. } |
pallet_uniques::Call::transfer { .. } |
pallet_uniques::Call::freeze { .. } |
pallet_uniques::Call::thaw { .. } |
pallet_uniques::Call::freeze_collection { .. } |
pallet_uniques::Call::thaw_collection { .. } |
pallet_uniques::Call::transfer_ownership { .. } |
pallet_uniques::Call::set_team { .. } |
pallet_uniques::Call::approve_transfer { .. } |
pallet_uniques::Call::cancel_approval { .. } |
pallet_uniques::Call::force_item_status { .. } |
pallet_uniques::Call::set_attribute { .. } |
pallet_uniques::Call::clear_attribute { .. } |
pallet_uniques::Call::set_metadata { .. } |
pallet_uniques::Call::clear_metadata { .. } |
pallet_uniques::Call::set_collection_metadata { .. } |
pallet_uniques::Call::clear_collection_metadata { .. } |
pallet_uniques::Call::set_accept_ownership { .. } |
pallet_uniques::Call::set_collection_max_supply { .. } |
pallet_uniques::Call::set_price { .. } |
pallet_uniques::Call::buy_item { .. },
) => true,
_ => false,
}
}
}
pub type Barrier = DenyThenTry<
DenyReserveTransferToRelayChain,
(
TakeWeightCredit,
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its plurality get free execution
AllowUnpaidExecutionFrom<ParentOrParentsPlurality>,
// Expected responses are OK.
AllowKnownQueryResponses<PolkadotXcm>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent or its plurality (i.e. governance bodies) gets free execution.
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<Everything>,
),
UniversalLocation,
ConstU32<8>,
>,
),
>;
@@ -171,7 +280,7 @@ impl xcm_executor::Config for XcmConfig {
// For WND, users must use teleport where allowed (e.g. with the Relay Chain).
type IsReserve = ();
type IsTeleporter = NativeAsset; // <- should be enough to allow teleportation of WND
type LocationInverter = LocationInverter<Ancestry>;
type UniversalLocation = UniversalLocation;
type Barrier = Barrier;
type Weigher = WeightInfoBounds<
crate::weights::xcm::WestmintXcmWeight<RuntimeCall>,
@@ -183,7 +292,7 @@ impl xcm_executor::Config for XcmConfig {
cumulus_primitives_utility::TakeFirstAssetTrader<
AccountId,
AssetFeeAsExistentialDepositMultiplierFeeCharger,
ConvertedConcreteAssetId<
ConvertedConcreteId<
AssetId,
Balance,
AsPrefixedGeneralIndex<AssetsPalletLocation, AssetId, JustTry>,
@@ -201,6 +310,15 @@ impl xcm_executor::Config for XcmConfig {
type AssetTrap = PolkadotXcm;
type AssetClaims = PolkadotXcm;
type SubscriptionService = PolkadotXcm;
type PalletInstancesInfo = AllPalletsWithSystem;
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
type AssetLocker = ();
type AssetExchanger = ();
type FeeManager = ();
type MessageExporter = ();
type UniversalAliases = Nothing;
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
type SafeCallFilter = SafeCallFilter;
}
/// Local origins on this chain are allowed to dispatch XCM sends/executions.
@@ -210,11 +328,16 @@ pub type LocalOriginToLocation = SignedToAccountId32<RuntimeOrigin, AccountId, R
/// queues.
pub type XcmRouter = (
// Two routers - use UMP to communicate with the relay chain:
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm>,
cumulus_primitives_utility::ParentAsUmp<ParachainSystem, PolkadotXcm, ()>,
// ..and XCMP to communicate with the sibling chains.
XcmpQueue,
);
#[cfg(feature = "runtime-benchmarks")]
parameter_types! {
pub ReachableDest: Option<MultiLocation> = Some(Parent.into());
}
impl pallet_xcm::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type SendXcmOrigin = EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
@@ -229,11 +352,19 @@ impl pallet_xcm::Config for Runtime {
RuntimeCall,
MaxInstructions,
>;
type LocationInverter = LocationInverter<Ancestry>;
type UniversalLocation = UniversalLocation;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
type Currency = Balances;
type CurrencyMatcher = ();
type TrustedLockers = ();
type SovereignAccountOf = LocationToAccountId;
type MaxLockers = ConstU32<8>;
type WeightInfo = crate::weights::pallet_xcm::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
}
impl cumulus_pallet_xcm::Config for Runtime {
@@ -62,13 +62,13 @@ fn test_asset_xcm_trader() {
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
// We are going to buy 4e9 weight
let bought = 4_000_000_000u64;
let bought = Weight::from_ref_time(4_000_000_000u64);
// Lets calculate amount needed
let asset_amount_needed =
AssetFeeAsExistentialDepositMultiplierFeeCharger::charge_weight_in_fungibles(
local_asset_id,
Weight::from_ref_time(bought),
bought,
)
.expect("failed to compute");
@@ -138,7 +138,7 @@ fn test_asset_xcm_trader_with_refund() {
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
// We are going to buy 4e9 weight
let bought = 4_000_000_000u64;
let bought = Weight::from_ref_time(4_000_000_000u64);
let asset_multilocation = MultiLocation::new(
0,
X2(
@@ -151,7 +151,7 @@ fn test_asset_xcm_trader_with_refund() {
);
// lets calculate amount needed
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
let amount_bought = WeightToFee::weight_to_fee(&bought);
let asset: MultiAsset = (asset_multilocation.clone(), amount_bought).into();
@@ -165,8 +165,7 @@ fn test_asset_xcm_trader_with_refund() {
let weight_used = bought / 2;
// Make sure refurnd works.
let amount_refunded =
WeightToFee::weight_to_fee(&Weight::from_ref_time(bought - weight_used));
let amount_refunded = WeightToFee::weight_to_fee(&(bought - weight_used));
assert_eq!(
trader.refund_weight(bought - weight_used),
@@ -177,7 +176,7 @@ fn test_asset_xcm_trader_with_refund() {
drop(trader);
// We only should have paid for half of the bought weight
let fees_paid = WeightToFee::weight_to_fee(&Weight::from_ref_time(weight_used));
let fees_paid = WeightToFee::weight_to_fee(&weight_used);
assert_eq!(
Assets::balance(1, AccountId::from(ALICE)),
@@ -216,7 +215,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
// We are going to buy 5e9 weight
let bought = 500_000_000u64;
let bought = Weight::from_ref_time(500_000_000u64);
let asset_multilocation = MultiLocation::new(
0,
@@ -229,7 +228,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
),
);
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
let amount_bought = WeightToFee::weight_to_fee(&bought);
assert!(
amount_bought < ExistentialDeposit::get(),
@@ -275,7 +274,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
// Set Alice as block author, who will receive fees
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
let bought = 500_000_000u64;
let bought = Weight::from_ref_time(500_000_000u64);
let asset_multilocation = MultiLocation::new(
0,
@@ -288,7 +287,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
),
);
let amount_bought = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
let amount_bought = WeightToFee::weight_to_fee(&bought);
assert!(
amount_bought < ExistentialDeposit::get(),
@@ -356,10 +355,10 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
// We are going to buy 4e9 weight
let bought = 4_000_000_000u64;
let bought = Weight::from_ref_time(4_000_000_000u64);
// lets calculate amount needed
let asset_amount_needed = WeightToFee::weight_to_fee(&Weight::from_ref_time(bought));
let asset_amount_needed = WeightToFee::weight_to_fee(&bought);
let asset_multilocation = MultiLocation::new(
0,