Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

XCM Benchmarks for Generic Instructions #3940

Merged
merged 46 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
16ad36c
initial stuff
shawntabrizi Sep 27, 2021
cbd0dc8
Merge branch 'master' into shawntabrizi-xcm-generic-benchmarks
shawntabrizi Oct 4, 2021
82caeec
quick fixes
shawntabrizi Oct 4, 2021
e3a0f4a
move to individual tests
shawntabrizi Oct 4, 2021
f5b3269
dont need these
shawntabrizi Oct 4, 2021
29bfa5d
Update benchmarking.rs
shawntabrizi Oct 4, 2021
ec573a0
add to westend
shawntabrizi Oct 4, 2021
e3a7c02
Merge branch 'master' into shawntabrizi-xcm-generic-benchmarks
shawntabrizi Nov 11, 2021
77b1fbd
make benchmarks execute
shawntabrizi Nov 12, 2021
470ce15
fix compile
shawntabrizi Nov 14, 2021
82149ac
add post_execute
shawntabrizi Nov 15, 2021
b817e7c
ClaimAsset benchmark working
shawntabrizi Nov 15, 2021
3d9f774
subscribe and unsubscribe benchmarks
shawntabrizi Nov 15, 2021
e85c556
benchmark for initiate reserve withdraw
shawntabrizi Nov 15, 2021
e64c9ae
Merge branch 'master' into shawntabrizi-xcm-generic-benchmarks
shawntabrizi Nov 15, 2021
3aa3b3c
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Nov 15, 2021
30c13a2
fix spell check
shawntabrizi Nov 15, 2021
270c283
Merge branch 'master' into shawntabrizi-xcm-generic-benchmarks
shawntabrizi Nov 15, 2021
041b3f4
Merge branch 'master' into shawntabrizi-xcm-generic-benchmarks
shawntabrizi Nov 15, 2021
cd190e2
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Nov 15, 2021
2ee0d81
update worst case for query_holding
shawntabrizi Nov 16, 2021
02248db
Merge branch 'master' of https://github.com/paritytech/polkadot into …
Nov 16, 2021
a9a3b29
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Nov 16, 2021
f51acc3
move verification logic below
shawntabrizi Nov 16, 2021
1e80cfe
introduce worst case holding to initiate reserve withdraw
shawntabrizi Nov 16, 2021
9178fbe
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Nov 16, 2021
d8da46b
Merge branch 'master' into shawntabrizi-xcm-generic-benchmarks
shawntabrizi Nov 24, 2021
978b015
Merge branch 'master' into shawntabrizi-xcm-generic-benchmarks
shawntabrizi Nov 30, 2021
23602ca
feedback
shawntabrizi Nov 30, 2021
21fde67
Merge branch 'master' into shawntabrizi-xcm-generic-benchmarks
shawntabrizi Nov 30, 2021
2779039
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Nov 30, 2021
98964be
Revert "cargo run --quiet --release --features=runtime-benchmarks -- …
shawntabrizi Nov 30, 2021
4939b63
fix benchmark template
shawntabrizi Nov 30, 2021
be2036d
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Nov 30, 2021
4efd026
use response::version
shawntabrizi Dec 1, 2021
6c0ceed
Merge branch 'master' of https://github.com/paritytech/polkadot into …
Dec 1, 2021
77b183f
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Dec 1, 2021
d783d40
refactor worst case holding
shawntabrizi Dec 1, 2021
2a9582b
Merge branch 'shawntabrizi-xcm-generic-benchmarks' of https://github.…
shawntabrizi Dec 1, 2021
6512a26
cargo run --quiet --release --features=runtime-benchmarks -- benchmar…
Dec 1, 2021
df66c1f
fmt
shawntabrizi Dec 1, 2021
fc51779
Merge branch 'shawntabrizi-xcm-generic-benchmarks' of https://github.…
shawntabrizi Dec 1, 2021
cd0f4b8
one more todo needs to be labeled
shawntabrizi Dec 1, 2021
b7e3ced
change option to result with benchmark error
shawntabrizi Dec 1, 2021
3c4dcb4
fmt and fix import
shawntabrizi Dec 1, 2021
a9ea6c1
Merge branch 'master' into shawntabrizi-xcm-generic-benchmarks
shawntabrizi Dec 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bridges/bin/rialto/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,6 @@ impl_runtime_apis! {
);
add_benchmark!(params, batches, pallet_bridge_grandpa, BridgeMillauGrandpa);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
}
}
Expand Down
1 change: 0 additions & 1 deletion runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,6 @@ sp_api::impl_runtime_apis! {
add_benchmark!(params, batches, pallet_utility, Utility);
add_benchmark!(params, batches, pallet_vesting, Vesting);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
}
}
Expand Down
1 change: 0 additions & 1 deletion runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,6 @@ sp_api::impl_runtime_apis! {
add_benchmark!(params, batches, runtime_parachains::paras_inherent, ParaInherent);
add_benchmark!(params, batches, runtime_parachains::paras, Paras);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
}
}
Expand Down
24 changes: 23 additions & 1 deletion runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,7 @@ sp_api::impl_runtime_apis! {
use frame_system_benchmarking::Pallet as SystemBench;

type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;

let mut list = Vec::<BenchmarkList>::new();

Expand Down Expand Up @@ -1508,6 +1509,7 @@ sp_api::impl_runtime_apis! {
// XCM Benchmarks
// NOTE: Make sure you point to the individual modules below.
list_benchmark!(list, extra, pallet_xcm_benchmarks::fungible, XcmBalances);
list_benchmark!(list, extra, pallet_xcm_benchmarks::generic, XcmGeneric);

let storage_info = AllPalletsWithSystem::storage_info();

Expand Down Expand Up @@ -1562,7 +1564,27 @@ sp_api::impl_runtime_apis! {
}
}

impl pallet_xcm_benchmarks::generic::Config for Runtime {
type Call = Call;

fn worst_case_response() -> (u64, Response) {
(0u64, Default::default())
shawntabrizi marked this conversation as resolved.
Show resolved Hide resolved
}

fn transact_origin() -> Option<MultiLocation> {
Some(Westmint::get())
}

fn claimable_asset() -> Option<(MultiLocation, MultiLocation, MultiAssets)> {
let origin = Westmint::get();
let assets: MultiAssets = (Concrete(WndLocation::get()), 1_000 * UNITS).into();
let ticket = MultiLocation { parents: 0, interior: Here };
Some((origin, ticket, assets))
}
}

type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;
type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::<Runtime>;

let whitelist: Vec<TrackedStorageKey> = vec![
// Block Number
Expand Down Expand Up @@ -1621,8 +1643,8 @@ sp_api::impl_runtime_apis! {
// XCM Benchmarks
// NOTE: Make sure you point to the individual modules below.
add_benchmark!(params, batches, pallet_xcm_benchmarks::fungible, XcmBalances);
add_benchmark!(params, batches, pallet_xcm_benchmarks::generic, XcmGeneric);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
}
}
Expand Down
33 changes: 17 additions & 16 deletions runtime/westend/src/weights/xcm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ impl<Call> XcmWeightInfo<Call> for WestendXcmWeight<Call> {
fn withdraw_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::withdraw_asset())
}
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmGeneric::<Runtime>::reserve_asset_deposited())
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
// Westend does not support reserve asset deposits.
Weight::MAX
}
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::receive_teleported_asset())
}
fn query_response(_query_id: &u64, _response: &Response, max_weight: &u64) -> Weight {
*max_weight
fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> Weight {
XcmGeneric::<Runtime>::query_response()
}
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::transfer_asset())
Expand All @@ -100,19 +101,22 @@ impl<Call> XcmWeightInfo<Call> for WestendXcmWeight<Call> {
_max_message_size: &u32,
_max_capacity: &u32,
) -> Weight {
XcmGeneric::<Runtime>::hrmp_new_channel_open_request()
// XCM Executor does not currently support HRMP channel operations
Weight::MAX
}
fn hrmp_channel_accepted(_recipient: &u32) -> Weight {
XcmGeneric::<Runtime>::hrmp_channel_accepted()
// XCM Executor does not currently support HRMP channel operations
Weight::MAX
}
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight {
XcmGeneric::<Runtime>::hrmp_channel_closing()
// XCM Executor does not currently support HRMP channel operations
Weight::MAX
}
fn clear_origin() -> Weight {
XcmGeneric::<Runtime>::clear_origin()
}
fn descend_origin(who: &InteriorMultiLocation) -> Weight {
XcmGeneric::<Runtime>::descend_origin(who)
fn descend_origin(_who: &InteriorMultiLocation) -> Weight {
XcmGeneric::<Runtime>::descend_origin()
}
fn report_error(
_query_id: &QueryId,
Expand All @@ -121,9 +125,6 @@ impl<Call> XcmWeightInfo<Call> for WestendXcmWeight<Call> {
) -> Weight {
XcmGeneric::<Runtime>::report_error()
}
fn relayed_from(_who: &Junctions, _message: &Box<Xcm<Call>>) -> Weight {
XcmGeneric::<Runtime>::relayed_from()
}

fn deposit_asset(
assets: &MultiAssetFilter,
Expand Down Expand Up @@ -180,11 +181,11 @@ impl<Call> XcmWeightInfo<Call> for WestendXcmWeight<Call> {
fn clear_error() -> Weight {
XcmGeneric::<Runtime>::clear_error()
}
fn claim_asset(assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
XcmGeneric::<Runtime>::claim_asset(assets)
fn claim_asset(_assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
XcmGeneric::<Runtime>::claim_asset()
}
fn trap(code: &u64) -> Weight {
XcmGeneric::<Runtime>::trap(code)
fn trap(_code: &u64) -> Weight {
XcmGeneric::<Runtime>::trap()
}
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> Weight {
XcmGeneric::<Runtime>::subscribe_version()
Expand Down
186 changes: 123 additions & 63 deletions runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs
Original file line number Diff line number Diff line change
@@ -1,73 +1,133 @@
// this whole file is temp, and will be replaced in the future TODO
// Copyright 2017-2021 Parity Technologies (UK) Ltd.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright 2017-2021 Parity Technologies (UK) Ltd.
// Copyright 2021 Parity Technologies (UK) Ltd.

// This file is part of Polkadot.

use frame_support::dispatch::Weight;
// Polkadot 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.

pub struct WeightInfo<T>(sp_std::marker::PhantomData<T>);
impl<T: frame_system::Config> WeightInfo<T> {
pub fn query_holding() -> Weight {
1_000_000_000
}
pub fn buy_execution() -> Weight {
1_000_000_000
}
pub fn transact() -> Weight {
1_000_000_000
}
pub fn reserve_asset_deposited() -> Weight {
1_000_000_000
}
pub fn hrmp_new_channel_open_request() -> Weight {
1_000_000_000
}
pub fn hrmp_channel_accepted() -> Weight {
1_000_000_000
}
pub fn hrmp_channel_closing() -> Weight {
1_000_000_000
}
pub fn relayed_from() -> Weight {
1_000_000_000
}
pub fn refund_surplus() -> Weight {
1_000_000_000
}
pub fn set_error_handler() -> Weight {
1_000_000_000
}
pub fn set_appendix() -> Weight {
1_000_000_000
}
pub fn clear_error() -> Weight {
1_000_000_000
}
pub fn claim_asset(_assets: &crate::MultiAssets) -> Weight {
1_000_000_000
}
pub fn trap(_code: &u64) -> Weight {
1_000_000_000
}
// Polkadot 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.

pub fn subscribe_version() -> Weight {
1_000_000_000
}
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

pub fn unsubscribe_version() -> Weight {
1_000_000_000
}
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-11-16, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128

pub fn clear_origin() -> Weight {
1_000_000_000
}
// Executed Command:
// target/release/polkadot
// benchmark
// --chain=westend-dev
// --steps=50
// --repeat=20
// --pallet=pallet_xcm_benchmarks::generic
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --template=./xcm/pallet-xcm-benchmarks/template.hbs
// --output=./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs

pub fn descend_origin(_who: &crate::InteriorMultiLocation) -> Weight {
1_000_000_000
}

pub fn initiate_reserve_withdraw() -> Weight {
1_000_000_000
}
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]

pub fn report_error() -> Weight {
1_000_000_000
use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

/// Weights for `pallet_xcm_benchmarks::generic`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo<T> {
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn query_holding() -> Weight {
(1_429_190_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
pub(crate) fn buy_execution() -> Weight {
(9_866_000 as Weight)
}
// Storage: XcmPallet Queries (r:1 w:0)
pub(crate) fn query_response() -> Weight {
(20_840_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
}
pub(crate) fn transact() -> Weight {
(22_698_000 as Weight)
}
pub(crate) fn refund_surplus() -> Weight {
(5_981_000 as Weight)
}
pub(crate) fn set_error_handler() -> Weight {
(5_752_000 as Weight)
}
pub(crate) fn set_appendix() -> Weight {
(5_783_000 as Weight)
}
pub(crate) fn clear_error() -> Weight {
(5_768_000 as Weight)
}
pub(crate) fn descend_origin() -> Weight {
(7_344_000 as Weight)
}
pub(crate) fn clear_origin() -> Weight {
(5_752_000 as Weight)
}
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn report_error() -> Weight {
(32_401_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
// Storage: XcmPallet AssetTraps (r:1 w:1)
pub(crate) fn claim_asset() -> Weight {
(13_904_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
pub(crate) fn trap() -> Weight {
(5_775_000 as Weight)
}
// Storage: XcmPallet VersionNotifyTargets (r:1 w:1)
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn subscribe_version() -> Weight {
(38_781_000 as Weight)
.saturating_add(T::DbWeight::get().reads(6 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
// Storage: XcmPallet VersionNotifyTargets (r:0 w:1)
pub(crate) fn unsubscribe_version() -> Weight {
(8_931_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: XcmPallet SupportedVersion (r:1 w:0)
// Storage: XcmPallet VersionDiscoveryQueue (r:1 w:1)
// Storage: XcmPallet SafeXcmVersion (r:1 w:0)
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
pub(crate) fn initiate_reserve_withdraw() -> Weight {
(1_948_419_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
}
Loading