mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 12:51:02 +00:00
Add missing XCM benchmarks for ReserveAssetDeposited (#4923)
* Add missing XCM benchmarks for ReserveAssetDeposited * Check whether checking account is zero before minting * Try and prevent overflow * Remove minting currencies into the checking account * cargo run --quiet --profile=production --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 * Use a smaller divisor * Mint a smaller amount still * cargo run --quiet --profile=production --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 * Remove logic for minting assets to the checking account * Configure a smaller amount of reserve asset used for testing * Try unwrapping the result of an execution * Set the origin properly * Revert "Set the origin properly" This reverts commit c748a05733173fb7072878c19b10a583675a5f54. * Update license year * cargo run --quiet --profile=production --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 * Update license year Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017-2021 Parity Technologies (UK) Ltd.
|
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
|
||||||
// This file is part of Polkadot.
|
// This file is part of Polkadot.
|
||||||
|
|
||||||
// Polkadot is free software: you can redistribute it and/or modify
|
// Polkadot is free software: you can redistribute it and/or modify
|
||||||
|
|||||||
@@ -1556,6 +1556,10 @@ sp_api::impl_runtime_apis! {
|
|||||||
Westmint::get(),
|
Westmint::get(),
|
||||||
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WndLocation::get()) },
|
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WndLocation::get()) },
|
||||||
));
|
));
|
||||||
|
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some((
|
||||||
|
Westmint::get(),
|
||||||
|
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(WndLocation::get()) },
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
impl pallet_xcm_benchmarks::fungible::Config for Runtime {
|
||||||
@@ -1563,6 +1567,7 @@ sp_api::impl_runtime_apis! {
|
|||||||
|
|
||||||
type CheckedAccount = xcm_config::CheckAccount;
|
type CheckedAccount = xcm_config::CheckAccount;
|
||||||
type TrustedTeleporter = TrustedTeleporter;
|
type TrustedTeleporter = TrustedTeleporter;
|
||||||
|
type TrustedReserve = TrustedReserve;
|
||||||
|
|
||||||
fn get_multi_asset() -> MultiAsset {
|
fn get_multi_asset() -> MultiAsset {
|
||||||
MultiAsset {
|
MultiAsset {
|
||||||
|
|||||||
@@ -69,9 +69,8 @@ impl<Call> XcmWeightInfo<Call> for WestendXcmWeight<Call> {
|
|||||||
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
fn withdraw_asset(assets: &MultiAssets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::withdraw_asset())
|
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::withdraw_asset())
|
||||||
}
|
}
|
||||||
fn reserve_asset_deposited(_assets: &MultiAssets) -> Weight {
|
fn reserve_asset_deposited(assets: &MultiAssets) -> Weight {
|
||||||
// Westend does not support reserve asset deposits.
|
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::reserve_asset_deposited())
|
||||||
Weight::MAX
|
|
||||||
}
|
}
|
||||||
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
fn receive_teleported_asset(assets: &MultiAssets) -> Weight {
|
||||||
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::receive_teleported_asset())
|
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::receive_teleported_asset())
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2017-2021 Parity Technologies (UK) Ltd.
|
// Copyright 2022 Parity Technologies (UK) Ltd.
|
||||||
// This file is part of Polkadot.
|
// This file is part of Polkadot.
|
||||||
|
|
||||||
// Polkadot is free software: you can redistribute it and/or modify
|
// Polkadot is free software: you can redistribute it and/or modify
|
||||||
@@ -17,11 +17,11 @@
|
|||||||
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
|
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
|
||||||
//!
|
//!
|
||||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||||
//! DATE: 2021-10-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
//! DATE: 2022-03-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 128
|
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024
|
||||||
|
|
||||||
// Executed Command:
|
// Executed Command:
|
||||||
// target/release/polkadot
|
// target/production/polkadot
|
||||||
// benchmark
|
// benchmark
|
||||||
// --chain=westend-dev
|
// --chain=westend-dev
|
||||||
// --steps=50
|
// --steps=50
|
||||||
@@ -35,7 +35,6 @@
|
|||||||
// --template=./xcm/pallet-xcm-benchmarks/template.hbs
|
// --template=./xcm/pallet-xcm-benchmarks/template.hbs
|
||||||
// --output=./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
|
// --output=./runtime/westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs
|
||||||
|
|
||||||
|
|
||||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||||
#![allow(unused_parens)]
|
#![allow(unused_parens)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
@@ -48,13 +47,13 @@ pub struct WeightInfo<T>(PhantomData<T>);
|
|||||||
impl<T: frame_system::Config> WeightInfo<T> {
|
impl<T: frame_system::Config> WeightInfo<T> {
|
||||||
// Storage: System Account (r:1 w:1)
|
// Storage: System Account (r:1 w:1)
|
||||||
pub(crate) fn withdraw_asset() -> Weight {
|
pub(crate) fn withdraw_asset() -> Weight {
|
||||||
(43_806_000 as Weight)
|
(20_308_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||||
}
|
}
|
||||||
// Storage: System Account (r:2 w:2)
|
// Storage: System Account (r:2 w:2)
|
||||||
pub(crate) fn transfer_asset() -> Weight {
|
pub(crate) fn transfer_asset() -> Weight {
|
||||||
(68_076_000 as Weight)
|
(32_193_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||||
}
|
}
|
||||||
@@ -65,19 +64,23 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
|||||||
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
|
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
|
||||||
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
|
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
|
||||||
pub(crate) fn transfer_reserve_asset() -> Weight {
|
pub(crate) fn transfer_reserve_asset() -> Weight {
|
||||||
(99_639_000 as Weight)
|
(50_731_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(5 as Weight))
|
.saturating_add(T::DbWeight::get().writes(5 as Weight))
|
||||||
}
|
}
|
||||||
|
// Storage: Benchmark Override (r:0 w:0)
|
||||||
|
pub(crate) fn reserve_asset_deposited() -> Weight {
|
||||||
|
(2_000_000_000_000 as Weight)
|
||||||
|
}
|
||||||
// Storage: System Account (r:1 w:1)
|
// Storage: System Account (r:1 w:1)
|
||||||
pub(crate) fn receive_teleported_asset() -> Weight {
|
pub(crate) fn receive_teleported_asset() -> Weight {
|
||||||
(38_670_000 as Weight)
|
(19_622_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||||
}
|
}
|
||||||
// Storage: System Account (r:1 w:1)
|
// Storage: System Account (r:1 w:1)
|
||||||
pub(crate) fn deposit_asset() -> Weight {
|
pub(crate) fn deposit_asset() -> Weight {
|
||||||
(51_793_000 as Weight)
|
(22_433_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||||
}
|
}
|
||||||
@@ -88,7 +91,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
|||||||
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
|
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
|
||||||
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
|
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
|
||||||
pub(crate) fn deposit_reserve_asset() -> Weight {
|
pub(crate) fn deposit_reserve_asset() -> Weight {
|
||||||
(85_782_000 as Weight)
|
(41_765_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||||
}
|
}
|
||||||
@@ -99,7 +102,7 @@ impl<T: frame_system::Config> WeightInfo<T> {
|
|||||||
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
|
// Storage: Dmp DownwardMessageQueueHeads (r:1 w:1)
|
||||||
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
|
// Storage: Dmp DownwardMessageQueues (r:1 w:1)
|
||||||
pub(crate) fn initiate_teleport() -> Weight {
|
pub(crate) fn initiate_teleport() -> Weight {
|
||||||
(84_873_000 as Weight)
|
(41_204_000 as Weight)
|
||||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,25 @@ benchmarks_instance_pallet! {
|
|||||||
// TODO: Check sender queue is not empty. #4426
|
// TODO: Check sender queue is not empty. #4426
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reserve_asset_deposited {
|
||||||
|
let (trusted_reserve, transferable_reserve_asset) = T::TrustedReserve::get()
|
||||||
|
.ok_or(BenchmarkError::Skip)?;
|
||||||
|
|
||||||
|
let assets: MultiAssets = vec![ transferable_reserve_asset ].into();
|
||||||
|
|
||||||
|
let mut executor = new_executor::<T>(trusted_reserve);
|
||||||
|
let instruction = Instruction::ReserveAssetDeposited(assets.clone());
|
||||||
|
let xcm = Xcm(vec![instruction]);
|
||||||
|
}: {
|
||||||
|
executor.execute(xcm).map_err(|_| {
|
||||||
|
BenchmarkError::Override(
|
||||||
|
BenchmarkResult::from_weight(T::BlockWeights::get().max_block)
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
} verify {
|
||||||
|
assert!(executor.holding.ensure_contains(&assets).is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
receive_teleported_asset {
|
receive_teleported_asset {
|
||||||
// If there is no trusted teleporter, then we skip this benchmark.
|
// If there is no trusted teleporter, then we skip this benchmark.
|
||||||
let (trusted_teleporter, teleportable_asset) = T::TrustedTeleporter::get()
|
let (trusted_teleporter, teleportable_asset) = T::TrustedTeleporter::get()
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ impl xcm_executor::Config for XcmConfig {
|
|||||||
type XcmSender = DevNull;
|
type XcmSender = DevNull;
|
||||||
type AssetTransactor = AssetTransactor;
|
type AssetTransactor = AssetTransactor;
|
||||||
type OriginConverter = ();
|
type OriginConverter = ();
|
||||||
type IsReserve = ();
|
type IsReserve = TrustedReserves;
|
||||||
type IsTeleporter = TrustedTeleporters;
|
type IsTeleporter = TrustedTeleporters;
|
||||||
type LocationInverter = xcm_builder::LocationInverter<Ancestry>;
|
type LocationInverter = xcm_builder::LocationInverter<Ancestry>;
|
||||||
type Barrier = AllowUnpaidExecutionFrom<Everything>;
|
type Barrier = AllowUnpaidExecutionFrom<Everything>;
|
||||||
@@ -159,6 +159,7 @@ impl crate::Config for Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub type TrustedTeleporters = (xcm_builder::Case<TeleConcreteFung>,);
|
pub type TrustedTeleporters = (xcm_builder::Case<TeleConcreteFung>,);
|
||||||
|
pub type TrustedReserves = (xcm_builder::Case<RsrvConcreteFung>,);
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const CheckedAccount: Option<u64> = Some(100);
|
pub const CheckedAccount: Option<u64> = Some(100);
|
||||||
@@ -167,14 +168,21 @@ parameter_types! {
|
|||||||
ChildTeleporter::get(),
|
ChildTeleporter::get(),
|
||||||
MultiAsset { id: Concrete(Here.into()), fun: Fungible(100) },
|
MultiAsset { id: Concrete(Here.into()), fun: Fungible(100) },
|
||||||
));
|
));
|
||||||
|
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = Some((
|
||||||
|
ChildTeleporter::get(),
|
||||||
|
MultiAsset { id: Concrete(Here.into()), fun: Fungible(100) },
|
||||||
|
));
|
||||||
pub const TeleConcreteFung: (MultiAssetFilter, MultiLocation) =
|
pub const TeleConcreteFung: (MultiAssetFilter, MultiLocation) =
|
||||||
(Wild(AllOf { fun: WildFungible, id: Concrete(Here.into()) }), ChildTeleporter::get());
|
(Wild(AllOf { fun: WildFungible, id: Concrete(Here.into()) }), ChildTeleporter::get());
|
||||||
|
pub const RsrvConcreteFung: (MultiAssetFilter, MultiLocation) =
|
||||||
|
(Wild(AllOf { fun: WildFungible, id: Concrete(Here.into()) }), ChildTeleporter::get());
|
||||||
}
|
}
|
||||||
|
|
||||||
impl xcm_balances_benchmark::Config for Test {
|
impl xcm_balances_benchmark::Config for Test {
|
||||||
type TransactAsset = Balances;
|
type TransactAsset = Balances;
|
||||||
type CheckedAccount = CheckedAccount;
|
type CheckedAccount = CheckedAccount;
|
||||||
type TrustedTeleporter = TrustedTeleporter;
|
type TrustedTeleporter = TrustedTeleporter;
|
||||||
|
type TrustedReserve = TrustedReserve;
|
||||||
|
|
||||||
fn get_multi_asset() -> MultiAsset {
|
fn get_multi_asset() -> MultiAsset {
|
||||||
let amount =
|
let amount =
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ pub mod pallet {
|
|||||||
/// A trusted location which we allow teleports from, and the asset we allow to teleport.
|
/// A trusted location which we allow teleports from, and the asset we allow to teleport.
|
||||||
type TrustedTeleporter: Get<Option<(xcm::latest::MultiLocation, xcm::latest::MultiAsset)>>;
|
type TrustedTeleporter: Get<Option<(xcm::latest::MultiLocation, xcm::latest::MultiAsset)>>;
|
||||||
|
|
||||||
|
/// A trusted location where reserve assets are stored, and the asset we allow to be
|
||||||
|
/// reserves.
|
||||||
|
type TrustedReserve: Get<Option<(xcm::latest::MultiLocation, xcm::latest::MultiAsset)>>;
|
||||||
|
|
||||||
/// Give me a fungible asset that your asset transactor is going to accept.
|
/// Give me a fungible asset that your asset transactor is going to accept.
|
||||||
fn get_multi_asset() -> xcm::latest::MultiAsset;
|
fn get_multi_asset() -> xcm::latest::MultiAsset;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user