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