From 3c520e38a4ffeed58084eea5c70fdd05925e9390 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 24 Jan 2025 12:47:16 +0100 Subject: [PATCH] Measured XCM weights and benchmarking for collectives-polkadot (#547) Closes: https://github.com/paritytech/polkadot-sdk/issues/2904 Closes: https://github.com/polkadot-fellows/runtimes/issues/446 Continuation: https://github.com/paritytech/polkadot-sdk/pull/6820 The `collectives-polkadot` uses `FixedWeightBounds`. This PR introduces a properly measured XCM benchmarking setup and updates the weights with fresh data. ## TODO - [x] check if we use somewhere some hard-coded weights for `Transact` that goes to the `collectives-polkadot` --------- Co-authored-by: GitHub Action Co-authored-by: Muharem --- CHANGELOG.md | 4 +- Cargo.lock | 1 + relay/kusama/src/weights/xcm/mod.rs | 30 +- relay/polkadot/src/weights/xcm/mod.rs | 30 +- .../asset-hub-kusama/src/weights/xcm/mod.rs | 28 +- .../asset-hub-polkadot/src/weights/xcm/mod.rs | 28 +- .../bridge-hub-kusama/src/weights/xcm/mod.rs | 28 +- .../src/weights/xcm/mod.rs | 28 +- .../collectives-polkadot/Cargo.toml | 3 + .../collectives-polkadot/src/lib.rs | 117 +++++- .../collectives-polkadot/src/weights/mod.rs | 1 + .../src/weights/pallet_xcm.rs | 78 ++-- .../src/weights/xcm/mod.rs | 234 ++++++++++++ .../xcm/pallet_xcm_benchmarks_fungible.rs | 190 ++++++++++ .../xcm/pallet_xcm_benchmarks_generic.rs | 352 ++++++++++++++++++ .../collectives-polkadot/src/xcm_config.rs | 25 +- 16 files changed, 1035 insertions(+), 142 deletions(-) create mode 100644 system-parachains/collectives/collectives-polkadot/src/weights/xcm/mod.rs create mode 100644 system-parachains/collectives/collectives-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs create mode 100644 system-parachains/collectives/collectives-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index c5c91b0479..c5a2958ce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix missing Encointer democracy pallet hook needed for enactment ([polkadot-fellows/runtimes/pull/508](https://github.com/polkadot-fellows/runtimes/pull/508)) - Improve benchmark configuration: fix storage whitelist in benchmarks ([polkadot-fellows/runtimes/pull/525](https://github.com/polkadot-fellows/runtimes/pull/525)) - Unstake the last remaining corrupt ledger ([polkadot-fellows/runtimes/pull/538](https://github.com/polkadot-fellows/runtimes/pull/538)) - -### Fixed - - Disallow `add_sub` and `set_subs` from `NonTransfer` proxy type in people chain runtimes ([polkadot-fellows/runtimes#518](https://github.com/polkadot-fellows/runtimes/pull/518)) ### Added @@ -30,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Kusama Treasury: remove funding to the Kappa Sigma Mu Society and disable burn ([polkadot-fellows/runtimes#507](https://github.com/polkadot-fellows/runtimes/pull/507)) - Kusama Treasury: allow burn parameters to be set via OpenGov ([polkadot-fellows/runtimes#511](https://github.com/polkadot-fellows/runtimes/pull/511)) - Remove Snowbridge create agent and channel extrinsics. ([polkadot-fellows/runtimes#506](https://github.com/polkadot-fellows/runtimes/pull/506)) +- Update the XCM `Weigher` from `FixedWeightBounds` to `WeightInfoBounds` with benchmarked weights for Polkadot Collectives ([polkadot-fellows/runtimes#547](https://github.com/polkadot-fellows/runtimes/pull/547)) - Increase max PoV size to 10Mib on Kusama ([polkadot-fellows/runtimes#553](https://github.com/polkadot-fellows/runtimes/pull/553)) #### From [#490](https://github.com/polkadot-fellows/runtimes/pull/490) diff --git a/Cargo.lock b/Cargo.lock index bb752b2ce6..cbd3e1e834 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2466,6 +2466,7 @@ dependencies = [ "pallet-treasury", "pallet-utility", "pallet-xcm", + "pallet-xcm-benchmarks", "parachains-common", "parity-scale-codec", "polkadot-core-primitives", diff --git a/relay/kusama/src/weights/xcm/mod.rs b/relay/kusama/src/weights/xcm/mod.rs index 8cc7122800..0df173d545 100644 --- a/relay/kusama/src/weights/xcm/mod.rs +++ b/relay/kusama/src/weights/xcm/mod.rs @@ -43,14 +43,14 @@ impl From<&Asset> for AssetTypes { } trait WeighAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight; + fn weigh_assets(&self, balances_weight: Weight) -> Weight; } // Kusama only knows about one asset, the balances pallet. const MAX_ASSETS: u64 = 1; impl WeighAssets for AssetFilter { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { + fn weigh_assets(&self, balances_weight: Weight) -> Weight { match self { Self::Definite(assets) => assets .inner() @@ -72,7 +72,7 @@ impl WeighAssets for AssetFilter { } impl WeighAssets for Assets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { + fn weigh_assets(&self, balances_weight: Weight) -> Weight { self.inner() .iter() .map(>::from) @@ -87,13 +87,13 @@ impl WeighAssets for Assets { pub struct KusamaXcmWeight(core::marker::PhantomData); impl XcmWeightInfo for KusamaXcmWeight { fn withdraw_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::withdraw_asset()) + assets.weigh_assets(XcmBalancesWeight::::withdraw_asset()) } fn reserve_asset_deposited(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::reserve_asset_deposited()) + assets.weigh_assets(XcmBalancesWeight::::reserve_asset_deposited()) } fn receive_teleported_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::receive_teleported_asset()) + assets.weigh_assets(XcmBalancesWeight::::receive_teleported_asset()) } fn query_response( _query_id: &u64, @@ -104,10 +104,10 @@ impl XcmWeightInfo for KusamaXcmWeight { XcmGeneric::::query_response() } fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::transfer_asset()) + assets.weigh_assets(XcmBalancesWeight::::transfer_asset()) } fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::transfer_reserve_asset()) + assets.weigh_assets(XcmBalancesWeight::::transfer_reserve_asset()) } fn transact( _origin_kind: &OriginKind, @@ -143,10 +143,10 @@ impl XcmWeightInfo for KusamaXcmWeight { } fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::deposit_asset()) + assets.weigh_assets(XcmBalancesWeight::::deposit_asset()) } fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) + assets.weigh_assets(XcmBalancesWeight::::deposit_reserve_asset()) } fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight { // Kusama does not currently support exchange asset operations @@ -157,10 +157,10 @@ impl XcmWeightInfo for KusamaXcmWeight { _reserve: &Location, _xcm: &Xcm<()>, ) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::initiate_reserve_withdraw()) + assets.weigh_assets(XcmBalancesWeight::::initiate_reserve_withdraw()) } fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) + assets.weigh_assets(XcmBalancesWeight::::initiate_teleport()) } fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight { XcmGeneric::::report_holding() @@ -193,10 +193,10 @@ impl XcmWeightInfo for KusamaXcmWeight { XcmGeneric::::unsubscribe_version() } fn burn_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::burn_asset()) + assets.weigh_assets(XcmGeneric::::burn_asset()) } fn expect_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::expect_asset()) + assets.weigh_assets(XcmGeneric::::expect_asset()) } fn expect_origin(_origin: &Option) -> Weight { XcmGeneric::::expect_origin() @@ -272,5 +272,5 @@ fn all_counted_has_a_sane_weight_upper_limit() { let assets = AssetFilter::Wild(AllCounted(4294967295)); let weight = Weight::from_parts(1000, 1000); - assert_eq!(assets.weigh_multi_assets(weight), weight * MAX_ASSETS); + assert_eq!(assets.weigh_assets(weight), weight * MAX_ASSETS); } diff --git a/relay/polkadot/src/weights/xcm/mod.rs b/relay/polkadot/src/weights/xcm/mod.rs index aedf2704b5..39b3f2b31f 100644 --- a/relay/polkadot/src/weights/xcm/mod.rs +++ b/relay/polkadot/src/weights/xcm/mod.rs @@ -43,14 +43,14 @@ impl From<&Asset> for AssetTypes { } trait WeighAssets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight; + fn weigh_assets(&self, balances_weight: Weight) -> Weight; } // Polkadot only knows about one asset, the balances pallet. const MAX_ASSETS: u64 = 1; impl WeighAssets for AssetFilter { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { + fn weigh_assets(&self, balances_weight: Weight) -> Weight { match self { Self::Definite(assets) => assets .inner() @@ -72,7 +72,7 @@ impl WeighAssets for AssetFilter { } impl WeighAssets for Assets { - fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight { + fn weigh_assets(&self, balances_weight: Weight) -> Weight { self.inner() .iter() .map(>::from) @@ -87,13 +87,13 @@ impl WeighAssets for Assets { pub struct PolkadotXcmWeight(core::marker::PhantomData); impl XcmWeightInfo for PolkadotXcmWeight { fn withdraw_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::withdraw_asset()) + assets.weigh_assets(XcmBalancesWeight::::withdraw_asset()) } fn reserve_asset_deposited(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::reserve_asset_deposited()) + assets.weigh_assets(XcmBalancesWeight::::reserve_asset_deposited()) } fn receive_teleported_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::receive_teleported_asset()) + assets.weigh_assets(XcmBalancesWeight::::receive_teleported_asset()) } fn query_response( _query_id: &u64, @@ -104,10 +104,10 @@ impl XcmWeightInfo for PolkadotXcmWeight XcmGeneric::::query_response() } fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::transfer_asset()) + assets.weigh_assets(XcmBalancesWeight::::transfer_asset()) } fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::transfer_reserve_asset()) + assets.weigh_assets(XcmBalancesWeight::::transfer_reserve_asset()) } fn transact( _origin_kind: &OriginKind, @@ -143,10 +143,10 @@ impl XcmWeightInfo for PolkadotXcmWeight } fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::deposit_asset()) + assets.weigh_assets(XcmBalancesWeight::::deposit_asset()) } fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::deposit_reserve_asset()) + assets.weigh_assets(XcmBalancesWeight::::deposit_reserve_asset()) } fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight { // Polkadot does not currently support exchange asset operations @@ -157,10 +157,10 @@ impl XcmWeightInfo for PolkadotXcmWeight _reserve: &Location, _xcm: &Xcm<()>, ) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::initiate_reserve_withdraw()) + assets.weigh_assets(XcmBalancesWeight::::initiate_reserve_withdraw()) } fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmBalancesWeight::::initiate_teleport()) + assets.weigh_assets(XcmBalancesWeight::::initiate_teleport()) } fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight { XcmGeneric::::report_holding() @@ -193,10 +193,10 @@ impl XcmWeightInfo for PolkadotXcmWeight XcmGeneric::::unsubscribe_version() } fn burn_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::burn_asset()) + assets.weigh_assets(XcmGeneric::::burn_asset()) } fn expect_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::expect_asset()) + assets.weigh_assets(XcmGeneric::::expect_asset()) } fn expect_origin(_origin: &Option) -> Weight { XcmGeneric::::expect_origin() @@ -272,5 +272,5 @@ fn all_counted_has_a_sane_weight_upper_limit() { let assets = AssetFilter::Wild(AllCounted(4294967295)); let weight = Weight::from_parts(1000, 1000); - assert_eq!(assets.weigh_multi_assets(weight), weight * MAX_ASSETS); + assert_eq!(assets.weigh_assets(weight), weight * MAX_ASSETS); } diff --git a/system-parachains/asset-hubs/asset-hub-kusama/src/weights/xcm/mod.rs b/system-parachains/asset-hubs/asset-hub-kusama/src/weights/xcm/mod.rs index d2866f2525..ce8a6b5402 100644 --- a/system-parachains/asset-hubs/asset-hub-kusama/src/weights/xcm/mod.rs +++ b/system-parachains/asset-hubs/asset-hub-kusama/src/weights/xcm/mod.rs @@ -24,13 +24,13 @@ use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { - fn weigh_multi_assets(&self, weight: Weight) -> Weight; + fn weigh_assets(&self, weight: Weight) -> Weight; } const MAX_ASSETS: u64 = 100; impl WeighAssets for AssetFilter { - fn weigh_multi_assets(&self, weight: Weight) -> Weight { + fn weigh_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { @@ -50,7 +50,7 @@ impl WeighAssets for AssetFilter { } impl WeighAssets for Assets { - fn weigh_multi_assets(&self, weight: Weight) -> Weight { + fn weigh_assets(&self, weight: Weight) -> Weight { weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -58,13 +58,13 @@ impl WeighAssets for Assets { pub struct AssetHubKusamaXcmWeight(core::marker::PhantomData); impl XcmWeightInfo for AssetHubKusamaXcmWeight { fn withdraw_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset()) + assets.weigh_assets(XcmFungibleWeight::::withdraw_asset()) } fn reserve_asset_deposited(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::reserve_asset_deposited()) + assets.weigh_assets(XcmFungibleWeight::::reserve_asset_deposited()) } fn receive_teleported_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) + assets.weigh_assets(XcmFungibleWeight::::receive_teleported_asset()) } fn query_response( _query_id: &u64, @@ -75,10 +75,10 @@ impl XcmWeightInfo for AssetHubKusamaXcmWeight { XcmGeneric::::query_response() } fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::transfer_asset()) + assets.weigh_assets(XcmFungibleWeight::::transfer_asset()) } fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::transfer_reserve_asset()) + assets.weigh_assets(XcmFungibleWeight::::transfer_reserve_asset()) } fn transact( _origin_type: &OriginKind, @@ -114,10 +114,10 @@ impl XcmWeightInfo for AssetHubKusamaXcmWeight { } fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()) + assets.weigh_assets(XcmFungibleWeight::::deposit_asset()) } fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::deposit_reserve_asset()) + assets.weigh_assets(XcmFungibleWeight::::deposit_reserve_asset()) } fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight { Weight::MAX @@ -127,10 +127,10 @@ impl XcmWeightInfo for AssetHubKusamaXcmWeight { _reserve: &Location, _xcm: &Xcm<()>, ) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::initiate_reserve_withdraw()) + assets.weigh_assets(XcmFungibleWeight::::initiate_reserve_withdraw()) } fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::initiate_teleport()) + assets.weigh_assets(XcmFungibleWeight::::initiate_teleport()) } fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight { XcmGeneric::::report_holding() @@ -163,10 +163,10 @@ impl XcmWeightInfo for AssetHubKusamaXcmWeight { XcmGeneric::::unsubscribe_version() } fn burn_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::burn_asset()) + assets.weigh_assets(XcmGeneric::::burn_asset()) } fn expect_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::expect_asset()) + assets.weigh_assets(XcmGeneric::::expect_asset()) } fn expect_origin(_origin: &Option) -> Weight { XcmGeneric::::expect_origin() diff --git a/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/xcm/mod.rs b/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/xcm/mod.rs index 2864aa093d..1b72853d0a 100644 --- a/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/xcm/mod.rs +++ b/system-parachains/asset-hubs/asset-hub-polkadot/src/weights/xcm/mod.rs @@ -24,13 +24,13 @@ use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { - fn weigh_multi_assets(&self, weight: Weight) -> Weight; + fn weigh_assets(&self, weight: Weight) -> Weight; } const MAX_ASSETS: u64 = 100; impl WeighAssets for AssetFilter { - fn weigh_multi_assets(&self, weight: Weight) -> Weight { + fn weigh_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { @@ -50,7 +50,7 @@ impl WeighAssets for AssetFilter { } impl WeighAssets for Assets { - fn weigh_multi_assets(&self, weight: Weight) -> Weight { + fn weigh_assets(&self, weight: Weight) -> Weight { weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -58,13 +58,13 @@ impl WeighAssets for Assets { pub struct AssetHubPolkadotXcmWeight(core::marker::PhantomData); impl XcmWeightInfo for AssetHubPolkadotXcmWeight { fn withdraw_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset()) + assets.weigh_assets(XcmFungibleWeight::::withdraw_asset()) } fn reserve_asset_deposited(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::reserve_asset_deposited()) + assets.weigh_assets(XcmFungibleWeight::::reserve_asset_deposited()) } fn receive_teleported_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) + assets.weigh_assets(XcmFungibleWeight::::receive_teleported_asset()) } fn query_response( _query_id: &u64, @@ -75,10 +75,10 @@ impl XcmWeightInfo for AssetHubPolkadotXcmWeight { XcmGeneric::::query_response() } fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::transfer_asset()) + assets.weigh_assets(XcmFungibleWeight::::transfer_asset()) } fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::transfer_reserve_asset()) + assets.weigh_assets(XcmFungibleWeight::::transfer_reserve_asset()) } fn transact( _origin_type: &OriginKind, @@ -114,10 +114,10 @@ impl XcmWeightInfo for AssetHubPolkadotXcmWeight { } fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()) + assets.weigh_assets(XcmFungibleWeight::::deposit_asset()) } fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::deposit_reserve_asset()) + assets.weigh_assets(XcmFungibleWeight::::deposit_reserve_asset()) } fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight { Weight::MAX @@ -127,10 +127,10 @@ impl XcmWeightInfo for AssetHubPolkadotXcmWeight { _reserve: &Location, _xcm: &Xcm<()>, ) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::initiate_reserve_withdraw()) + assets.weigh_assets(XcmFungibleWeight::::initiate_reserve_withdraw()) } fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::initiate_teleport()) + assets.weigh_assets(XcmFungibleWeight::::initiate_teleport()) } fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight { XcmGeneric::::report_holding() @@ -163,10 +163,10 @@ impl XcmWeightInfo for AssetHubPolkadotXcmWeight { XcmGeneric::::unsubscribe_version() } fn burn_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::burn_asset()) + assets.weigh_assets(XcmGeneric::::burn_asset()) } fn expect_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::expect_asset()) + assets.weigh_assets(XcmGeneric::::expect_asset()) } fn expect_origin(_origin: &Option) -> Weight { XcmGeneric::::expect_origin() diff --git a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs b/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs index a3ee2c451e..64119a69b5 100644 --- a/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs +++ b/system-parachains/bridge-hubs/bridge-hub-kusama/src/weights/xcm/mod.rs @@ -25,13 +25,13 @@ use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { - fn weigh_multi_assets(&self, weight: Weight) -> Weight; + fn weigh_assets(&self, weight: Weight) -> Weight; } const MAX_ASSETS: u64 = 100; impl WeighAssets for AssetFilter { - fn weigh_multi_assets(&self, weight: Weight) -> Weight { + fn weigh_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { @@ -51,7 +51,7 @@ impl WeighAssets for AssetFilter { } impl WeighAssets for Assets { - fn weigh_multi_assets(&self, weight: Weight) -> Weight { + fn weigh_assets(&self, weight: Weight) -> Weight { weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -59,13 +59,13 @@ impl WeighAssets for Assets { pub struct BridgeHubKusamaXcmWeight(core::marker::PhantomData); impl XcmWeightInfo for BridgeHubKusamaXcmWeight { fn withdraw_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset()) + assets.weigh_assets(XcmFungibleWeight::::withdraw_asset()) } fn reserve_asset_deposited(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::reserve_asset_deposited()) + assets.weigh_assets(XcmFungibleWeight::::reserve_asset_deposited()) } fn receive_teleported_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) + assets.weigh_assets(XcmFungibleWeight::::receive_teleported_asset()) } fn query_response( _query_id: &u64, @@ -76,10 +76,10 @@ impl XcmWeightInfo for BridgeHubKusamaXcmWeight { XcmGeneric::::query_response() } fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::transfer_asset()) + assets.weigh_assets(XcmFungibleWeight::::transfer_asset()) } fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::transfer_reserve_asset()) + assets.weigh_assets(XcmFungibleWeight::::transfer_reserve_asset()) } fn transact( _origin_type: &OriginKind, @@ -115,10 +115,10 @@ impl XcmWeightInfo for BridgeHubKusamaXcmWeight { } fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()) + assets.weigh_assets(XcmFungibleWeight::::deposit_asset()) } fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::deposit_reserve_asset()) + assets.weigh_assets(XcmFungibleWeight::::deposit_reserve_asset()) } fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight { Weight::MAX @@ -128,10 +128,10 @@ impl XcmWeightInfo for BridgeHubKusamaXcmWeight { _reserve: &Location, _xcm: &Xcm<()>, ) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::initiate_reserve_withdraw()) + assets.weigh_assets(XcmFungibleWeight::::initiate_reserve_withdraw()) } fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::initiate_teleport()) + assets.weigh_assets(XcmFungibleWeight::::initiate_teleport()) } fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight { XcmGeneric::::report_holding() @@ -164,10 +164,10 @@ impl XcmWeightInfo for BridgeHubKusamaXcmWeight { XcmGeneric::::unsubscribe_version() } fn burn_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::burn_asset()) + assets.weigh_assets(XcmGeneric::::burn_asset()) } fn expect_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::expect_asset()) + assets.weigh_assets(XcmGeneric::::expect_asset()) } fn expect_origin(_origin: &Option) -> Weight { XcmGeneric::::expect_origin() diff --git a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs index 8f60b012ee..0892a9ba45 100644 --- a/system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs +++ b/system-parachains/bridge-hubs/bridge-hub-polkadot/src/weights/xcm/mod.rs @@ -25,13 +25,13 @@ use sp_std::prelude::*; use xcm::{latest::prelude::*, DoubleEncoded}; trait WeighAssets { - fn weigh_multi_assets(&self, weight: Weight) -> Weight; + fn weigh_assets(&self, weight: Weight) -> Weight; } const MAX_ASSETS: u64 = 100; impl WeighAssets for AssetFilter { - fn weigh_multi_assets(&self, weight: Weight) -> Weight { + fn weigh_assets(&self, weight: Weight) -> Weight { match self { Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), Self::Wild(asset) => match asset { @@ -51,7 +51,7 @@ impl WeighAssets for AssetFilter { } impl WeighAssets for Assets { - fn weigh_multi_assets(&self, weight: Weight) -> Weight { + fn weigh_assets(&self, weight: Weight) -> Weight { weight.saturating_mul(self.inner().iter().count() as u64) } } @@ -59,13 +59,13 @@ impl WeighAssets for Assets { pub struct BridgeHubPolkadotXcmWeight(core::marker::PhantomData); impl XcmWeightInfo for BridgeHubPolkadotXcmWeight { fn withdraw_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::withdraw_asset()) + assets.weigh_assets(XcmFungibleWeight::::withdraw_asset()) } fn reserve_asset_deposited(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::reserve_asset_deposited()) + assets.weigh_assets(XcmFungibleWeight::::reserve_asset_deposited()) } fn receive_teleported_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::receive_teleported_asset()) + assets.weigh_assets(XcmFungibleWeight::::receive_teleported_asset()) } fn query_response( _query_id: &u64, @@ -76,10 +76,10 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight { XcmGeneric::::query_response() } fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::transfer_asset()) + assets.weigh_assets(XcmFungibleWeight::::transfer_asset()) } fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::transfer_reserve_asset()) + assets.weigh_assets(XcmFungibleWeight::::transfer_reserve_asset()) } fn transact( _origin_type: &OriginKind, @@ -115,10 +115,10 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight { } fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::deposit_asset()) + assets.weigh_assets(XcmFungibleWeight::::deposit_asset()) } fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::deposit_reserve_asset()) + assets.weigh_assets(XcmFungibleWeight::::deposit_reserve_asset()) } fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight { Weight::MAX @@ -128,10 +128,10 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight { _reserve: &Location, _xcm: &Xcm<()>, ) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::initiate_reserve_withdraw()) + assets.weigh_assets(XcmFungibleWeight::::initiate_reserve_withdraw()) } fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { - assets.weigh_multi_assets(XcmFungibleWeight::::initiate_teleport()) + assets.weigh_assets(XcmFungibleWeight::::initiate_teleport()) } fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight { XcmGeneric::::report_holding() @@ -164,10 +164,10 @@ impl XcmWeightInfo for BridgeHubPolkadotXcmWeight { XcmGeneric::::unsubscribe_version() } fn burn_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::burn_asset()) + assets.weigh_assets(XcmGeneric::::burn_asset()) } fn expect_asset(assets: &Assets) -> Weight { - assets.weigh_multi_assets(XcmGeneric::::expect_asset()) + assets.weigh_assets(XcmGeneric::::expect_asset()) } fn expect_origin(_origin: &Option) -> Weight { XcmGeneric::::expect_origin() diff --git a/system-parachains/collectives/collectives-polkadot/Cargo.toml b/system-parachains/collectives/collectives-polkadot/Cargo.toml index 6c7eec3d7d..c891ccf748 100644 --- a/system-parachains/collectives/collectives-polkadot/Cargo.toml +++ b/system-parachains/collectives/collectives-polkadot/Cargo.toml @@ -62,6 +62,7 @@ sp-version = { workspace = true } # Polkadot pallet-xcm = { workspace = true } +pallet-xcm-benchmarks = { optional = true, workspace = true } polkadot-core-primitives = { workspace = true } polkadot-parachain-primitives = { workspace = true } polkadot-runtime-common = { workspace = true } @@ -121,6 +122,7 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", "pallet-utility/runtime-benchmarks", + "pallet-xcm-benchmarks/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "parachains-common/runtime-benchmarks", "polkadot-parachain-primitives/runtime-benchmarks", @@ -206,6 +208,7 @@ std = [ "pallet-transaction-payment/std", "pallet-treasury/std", "pallet-utility/std", + "pallet-xcm-benchmarks?/std", "pallet-xcm/std", "parachain-info/std", "parachains-common/std", diff --git a/system-parachains/collectives/collectives-polkadot/src/lib.rs b/system-parachains/collectives/collectives-polkadot/src/lib.rs index 41771e98ce..09e1691e1d 100644 --- a/system-parachains/collectives/collectives-polkadot/src/lib.rs +++ b/system-parachains/collectives/collectives-polkadot/src/lib.rs @@ -809,7 +809,6 @@ mod benches { [cumulus_pallet_xcmp_queue, XcmpQueue] [pallet_alliance, Alliance] [pallet_collective, AllianceMotion] - [pallet_xcm, PalletXcmExtrinsiscsBenchmark::] [pallet_preimage, Preimage] [pallet_scheduler, Scheduler] [pallet_referenda, FellowshipReferenda] @@ -823,6 +822,10 @@ mod benches { [pallet_core_fellowship, AmbassadorCore] [pallet_salary, AmbassadorSalary] [pallet_treasury, AmbassadorTreasury] + // XCM + [pallet_xcm, PalletXcmExtrinsiscsBenchmark::] + [pallet_xcm_benchmarks::fungible, XcmBalances] + [pallet_xcm_benchmarks::generic, XcmGeneric] ); } @@ -1078,6 +1081,12 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + // This is defined once again in dispatch_benchmark, because list_benchmarks! + // and add_benchmarks! are macros exported by define_benchmarks! macros and those types + // are referenced in that call. + type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; + type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; + let mut list = Vec::::new(); list_benchmarks!(list, extra); @@ -1108,10 +1117,11 @@ impl_runtime_apis! { impl cumulus_pallet_session_benchmarking::Config for Runtime {} use xcm::latest::prelude::*; + use xcm_config::DotLocation; parameter_types! { pub ExistentialDepositAsset: Option = Some(( - xcm_config::DotLocation::get(), + DotLocation::get(), ExistentialDeposit::get() ).into()); } @@ -1164,12 +1174,113 @@ impl_runtime_apis! { } } + impl pallet_xcm_benchmarks::Config for Runtime { + type XcmConfig = xcm_config::XcmConfig; + type AccountIdConverter = xcm_config::LocationToAccountId; + type DeliveryHelper = cumulus_primitives_utility::ToParentDeliveryHelper< + xcm_config::XcmConfig, + ExistentialDepositAsset, + PriceForParentDelivery, + >; + fn valid_destination() -> Result { + Ok(DotLocation::get()) + } + fn worst_case_holding(_depositable_count: u32) -> Assets { + // just concrete assets according to relay chain. + let assets: Vec = vec![ + Asset { + id: AssetId(DotLocation::get()), + fun: Fungible(1_000_000 * UNITS), + } + ]; + assets.into() + } + } + + parameter_types! { + pub const TrustedTeleporter: Option<(Location, Asset)> = Some(( + DotLocation::get(), + Asset { fun: Fungible(UNITS), id: AssetId(DotLocation::get()) }, + )); + pub const CheckedAccount: Option<(AccountId, xcm_builder::MintLocation)> = None; + pub const TrustedReserve: Option<(Location, Asset)> = None; + } + + impl pallet_xcm_benchmarks::fungible::Config for Runtime { + type TransactAsset = Balances; + + type CheckedAccount = CheckedAccount; + type TrustedTeleporter = TrustedTeleporter; + type TrustedReserve = TrustedReserve; + + fn get_asset() -> Asset { + Asset { + id: AssetId(DotLocation::get()), + fun: Fungible(UNITS), + } + } + } + + impl pallet_xcm_benchmarks::generic::Config for Runtime { + type TransactAsset = Balances; + type RuntimeCall = RuntimeCall; + + fn worst_case_response() -> (u64, Response) { + (0u64, Response::Version(Default::default())) + } + + fn worst_case_asset_exchange() -> Result<(Assets, Assets), BenchmarkError> { + Err(BenchmarkError::Skip) + } + + fn universal_alias() -> Result<(Location, Junction), BenchmarkError> { + Err(BenchmarkError::Skip) + } + + fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> { + Ok((DotLocation::get(), frame_system::Call::remark_with_event { remark: vec![] }.into())) + } + + fn subscribe_origin() -> Result { + Ok(DotLocation::get()) + } + + fn claimable_asset() -> Result<(Location, Location, Assets), BenchmarkError> { + let origin = DotLocation::get(); + let assets: Assets = (AssetId(DotLocation::get()), 1_000 * UNITS).into(); + let ticket = Location { parents: 0, interior: Here }; + Ok((origin, ticket, assets)) + } + + fn fee_asset() -> Result { + Ok(Asset { + id: AssetId(DotLocation::get()), + fun: Fungible(1_000_000 * UNITS), + }) + } + + fn unlockable_asset() -> Result<(Location, Location, Asset), BenchmarkError> { + Err(BenchmarkError::Skip) + } + + fn export_message_origin_and_destination( + ) -> Result<(Location, NetworkId, InteriorLocation), BenchmarkError> { + Err(BenchmarkError::Skip) + } + + fn alias_origin() -> Result<(Location, Location), BenchmarkError> { + Err(BenchmarkError::Skip) + } + } + + type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::; + type XcmGeneric = pallet_xcm_benchmarks::generic::Pallet::; + let whitelist: Vec = AllPalletsWithSystem::whitelisted_storage_keys(); let mut batches = Vec::::new(); let params = (&config, &whitelist); add_benchmarks!(params, batches); - if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } Ok(batches) } } diff --git a/system-parachains/collectives/collectives-polkadot/src/weights/mod.rs b/system-parachains/collectives/collectives-polkadot/src/weights/mod.rs index 30c6e7cdb0..4ea2d6cddb 100644 --- a/system-parachains/collectives/collectives-polkadot/src/weights/mod.rs +++ b/system-parachains/collectives/collectives-polkadot/src/weights/mod.rs @@ -45,6 +45,7 @@ pub mod pallet_utility; pub mod pallet_xcm; pub mod paritydb_weights; pub mod rocksdb_weights; +pub mod xcm; pub use block_weights::constants::BlockExecutionWeight; pub use extrinsic_weights::constants::ExtrinsicBaseWeight; diff --git a/system-parachains/collectives/collectives-polkadot/src/weights/pallet_xcm.rs b/system-parachains/collectives/collectives-polkadot/src/weights/pallet_xcm.rs index 137b260259..8c9ba50931 100644 --- a/system-parachains/collectives/collectives-polkadot/src/weights/pallet_xcm.rs +++ b/system-parachains/collectives/collectives-polkadot/src/weights/pallet_xcm.rs @@ -17,7 +17,7 @@ //! Autogenerated weights for `pallet_xcm` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 -//! DATE: 2025-01-05, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2025-01-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./collectives-polkadot-chain-spec.json")`, DB CACHE: 1024 @@ -59,8 +59,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3507` - // Minimum execution time: 29_200_000 picoseconds. - Weight::from_parts(29_930_000, 0) + // Minimum execution time: 29_790_000 picoseconds. + Weight::from_parts(30_330_000, 0) .saturating_add(Weight::from_parts(0, 3507)) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)) @@ -81,8 +81,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `111` // Estimated: `3593` - // Minimum execution time: 111_651_000 picoseconds. - Weight::from_parts(112_471_000, 0) + // Minimum execution time: 111_891_000 picoseconds. + Weight::from_parts(113_361_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(1)) @@ -113,8 +113,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `111` // Estimated: `3593` - // Minimum execution time: 113_581_000 picoseconds. - Weight::from_parts(114_611_000, 0) + // Minimum execution time: 113_860_000 picoseconds. + Weight::from_parts(115_031_000, 0) .saturating_add(Weight::from_parts(0, 3593)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(1)) @@ -123,8 +123,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 13_480_000 picoseconds. - Weight::from_parts(13_910_000, 0) + // Minimum execution time: 14_230_000 picoseconds. + Weight::from_parts(14_550_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// Storage: `PolkadotXcm::SupportedVersion` (r:0 w:1) @@ -133,8 +133,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 9_380_000 picoseconds. - Weight::from_parts(9_690_000, 0) + // Minimum execution time: 9_190_000 picoseconds. + Weight::from_parts(9_610_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -142,8 +142,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_190_000 picoseconds. - Weight::from_parts(3_470_000, 0) + // Minimum execution time: 3_060_000 picoseconds. + Weight::from_parts(3_281_000, 0) .saturating_add(Weight::from_parts(0, 0)) } /// Storage: `PolkadotXcm::VersionNotifiers` (r:1 w:1) @@ -164,8 +164,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `42` // Estimated: `3507` - // Minimum execution time: 37_261_000 picoseconds. - Weight::from_parts(37_851_000, 0) + // Minimum execution time: 37_360_000 picoseconds. + Weight::from_parts(37_730_000, 0) .saturating_add(Weight::from_parts(0, 3507)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(4)) @@ -186,8 +186,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `136` // Estimated: `3601` - // Minimum execution time: 36_690_000 picoseconds. - Weight::from_parts(37_320_000, 0) + // Minimum execution time: 36_720_000 picoseconds. + Weight::from_parts(37_451_000, 0) .saturating_add(Weight::from_parts(0, 3601)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(3)) @@ -198,8 +198,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 3_200_000 picoseconds. - Weight::from_parts(3_400_000, 0) + // Minimum execution time: 3_190_000 picoseconds. + Weight::from_parts(3_320_000, 0) .saturating_add(Weight::from_parts(0, 0)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -209,8 +209,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `22` // Estimated: `13387` - // Minimum execution time: 22_610_000 picoseconds. - Weight::from_parts(22_880_000, 0) + // Minimum execution time: 22_640_000 picoseconds. + Weight::from_parts(22_980_000, 0) .saturating_add(Weight::from_parts(0, 13387)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) @@ -221,8 +221,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `26` // Estimated: `13391` - // Minimum execution time: 22_630_000 picoseconds. - Weight::from_parts(22_900_000, 0) + // Minimum execution time: 22_680_000 picoseconds. + Weight::from_parts(23_180_000, 0) .saturating_add(Weight::from_parts(0, 13391)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) @@ -233,8 +233,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `37` // Estimated: `15877` - // Minimum execution time: 25_991_000 picoseconds. - Weight::from_parts(26_300_000, 0) + // Minimum execution time: 26_390_000 picoseconds. + Weight::from_parts(26_970_000, 0) .saturating_add(Weight::from_parts(0, 15877)) .saturating_add(T::DbWeight::get().reads(6)) } @@ -252,8 +252,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `75` // Estimated: `6015` - // Minimum execution time: 36_040_000 picoseconds. - Weight::from_parts(36_990_000, 0) + // Minimum execution time: 36_151_000 picoseconds. + Weight::from_parts(37_001_000, 0) .saturating_add(Weight::from_parts(0, 6015)) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(2)) @@ -264,8 +264,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `36` // Estimated: `10926` - // Minimum execution time: 16_890_000 picoseconds. - Weight::from_parts(17_170_000, 0) + // Minimum execution time: 17_060_000 picoseconds. + Weight::from_parts(17_270_000, 0) .saturating_add(Weight::from_parts(0, 10926)) .saturating_add(T::DbWeight::get().reads(4)) } @@ -275,8 +275,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `33` // Estimated: `13398` - // Minimum execution time: 22_900_000 picoseconds. - Weight::from_parts(23_400_000, 0) + // Minimum execution time: 23_491_000 picoseconds. + Weight::from_parts(23_920_000, 0) .saturating_add(Weight::from_parts(0, 13398)) .saturating_add(T::DbWeight::get().reads(5)) .saturating_add(T::DbWeight::get().writes(2)) @@ -295,8 +295,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `75` // Estimated: `13440` - // Minimum execution time: 48_620_000 picoseconds. - Weight::from_parts(49_101_000, 0) + // Minimum execution time: 48_641_000 picoseconds. + Weight::from_parts(49_420_000, 0) .saturating_add(Weight::from_parts(0, 13440)) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(3)) @@ -309,8 +309,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `0` // Estimated: `1485` - // Minimum execution time: 3_350_000 picoseconds. - Weight::from_parts(3_430_000, 0) + // Minimum execution time: 3_210_000 picoseconds. + Weight::from_parts(3_340_000, 0) .saturating_add(Weight::from_parts(0, 1485)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(2)) @@ -321,8 +321,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `7576` // Estimated: `11041` - // Minimum execution time: 33_290_000 picoseconds. - Weight::from_parts(33_700_000, 0) + // Minimum execution time: 33_020_000 picoseconds. + Weight::from_parts(33_480_000, 0) .saturating_add(Weight::from_parts(0, 11041)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) @@ -333,8 +333,8 @@ impl pallet_xcm::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `23` // Estimated: `3488` - // Minimum execution time: 49_450_000 picoseconds. - Weight::from_parts(49_960_000, 0) + // Minimum execution time: 49_930_000 picoseconds. + Weight::from_parts(50_630_000, 0) .saturating_add(Weight::from_parts(0, 3488)) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) diff --git a/system-parachains/collectives/collectives-polkadot/src/weights/xcm/mod.rs b/system-parachains/collectives/collectives-polkadot/src/weights/xcm/mod.rs new file mode 100644 index 0000000000..36260632f8 --- /dev/null +++ b/system-parachains/collectives/collectives-polkadot/src/weights/xcm/mod.rs @@ -0,0 +1,234 @@ +// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md +// for a list of specific contributors. +// 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. + +mod pallet_xcm_benchmarks_fungible; +mod pallet_xcm_benchmarks_generic; + +use crate::{xcm_config::MaxAssetsIntoHolding, Runtime}; +use frame_support::weights::Weight; +use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight; +use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric; +use sp_std::prelude::*; +use xcm::{latest::prelude::*, DoubleEncoded}; + +trait WeighAssets { + fn weigh_assets(&self, weight: Weight) -> Weight; +} + +// Collectives only knows about DOT. +const MAX_ASSETS: u64 = 1; + +impl WeighAssets for AssetFilter { + fn weigh_assets(&self, weight: Weight) -> Weight { + match self { + Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64), + Self::Wild(asset) => match asset { + All => weight.saturating_mul(MAX_ASSETS), + AllOf { fun, .. } => match fun { + WildFungibility::Fungible => weight, + // Magic number 2 has to do with the fact that we could have up to 2 times + // MaxAssetsIntoHolding in the worst-case scenario. + WildFungibility::NonFungible => + weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64), + }, + AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)), + AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)), + }, + } + } +} + +impl WeighAssets for Assets { + fn weigh_assets(&self, weight: Weight) -> Weight { + weight.saturating_mul(self.inner().iter().count() as u64) + } +} + +pub struct CollectivesWestendXcmWeight(core::marker::PhantomData); +impl XcmWeightInfo for CollectivesWestendXcmWeight { + fn withdraw_asset(assets: &Assets) -> Weight { + assets.weigh_assets(XcmFungibleWeight::::withdraw_asset()) + } + fn reserve_asset_deposited(assets: &Assets) -> Weight { + assets.weigh_assets(XcmFungibleWeight::::reserve_asset_deposited()) + } + fn receive_teleported_asset(assets: &Assets) -> Weight { + assets.weigh_assets(XcmFungibleWeight::::receive_teleported_asset()) + } + fn query_response( + _query_id: &u64, + _response: &Response, + _max_weight: &Weight, + _querier: &Option, + ) -> Weight { + XcmGeneric::::query_response() + } + fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight { + assets.weigh_assets(XcmFungibleWeight::::transfer_asset()) + } + fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight { + assets.weigh_assets(XcmFungibleWeight::::transfer_reserve_asset()) + } + fn transact( + _origin_type: &OriginKind, + _require_weight_at_most: &Weight, + _call: &DoubleEncoded, + ) -> Weight { + XcmGeneric::::transact() + } + fn hrmp_new_channel_open_request( + _sender: &u32, + _max_message_size: &u32, + _max_capacity: &u32, + ) -> Weight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX + } + fn hrmp_channel_accepted(_recipient: &u32) -> Weight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX + } + fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight { + // XCM Executor does not currently support HRMP channel operations + Weight::MAX + } + fn clear_origin() -> Weight { + XcmGeneric::::clear_origin() + } + fn descend_origin(_who: &InteriorLocation) -> Weight { + XcmGeneric::::descend_origin() + } + fn report_error(_query_response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::report_error() + } + + fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight { + assets.weigh_assets(XcmFungibleWeight::::deposit_asset()) + } + 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 { + Weight::MAX + } + fn initiate_reserve_withdraw( + assets: &AssetFilter, + _reserve: &Location, + _xcm: &Xcm<()>, + ) -> Weight { + assets.weigh_assets(XcmFungibleWeight::::initiate_reserve_withdraw()) + } + fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight { + assets.weigh_assets(XcmFungibleWeight::::initiate_teleport()) + } + fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight { + XcmGeneric::::report_holding() + } + fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight { + XcmGeneric::::buy_execution() + } + fn refund_surplus() -> Weight { + XcmGeneric::::refund_surplus() + } + fn set_error_handler(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_error_handler() + } + fn set_appendix(_xcm: &Xcm) -> Weight { + XcmGeneric::::set_appendix() + } + fn clear_error() -> Weight { + XcmGeneric::::clear_error() + } + fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight { + XcmGeneric::::claim_asset() + } + fn trap(_code: &u64) -> Weight { + XcmGeneric::::trap() + } + fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight { + XcmGeneric::::subscribe_version() + } + fn unsubscribe_version() -> Weight { + XcmGeneric::::unsubscribe_version() + } + fn burn_asset(assets: &Assets) -> Weight { + assets.weigh_assets(XcmGeneric::::burn_asset()) + } + fn expect_asset(assets: &Assets) -> Weight { + assets.weigh_assets(XcmGeneric::::expect_asset()) + } + fn expect_origin(_origin: &Option) -> Weight { + XcmGeneric::::expect_origin() + } + fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight { + XcmGeneric::::expect_error() + } + fn expect_transact_status(_transact_status: &MaybeErrorCode) -> Weight { + XcmGeneric::::expect_transact_status() + } + fn query_pallet(_module_name: &Vec, _response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::query_pallet() + } + fn expect_pallet( + _index: &u32, + _name: &Vec, + _module_name: &Vec, + _crate_major: &u32, + _min_crate_minor: &u32, + ) -> Weight { + XcmGeneric::::expect_pallet() + } + fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight { + XcmGeneric::::report_transact_status() + } + fn clear_transact_status() -> Weight { + XcmGeneric::::clear_transact_status() + } + fn universal_origin(_: &Junction) -> Weight { + Weight::MAX + } + fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight { + Weight::MAX + } + fn lock_asset(_: &Asset, _: &Location) -> Weight { + Weight::MAX + } + fn unlock_asset(_: &Asset, _: &Location) -> Weight { + Weight::MAX + } + fn note_unlockable(_: &Asset, _: &Location) -> Weight { + Weight::MAX + } + fn request_unlock(_: &Asset, _: &Location) -> Weight { + Weight::MAX + } + fn set_fees_mode(_: &bool) -> Weight { + XcmGeneric::::set_fees_mode() + } + fn set_topic(_topic: &[u8; 32]) -> Weight { + XcmGeneric::::set_topic() + } + fn clear_topic() -> Weight { + XcmGeneric::::clear_topic() + } + fn alias_origin(_: &Location) -> Weight { + // XCM Executor does not currently support alias origin operations + Weight::MAX + } + fn unpaid_execution(_: &WeightLimit, _: &Option) -> Weight { + XcmGeneric::::unpaid_execution() + } +} diff --git a/system-parachains/collectives/collectives-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs b/system-parachains/collectives/collectives-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs new file mode 100644 index 0000000000..85eba7cd8e --- /dev/null +++ b/system-parachains/collectives/collectives-polkadot/src/weights/xcm/pallet_xcm_benchmarks_fungible.rs @@ -0,0 +1,190 @@ +// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md +// for a list of specific contributors. +// 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. + +//! Autogenerated weights for `pallet_xcm_benchmarks::fungible` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2025-01-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./collectives-polkadot-chain-spec.json")`, DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot-parachain +// benchmark +// pallet +// --chain=./collectives-polkadot-chain-spec.json +// --steps=50 +// --repeat=20 +// --pallet=pallet_xcm_benchmarks::fungible +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./collectives-polkadot-weights/xcm/pallet_xcm_benchmarks_fungible.rs +// --header=./file_header.txt + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_xcm_benchmarks::fungible`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + pub(crate) fn withdraw_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `101` + // Estimated: `3593` + // Minimum execution time: 40_160_000 picoseconds. + Weight::from_parts(40_961_000, 0) + .saturating_add(Weight::from_parts(0, 3593)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + pub(crate) fn transfer_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `153` + // Estimated: `6196` + // Minimum execution time: 54_831_000 picoseconds. + Weight::from_parts(55_110_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `System::Account` (r:3 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn transfer_reserve_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `264` + // Estimated: `8799` + // Minimum execution time: 109_430_000 picoseconds. + Weight::from_parts(111_451_000, 0) + .saturating_add(Weight::from_parts(0, 8799)) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `Benchmark::Override` (r:0 w:0) + /// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn reserve_asset_deposited() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 18_446_744_073_709_551_000 picoseconds. + Weight::from_parts(18_446_744_073_709_551_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn initiate_reserve_withdraw() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `6196` + // Minimum execution time: 69_691_000 picoseconds. + Weight::from_parts(70_671_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(2)) + } + pub(crate) fn receive_teleported_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_250_000 picoseconds. + Weight::from_parts(3_550_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + pub(crate) fn deposit_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `52` + // Estimated: `3593` + // Minimum execution time: 30_060_000 picoseconds. + Weight::from_parts(30_570_000, 0) + .saturating_add(Weight::from_parts(0, 3593)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn deposit_reserve_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `163` + // Estimated: `3628` + // Minimum execution time: 74_150_000 picoseconds. + Weight::from_parts(74_821_000, 0) + .saturating_add(Weight::from_parts(0, 3628)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn initiate_teleport() -> Weight { + // Proof Size summary in bytes: + // Measured: `111` + // Estimated: `3576` + // Minimum execution time: 32_130_000 picoseconds. + Weight::from_parts(32_600_000, 0) + .saturating_add(Weight::from_parts(0, 3576)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/system-parachains/collectives/collectives-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs b/system-parachains/collectives/collectives-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs new file mode 100644 index 0000000000..aa0736dd80 --- /dev/null +++ b/system-parachains/collectives/collectives-polkadot/src/weights/xcm/pallet_xcm_benchmarks_generic.rs @@ -0,0 +1,352 @@ +// Copyright (C) Parity Technologies and the various Polkadot contributors, see Contributions.md +// for a list of specific contributors. +// 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. + +//! Autogenerated weights for `pallet_xcm_benchmarks::generic` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0 +//! DATE: 2025-01-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("./collectives-polkadot-chain-spec.json")`, DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot-parachain +// benchmark +// pallet +// --chain=./collectives-polkadot-chain-spec.json +// --steps=50 +// --repeat=20 +// --pallet=pallet_xcm_benchmarks::generic +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./collectives-polkadot-weights/xcm/pallet_xcm_benchmarks_generic.rs +// --header=./file_header.txt + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_xcm_benchmarks::generic`. +pub struct WeightInfo(PhantomData); +impl WeightInfo { + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn report_holding() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `6196` + // Minimum execution time: 69_821_000 picoseconds. + Weight::from_parts(71_130_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(2)) + } + pub(crate) fn buy_execution() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 890_000 picoseconds. + Weight::from_parts(970_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + /// Storage: `PolkadotXcm::Queries` (r:1 w:0) + /// Proof: `PolkadotXcm::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn query_response() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `3465` + // Minimum execution time: 7_530_000 picoseconds. + Weight::from_parts(7_710_000, 0) + .saturating_add(Weight::from_parts(0, 3465)) + .saturating_add(T::DbWeight::get().reads(1)) + } + pub(crate) fn transact() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 9_160_000 picoseconds. + Weight::from_parts(9_450_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn refund_surplus() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_830_000 picoseconds. + Weight::from_parts(1_930_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn set_error_handler() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 960_000 picoseconds. + Weight::from_parts(1_000_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn set_appendix() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 910_000 picoseconds. + Weight::from_parts(960_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn clear_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 780_000 picoseconds. + Weight::from_parts(860_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn descend_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 920_000 picoseconds. + Weight::from_parts(1_000_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn clear_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 820_000 picoseconds. + Weight::from_parts(900_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn report_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `6196` + // Minimum execution time: 64_900_000 picoseconds. + Weight::from_parts(65_791_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `PolkadotXcm::AssetTraps` (r:1 w:1) + /// Proof: `PolkadotXcm::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn claim_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `23` + // Estimated: `3488` + // Minimum execution time: 11_440_000 picoseconds. + Weight::from_parts(11_700_000, 0) + .saturating_add(Weight::from_parts(0, 3488)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub(crate) fn trap() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 820_000 picoseconds. + Weight::from_parts(880_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:1 w:1) + /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn subscribe_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `3507` + // Minimum execution time: 31_201_000 picoseconds. + Weight::from_parts(31_810_000, 0) + .saturating_add(Weight::from_parts(0, 3507)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `PolkadotXcm::VersionNotifyTargets` (r:0 w:1) + /// Proof: `PolkadotXcm::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`) + pub(crate) fn unsubscribe_version() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_690_000 picoseconds. + Weight::from_parts(3_800_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) + } + pub(crate) fn burn_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_470_000 picoseconds. + Weight::from_parts(1_580_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn expect_asset() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_020_000 picoseconds. + Weight::from_parts(1_090_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn expect_origin() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 850_000 picoseconds. + Weight::from_parts(930_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn expect_error() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 820_000 picoseconds. + Weight::from_parts(890_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn expect_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_010_000 picoseconds. + Weight::from_parts(1_080_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn query_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `6196` + // Minimum execution time: 72_950_000 picoseconds. + Weight::from_parts(73_611_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(2)) + } + pub(crate) fn expect_pallet() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 6_530_000 picoseconds. + Weight::from_parts(6_730_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + /// Storage: `ParachainInfo::ParachainId` (r:1 w:0) + /// Proof: `ParachainInfo::ParachainId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::UpwardDeliveryFeeFactor` (r:1 w:0) + /// Proof: `ParachainSystem::UpwardDeliveryFeeFactor` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `PolkadotXcm::SupportedVersion` (r:1 w:0) + /// Proof: `PolkadotXcm::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:2 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingUpwardMessages` (r:1 w:1) + /// Proof: `ParachainSystem::PendingUpwardMessages` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + pub(crate) fn report_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `212` + // Estimated: `6196` + // Minimum execution time: 65_030_000 picoseconds. + Weight::from_parts(65_860_000, 0) + .saturating_add(Weight::from_parts(0, 6196)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(2)) + } + pub(crate) fn clear_transact_status() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 910_000 picoseconds. + Weight::from_parts(980_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn set_topic() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 800_000 picoseconds. + Weight::from_parts(870_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn clear_topic() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 830_000 picoseconds. + Weight::from_parts(870_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn set_fees_mode() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 760_000 picoseconds. + Weight::from_parts(830_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } + pub(crate) fn unpaid_execution() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 830_000 picoseconds. + Weight::from_parts(910_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + } +} \ No newline at end of file diff --git a/system-parachains/collectives/collectives-polkadot/src/xcm_config.rs b/system-parachains/collectives/collectives-polkadot/src/xcm_config.rs index 1d12636e9d..2872a9a4e4 100644 --- a/system-parachains/collectives/collectives-polkadot/src/xcm_config.rs +++ b/system-parachains/collectives/collectives-polkadot/src/xcm_config.rs @@ -40,11 +40,11 @@ use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, DescribeAllTerminal, DescribeFamily, DescribeTerminus, EnsureXcmOrigin, - FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete, - LocatableAssetId, OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, - RelayChainAsNative, SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, + FrameTransactionalProcessor, FungibleAdapter, HashedDescription, IsConcrete, LocatableAssetId, + OriginToPluralityVoice, ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, + SendXcmFeeToAccount, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - TrailingSetTopicAsId, UsingComponents, WithComputedOrigin, WithUniqueTopic, + TrailingSetTopicAsId, UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeeManagerFromComponents, }; use xcm_executor::{traits::ConvertLocation, XcmExecutor}; @@ -133,11 +133,6 @@ pub type XcmOriginToTransactDispatchOrigin = ( ); parameter_types! { - /// The amount of weight an XCM operation takes. This is a safe overestimate. - pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 1024); - /// A temporary weight value for each XCM instruction. - /// NOTE: This should be removed after we account for PoV weights. - pub const TempFixedXcmWeight: Weight = Weight::from_parts(1_000_000_000, 0); pub const MaxInstructions: u32 = 100; pub const MaxAssetsIntoHolding: u32 = 64; // Fellows pluralistic body. @@ -215,7 +210,11 @@ impl xcm_executor::Config for XcmConfig { type IsTeleporter = TrustedTeleporters; type UniversalLocation = UniversalLocation; type Barrier = Barrier; - type Weigher = FixedWeightBounds; + type Weigher = WeightInfoBounds< + crate::weights::xcm::CollectivesWestendXcmWeight, + RuntimeCall, + MaxInstructions, + >; type Trader = UsingComponents< WeightToFee, DotLocation, @@ -273,7 +272,11 @@ impl pallet_xcm::Config for Runtime { type XcmExecutor = XcmExecutor; type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Nothing; // This parachain is not meant as a reserve location. - type Weigher = FixedWeightBounds; + type Weigher = WeightInfoBounds< + crate::weights::xcm::CollectivesWestendXcmWeight, + RuntimeCall, + MaxInstructions, + >; type UniversalLocation = UniversalLocation; type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall;