mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
XCM Benchmarks for Generic Instructions (#3940)
* initial stuff * quick fixes * move to individual tests * dont need these * Update benchmarking.rs * add to westend * make benchmarks execute * fix compile * add post_execute * ClaimAsset benchmark working * subscribe and unsubscribe benchmarks * benchmark for initiate reserve withdraw * cargo run --quiet --release --features=runtime-benchmarks -- 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 * fix spell check * cargo run --quiet --release --features=runtime-benchmarks -- 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 * update worst case for query_holding * cargo run --quiet --release --features=runtime-benchmarks -- 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 * move verification logic below * introduce worst case holding to initiate reserve withdraw * cargo run --quiet --release --features=runtime-benchmarks -- 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 * feedback * cargo run --quiet --release --features=runtime-benchmarks -- 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 * Revert "cargo run --quiet --release --features=runtime-benchmarks -- 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" This reverts commit 277903944be620dc57d83b9bcf3b462d2fb73ab5. * fix benchmark template * cargo run --quiet --release --features=runtime-benchmarks -- 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 * use response::version * cargo run --quiet --release --features=runtime-benchmarks -- 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 * refactor worst case holding * cargo run --quiet --release --features=runtime-benchmarks -- 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 * fmt * one more todo needs to be labeled * change option to result with benchmark error * fmt and fix import Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
@@ -1497,6 +1497,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();
|
||||
|
||||
@@ -1533,6 +1534,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();
|
||||
|
||||
@@ -1545,7 +1547,7 @@ sp_api::impl_runtime_apis! {
|
||||
Vec<frame_benchmarking::BenchmarkBatch>,
|
||||
sp_runtime::RuntimeString,
|
||||
> {
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
|
||||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey, BenchmarkError};
|
||||
// Trying to add benchmarks directly to some pallets caused cyclic dependency issues.
|
||||
// To get around that, we separated the benchmarks into its own crate.
|
||||
use pallet_session_benchmarking::Pallet as SessionBench;
|
||||
@@ -1561,9 +1563,16 @@ sp_api::impl_runtime_apis! {
|
||||
impl pallet_xcm_benchmarks::Config for Runtime {
|
||||
type XcmConfig = XcmConfig;
|
||||
type AccountIdConverter = LocationConverter;
|
||||
fn valid_destination() -> Result<MultiLocation, sp_runtime::DispatchError> {
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(Westmint::get())
|
||||
}
|
||||
fn worst_case_holding() -> MultiAssets {
|
||||
// Westend only knows about WND.
|
||||
vec![MultiAsset{
|
||||
id: Concrete(WndLocation::get()),
|
||||
fun: Fungible(1_000_000 * UNITS),
|
||||
}].into()
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -1587,7 +1596,31 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl pallet_xcm_benchmarks::generic::Config for Runtime {
|
||||
type Call = Call;
|
||||
|
||||
fn worst_case_response() -> (u64, Response) {
|
||||
(0u64, Response::Version(Default::default()))
|
||||
}
|
||||
|
||||
fn transact_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(Westmint::get())
|
||||
}
|
||||
|
||||
fn subscribe_origin() -> Result<MultiLocation, BenchmarkError> {
|
||||
Ok(Westmint::get())
|
||||
}
|
||||
|
||||
fn claimable_asset() -> Result<(MultiLocation, MultiLocation, MultiAssets), BenchmarkError> {
|
||||
let origin = Westmint::get();
|
||||
let assets: MultiAssets = (Concrete(WndLocation::get()), 1_000 * UNITS).into();
|
||||
let ticket = MultiLocation { parents: 0, interior: Here };
|
||||
Ok((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
|
||||
@@ -1646,8 +1679,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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
@@ -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,
|
||||
@@ -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,
|
||||
@@ -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()
|
||||
|
||||
@@ -1,73 +1,132 @@
|
||||
// this whole file is temp, and will be replaced in the future TODO
|
||||
// Copyright 2017-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>);
|
||||
// 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.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2021-12-01, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128
|
||||
|
||||
// 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
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
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> {
|
||||
pub fn query_holding() -> Weight {
|
||||
1_000_000_000
|
||||
// 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 {
|
||||
(39_278_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
pub fn buy_execution() -> Weight {
|
||||
1_000_000_000
|
||||
pub(crate) fn buy_execution() -> Weight {
|
||||
(5_922_000 as Weight)
|
||||
}
|
||||
pub fn transact() -> Weight {
|
||||
1_000_000_000
|
||||
// Storage: XcmPallet Queries (r:1 w:0)
|
||||
pub(crate) fn query_response() -> Weight {
|
||||
(20_625_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
}
|
||||
pub fn reserve_asset_deposited() -> Weight {
|
||||
1_000_000_000
|
||||
pub(crate) fn transact() -> Weight {
|
||||
(22_198_000 as Weight)
|
||||
}
|
||||
pub fn hrmp_new_channel_open_request() -> Weight {
|
||||
1_000_000_000
|
||||
pub(crate) fn refund_surplus() -> Weight {
|
||||
(6_122_000 as Weight)
|
||||
}
|
||||
pub fn hrmp_channel_accepted() -> Weight {
|
||||
1_000_000_000
|
||||
pub(crate) fn set_error_handler() -> Weight {
|
||||
(5_758_000 as Weight)
|
||||
}
|
||||
pub fn hrmp_channel_closing() -> Weight {
|
||||
1_000_000_000
|
||||
pub(crate) fn set_appendix() -> Weight {
|
||||
(5_764_000 as Weight)
|
||||
}
|
||||
pub fn relayed_from() -> Weight {
|
||||
1_000_000_000
|
||||
pub(crate) fn clear_error() -> Weight {
|
||||
(5_679_000 as Weight)
|
||||
}
|
||||
pub fn refund_surplus() -> Weight {
|
||||
1_000_000_000
|
||||
pub(crate) fn descend_origin() -> Weight {
|
||||
(7_206_000 as Weight)
|
||||
}
|
||||
pub fn set_error_handler() -> Weight {
|
||||
1_000_000_000
|
||||
pub(crate) fn clear_origin() -> Weight {
|
||||
(5_738_000 as Weight)
|
||||
}
|
||||
pub fn set_appendix() -> Weight {
|
||||
1_000_000_000
|
||||
// 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 {
|
||||
(31_512_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
pub fn clear_error() -> Weight {
|
||||
1_000_000_000
|
||||
// Storage: XcmPallet AssetTraps (r:1 w:1)
|
||||
pub(crate) fn claim_asset() -> Weight {
|
||||
(13_594_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
pub fn claim_asset(_assets: &crate::MultiAssets) -> Weight {
|
||||
1_000_000_000
|
||||
pub(crate) fn trap() -> Weight {
|
||||
(5_745_000 as Weight)
|
||||
}
|
||||
pub fn trap(_code: &u64) -> Weight {
|
||||
1_000_000_000
|
||||
// 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_138_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
|
||||
pub fn subscribe_version() -> Weight {
|
||||
1_000_000_000
|
||||
// Storage: XcmPallet VersionNotifyTargets (r:0 w:1)
|
||||
pub(crate) fn unsubscribe_version() -> Weight {
|
||||
(9_127_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
|
||||
pub fn unsubscribe_version() -> Weight {
|
||||
1_000_000_000
|
||||
}
|
||||
|
||||
pub fn clear_origin() -> Weight {
|
||||
1_000_000_000
|
||||
}
|
||||
|
||||
pub fn descend_origin(_who: &crate::InteriorMultiLocation) -> Weight {
|
||||
1_000_000_000
|
||||
}
|
||||
|
||||
pub fn initiate_reserve_withdraw() -> Weight {
|
||||
1_000_000_000
|
||||
}
|
||||
|
||||
pub fn report_error() -> Weight {
|
||||
1_000_000_000
|
||||
// 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 {
|
||||
(41_443_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user