[xcm] Use Weight::MAX for reserve_asset_deposited, receive_teleported_asset benchmarks (#1726)

# Description

## Summary

Previously, the `pallet_xcm::do_reserve_transfer_assets` and
`pallet_xcm::do_teleport_assets` functions relied on weight estimation
for remote chain execution, which was based on guesswork derived from
the local chain. This approach led to complications for runtimes that
did not provide or support specific [XCM
configurations](https://github.com/paritytech/polkadot-sdk/blob/7cbe0c76ef8fd2aabf9f07de0156941ce3ed44b0/polkadot/xcm/xcm-executor/src/config.rs#L43-L47)
for `IsReserve` or `IsTeleporter`. Consequently, such runtimes had to
resort to implementing hard-coded weights for XCM instructions like
`reserve_asset_deposited` or `receive_teleported_asset` to support
extrinsics such as `pallet_xcm::reserve_transfer_assets` and
`pallet_xcm::teleport_assets`, which depended on remote weight
estimation.

The issue of remote weight estimation was addressed and resolved by
[Pull Request
#1645](https://github.com/paritytech/polkadot-sdk/pull/1645), which
removed the need for remote weight estimation.

## Solution

As a continuation of this improvement, the current PR proposes further
cleanup by removing unnecessary hard-coded values and rectifying
benchmark results with `Weight::MAX` that previously used
`T::BlockWeights::get().max_block` as an override for unsupported XCM
instructions like `ReserveAssetDeposited` and `ReceiveTeleportedAsset`.


## Questions

- [x] Can we remove now also `Hardcoded till the XCM pallet is fixed`
for `deposit_asset`? E.g. for AssetHubKusama
[here](https://github.com/paritytech/polkadot-sdk/blob/7cbe0c76ef8fd2aabf9f07de0156941ce3ed44b0/cumulus/parachains/runtimes/assets/asset-hub-kusama/src/weights/xcm/mod.rs#L129-L134)
- [x] Are comments like
[this](https://github.com/paritytech/polkadot-sdk/blob/7cbe0c76ef8fd2aabf9f07de0156941ce3ed44b0/polkadot/runtime/kusama/src/weights/xcm/mod.rs#L94)
`// Kusama doesn't support ReserveAssetDeposited, so this benchmark has
a default weight` still relevant? Shouldnt be removed/changed?


## TODO

- [x] `bench bot` regenerate xcm weights for all runtimes
- [x] remove hard-coded stuff from system parachain weight files
- [ ] when merged, open `polkadot-fellow/runtimes` PR

## References

Fixes #1132
Closes #1132
Old polkadot repo [PR](https://github.com/paritytech/polkadot/pull/7546)

---------

Co-authored-by: command-bot <>
This commit is contained in:
Branislav Kontur
2023-10-10 13:26:22 +02:00
committed by GitHub
parent ebf442336f
commit e3c97e4860
21 changed files with 367 additions and 440 deletions
@@ -91,7 +91,6 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for RococoXcmWeight<RuntimeCall> {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::withdraw_asset())
}
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
// Rococo doesn't support ReserveAssetDeposited, so this benchmark has a default weight
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::reserve_asset_deposited())
}
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
@@ -17,10 +17,10 @@
//! 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-17, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-09-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-gghbxkbs-project-163-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024
//! HOSTNAME: `runner-nbnwcyh-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: Compiled, CHAIN: Some("rococo-dev"), DB CACHE: 1024
// Executed Command:
// target/production/polkadot
@@ -31,12 +31,12 @@
// --extrinsic=*
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/polkadot/.git/.artifacts/bench.json
// --json-file=/builds/parity/mirrors/polkadot-sdk/.git/.artifacts/bench.json
// --pallet=pallet_xcm_benchmarks::fungible
// --chain=rococo-dev
// --header=./file_header.txt
// --template=./xcm/pallet-xcm-benchmarks/template.hbs
// --output=./runtime/rococo/src/weights/xcm/
// --header=./polkadot/file_header.txt
// --template=./polkadot/xcm/pallet-xcm-benchmarks/template.hbs
// --output=./polkadot/runtime/rococo/src/weights/xcm/
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
@@ -55,8 +55,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `3593`
// Minimum execution time: 24_892_000 picoseconds.
Weight::from_parts(25_219_000, 3593)
// Minimum execution time: 23_189_000 picoseconds.
Weight::from_parts(23_896_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -66,8 +66,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `6196`
// Minimum execution time: 52_112_000 picoseconds.
Weight::from_parts(53_104_000, 6196)
// Minimum execution time: 50_299_000 picoseconds.
Weight::from_parts(50_962_000, 6196)
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -83,10 +83,10 @@ impl<T: frame_system::Config> WeightInfo<T> {
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
pub(crate) fn transfer_reserve_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `210`
// Measured: `243`
// Estimated: `6196`
// Minimum execution time: 76_459_000 picoseconds.
Weight::from_parts(79_152_000, 6196)
// Minimum execution time: 71_748_000 picoseconds.
Weight::from_parts(74_072_000, 6196)
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
}
@@ -96,8 +96,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_000_000_000_000 picoseconds.
Weight::from_parts(2_000_000_000_000, 0)
// Minimum execution time: 18_446_744_073_709_551_000 picoseconds.
Weight::from_parts(18_446_744_073_709_551_000, 0)
}
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
@@ -109,10 +109,10 @@ impl<T: frame_system::Config> WeightInfo<T> {
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
pub(crate) fn initiate_reserve_withdraw() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `3574`
// Minimum execution time: 29_734_000 picoseconds.
Weight::from_parts(30_651_000, 3574)
// Measured: `142`
// Estimated: `3607`
// Minimum execution time: 27_806_000 picoseconds.
Weight::from_parts(28_594_000, 3607)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
}
@@ -122,8 +122,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `103`
// Estimated: `3593`
// Minimum execution time: 23_028_000 picoseconds.
Weight::from_parts(23_687_000, 3593)
// Minimum execution time: 21_199_000 picoseconds.
Weight::from_parts(21_857_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -133,8 +133,8 @@ impl<T: frame_system::Config> WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3593`
// Minimum execution time: 26_399_000 picoseconds.
Weight::from_parts(27_262_000, 3593)
// Minimum execution time: 23_578_000 picoseconds.
Weight::from_parts(24_060_000, 3593)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
@@ -150,10 +150,10 @@ impl<T: frame_system::Config> WeightInfo<T> {
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
pub(crate) fn deposit_reserve_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `3593`
// Minimum execution time: 52_015_000 picoseconds.
Weight::from_parts(53_498_000, 3593)
// Measured: `142`
// Estimated: `3607`
// Minimum execution time: 48_522_000 picoseconds.
Weight::from_parts(49_640_000, 3607)
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
@@ -169,10 +169,10 @@ impl<T: frame_system::Config> WeightInfo<T> {
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
pub(crate) fn initiate_teleport() -> Weight {
// Proof Size summary in bytes:
// Measured: `109`
// Estimated: `3593`
// Minimum execution time: 53_833_000 picoseconds.
Weight::from_parts(55_688_000, 3593)
// Measured: `142`
// Estimated: `3607`
// Minimum execution time: 50_429_000 picoseconds.
Weight::from_parts(51_295_000, 3607)
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}