Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use non-native token to benchmark xcm on asset hub #7893

Merged
merged 14 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,7 @@ impl_runtime_apis! {
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, alloc::string::String> {
use frame_benchmarking::{BenchmarkBatch, BenchmarkError};
use frame_support::assert_ok;
use sp_storage::TrackedStorageKey;

use frame_system_benchmarking::Pallet as SystemBench;
Expand Down Expand Up @@ -1818,9 +1819,27 @@ impl_runtime_apis! {
}

fn get_asset() -> Asset {
use frame_benchmarking::whitelisted_caller;
use frame_support::traits::tokens::fungible::{Inspect, Mutate};
let account = whitelisted_caller();
assert_ok!(<Balances as Mutate<_>>::mint_into(
&account,
<Balances as Inspect<_>>::minimum_balance(),
));
let asset_id = 1984;
assert_ok!(Assets::force_create(
RuntimeOrigin::root(),
asset_id.into(),
account.into(),
true,
1u128,
));
let amount = 1_000_000u128;
let asset_location = Location::new(0, [PalletInstance(50), GeneralIndex(u32::from(asset_id).into())]);

Asset {
id: AssetId(Location::parent()),
fun: Fungible(ExistentialDeposit::get()),
id: AssetId(asset_location),
fun: Fungible(amount),
}
}
}
Expand Down Expand Up @@ -1914,9 +1933,26 @@ impl_runtime_apis! {
type TrustedReserve = TrustedReserve;

fn get_asset() -> Asset {
use frame_support::traits::tokens::fungible::{Inspect, Mutate};
let (account, _) = pallet_xcm_benchmarks::account_and_location::<Runtime>(1);
assert_ok!(<Balances as Mutate<_>>::mint_into(
&account,
<Balances as Inspect<_>>::minimum_balance(),
));
let asset_id = 1984;
assert_ok!(Assets::force_create(
RuntimeOrigin::root(),
asset_id.into(),
account.clone().into(),
true,
1u128,
));
let amount = 1_000_000u128;
let asset_location = Location::new(0, [PalletInstance(50), GeneralIndex(u32::from(asset_id).into())]);

Asset {
id: AssetId(TokenLocation::get()),
fun: Fungible(UNITS),
id: AssetId(asset_location),
fun: Fungible(amount),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
//! Autogenerated weights for `pallet_xcm`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2025-03-12, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ef4134d66388`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! HOSTNAME: `f69416f67ec1`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024

// Executed Command:
Expand Down Expand Up @@ -62,8 +62,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `42`
// Estimated: `3507`
// Minimum execution time: 22_012_000 picoseconds.
Weight::from_parts(22_991_000, 0)
// Minimum execution time: 21_641_000 picoseconds.
Weight::from_parts(22_643_000, 0)
.saturating_add(Weight::from_parts(0, 3507))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -86,8 +86,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `74`
// Estimated: `3593`
// Minimum execution time: 109_166_000 picoseconds.
Weight::from_parts(113_546_000, 0)
// Minimum execution time: 104_695_000 picoseconds.
Weight::from_parts(108_272_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -112,8 +112,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `329`
// Estimated: `6196`
// Minimum execution time: 140_176_000 picoseconds.
Weight::from_parts(147_518_000, 0)
// Minimum execution time: 134_968_000 picoseconds.
Weight::from_parts(139_074_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(4))
Expand Down Expand Up @@ -142,8 +142,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `466`
// Estimated: `6208`
// Minimum execution time: 180_003_000 picoseconds.
Weight::from_parts(188_048_000, 0)
// Minimum execution time: 171_734_000 picoseconds.
Weight::from_parts(178_520_000, 0)
.saturating_add(Weight::from_parts(0, 6208))
.saturating_add(T::DbWeight::get().reads(12))
.saturating_add(T::DbWeight::get().writes(6))
Expand All @@ -154,8 +154,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `1485`
// Minimum execution time: 9_545_000 picoseconds.
Weight::from_parts(10_172_000, 0)
// Minimum execution time: 9_417_000 picoseconds.
Weight::from_parts(9_919_000, 0)
.saturating_add(Weight::from_parts(0, 1485))
.saturating_add(T::DbWeight::get().reads(1))
}
Expand All @@ -165,17 +165,17 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_533_000 picoseconds.
Weight::from_parts(7_871_000, 0)
// Minimum execution time: 7_400_000 picoseconds.
Weight::from_parts(7_689_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
fn force_default_xcm_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_381_000 picoseconds.
Weight::from_parts(2_590_000, 0)
// Minimum execution time: 2_627_000 picoseconds.
Weight::from_parts(2_694_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1)
Expand All @@ -196,8 +196,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `42`
// Estimated: `3507`
// Minimum execution time: 28_400_000 picoseconds.
Weight::from_parts(29_497_000, 0)
// Minimum execution time: 28_334_000 picoseconds.
Weight::from_parts(28_827_000, 0)
.saturating_add(Weight::from_parts(0, 3507))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
Expand All @@ -218,8 +218,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `136`
// Estimated: `3601`
// Minimum execution time: 30_354_000 picoseconds.
Weight::from_parts(31_338_000, 0)
// Minimum execution time: 29_803_000 picoseconds.
Weight::from_parts(30_535_000, 0)
.saturating_add(Weight::from_parts(0, 3601))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
Expand All @@ -230,8 +230,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_419_000 picoseconds.
Weight::from_parts(2_613_000, 0)
// Minimum execution time: 2_508_000 picoseconds.
Weight::from_parts(2_678_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
Expand All @@ -241,8 +241,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `22`
// Estimated: `15862`
// Minimum execution time: 22_129_000 picoseconds.
Weight::from_parts(22_513_000, 0)
// Minimum execution time: 21_973_000 picoseconds.
Weight::from_parts(22_169_000, 0)
.saturating_add(Weight::from_parts(0, 15862))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -253,8 +253,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `26`
// Estimated: `15866`
// Minimum execution time: 21_614_000 picoseconds.
Weight::from_parts(22_249_000, 0)
// Minimum execution time: 22_064_000 picoseconds.
Weight::from_parts(22_446_000, 0)
.saturating_add(Weight::from_parts(0, 15866))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -265,8 +265,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `36`
// Estimated: `18351`
// Minimum execution time: 24_910_000 picoseconds.
Weight::from_parts(25_369_000, 0)
// Minimum execution time: 25_450_000 picoseconds.
Weight::from_parts(25_918_000, 0)
.saturating_add(Weight::from_parts(0, 18351))
.saturating_add(T::DbWeight::get().reads(7))
}
Expand All @@ -284,8 +284,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `75`
// Estimated: `6015`
// Minimum execution time: 27_968_000 picoseconds.
Weight::from_parts(28_837_000, 0)
// Minimum execution time: 26_915_000 picoseconds.
Weight::from_parts(28_156_000, 0)
.saturating_add(Weight::from_parts(0, 6015))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -296,8 +296,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `39`
// Estimated: `13404`
// Minimum execution time: 17_300_000 picoseconds.
Weight::from_parts(17_727_000, 0)
// Minimum execution time: 18_127_000 picoseconds.
Weight::from_parts(18_559_000, 0)
.saturating_add(Weight::from_parts(0, 13404))
.saturating_add(T::DbWeight::get().reads(5))
}
Expand All @@ -307,8 +307,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `33`
// Estimated: `15873`
// Minimum execution time: 21_937_000 picoseconds.
Weight::from_parts(22_374_000, 0)
// Minimum execution time: 22_240_000 picoseconds.
Weight::from_parts(22_779_000, 0)
.saturating_add(Weight::from_parts(0, 15873))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -327,8 +327,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `75`
// Estimated: `15915`
// Minimum execution time: 41_182_000 picoseconds.
Weight::from_parts(42_297_000, 0)
// Minimum execution time: 40_206_000 picoseconds.
Weight::from_parts(41_244_000, 0)
.saturating_add(Weight::from_parts(0, 15915))
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(3))
Expand All @@ -341,8 +341,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `1485`
// Minimum execution time: 2_736_000 picoseconds.
Weight::from_parts(2_944_000, 0)
// Minimum execution time: 2_683_000 picoseconds.
Weight::from_parts(2_848_000, 0)
.saturating_add(Weight::from_parts(0, 1485))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -353,8 +353,8 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `7576`
// Estimated: `11041`
// Minimum execution time: 26_971_000 picoseconds.
Weight::from_parts(27_284_000, 0)
// Minimum execution time: 25_440_000 picoseconds.
Weight::from_parts(26_113_000, 0)
.saturating_add(Weight::from_parts(0, 11041))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -363,14 +363,18 @@ impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
/// Proof: `PolkadotXcm::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `PolkadotXcm::AssetTraps` (r:1 w:1)
/// Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Assets::Asset` (r:1 w:1)
/// Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`)
/// Storage: `Assets::Account` (r:1 w:1)
/// Proof: `Assets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`)
fn claim_assets() -> Weight {
// Proof Size summary in bytes:
// Measured: `23`
// Estimated: `3488`
// Minimum execution time: 40_116_000 picoseconds.
Weight::from_parts(41_222_000, 0)
.saturating_add(Weight::from_parts(0, 3488))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
// Measured: `303`
// Estimated: `3768`
// Minimum execution time: 45_551_000 picoseconds.
Weight::from_parts(47_389_000, 0)
.saturating_add(Weight::from_parts(0, 3768))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}
}
Loading
Loading