collectives_westend_runtime/weights/xcm/
mod.rs1mod pallet_xcm_benchmarks_fungible;
17mod pallet_xcm_benchmarks_generic;
18
19use crate::{xcm_config::MaxAssetsIntoHolding, Runtime};
20use alloc::vec::Vec;
21use frame_support::weights::Weight;
22use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
23use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
24use sp_runtime::BoundedVec;
25use xcm::{
26 latest::{prelude::*, AssetTransferFilter},
27 DoubleEncoded,
28};
29
30trait WeighAssets {
31 fn weigh_assets(&self, weight: Weight) -> Weight;
32}
33
34const MAX_ASSETS: u64 = 1;
36
37impl WeighAssets for AssetFilter {
38 fn weigh_assets(&self, weight: Weight) -> Weight {
39 match self {
40 Self::Definite(assets) => weight.saturating_mul(assets.inner().iter().count() as u64),
41 Self::Wild(asset) => match asset {
42 All => weight.saturating_mul(MAX_ASSETS),
43 AllOf { fun, .. } => match fun {
44 WildFungibility::Fungible => weight,
45 WildFungibility::NonFungible =>
48 weight.saturating_mul((MaxAssetsIntoHolding::get() * 2) as u64),
49 },
50 AllCounted(count) => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
51 AllOfCounted { count, .. } => weight.saturating_mul(MAX_ASSETS.min(*count as u64)),
52 },
53 }
54 }
55}
56
57impl WeighAssets for Assets {
58 fn weigh_assets(&self, weight: Weight) -> Weight {
59 weight.saturating_mul(self.inner().iter().count() as u64)
60 }
61}
62
63pub struct CollectivesWestendXcmWeight<Call>(core::marker::PhantomData<Call>);
64impl<Call> XcmWeightInfo<Call> for CollectivesWestendXcmWeight<Call> {
65 fn withdraw_asset(assets: &Assets) -> Weight {
66 assets.weigh_assets(XcmFungibleWeight::<Runtime>::withdraw_asset())
67 }
68 fn reserve_asset_deposited(assets: &Assets) -> Weight {
69 assets.weigh_assets(XcmFungibleWeight::<Runtime>::reserve_asset_deposited())
70 }
71 fn receive_teleported_asset(assets: &Assets) -> Weight {
72 assets.weigh_assets(XcmFungibleWeight::<Runtime>::receive_teleported_asset())
73 }
74 fn query_response(
75 _query_id: &u64,
76 _response: &Response,
77 _max_weight: &Weight,
78 _querier: &Option<Location>,
79 ) -> Weight {
80 XcmGeneric::<Runtime>::query_response()
81 }
82 fn transfer_asset(assets: &Assets, _dest: &Location) -> Weight {
83 assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_asset())
84 }
85 fn transfer_reserve_asset(assets: &Assets, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
86 assets.weigh_assets(XcmFungibleWeight::<Runtime>::transfer_reserve_asset())
87 }
88 fn transact(
89 _origin_type: &OriginKind,
90 _fallback_max_weight: &Option<Weight>,
91 _call: &DoubleEncoded<Call>,
92 ) -> Weight {
93 XcmGeneric::<Runtime>::transact()
94 }
95 fn hrmp_new_channel_open_request(
96 _sender: &u32,
97 _max_message_size: &u32,
98 _max_capacity: &u32,
99 ) -> Weight {
100 Weight::MAX
102 }
103 fn hrmp_channel_accepted(_recipient: &u32) -> Weight {
104 Weight::MAX
106 }
107 fn hrmp_channel_closing(_initiator: &u32, _sender: &u32, _recipient: &u32) -> Weight {
108 Weight::MAX
110 }
111 fn clear_origin() -> Weight {
112 XcmGeneric::<Runtime>::clear_origin()
113 }
114 fn descend_origin(_who: &InteriorLocation) -> Weight {
115 XcmGeneric::<Runtime>::descend_origin()
116 }
117 fn report_error(_query_response_info: &QueryResponseInfo) -> Weight {
118 XcmGeneric::<Runtime>::report_error()
119 }
120
121 fn deposit_asset(assets: &AssetFilter, _dest: &Location) -> Weight {
122 assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_asset())
123 }
124 fn deposit_reserve_asset(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
125 assets.weigh_assets(XcmFungibleWeight::<Runtime>::deposit_reserve_asset())
126 }
127 fn exchange_asset(_give: &AssetFilter, _receive: &Assets, _maximal: &bool) -> Weight {
128 Weight::MAX
129 }
130 fn initiate_reserve_withdraw(
131 assets: &AssetFilter,
132 _reserve: &Location,
133 _xcm: &Xcm<()>,
134 ) -> Weight {
135 assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_reserve_withdraw())
136 }
137 fn initiate_teleport(assets: &AssetFilter, _dest: &Location, _xcm: &Xcm<()>) -> Weight {
138 assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_teleport())
139 }
140 fn initiate_transfer(
141 _dest: &Location,
142 remote_fees: &Option<AssetTransferFilter>,
143 _preserve_origin: &bool,
144 assets: &BoundedVec<AssetTransferFilter, MaxAssetTransferFilters>,
145 _xcm: &Xcm<()>,
146 ) -> Weight {
147 let mut weight = if let Some(remote_fees) = remote_fees {
148 let fees = remote_fees.inner();
149 fees.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_transfer())
150 } else {
151 Weight::zero()
152 };
153 for asset_filter in assets {
154 let assets = asset_filter.inner();
155 let extra = assets.weigh_assets(XcmFungibleWeight::<Runtime>::initiate_transfer());
156 weight = weight.saturating_add(extra);
157 }
158 weight
159 }
160 fn report_holding(_response_info: &QueryResponseInfo, _assets: &AssetFilter) -> Weight {
161 XcmGeneric::<Runtime>::report_holding()
162 }
163 fn buy_execution(_fees: &Asset, _weight_limit: &WeightLimit) -> Weight {
164 XcmGeneric::<Runtime>::buy_execution()
165 }
166 fn pay_fees(_asset: &Asset) -> Weight {
167 XcmGeneric::<Runtime>::pay_fees()
168 }
169 fn refund_surplus() -> Weight {
170 XcmGeneric::<Runtime>::refund_surplus()
171 }
172 fn set_error_handler(_xcm: &Xcm<Call>) -> Weight {
173 XcmGeneric::<Runtime>::set_error_handler()
174 }
175 fn set_appendix(_xcm: &Xcm<Call>) -> Weight {
176 XcmGeneric::<Runtime>::set_appendix()
177 }
178 fn clear_error() -> Weight {
179 XcmGeneric::<Runtime>::clear_error()
180 }
181 fn set_hints(hints: &BoundedVec<Hint, HintNumVariants>) -> Weight {
182 let mut weight = Weight::zero();
183 for hint in hints {
184 match hint {
185 AssetClaimer { .. } => {
186 weight = weight.saturating_add(XcmGeneric::<Runtime>::asset_claimer());
187 },
188 }
189 }
190 weight
191 }
192 fn claim_asset(_assets: &Assets, _ticket: &Location) -> Weight {
193 XcmGeneric::<Runtime>::claim_asset()
194 }
195 fn trap(_code: &u64) -> Weight {
196 XcmGeneric::<Runtime>::trap()
197 }
198 fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight {
199 XcmGeneric::<Runtime>::subscribe_version()
200 }
201 fn unsubscribe_version() -> Weight {
202 XcmGeneric::<Runtime>::unsubscribe_version()
203 }
204 fn burn_asset(assets: &Assets) -> Weight {
205 assets.weigh_assets(XcmGeneric::<Runtime>::burn_asset())
206 }
207 fn expect_asset(assets: &Assets) -> Weight {
208 assets.weigh_assets(XcmGeneric::<Runtime>::expect_asset())
209 }
210 fn expect_origin(_origin: &Option<Location>) -> Weight {
211 XcmGeneric::<Runtime>::expect_origin()
212 }
213 fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
214 XcmGeneric::<Runtime>::expect_error()
215 }
216 fn expect_transact_status(_transact_status: &MaybeErrorCode) -> Weight {
217 XcmGeneric::<Runtime>::expect_transact_status()
218 }
219 fn query_pallet(_module_name: &Vec<u8>, _response_info: &QueryResponseInfo) -> Weight {
220 XcmGeneric::<Runtime>::query_pallet()
221 }
222 fn expect_pallet(
223 _index: &u32,
224 _name: &Vec<u8>,
225 _module_name: &Vec<u8>,
226 _crate_major: &u32,
227 _min_crate_minor: &u32,
228 ) -> Weight {
229 XcmGeneric::<Runtime>::expect_pallet()
230 }
231 fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight {
232 XcmGeneric::<Runtime>::report_transact_status()
233 }
234 fn clear_transact_status() -> Weight {
235 XcmGeneric::<Runtime>::clear_transact_status()
236 }
237 fn universal_origin(_: &Junction) -> Weight {
238 Weight::MAX
239 }
240 fn export_message(_: &NetworkId, _: &Junctions, _: &Xcm<()>) -> Weight {
241 Weight::MAX
242 }
243 fn lock_asset(_: &Asset, _: &Location) -> Weight {
244 Weight::MAX
245 }
246 fn unlock_asset(_: &Asset, _: &Location) -> Weight {
247 Weight::MAX
248 }
249 fn note_unlockable(_: &Asset, _: &Location) -> Weight {
250 Weight::MAX
251 }
252 fn request_unlock(_: &Asset, _: &Location) -> Weight {
253 Weight::MAX
254 }
255 fn set_fees_mode(_: &bool) -> Weight {
256 XcmGeneric::<Runtime>::set_fees_mode()
257 }
258 fn set_topic(_topic: &[u8; 32]) -> Weight {
259 XcmGeneric::<Runtime>::set_topic()
260 }
261 fn clear_topic() -> Weight {
262 XcmGeneric::<Runtime>::clear_topic()
263 }
264 fn alias_origin(_: &Location) -> Weight {
265 XcmGeneric::<Runtime>::alias_origin()
266 }
267 fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
268 XcmGeneric::<Runtime>::unpaid_execution()
269 }
270 fn execute_with_origin(_: &Option<InteriorLocation>, _: &Xcm<Call>) -> Weight {
271 XcmGeneric::<Runtime>::execute_with_origin()
272 }
273}