mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 14:31: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:
@@ -15,7 +15,7 @@
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use super::*;
|
||||
use crate::{account_and_location, new_executor, worst_case_holding, AssetTransactorOf, XcmCallOf};
|
||||
use crate::{account_and_location, new_executor, AssetTransactorOf, XcmCallOf};
|
||||
use frame_benchmarking::{benchmarks_instance_pallet, BenchmarkError, BenchmarkResult};
|
||||
use frame_support::{
|
||||
pallet_prelude::Get,
|
||||
@@ -41,7 +41,7 @@ benchmarks_instance_pallet! {
|
||||
|
||||
withdraw_asset {
|
||||
let (sender_account, sender_location) = account_and_location::<T>(1);
|
||||
let worst_case_holding = worst_case_holding();
|
||||
let worst_case_holding = T::worst_case_holding();
|
||||
let asset = T::get_multi_asset();
|
||||
|
||||
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location).unwrap();
|
||||
@@ -49,7 +49,7 @@ benchmarks_instance_pallet! {
|
||||
assert!(!T::TransactAsset::balance(&sender_account).is_zero());
|
||||
|
||||
let mut executor = new_executor::<T>(sender_location);
|
||||
executor.holding = worst_case_holding;
|
||||
executor.holding = worst_case_holding.into();
|
||||
let instruction = Instruction::<XcmCallOf<T>>::WithdrawAsset(vec![asset.clone()].into());
|
||||
let xcm = Xcm(vec![instruction]);
|
||||
}: {
|
||||
@@ -104,7 +104,7 @@ benchmarks_instance_pallet! {
|
||||
} verify {
|
||||
assert!(T::TransactAsset::balance(&sender_account).is_zero());
|
||||
assert!(!T::TransactAsset::balance(&dest_account).is_zero());
|
||||
// TODO: Check sender queue is not empty.
|
||||
// TODO: Check sender queue is not empty. #4426
|
||||
}
|
||||
|
||||
receive_teleported_asset {
|
||||
@@ -140,10 +140,10 @@ benchmarks_instance_pallet! {
|
||||
|
||||
deposit_asset {
|
||||
let asset = T::get_multi_asset();
|
||||
let mut holding = worst_case_holding();
|
||||
let mut holding = T::worst_case_holding();
|
||||
|
||||
// Add our asset to the holding.
|
||||
holding.subsume(asset.clone());
|
||||
holding.push(asset.clone());
|
||||
|
||||
// our dest must have no balance initially.
|
||||
let dest_location = T::valid_destination()?;
|
||||
@@ -151,7 +151,7 @@ benchmarks_instance_pallet! {
|
||||
assert!(T::TransactAsset::balance(&dest_account).is_zero());
|
||||
|
||||
let mut executor = new_executor::<T>(Default::default());
|
||||
executor.holding = holding;
|
||||
executor.holding = holding.into();
|
||||
let instruction = Instruction::<XcmCallOf<T>>::DepositAsset {
|
||||
assets: asset.into(),
|
||||
max_assets: 1,
|
||||
@@ -167,10 +167,10 @@ benchmarks_instance_pallet! {
|
||||
|
||||
deposit_reserve_asset {
|
||||
let asset = T::get_multi_asset();
|
||||
let mut holding = worst_case_holding();
|
||||
let mut holding = T::worst_case_holding();
|
||||
|
||||
// Add our asset to the holding.
|
||||
holding.subsume(asset.clone());
|
||||
holding.push(asset.clone());
|
||||
|
||||
// our dest must have no balance initially.
|
||||
let dest_location = T::valid_destination()?;
|
||||
@@ -178,7 +178,7 @@ benchmarks_instance_pallet! {
|
||||
assert!(T::TransactAsset::balance(&dest_account).is_zero());
|
||||
|
||||
let mut executor = new_executor::<T>(Default::default());
|
||||
executor.holding = holding;
|
||||
executor.holding = holding.into();
|
||||
let instruction = Instruction::<XcmCallOf<T>>::DepositReserveAsset {
|
||||
assets: asset.into(),
|
||||
max_assets: 1,
|
||||
@@ -195,16 +195,16 @@ benchmarks_instance_pallet! {
|
||||
|
||||
initiate_teleport {
|
||||
let asset = T::get_multi_asset();
|
||||
let mut holding = worst_case_holding();
|
||||
let mut holding = T::worst_case_holding();
|
||||
|
||||
// Add our asset to the holding.
|
||||
holding.subsume(asset.clone());
|
||||
holding.push(asset.clone());
|
||||
|
||||
// Checked account starts at zero
|
||||
assert!(T::CheckedAccount::get().map_or(true, |c| T::TransactAsset::balance(&c).is_zero()));
|
||||
|
||||
let mut executor = new_executor::<T>(Default::default());
|
||||
executor.holding = holding;
|
||||
executor.holding = holding.into();
|
||||
let instruction = Instruction::<XcmCallOf<T>>::InitiateTeleport {
|
||||
assets: asset.into(),
|
||||
dest: T::valid_destination()?,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
//! A mock runtime for XCM benchmarking.
|
||||
|
||||
use crate::{fungible as xcm_balances_benchmark, mock::*};
|
||||
use frame_benchmarking::BenchmarkError;
|
||||
use frame_support::{parameter_types, traits::Everything};
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
@@ -145,12 +146,15 @@ impl xcm_executor::Config for XcmConfig {
|
||||
impl crate::Config for Test {
|
||||
type XcmConfig = XcmConfig;
|
||||
type AccountIdConverter = AccountIdConverter;
|
||||
fn valid_destination() -> Result<MultiLocation, sp_runtime::DispatchError> {
|
||||
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
|
||||
let valid_destination: MultiLocation =
|
||||
X1(AccountId32 { network: NetworkId::Any, id: [0u8; 32] }).into();
|
||||
|
||||
Ok(valid_destination)
|
||||
}
|
||||
fn worst_case_holding() -> MultiAssets {
|
||||
crate::mock_worst_case_holding()
|
||||
}
|
||||
}
|
||||
|
||||
pub type TrustedTeleporters = (xcm_builder::Case<TeleConcreteFung>,);
|
||||
|
||||
Reference in New Issue
Block a user