diff --git a/Cargo.lock b/Cargo.lock index 05800e3468718..af14ecfb3343c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1072,6 +1072,7 @@ dependencies = [ "polkadot-runtime-common", "sp-core 28.0.0", "sp-runtime 31.0.1", + "sp-tracing 16.0.0", "staging-xcm", "staging-xcm-builder", "staging-xcm-executor", @@ -13441,13 +13442,9 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "log", "pallet-assets", "pallet-balances", - "pallet-xcm", "parity-scale-codec", - "polkadot-primitives", - "polkadot-runtime-common", "scale-info", "sp-io 30.0.0", "sp-runtime 31.0.1", diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/Cargo.toml b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/Cargo.toml index ef68a53c3b18b..4702f271c1284 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/Cargo.toml +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/Cargo.toml @@ -45,3 +45,6 @@ cumulus-pallet-xcmp-queue = { workspace = true } emulated-integration-tests-common = { workspace = true } parachains-common = { workspace = true, default-features = true } westend-system-emulated-network = { workspace = true } + +[dev-dependencies] +sp-tracing = { features = ["test-utils"], workspace = true, default-features = true } diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/exchange_asset.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/exchange_asset.rs new file mode 100644 index 0000000000000..ccfb00b3e77ad --- /dev/null +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/exchange_asset.rs @@ -0,0 +1,140 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::{ + create_pool_with_wnd_on, + imports::{ + asset_hub_westend_runtime::{ExistentialDeposit, Runtime}, + *, + }, +}; +use asset_hub_westend_runtime::{ + xcm_config::WestendLocation, Balances, ForeignAssets, PolkadotXcm, RuntimeOrigin, +}; +use emulated_integration_tests_common::{accounts::ALICE, xcm_emulator::TestExt}; +use frame_support::{ + assert_err_ignore_postinfo, assert_ok, + traits::fungible::{Inspect, Mutate}, +}; +use parachains_common::{AccountId, Balance}; +use sp_tracing::capture_test_logs; +use std::convert::Into; +use xcm::latest::{Assets, Location, Xcm}; + +const UNITS: Balance = 1_000_000_000; + +#[test] +fn exchange_asset_success() { + test_exchange_asset(true, 500 * UNITS, 665 * UNITS, true); +} + +#[test] +fn exchange_asset_insufficient_liquidity() { + let log_capture = capture_test_logs!({ + test_exchange_asset(true, 1_000 * UNITS, 2_000 * UNITS, false); + }); + assert!(log_capture.contains("NoDeal")); +} + +#[test] +fn exchange_asset_insufficient_balance() { + let log_capture = capture_test_logs!({ + test_exchange_asset(true, 5_000 * UNITS, 1_665 * UNITS, false); + }); + assert!(log_capture.contains("Funds are unavailable")); +} + +#[test] +fn exchange_asset_pool_not_created() { + test_exchange_asset(false, 500 * UNITS, 665 * UNITS, false); +} + +fn test_exchange_asset( + create_pool: bool, + give_amount: Balance, + want_amount: Balance, + should_succeed: bool, +) { + let alice: AccountId = Westend::account_id_of(ALICE); + let native_asset_location = WestendLocation::get(); + let native_asset_id = AssetId(native_asset_location.clone()); + let origin = RuntimeOrigin::signed(alice.clone()); + let asset_location = Location::new(1, [Parachain(2001)]); + let asset_id = AssetId(asset_location.clone()); + + // Setup initial state + AssetHubWestend::execute_with(|| { + assert_ok!(>::mint_into( + &alice, + ExistentialDeposit::get() + (1_000 * UNITS) + )); + + assert_ok!(ForeignAssets::force_create( + RuntimeOrigin::root(), + asset_location.clone().into(), + alice.clone().into(), + true, + 1 + )); + }); + + if create_pool { + create_pool_with_wnd_on!(AssetHubWestend, asset_location.clone(), true, alice.clone()); + } + + // Execute and verify swap + AssetHubWestend::execute_with(|| { + let foreign_balance_before = ForeignAssets::balance(asset_location.clone(), &alice); + let wnd_balance_before = Balances::total_balance(&alice); + + let give: Assets = (native_asset_id, give_amount).into(); + let want: Assets = (asset_id, want_amount).into(); + let xcm = Xcm(vec![ + WithdrawAsset(give.clone().into()), + ExchangeAsset { give: give.into(), want: want.into(), maximal: true }, + DepositAsset { assets: Wild(All), beneficiary: alice.clone().into() }, + ]); + + let result = PolkadotXcm::execute(origin, bx!(xcm::VersionedXcm::from(xcm)), Weight::MAX); + + let foreign_balance_after = ForeignAssets::balance(asset_location, &alice); + let wnd_balance_after = Balances::total_balance(&alice); + + if should_succeed { + assert_ok!(result); + assert!( + foreign_balance_after >= foreign_balance_before + want_amount, + "Expected foreign balance to increase by at least {want_amount} units, got {foreign_balance_after} from {foreign_balance_before}" + ); + assert_eq!( + wnd_balance_after, wnd_balance_before - give_amount, + "Expected WND balance to decrease by {give_amount} units, got {wnd_balance_after} from {wnd_balance_before}" + ); + } else { + assert_err_ignore_postinfo!( + result, + pallet_xcm::Error::::LocalExecutionIncomplete + ); + assert_eq!( + foreign_balance_after, foreign_balance_before, + "Foreign balance changed unexpectedly: got {foreign_balance_after}, expected {foreign_balance_before}" + ); + assert_eq!( + wnd_balance_after, wnd_balance_before, + "WND balance changed unexpectedly: got {wnd_balance_after}, expected {wnd_balance_before}" + ); + } + }); +} diff --git a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs index 576c44fc542fd..c8248f554fa66 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/mod.rs @@ -14,6 +14,7 @@ // limitations under the License. mod claim_assets; +mod exchange_asset; mod fellowship_treasury; mod hybrid_transfers; mod reserve_transfer; diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index d2fca4ac40d08..6b7556de8627e 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -2167,7 +2167,54 @@ impl_runtime_apis! { } fn worst_case_asset_exchange() -> Result<(XcmAssets, XcmAssets), BenchmarkError> { - Err(BenchmarkError::Skip) + let native_asset_location = WestendLocation::get(); + let native_asset_id = AssetId(native_asset_location.clone()); + let (account, _) = pallet_xcm_benchmarks::account_and_location::(1); + let origin = RuntimeOrigin::signed(account.clone()); + let asset_location = Location::new(1, [Parachain(2001)]); + let asset_id = AssetId(asset_location.clone()); + + assert_ok!(>::mint_into( + &account, + ExistentialDeposit::get() + (1_000 * UNITS) + )); + + assert_ok!(ForeignAssets::force_create( + RuntimeOrigin::root(), + asset_location.clone().into(), + account.clone().into(), + true, + 1, + )); + + assert_ok!(ForeignAssets::mint( + origin.clone(), + asset_location.clone().into(), + account.clone().into(), + 3_000 * UNITS, + )); + + assert_ok!(AssetConversion::create_pool( + origin.clone(), + native_asset_location.clone().into(), + asset_location.clone().into(), + )); + + assert_ok!(AssetConversion::add_liquidity( + origin, + native_asset_location.into(), + asset_location.into(), + 1_000 * UNITS, + 2_000 * UNITS, + 1, + 1, + account.into(), + )); + + let give_assets: XcmAssets = (native_asset_id, 500 * UNITS).into(); + let receive_assets: XcmAssets = (asset_id, 660 * UNITS).into(); + + Ok((give_assets, receive_assets)) } fn universal_alias() -> Result<(Location, Junction), BenchmarkError> { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs index a56ccfb9b62d5..a6b5d3d0fd08a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/mod.rs @@ -124,8 +124,11 @@ impl XcmWeightInfo for AssetHubWestendXcmWeight { fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { assets.weigh_assets(XcmFungibleWeight::::deposit_reserve_asset()) } - fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight { - XcmFungibleWeight::::exchange_asset() + fn exchange_asset(give: &AssetFilter, receive: &Assets, _maximal: &bool) -> Weight { + let base_weight = XcmGeneric::::exchange_asset(); + let give_weight = give.weigh_assets(base_weight); + let receive_weight = receive.weigh_assets(base_weight); + give_weight.max(receive_weight) } fn initiate_reserve_withdraw( assets: &AssetFilter, diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs index b7b6139ed87c1..b3f1b009b8a0c 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -16,9 +16,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::fungible` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2025-03-12, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-03-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `20719bd74377`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `c2cc39483446`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -64,8 +64,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `527` // Estimated: `3675` - // Minimum execution time: 56_528_000 picoseconds. - Weight::from_parts(58_602_000, 3675) + // Minimum execution time: 55_738_000 picoseconds. + Weight::from_parts(57_700_000, 3675) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -81,8 +81,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `426` // Estimated: `6208` - // Minimum execution time: 52_035_000 picoseconds. - Weight::from_parts(53_454_000, 6208) + // Minimum execution time: 52_416_000 picoseconds. + Weight::from_parts(53_673_000, 6208) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -108,8 +108,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `638` // Estimated: `8799` - // Minimum execution time: 128_026_000 picoseconds. - Weight::from_parts(133_433_000, 8799) + // Minimum execution time: 130_383_000 picoseconds. + Weight::from_parts(134_409_000, 8799) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -117,8 +117,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 1_272_000 picoseconds. - Weight::from_parts(1_371_000, 0) + // Minimum execution time: 1_397_000 picoseconds. + Weight::from_parts(1_511_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -136,8 +136,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `212` // Estimated: `6196` - // Minimum execution time: 109_813_000 picoseconds. - Weight::from_parts(112_513_000, 6196) + // Minimum execution time: 109_295_000 picoseconds. + Weight::from_parts(120_413_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -145,8 +145,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_885_000 picoseconds. - Weight::from_parts(3_112_000, 0) + // Minimum execution time: 2_910_000 picoseconds. + Weight::from_parts(3_056_000, 0) } // Storage: `Assets::Asset` (r:1 w:1) // Proof: `Assets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) @@ -158,8 +158,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `314` // Estimated: `3675` - // Minimum execution time: 32_702_000 picoseconds. - Weight::from_parts(33_820_000, 3675) + // Minimum execution time: 32_342_000 picoseconds. + Weight::from_parts(34_037_000, 3675) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -183,8 +183,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `425` // Estimated: `3890` - // Minimum execution time: 70_293_000 picoseconds. - Weight::from_parts(73_276_000, 3890) + // Minimum execution time: 72_043_000 picoseconds. + Weight::from_parts(74_586_000, 3890) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -204,8 +204,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `425` // Estimated: `3890` - // Minimum execution time: 53_316_000 picoseconds. - Weight::from_parts(55_533_000, 3890) + // Minimum execution time: 53_342_000 picoseconds. + Weight::from_parts(56_209_000, 3890) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -229,19 +229,9 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `425` // Estimated: `6196` - // Minimum execution time: 87_707_000 picoseconds. - Weight::from_parts(92_810_000, 6196) + // Minimum execution time: 89_970_000 picoseconds. + Weight::from_parts(92_829_000, 6196) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(5)) } - - pub fn exchange_asset() -> Weight { - // Proof Size summary in bytes: - // Measured: `159` - // Estimated: `6196` - // Minimum execution time: 87_253_000 picoseconds. - Weight::from_parts(88_932_000, 6196) - .saturating_add(T::DbWeight::get().reads(9)) - .saturating_add(T::DbWeight::get().writes(4)) - } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs index 1c6b0edcf17a8..e2710b494626b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -16,9 +16,9 @@ //! Autogenerated weights for `pallet_xcm_benchmarks::generic` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2025-03-12, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-03-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `539ea74f622e`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` +//! HOSTNAME: `3c24194516f3`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz` //! WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 // Executed Command: @@ -66,8 +66,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `212` // Estimated: `6196` - // Minimum execution time: 99_866_000 picoseconds. - Weight::from_parts(104_089_000, 6196) + // Minimum execution time: 100_738_000 picoseconds. + Weight::from_parts(102_746_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -75,8 +75,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 625_000 picoseconds. - Weight::from_parts(699_000, 0) + // Minimum execution time: 653_000 picoseconds. + Weight::from_parts(721_000, 0) } // Storage: `System::Account` (r:1 w:1) // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) @@ -84,8 +84,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3593` - // Minimum execution time: 6_146_000 picoseconds. - Weight::from_parts(6_457_000, 3593) + // Minimum execution time: 6_108_000 picoseconds. + Weight::from_parts(6_562_000, 3593) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -93,8 +93,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 684_000 picoseconds. - Weight::from_parts(749_000, 0) + // Minimum execution time: 658_000 picoseconds. + Weight::from_parts(706_000, 0) } // Storage: `PolkadotXcm::Queries` (r:1 w:0) // Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -102,65 +102,67 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `3465` - // Minimum execution time: 5_437_000 picoseconds. - Weight::from_parts(5_762_000, 3465) + // Minimum execution time: 5_712_000 picoseconds. + Weight::from_parts(5_871_000, 3465) .saturating_add(T::DbWeight::get().reads(1)) } pub fn transact() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 7_301_000 picoseconds. - Weight::from_parts(7_556_000, 0) + // Minimum execution time: 6_836_000 picoseconds. + Weight::from_parts(7_253_000, 0) } pub fn refund_surplus() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_685_000 picoseconds. - Weight::from_parts(2_784_000, 0) + // Minimum execution time: 2_778_000 picoseconds. + Weight::from_parts(2_969_000, 0) } pub fn set_error_handler() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 634_000 picoseconds. - Weight::from_parts(713_000, 0) + // Minimum execution time: 651_000 picoseconds. + Weight::from_parts(717_000, 0) } pub fn set_appendix() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 600_000 picoseconds. - Weight::from_parts(693_000, 0) + // Minimum execution time: 654_000 picoseconds. + Weight::from_parts(715_000, 0) } pub fn clear_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 613_000 picoseconds. - Weight::from_parts(664_000, 0) + // Minimum execution time: 635_000 picoseconds. + Weight::from_parts(688_000, 0) } pub fn descend_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 673_000 picoseconds. - Weight::from_parts(727_000, 0) + // Minimum execution time: 708_000 picoseconds. + Weight::from_parts(742_000, 0) } + // Storage: `Benchmark::Override` (r:0 w:0) + // Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) pub fn execute_with_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 734_000 picoseconds. - Weight::from_parts(783_000, 0) + // Minimum execution time: 18_446_744_073_709_551_000 picoseconds. + Weight::from_parts(18_446_744_073_709_551_000, 0) } pub fn clear_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 595_000 picoseconds. - Weight::from_parts(674_000, 0) + // Minimum execution time: 694_000 picoseconds. + Weight::from_parts(731_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -178,8 +180,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `212` // Estimated: `6196` - // Minimum execution time: 66_354_000 picoseconds. - Weight::from_parts(68_615_000, 6196) + // Minimum execution time: 67_336_000 picoseconds. + Weight::from_parts(69_034_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -189,8 +191,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `23` // Estimated: `3488` - // Minimum execution time: 8_810_000 picoseconds. - Weight::from_parts(9_020_000, 3488) + // Minimum execution time: 8_830_000 picoseconds. + Weight::from_parts(9_038_000, 3488) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -198,8 +200,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_258_000 picoseconds. - Weight::from_parts(3_447_000, 0) + // Minimum execution time: 3_234_000 picoseconds. + Weight::from_parts(3_353_000, 0) } // Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) // Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) @@ -215,8 +217,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3507` - // Minimum execution time: 22_785_000 picoseconds. - Weight::from_parts(23_226_000, 3507) + // Minimum execution time: 22_885_000 picoseconds. + Weight::from_parts(23_427_000, 3507) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -226,44 +228,44 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 2_642_000 picoseconds. - Weight::from_parts(2_872_000, 0) + // Minimum execution time: 2_729_000 picoseconds. + Weight::from_parts(2_904_000, 0) .saturating_add(T::DbWeight::get().writes(1)) } pub fn burn_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 23_421_000 picoseconds. - Weight::from_parts(23_829_000, 0) + // Minimum execution time: 23_298_000 picoseconds. + Weight::from_parts(23_607_000, 0) } pub fn expect_asset() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 6_496_000 picoseconds. - Weight::from_parts(6_603_000, 0) + // Minimum execution time: 6_698_000 picoseconds. + Weight::from_parts(6_845_000, 0) } pub fn expect_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_339_000 picoseconds. - Weight::from_parts(3_473_000, 0) + // Minimum execution time: 3_110_000 picoseconds. + Weight::from_parts(3_347_000, 0) } pub fn expect_error() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_284_000 picoseconds. - Weight::from_parts(3_459_000, 0) + // Minimum execution time: 3_211_000 picoseconds. + Weight::from_parts(3_368_000, 0) } pub fn expect_transact_status() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 798_000 picoseconds. - Weight::from_parts(838_000, 0) + // Minimum execution time: 759_000 picoseconds. + Weight::from_parts(853_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -281,8 +283,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `212` // Estimated: `6196` - // Minimum execution time: 72_359_000 picoseconds. - Weight::from_parts(74_856_000, 6196) + // Minimum execution time: 73_562_000 picoseconds. + Weight::from_parts(76_153_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -290,8 +292,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 5_079_000 picoseconds. - Weight::from_parts(5_323_000, 0) + // Minimum execution time: 5_209_000 picoseconds. + Weight::from_parts(5_363_000, 0) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -309,8 +311,8 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `212` // Estimated: `6196` - // Minimum execution time: 66_954_000 picoseconds. - Weight::from_parts(69_560_000, 6196) + // Minimum execution time: 67_567_000 picoseconds. + Weight::from_parts(69_822_000, 6196) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -318,22 +320,39 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 662_000 picoseconds. - Weight::from_parts(735_000, 0) + // Minimum execution time: 696_000 picoseconds. + Weight::from_parts(747_000, 0) } pub fn set_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 592_000 picoseconds. - Weight::from_parts(681_000, 0) + // Minimum execution time: 631_000 picoseconds. + Weight::from_parts(685_000, 0) } pub fn clear_topic() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 585_000 picoseconds. - Weight::from_parts(655_000, 0) + // Minimum execution time: 617_000 picoseconds. + Weight::from_parts(689_000, 0) + } + // Storage: `System::Account` (r:1 w:1) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `ForeignAssets::Asset` (r:1 w:1) + // Proof: `ForeignAssets::Asset` (`max_values`: None, `max_size`: Some(808), added: 3283, mode: `MaxEncodedLen`) + // Storage: `ForeignAssets::Account` (r:1 w:1) + // Proof: `ForeignAssets::Account` (`max_values`: None, `max_size`: Some(732), added: 3207, mode: `MaxEncodedLen`) + // Storage: `ForeignAssetsFreezer::FrozenBalances` (r:1 w:0) + // Proof: `ForeignAssetsFreezer::FrozenBalances` (`max_values`: None, `max_size`: Some(682), added: 3157, mode: `MaxEncodedLen`) + pub fn exchange_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `4273` + // Minimum execution time: 81_324_000 picoseconds. + Weight::from_parts(83_920_000, 4273) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: `ParachainInfo::ParachainId` (r:1 w:0) // Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) @@ -341,29 +360,29 @@ impl WeightInfo { // Proof Size summary in bytes: // Measured: `69` // Estimated: `1489` - // Minimum execution time: 5_229_000 picoseconds. - Weight::from_parts(5_466_000, 1489) + // Minimum execution time: 5_200_000 picoseconds. + Weight::from_parts(5_384_000, 1489) .saturating_add(T::DbWeight::get().reads(1)) } pub fn set_fees_mode() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 594_000 picoseconds. - Weight::from_parts(663_000, 0) + // Minimum execution time: 642_000 picoseconds. + Weight::from_parts(691_000, 0) } pub fn unpaid_execution() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 631_000 picoseconds. - Weight::from_parts(695_000, 0) + // Minimum execution time: 666_000 picoseconds. + Weight::from_parts(718_000, 0) } pub fn alias_origin() -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 621_000 picoseconds. - Weight::from_parts(690_000, 0) + // Minimum execution time: 676_000 picoseconds. + Weight::from_parts(738_000, 0) } } diff --git a/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml b/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml index 5d5926ae01e0d..81ed9ffa189f1 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml +++ b/polkadot/xcm/pallet-xcm-benchmarks/Cargo.toml @@ -19,7 +19,6 @@ codec = { workspace = true } frame-benchmarking = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } -log = { workspace = true, default-features = true } scale-info = { features = ["derive"], workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } @@ -32,11 +31,6 @@ pallet-assets = { workspace = true, default-features = true } pallet-balances = { workspace = true, default-features = true } sp-tracing = { workspace = true, default-features = true } xcm = { workspace = true, default-features = true } -# temp -pallet-xcm = { workspace = true, default-features = true } -polkadot-runtime-common = { workspace = true, default-features = true } -# westend-runtime = { path = "../../runtime/westend", features = ["runtime-benchmarks"] } -polkadot-primitives = { workspace = true, default-features = true } [features] default = ["std"] @@ -45,7 +39,6 @@ std = [ "frame-benchmarking/std", "frame-support/std", "frame-system/std", - "log/std", "scale-info/std", "sp-io/std", "sp-runtime/std", @@ -58,9 +51,6 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "pallet-assets/runtime-benchmarks", "pallet-balances/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "polkadot-primitives/runtime-benchmarks", - "polkadot-runtime-common/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", diff --git a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs index a4de7d1c7d861..6daa1ea425d5b 100644 --- a/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs +++ b/polkadot/xcm/pallet-xcm-benchmarks/src/generic/benchmarking.rs @@ -708,7 +708,7 @@ mod benchmarks { { executor.bench_process(xcm)?; } - assert_eq!(executor.holding(), &want.into()); + assert!(executor.holding().contains(&want.into())); Ok(()) } diff --git a/prdoc/pr_7952.prdoc b/prdoc/pr_7952.prdoc new file mode 100644 index 0000000000000..8e193411d806a --- /dev/null +++ b/prdoc/pr_7952.prdoc @@ -0,0 +1,10 @@ +title: Add expensive scenario for asset exchange +doc: +- audience: Runtime Dev + description: |- + This PR introduces an implementation for `worst_case_asset_exchange()` in the `AssetHubWestend` benchmarking setup. +crates: +- name: asset-hub-westend-runtime + bump: patch +- name: pallet-xcm-benchmarks + bump: patch