mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 07:01:03 +00:00
XCM Benchmarks for Asset Transactor w/ Fungible Asset (#3818)
* benchmarks for fungibles * add benchmark to westend * fix hex * clean up a bit * update code doc * fix warnings * cargo run --quiet --release --features runtime-benchmarks -- benchmark --chain=westend-dev --pallet=pallet_xcm_benchmarks::fungible --extrinsic=* --steps=10 --repeat=10 --template=./xcm/pallet-xcm-benchmarks/template.hbs --output=./ --execution=wasm --wasm-execution=compiled * use skip * fix spelling * Update Cargo.lock * add scale-info * Update Cargo.lock * update bench * cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=westend-dev --steps=50 --repeat=20 --pallet=pallet_xcm_benchmarks::fungible --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_fungible.rs * weights compile * update westend to use weights * fmt * spelling fixes * Delete pallet_xcm_benchmarks::fungible.rs * Apply suggestions from code review Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * fix code review * update weight * fix report_error * fix spell check Co-authored-by: Parity Bot <admin@parity.io> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -36,3 +36,4 @@ pub mod runtime_common_paras_registrar;
|
||||
pub mod runtime_common_slots;
|
||||
pub mod runtime_parachains_configuration;
|
||||
pub mod runtime_parachains_paras;
|
||||
pub mod xcm;
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
mod pallet_xcm_benchmarks_fungible;
|
||||
mod pallet_xcm_benchmarks_generic;
|
||||
|
||||
use crate::Runtime;
|
||||
use frame_support::weights::Weight;
|
||||
use sp_std::prelude::*;
|
||||
use xcm::{latest::prelude::*, DoubleEncoded};
|
||||
|
||||
use pallet_xcm_benchmarks_fungible::WeightInfo as XcmBalancesWeight;
|
||||
use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
|
||||
|
||||
/// Types of asset supported by the westend runtime.
|
||||
pub enum AssetTypes {
|
||||
/// An asset backed by `pallet-balances`.
|
||||
Balances,
|
||||
/// Unknown asset.
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl From<&MultiAsset> for AssetTypes {
|
||||
fn from(asset: &MultiAsset) -> Self {
|
||||
match asset {
|
||||
MultiAsset { id: Concrete(MultiLocation { parents: 0, interior: Here }), .. } =>
|
||||
AssetTypes::Balances,
|
||||
_ => AssetTypes::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait WeighMultiAssets {
|
||||
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight;
|
||||
}
|
||||
|
||||
// TODO wild case
|
||||
impl WeighMultiAssets for MultiAssetFilter {
|
||||
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight {
|
||||
match self {
|
||||
Self::Definite(assets) => assets
|
||||
.inner()
|
||||
.into_iter()
|
||||
.map(From::from)
|
||||
.map(|t| match t {
|
||||
AssetTypes::Balances => balances_weight,
|
||||
AssetTypes::Unknown => Weight::MAX,
|
||||
})
|
||||
.fold(0, |acc, x| acc.saturating_add(x)),
|
||||
_ => Weight::MAX,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl WeighMultiAssets for MultiAssets {
|
||||
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight {
|
||||
self.inner()
|
||||
.into_iter()
|
||||
.map(|m| <AssetTypes as From<&MultiAsset>>::from(m))
|
||||
.map(|t| match t {
|
||||
AssetTypes::Balances => balances_weight,
|
||||
AssetTypes::Unknown => Weight::MAX,
|
||||
})
|
||||
.fold(0, |acc, x| acc.saturating_add(x))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WestendXcmWeight<Call>(core::marker::PhantomData<Call>);
|
||||
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 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 transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::transfer_asset())
|
||||
}
|
||||
fn transfer_reserve_asset(
|
||||
assets: &MultiAssets,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::transfer_reserve_asset())
|
||||
}
|
||||
fn transact(
|
||||
_origin_type: &OriginKind,
|
||||
_require_weight_at_most: &u64,
|
||||
_call: &DoubleEncoded<Call>,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::transact()
|
||||
}
|
||||
fn hrmp_new_channel_open_request(
|
||||
_sender: &u32,
|
||||
_max_message_size: &u32,
|
||||
_max_capacity: &u32,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::hrmp_new_channel_open_request()
|
||||
}
|
||||
fn hrmp_channel_accepted(_recipient: &u32) -> Weight {
|
||||
XcmGeneric::<Runtime>::hrmp_channel_accepted()
|
||||
}
|
||||
fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight {
|
||||
XcmGeneric::<Runtime>::hrmp_channel_closing()
|
||||
}
|
||||
fn clear_origin() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_origin()
|
||||
}
|
||||
fn descend_origin(who: &InteriorMultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::descend_origin(who)
|
||||
}
|
||||
fn report_error(
|
||||
_query_id: &QueryId,
|
||||
_dest: &MultiLocation,
|
||||
_max_response_weight: &u64,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::report_error()
|
||||
}
|
||||
fn relayed_from(_who: &Junctions, _message: &Box<Xcm<Call>>) -> Weight {
|
||||
XcmGeneric::<Runtime>::relayed_from()
|
||||
}
|
||||
|
||||
fn deposit_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32, // TODO use max assets?
|
||||
_dest: &MultiLocation,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::deposit_asset())
|
||||
}
|
||||
fn deposit_reserve_asset(
|
||||
assets: &MultiAssetFilter,
|
||||
_max_assets: &u32, // TODO use max assets?
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::deposit_reserve_asset())
|
||||
}
|
||||
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> Weight {
|
||||
Weight::MAX // todo fix
|
||||
}
|
||||
fn initiate_reserve_withdraw(
|
||||
assets: &MultiAssetFilter,
|
||||
_reserve: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmGeneric::<Runtime>::initiate_reserve_withdraw())
|
||||
}
|
||||
fn initiate_teleport(
|
||||
assets: &MultiAssetFilter,
|
||||
_dest: &MultiLocation,
|
||||
_xcm: &Xcm<()>,
|
||||
) -> Weight {
|
||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::initiate_teleport())
|
||||
}
|
||||
fn query_holding(
|
||||
_query_id: &u64,
|
||||
_dest: &MultiLocation,
|
||||
_assets: &MultiAssetFilter,
|
||||
_max_response_weight: &u64,
|
||||
) -> Weight {
|
||||
XcmGeneric::<Runtime>::query_holding()
|
||||
}
|
||||
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> Weight {
|
||||
XcmGeneric::<Runtime>::buy_execution()
|
||||
}
|
||||
fn refund_surplus() -> Weight {
|
||||
XcmGeneric::<Runtime>::refund_surplus()
|
||||
}
|
||||
fn set_error_handler(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_error_handler()
|
||||
}
|
||||
fn set_appendix(_xcm: &Xcm<Call>) -> Weight {
|
||||
XcmGeneric::<Runtime>::set_appendix()
|
||||
}
|
||||
fn clear_error() -> Weight {
|
||||
XcmGeneric::<Runtime>::clear_error()
|
||||
}
|
||||
fn claim_asset(assets: &MultiAssets, _ticket: &MultiLocation) -> Weight {
|
||||
XcmGeneric::<Runtime>::claim_asset(assets)
|
||||
}
|
||||
fn trap(code: &u64) -> Weight {
|
||||
XcmGeneric::<Runtime>::trap(code)
|
||||
}
|
||||
fn subscribe_version(_query_id: &QueryId, _max_response_weight: &u64) -> Weight {
|
||||
XcmGeneric::<Runtime>::subscribe_version()
|
||||
}
|
||||
fn unsubscribe_version() -> Weight {
|
||||
XcmGeneric::<Runtime>::unsubscribe_version()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
// Copyright 2017-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// 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.
|
||||
|
||||
// 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::fungible`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2021-09-17, 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::fungible
|
||||
// --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_fungible.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::fungible`.
|
||||
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 {
|
||||
(39_691_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: System Account (r:2 w:2)
|
||||
pub(crate) fn transfer_asset() -> Weight {
|
||||
(62_616_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: System Account (r:2 w:2)
|
||||
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
|
||||
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
|
||||
pub(crate) fn transfer_reserve_asset() -> Weight {
|
||||
(86_642_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
// Storage: Benchmark Override (r:0 w:0)
|
||||
pub(crate) fn receive_teleported_asset() -> Weight {
|
||||
(2_000_000_000_000 as Weight)
|
||||
}
|
||||
// Storage: System Account (r:1 w:1)
|
||||
pub(crate) fn deposit_asset() -> Weight {
|
||||
(49_745_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: System Account (r:1 w:1)
|
||||
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
|
||||
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
|
||||
pub(crate) fn deposit_reserve_asset() -> Weight {
|
||||
(75_318_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
// Storage: System Account (r:1 w:1)
|
||||
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
|
||||
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
|
||||
pub(crate) fn initiate_teleport() -> Weight {
|
||||
(75_467_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// this whole file is temp, and will be replaced in the future TODO
|
||||
|
||||
use frame_support::dispatch::Weight;
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
pub fn subscribe_version() -> Weight {
|
||||
1_000_000_000
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user