Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 483b20c

Browse files
authored
XCMv3 fixes (#1710)
* Fixes XCMv3 related Fixes XCMv3 (removed query_holding) Fixes XCMv3 - should use _depositable_count? Fixes XCMv3 - removed TrustedReserve Fixes - missing weights for statemine/statemint/westmint [DO-NOT-CHERRY-PICK] tmp return query_holding to aviod conficts to master Fixes - missing functions for pallet_xcm_benchmarks::generic::Config Fixes for XCMv3 benchmarking Fix xcm - removed query_holding * ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic * ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic * Fix imports
1 parent 5efee4c commit 483b20c

File tree

18 files changed

+515
-160
lines changed

18 files changed

+515
-160
lines changed

parachain-template/runtime/src/xcm_config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{
2-
AccountId, Balances, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall,
3-
RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
2+
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
3+
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
44
};
55
use core::marker::PhantomData;
66
use frame_support::{
@@ -180,7 +180,7 @@ impl xcm_executor::Config for XcmConfig {
180180
type AssetTrap = PolkadotXcm;
181181
type AssetClaims = PolkadotXcm;
182182
type SubscriptionService = PolkadotXcm;
183-
type PalletInstancesInfo = ();
183+
type PalletInstancesInfo = AllPalletsWithSystem;
184184
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
185185
type AssetLocker = ();
186186
type AssetExchanger = ();

parachains/runtimes/assets/statemine/src/lib.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ impl_runtime_apis! {
849849
fn valid_destination() -> Result<MultiLocation, BenchmarkError> {
850850
Ok(KsmLocation::get())
851851
}
852-
fn worst_case_holding() -> MultiAssets {
852+
fn worst_case_holding(_depositable_count: u32) -> MultiAssets {
853853
// A mix of fungible, non-fungible, and concrete assets.
854854
const HOLDING_FUNGIBLES: u32 = 100;
855855
const HOLDING_NON_FUNGIBLES: u32 = 100;
@@ -882,7 +882,6 @@ impl_runtime_apis! {
882882
KsmLocation::get(),
883883
MultiAsset { fun: Fungible(1 * UNITS), id: Concrete(KsmLocation::get()) },
884884
));
885-
pub const TrustedReserve: Option<(MultiLocation, MultiAsset)> = None;
886885
pub const CheckedAccount: Option<AccountId> = None;
887886

888887
}
@@ -892,7 +891,6 @@ impl_runtime_apis! {
892891

893892
type CheckedAccount = CheckedAccount;
894893
type TrustedTeleporter = TrustedTeleporter;
895-
type TrustedReserve = TrustedReserve;
896894

897895
fn get_multi_asset() -> MultiAsset {
898896
MultiAsset {
@@ -909,6 +907,14 @@ impl_runtime_apis! {
909907
(0u64, Response::Version(Default::default()))
910908
}
911909

910+
fn worst_case_asset_exchange() -> Result<(MultiAssets, MultiAssets), BenchmarkError> {
911+
Err(BenchmarkError::Skip)
912+
}
913+
914+
fn universal_alias() -> Result<Junction, BenchmarkError> {
915+
Err(BenchmarkError::Skip)
916+
}
917+
912918
fn transact_origin() -> Result<MultiLocation, BenchmarkError> {
913919
Ok(KsmLocation::get())
914920
}
@@ -923,6 +929,10 @@ impl_runtime_apis! {
923929
let ticket = MultiLocation { parents: 0, interior: Here };
924930
Ok((origin, ticket, assets))
925931
}
932+
933+
fn unlockable_asset() -> Result<(MultiLocation, MultiLocation, MultiAsset), BenchmarkError> {
934+
Err(BenchmarkError::Skip)
935+
}
926936
}
927937

928938
type XcmBalances = pallet_xcm_benchmarks::fungible::Pallet::<Runtime>;

parachains/runtimes/assets/statemine/src/weights/xcm/mod.rs

Lines changed: 76 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ impl<Call> XcmWeightInfo<Call> for StatemineXcmWeight<Call> {
6262
fn receive_teleported_asset(assets: &MultiAssets) -> XCMWeight {
6363
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
6464
}
65-
fn query_response(_query_id: &u64, _response: &Response, _max_weight: &u64) -> XCMWeight {
65+
fn query_response(
66+
_query_id: &u64,
67+
_response: &Response,
68+
_max_weight: &u64,
69+
_querier: &Option<MultiLocation>,
70+
) -> XCMWeight {
6671
XcmGeneric::<Runtime>::query_response().ref_time()
6772
}
6873
fn transfer_asset(assets: &MultiAssets, _dest: &MultiLocation) -> XCMWeight {
@@ -104,33 +109,28 @@ impl<Call> XcmWeightInfo<Call> for StatemineXcmWeight<Call> {
104109
fn descend_origin(_who: &InteriorMultiLocation) -> XCMWeight {
105110
XcmGeneric::<Runtime>::descend_origin().ref_time()
106111
}
107-
fn report_error(
108-
_query_id: &QueryId,
109-
_dest: &MultiLocation,
110-
_max_response_weight: &u64,
111-
) -> XCMWeight {
112+
fn report_error(_query_response_info: &QueryResponseInfo) -> XCMWeight {
112113
XcmGeneric::<Runtime>::report_error().ref_time()
113114
}
114115

115-
fn deposit_asset(
116-
assets: &MultiAssetFilter,
117-
_max_assets: &u32,
118-
_dest: &MultiLocation,
119-
) -> XCMWeight {
116+
fn deposit_asset(assets: &MultiAssetFilter, _dest: &MultiLocation) -> XCMWeight {
120117
// Hardcoded till the XCM pallet is fixed
121118
let hardcoded_weight = Weight::from_ref_time(1_000_000_000 as u64).ref_time();
122119
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_asset());
123120
cmp::min(hardcoded_weight, weight)
124121
}
125122
fn deposit_reserve_asset(
126123
assets: &MultiAssetFilter,
127-
_max_assets: &u32,
128124
_dest: &MultiLocation,
129125
_xcm: &Xcm<()>,
130126
) -> XCMWeight {
131127
assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
132128
}
133-
fn exchange_asset(_give: &MultiAssetFilter, _receive: &MultiAssets) -> XCMWeight {
129+
fn exchange_asset(
130+
_give: &MultiAssetFilter,
131+
_receive: &MultiAssets,
132+
_maximal: &bool,
133+
) -> XCMWeight {
134134
Weight::MAX.ref_time()
135135
}
136136
fn initiate_reserve_withdraw(
@@ -150,13 +150,8 @@ impl<Call> XcmWeightInfo<Call> for StatemineXcmWeight<Call> {
150150
let weight = assets.weigh_multi_assets(XcmFungibleWeight::<Runtime>::initiate_teleport());
151151
cmp::min(hardcoded_weight, weight)
152152
}
153-
fn query_holding(
154-
_query_id: &u64,
155-
_dest: &MultiLocation,
156-
_assets: &MultiAssetFilter,
157-
_max_response_weight: &u64,
158-
) -> XCMWeight {
159-
XcmGeneric::<Runtime>::query_holding().ref_time()
153+
fn report_holding(_response_info: &QueryResponseInfo, _assets: &MultiAssetFilter) -> XCMWeight {
154+
XcmGeneric::<Runtime>::report_holding().ref_time()
160155
}
161156
fn buy_execution(_fees: &MultiAsset, _weight_limit: &WeightLimit) -> XCMWeight {
162157
XcmGeneric::<Runtime>::buy_execution().ref_time()
@@ -185,4 +180,65 @@ impl<Call> XcmWeightInfo<Call> for StatemineXcmWeight<Call> {
185180
fn unsubscribe_version() -> XCMWeight {
186181
XcmGeneric::<Runtime>::unsubscribe_version().ref_time()
187182
}
183+
fn burn_asset(assets: &MultiAssets) -> XCMWeight {
184+
assets.weigh_multi_assets(XcmGeneric::<Runtime>::burn_asset())
185+
}
186+
fn expect_asset(assets: &MultiAssets) -> XCMWeight {
187+
assets.weigh_multi_assets(XcmGeneric::<Runtime>::expect_asset())
188+
}
189+
fn expect_origin(_origin: &Option<MultiLocation>) -> XCMWeight {
190+
XcmGeneric::<Runtime>::expect_origin().ref_time()
191+
}
192+
fn expect_error(_error: &Option<(u32, XcmError)>) -> XCMWeight {
193+
XcmGeneric::<Runtime>::expect_error().ref_time()
194+
}
195+
fn query_pallet(_module_name: &Vec<u8>, _response_info: &QueryResponseInfo) -> XCMWeight {
196+
XcmGeneric::<Runtime>::query_pallet().ref_time()
197+
}
198+
fn expect_pallet(
199+
_index: &u32,
200+
_name: &Vec<u8>,
201+
_module_name: &Vec<u8>,
202+
_crate_major: &u32,
203+
_min_crate_minor: &u32,
204+
) -> XCMWeight {
205+
XcmGeneric::<Runtime>::expect_pallet().ref_time()
206+
}
207+
fn report_transact_status(_response_info: &QueryResponseInfo) -> XCMWeight {
208+
XcmGeneric::<Runtime>::report_transact_status().ref_time()
209+
}
210+
fn clear_transact_status() -> XCMWeight {
211+
XcmGeneric::<Runtime>::clear_transact_status().ref_time()
212+
}
213+
fn universal_origin(_: &Junction) -> XCMWeight {
214+
Weight::MAX.ref_time()
215+
}
216+
fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> XCMWeight {
217+
Weight::MAX.ref_time()
218+
}
219+
fn lock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight {
220+
Weight::MAX.ref_time()
221+
}
222+
fn unlock_asset(_: &MultiAsset, _: &MultiLocation) -> XCMWeight {
223+
Weight::MAX.ref_time()
224+
}
225+
fn note_unlockable(_: &MultiAsset, _: &MultiLocation) -> XCMWeight {
226+
Weight::MAX.ref_time()
227+
}
228+
fn request_unlock(_: &MultiAsset, _: &MultiLocation) -> XCMWeight {
229+
Weight::MAX.ref_time()
230+
}
231+
fn set_fees_mode(_: &bool) -> XCMWeight {
232+
XcmGeneric::<Runtime>::set_fees_mode().ref_time()
233+
}
234+
fn set_topic(_topic: &[u8; 32]) -> XCMWeight {
235+
XcmGeneric::<Runtime>::set_topic().ref_time()
236+
}
237+
fn clear_topic() -> XCMWeight {
238+
XcmGeneric::<Runtime>::clear_topic().ref_time()
239+
}
240+
fn alias_origin(_: &MultiLocation) -> XCMWeight {
241+
// XCM Executor does not currently support alias origin operations
242+
Weight::MAX.ref_time()
243+
}
188244
}

parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_generic.rs

Lines changed: 71 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
1919
//!
2020
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
21-
//! DATE: 2022-08-17, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
21+
//! DATE: 2022-09-30, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
22+
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
2223
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("statemine-dev"), DB CACHE: 1024
2324
2425
// Executed Command:
@@ -36,7 +37,7 @@
3637
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/cumulus/.git/.artifacts/bench.json
3738
// --header=./file_header.txt
3839
// --template=./templates/xcm-bench-template.hbs
39-
// --output=./parachains/runtimes/assets/statemine/src/weights/xcm/pallet_xcm_benchmarks_generic.rs
40+
// --output=./parachains/runtimes/assets/statemine/src/weights/xcm/
4041

4142
#![cfg_attr(rustfmt, rustfmt_skip)]
4243
#![allow(unused_parens)]
@@ -54,58 +55,59 @@ impl<T: frame_system::Config> WeightInfo<T> {
5455
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
5556
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
5657
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
57-
pub(crate) fn query_holding() -> Weight {
58-
Weight::from_ref_time(694_466_000 as u64)
58+
pub(crate) fn report_holding() -> Weight {
59+
Weight::from_ref_time(1_303_495_000 as u64)
5960
.saturating_add(T::DbWeight::get().reads(6 as u64))
6061
.saturating_add(T::DbWeight::get().writes(2 as u64))
6162
}
6263
pub(crate) fn buy_execution() -> Weight {
63-
Weight::from_ref_time(7_095_000 as u64)
64+
Weight::from_ref_time(8_667_000 as u64)
6465
}
6566
// Storage: PolkadotXcm Queries (r:1 w:0)
6667
pub(crate) fn query_response() -> Weight {
67-
Weight::from_ref_time(13_270_000 as u64)
68+
Weight::from_ref_time(19_292_000 as u64)
6869
.saturating_add(T::DbWeight::get().reads(1 as u64))
6970
}
7071
pub(crate) fn transact() -> Weight {
71-
Weight::from_ref_time(16_375_000 as u64)
72+
Weight::from_ref_time(37_996_000 as u64)
7273
}
7374
pub(crate) fn refund_surplus() -> Weight {
74-
Weight::from_ref_time(7_319_000 as u64)
75+
Weight::from_ref_time(9_076_000 as u64)
7576
}
7677
pub(crate) fn set_error_handler() -> Weight {
77-
Weight::from_ref_time(3_515_000 as u64)
78+
Weight::from_ref_time(6_410_000 as u64)
7879
}
7980
pub(crate) fn set_appendix() -> Weight {
80-
Weight::from_ref_time(3_501_000 as u64)
81+
Weight::from_ref_time(6_412_000 as u64)
8182
}
8283
pub(crate) fn clear_error() -> Weight {
83-
Weight::from_ref_time(3_459_000 as u64)
84+
Weight::from_ref_time(6_311_000 as u64)
8485
}
8586
pub(crate) fn descend_origin() -> Weight {
86-
Weight::from_ref_time(4_319_000 as u64)
87+
Weight::from_ref_time(7_355_000 as u64)
8788
}
8889
pub(crate) fn clear_origin() -> Weight {
89-
Weight::from_ref_time(3_511_000 as u64)
90+
Weight::from_ref_time(6_389_000 as u64)
9091
}
92+
// Storage: ParachainInfo ParachainId (r:1 w:0)
9193
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
9294
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
9395
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
9496
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
9597
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
9698
pub(crate) fn report_error() -> Weight {
97-
Weight::from_ref_time(13_284_000 as u64)
98-
.saturating_add(T::DbWeight::get().reads(5 as u64))
99+
Weight::from_ref_time(23_020_000 as u64)
100+
.saturating_add(T::DbWeight::get().reads(6 as u64))
99101
.saturating_add(T::DbWeight::get().writes(2 as u64))
100102
}
101103
// Storage: PolkadotXcm AssetTraps (r:1 w:1)
102104
pub(crate) fn claim_asset() -> Weight {
103-
Weight::from_ref_time(7_985_000 as u64)
105+
Weight::from_ref_time(13_613_000 as u64)
104106
.saturating_add(T::DbWeight::get().reads(1 as u64))
105107
.saturating_add(T::DbWeight::get().writes(1 as u64))
106108
}
107109
pub(crate) fn trap() -> Weight {
108-
Weight::from_ref_time(3_515_000 as u64)
110+
Weight::from_ref_time(6_457_000 as u64)
109111
}
110112
// Storage: PolkadotXcm VersionNotifyTargets (r:1 w:1)
111113
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
@@ -114,13 +116,13 @@ impl<T: frame_system::Config> WeightInfo<T> {
114116
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
115117
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
116118
pub(crate) fn subscribe_version() -> Weight {
117-
Weight::from_ref_time(16_657_000 as u64)
119+
Weight::from_ref_time(31_677_000 as u64)
118120
.saturating_add(T::DbWeight::get().reads(6 as u64))
119121
.saturating_add(T::DbWeight::get().writes(3 as u64))
120122
}
121123
// Storage: PolkadotXcm VersionNotifyTargets (r:0 w:1)
122124
pub(crate) fn unsubscribe_version() -> Weight {
123-
Weight::from_ref_time(5_622_000 as u64)
125+
Weight::from_ref_time(9_613_000 as u64)
124126
.saturating_add(T::DbWeight::get().writes(1 as u64))
125127
}
126128
// Storage: ParachainInfo ParachainId (r:1 w:0)
@@ -130,8 +132,57 @@ impl<T: frame_system::Config> WeightInfo<T> {
130132
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
131133
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
132134
pub(crate) fn initiate_reserve_withdraw() -> Weight {
133-
Weight::from_ref_time(878_786_000 as u64)
135+
Weight::from_ref_time(1_588_580_000 as u64)
136+
.saturating_add(T::DbWeight::get().reads(6 as u64))
137+
.saturating_add(T::DbWeight::get().writes(2 as u64))
138+
}
139+
pub(crate) fn burn_asset() -> Weight {
140+
Weight::from_ref_time(497_452_000 as u64)
141+
}
142+
pub(crate) fn expect_asset() -> Weight {
143+
Weight::from_ref_time(38_502_000 as u64)
144+
}
145+
pub(crate) fn expect_origin() -> Weight {
146+
Weight::from_ref_time(6_427_000 as u64)
147+
}
148+
pub(crate) fn expect_error() -> Weight {
149+
Weight::from_ref_time(6_303_000 as u64)
150+
}
151+
// Storage: ParachainInfo ParachainId (r:1 w:0)
152+
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
153+
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
154+
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
155+
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
156+
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
157+
pub(crate) fn query_pallet() -> Weight {
158+
Weight::from_ref_time(25_510_000 as u64)
134159
.saturating_add(T::DbWeight::get().reads(6 as u64))
135160
.saturating_add(T::DbWeight::get().writes(2 as u64))
136161
}
162+
pub(crate) fn expect_pallet() -> Weight {
163+
Weight::from_ref_time(7_909_000 as u64)
164+
}
165+
// Storage: ParachainInfo ParachainId (r:1 w:0)
166+
// Storage: PolkadotXcm SupportedVersion (r:1 w:0)
167+
// Storage: PolkadotXcm VersionDiscoveryQueue (r:1 w:1)
168+
// Storage: PolkadotXcm SafeXcmVersion (r:1 w:0)
169+
// Storage: ParachainSystem HostConfiguration (r:1 w:0)
170+
// Storage: ParachainSystem PendingUpwardMessages (r:1 w:1)
171+
pub(crate) fn report_transact_status() -> Weight {
172+
Weight::from_ref_time(22_949_000 as u64)
173+
.saturating_add(T::DbWeight::get().reads(6 as u64))
174+
.saturating_add(T::DbWeight::get().writes(2 as u64))
175+
}
176+
pub(crate) fn clear_transact_status() -> Weight {
177+
Weight::from_ref_time(6_491_000 as u64)
178+
}
179+
pub(crate) fn set_topic() -> Weight {
180+
Weight::from_ref_time(6_527_000 as u64)
181+
}
182+
pub(crate) fn clear_topic() -> Weight {
183+
Weight::from_ref_time(6_440_000 as u64)
184+
}
185+
pub(crate) fn set_fees_mode() -> Weight {
186+
Weight::from_ref_time(6_426_000 as u64)
187+
}
137188
}

parachains/runtimes/assets/statemine/src/xcm_config.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
// limitations under the License.
1515

1616
use super::{
17-
AccountId, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo, ParachainSystem,
18-
PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
17+
AccountId, AllPalletsWithSystem, AssetId, Assets, Authorship, Balance, Balances, ParachainInfo,
18+
ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee,
19+
XcmpQueue,
1920
};
2021
use frame_support::{
2122
match_types, parameter_types,
@@ -202,7 +203,7 @@ impl xcm_executor::Config for XcmConfig {
202203
type AssetTrap = PolkadotXcm;
203204
type AssetClaims = PolkadotXcm;
204205
type SubscriptionService = PolkadotXcm;
205-
type PalletInstancesInfo = ();
206+
type PalletInstancesInfo = AllPalletsWithSystem;
206207
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
207208
type AssetLocker = ();
208209
type AssetExchanger = ();

0 commit comments

Comments
 (0)