Skip to content

Commit 3c520e3

Browse files
bkonturactions-usermuharem
authored
Measured XCM weights and benchmarking for collectives-polkadot (#547)
Closes: paritytech/polkadot-sdk#2904 Closes: #446 Continuation: paritytech/polkadot-sdk#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 <action@github.com> Co-authored-by: Muharem <ismailov.m.h@gmail.com>
1 parent 5099ad4 commit 3c520e3

File tree

16 files changed

+1035
-142
lines changed

16 files changed

+1035
-142
lines changed

CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1111
- Fix missing Encointer democracy pallet hook needed for enactment ([polkadot-fellows/runtimes/pull/508](https://github.com/polkadot-fellows/runtimes/pull/508))
1212
- Improve benchmark configuration: fix storage whitelist in benchmarks ([polkadot-fellows/runtimes/pull/525](https://github.com/polkadot-fellows/runtimes/pull/525))
1313
- Unstake the last remaining corrupt ledger ([polkadot-fellows/runtimes/pull/538](https://github.com/polkadot-fellows/runtimes/pull/538))
14-
15-
### Fixed
16-
1714
- 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))
1815

1916
### Added
@@ -30,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
3027
- 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))
3128
- Kusama Treasury: allow burn parameters to be set via OpenGov ([polkadot-fellows/runtimes#511](https://github.com/polkadot-fellows/runtimes/pull/511))
3229
- Remove Snowbridge create agent and channel extrinsics. ([polkadot-fellows/runtimes#506](https://github.com/polkadot-fellows/runtimes/pull/506))
30+
- 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))
3331
- Increase max PoV size to 10Mib on Kusama ([polkadot-fellows/runtimes#553](https://github.com/polkadot-fellows/runtimes/pull/553))
3432

3533
#### From [#490](https://github.com/polkadot-fellows/runtimes/pull/490)

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

relay/kusama/src/weights/xcm/mod.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ impl From<&Asset> for AssetTypes {
4343
}
4444

4545
trait WeighAssets {
46-
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight;
46+
fn weigh_assets(&self, balances_weight: Weight) -> Weight;
4747
}
4848

4949
// Kusama only knows about one asset, the balances pallet.
5050
const MAX_ASSETS: u64 = 1;
5151

5252
impl WeighAssets for AssetFilter {
53-
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight {
53+
fn weigh_assets(&self, balances_weight: Weight) -> Weight {
5454
match self {
5555
Self::Definite(assets) => assets
5656
.inner()
@@ -72,7 +72,7 @@ impl WeighAssets for AssetFilter {
7272
}
7373

7474
impl WeighAssets for Assets {
75-
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight {
75+
fn weigh_assets(&self, balances_weight: Weight) -> Weight {
7676
self.inner()
7777
.iter()
7878
.map(<AssetTypes as From<&Asset>>::from)
@@ -87,13 +87,13 @@ impl WeighAssets for Assets {
8787
pub struct KusamaXcmWeight<RuntimeCall>(core::marker::PhantomData<RuntimeCall>);
8888
impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for KusamaXcmWeight<RuntimeCall> {
8989
fn withdraw_asset(assets: &Assets) -> Weight {
90-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::withdraw_asset())
90+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::withdraw_asset())
9191
}
9292
fn reserve_asset_deposited(assets: &Assets) -> Weight {
93-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::reserve_asset_deposited())
93+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::reserve_asset_deposited())
9494
}
9595
fn receive_teleported_asset(assets: &Assets) -> Weight {
96-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::receive_teleported_asset())
96+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::receive_teleported_asset())
9797
}
9898
fn query_response(
9999
_query_id: &u64,
@@ -104,10 +104,10 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for KusamaXcmWeight<RuntimeCall> {
104104
XcmGeneric::<Runtime>::query_response()
105105
}
106106
fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight {
107-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::transfer_asset())
107+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::transfer_asset())
108108
}
109109
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
110-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::transfer_reserve_asset())
110+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::transfer_reserve_asset())
111111
}
112112
fn transact(
113113
_origin_kind: &OriginKind,
@@ -143,10 +143,10 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for KusamaXcmWeight<RuntimeCall> {
143143
}
144144

145145
fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight {
146-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::deposit_asset())
146+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::deposit_asset())
147147
}
148148
fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
149-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::deposit_reserve_asset())
149+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::deposit_reserve_asset())
150150
}
151151
fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight {
152152
// Kusama does not currently support exchange asset operations
@@ -157,10 +157,10 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for KusamaXcmWeight<RuntimeCall> {
157157
_reserve: &Location,
158158
_xcm: &Xcm<()>,
159159
) -> Weight {
160-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::initiate_reserve_withdraw())
160+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::initiate_reserve_withdraw())
161161
}
162162
fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
163-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::initiate_teleport())
163+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::initiate_teleport())
164164
}
165165
fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight {
166166
XcmGeneric::<Runtime>::report_holding()
@@ -193,10 +193,10 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for KusamaXcmWeight<RuntimeCall> {
193193
XcmGeneric::<Runtime>::unsubscribe_version()
194194
}
195195
fn burn_asset(assets: &Assets) -> Weight {
196-
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
196+
assets.weigh_assets(XcmGeneric::<Runtime>::burn_asset())
197197
}
198198
fn expect_asset(assets: &Assets) -> Weight {
199-
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
199+
assets.weigh_assets(XcmGeneric::<Runtime>::expect_asset())
200200
}
201201
fn expect_origin(_origin: &Option<Location>) -> Weight {
202202
XcmGeneric::<Runtime>::expect_origin()
@@ -272,5 +272,5 @@ fn all_counted_has_a_sane_weight_upper_limit() {
272272
let assets = AssetFilter::Wild(AllCounted(4294967295));
273273
let weight = Weight::from_parts(1000, 1000);
274274

275-
assert_eq!(assets.weigh_multi_assets(weight), weight * MAX_ASSETS);
275+
assert_eq!(assets.weigh_assets(weight), weight * MAX_ASSETS);
276276
}

relay/polkadot/src/weights/xcm/mod.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ impl From<&Asset> for AssetTypes {
4343
}
4444

4545
trait WeighAssets {
46-
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight;
46+
fn weigh_assets(&self, balances_weight: Weight) -> Weight;
4747
}
4848

4949
// Polkadot only knows about one asset, the balances pallet.
5050
const MAX_ASSETS: u64 = 1;
5151

5252
impl WeighAssets for AssetFilter {
53-
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight {
53+
fn weigh_assets(&self, balances_weight: Weight) -> Weight {
5454
match self {
5555
Self::Definite(assets) => assets
5656
.inner()
@@ -72,7 +72,7 @@ impl WeighAssets for AssetFilter {
7272
}
7373

7474
impl WeighAssets for Assets {
75-
fn weigh_multi_assets(&self, balances_weight: Weight) -> Weight {
75+
fn weigh_assets(&self, balances_weight: Weight) -> Weight {
7676
self.inner()
7777
.iter()
7878
.map(<AssetTypes as From<&Asset>>::from)
@@ -87,13 +87,13 @@ impl WeighAssets for Assets {
8787
pub struct PolkadotXcmWeight<RuntimeCall>(core::marker::PhantomData<RuntimeCall>);
8888
impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for PolkadotXcmWeight<RuntimeCall> {
8989
fn withdraw_asset(assets: &Assets) -> Weight {
90-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::withdraw_asset())
90+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::withdraw_asset())
9191
}
9292
fn reserve_asset_deposited(assets: &Assets) -> Weight {
93-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::reserve_asset_deposited())
93+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::reserve_asset_deposited())
9494
}
9595
fn receive_teleported_asset(assets: &Assets) -> Weight {
96-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::receive_teleported_asset())
96+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::receive_teleported_asset())
9797
}
9898
fn query_response(
9999
_query_id: &u64,
@@ -104,10 +104,10 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for PolkadotXcmWeight<RuntimeCall>
104104
XcmGeneric::<Runtime>::query_response()
105105
}
106106
fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight {
107-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::transfer_asset())
107+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::transfer_asset())
108108
}
109109
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
110-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::transfer_reserve_asset())
110+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::transfer_reserve_asset())
111111
}
112112
fn transact(
113113
_origin_kind: &OriginKind,
@@ -143,10 +143,10 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for PolkadotXcmWeight<RuntimeCall>
143143
}
144144

