Skip to content

Commit

Permalink
[xcm] Use Weight::MAX for reserve_asset_deposited, `receive_telep…
Browse files Browse the repository at this point in the history
…orted_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](paritytech/polkadot-sdk#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](paritytech/polkadot#7546)

---------

Co-authored-by: command-bot <>
  • Loading branch information
bkontur committed Oct 10, 2023
1 parent aba60cb commit 6ef8495
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pallet-xcm-benchmarks/src/fungible/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use frame_benchmarking::{benchmarks_instance_pallet, BenchmarkError, BenchmarkRe
use frame_support::{
pallet_prelude::Get,
traits::fungible::{Inspect, Mutate},
weights::Weight,
};
use sp_runtime::traits::{Bounded, Zero};
use sp_std::{prelude::*, vec};
Expand Down Expand Up @@ -134,7 +135,7 @@ benchmarks_instance_pallet! {
reserve_asset_deposited {
let (trusted_reserve, transferable_reserve_asset) = T::TrustedReserve::get()
.ok_or(BenchmarkError::Override(
BenchmarkResult::from_weight(T::BlockWeights::get().max_block)
BenchmarkResult::from_weight(Weight::MAX)
))?;

let assets: MultiAssets = vec![ transferable_reserve_asset ].into();
Expand Down Expand Up @@ -187,7 +188,7 @@ benchmarks_instance_pallet! {
}: {
executor.bench_process(xcm).map_err(|_| {
BenchmarkError::Override(
BenchmarkResult::from_weight(T::BlockWeights::get().max_block)
BenchmarkResult::from_weight(Weight::MAX)
)
})?;
} verify {
Expand Down

0 comments on commit 6ef8495

Please sign in to comment.