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:
Shawn Tabrizi
2021-09-27 00:38:46 -04:00
committed by GitHub
parent 37a5f95c29
commit 7c8804c049
22 changed files with 1206 additions and 16 deletions
@@ -0,0 +1,64 @@
// Copyright 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/>.
use crate::*;
use frame_support::{parameter_types, weights::Weight};
use xcm_executor::traits::FilterAssetLocation;
// An xcm sender/receiver akin to > /dev/null
pub struct DevNull;
impl xcm::opaque::latest::SendXcm for DevNull {
fn send_xcm(_: MultiLocation, _: Xcm<()>) -> SendResult {
Ok(())
}
}
impl xcm_executor::traits::OnResponse for DevNull {
fn expecting_response(_: &MultiLocation, _: u64) -> bool {
false
}
fn on_response(_: &MultiLocation, _: u64, _: Response, _: Weight) -> Weight {
0
}
}
pub struct AccountIdConverter;
impl xcm_executor::traits::Convert<MultiLocation, u64> for AccountIdConverter {
fn convert(ml: MultiLocation) -> Result<u64, MultiLocation> {
match ml {
MultiLocation { parents: 0, interior: X1(Junction::AccountId32 { id, .. }) } =>
Ok(<u64 as codec::Decode>::decode(&mut &*id.to_vec()).unwrap()),
_ => Err(ml),
}
}
fn reverse(acc: u64) -> Result<MultiLocation, u64> {
Err(acc)
}
}
parameter_types! {
pub Ancestry: MultiLocation = Junction::Parachain(101).into();
pub UnitWeightCost: Weight = 10;
pub WeightPrice: (AssetId, u128) = (Concrete(Here.into()), 1_000_000);
}
pub struct AllAssetLocationsPass;
impl FilterAssetLocation for AllAssetLocationsPass {
fn filter_asset_location(_: &MultiAsset, _: &MultiLocation) -> bool {
true
}
}