145145
fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight {
146-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::deposit_asset())
146+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::deposit_asset())
147147
}
148148
fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
149-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::deposit_reserve_asset())
149+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::deposit_reserve_asset())
150150
}
151151
fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight {
152152
// Polkadot does not currently support exchange asset operations
@@ -157,10 +157,10 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for PolkadotXcmWeight<RuntimeCall>
157157
_reserve: &Location,
158158
_xcm: &Xcm<()>,
159159
) -> Weight {
160-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::initiate_reserve_withdraw())
160+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::initiate_reserve_withdraw())
161161
}
162162
fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
163-
assets.weigh_multi_assets(XcmBalancesWeight::<Runtime>::initiate_teleport())
163+
assets.weigh_assets(XcmBalancesWeight::<Runtime>::initiate_teleport())
164164
}
165165
fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight {
166166
XcmGeneric::<Runtime>::report_holding()
@@ -193,10 +193,10 @@ impl<RuntimeCall> XcmWeightInfo<RuntimeCall> for PolkadotXcmWeight<RuntimeCall>
193193
XcmGeneric::<Runtime>::unsubscribe_version()
194194
}
195195
fn burn_asset(assets: &Assets) -> Weight {
196-
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
196+
assets.weigh_assets(XcmGeneric::<Runtime>::burn_asset())
197197
}
198198
fn expect_asset(assets: &Assets) -> Weight {
199-
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
199+
assets.weigh_assets(XcmGeneric::<Runtime>::expect_asset())
200200
}
201201
fn expect_origin(_origin: &Option<Location>) -> Weight {
202202
XcmGeneric::<Runtime>::expect_origin()
@@ -272,5 +272,5 @@ fn all_counted_has_a_sane_weight_upper_limit() {
272272
let assets = AssetFilter::Wild(AllCounted(4294967295));
273273
let weight = Weight::from_parts(1000, 1000);
274274

275-
assert_eq!(assets.weigh_multi_assets(weight), weight * MAX_ASSETS);
275+
assert_eq!(assets.weigh_assets(weight), weight * MAX_ASSETS);
276276
}

system-parachains/asset-hubs/asset-hub-kusama/src/weights/xcm/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ use sp_std::prelude::*;
2424
use xcm::{latest::prelude::*, DoubleEncoded};
2525

2626
trait WeighAssets {
27-
fn weigh_multi_assets(&self, weight: Weight) -> Weight;
27+
fn weigh_assets(&self, weight: Weight) -> Weight;
2828
}
2929

3030
const MAX_ASSETS: u64 = 100;
3131

3232
impl WeighAssets for AssetFilter {
33-
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
33+
fn weigh_assets(&self, weight: Weight) -> Weight {
3434
match self {
3535
Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
3636
Self::Wild(asset) => match asset {
@@ -50,21 +50,21 @@ impl WeighAssets for AssetFilter {
5050
}
5151

5252
impl WeighAssets for Assets {
53-
fn weigh_multi_assets(&self, weight: Weight) -> Weight {
53+
fn weigh_assets(&self, weight: Weight) -> Weight {
5454
weight.saturating_mul(self.inner().iter().count() as u64)
5555
}
5656
}
5757

5858
pub struct AssetHubKusamaXcmWeight<Call>(core::marker::PhantomData<Call>);
5959
impl<Call> XcmWeightInfo<Call> for AssetHubKusamaXcmWeight<Call> {
6060
fn withdraw_asset(assets: &Assets) -> Weight {
61-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
61+
assets.weigh_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
6262
}
6363
fn reserve_asset_deposited(assets: &Assets) -> Weight {
64-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
64+
assets.weigh_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
6565
}
6666
fn receive_teleported_asset(assets: &Assets) -> Weight {
67-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
67+
assets.weigh_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
6868
}
6969
fn query_response(
7070
_query_id: &u64,
@@ -75,10 +75,10 @@ impl<Call> XcmWeightInfo<Call> for AssetHubKusamaXcmWeight<Call> {
7575
XcmGeneric::<Runtime>::query_response()
7676
}
7777
fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight {
78-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
78+
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
7979
}
8080
fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
81-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
81+
assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
8282
}
8383
fn transact(
8484
_origin_type: &OriginKind,
@@ -114,10 +114,10 @@ impl<Call> XcmWeightInfo<Call> for AssetHubKusamaXcmWeight<Call> {
114114
}
115115

116116
fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight {
117-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
117+
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
118118
}
119119
fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
120-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
120+
assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
121121
}
122122
fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight {
123123
Weight::MAX
@@ -127,10 +127,10 @@ impl<Call> XcmWeightInfo<Call> for AssetHubKusamaXcmWeight<Call> {
127127
_reserve: &Location,
128128
_xcm: &Xcm<()>,
129129
) -> Weight {
130-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
130+
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
131131
}
132132
fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
133-
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
133+
assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
134134
}
135135
fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight {
136136
XcmGeneric::<Runtime>::report_holding()
@@ -163,10 +163,10 @@ impl<Call> XcmWeightInfo<Call> for AssetHubKusamaXcmWeight<Call> {
163163
XcmGeneric::<Runtime>::unsubscribe_version()
164164
}
165165
fn burn_asset(assets: &Assets) -> Weight {
166-
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
166+
assets.weigh_assets(XcmGeneric::<Runtime>::burn_asset())
167167
}
168168
fn expect_asset(assets: &Assets) -> Weight {
169-
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
169+
assets.weigh_assets(XcmGeneric::<Runtime>::expect_asset())
170170
}
171171
fn expect_origin(_origin: &Option<Location>) -> Weight {
172172
XcmGeneric::<Runtime>::expect_origin()

0 commit comments

Comments
 (0)