bridge_hub_rococo_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 codec::Encode;
22use frame_support::weights::Weight;
23use pallet_xcm_benchmarks_fungible::WeightInfo as XcmFungibleWeight;
24use pallet_xcm_benchmarks_generic::WeightInfo as XcmGeneric;
25use sp_runtime::BoundedVec;
26use xcm::{
27 latest::{prelude::*, AssetTransferFilter},
28 DoubleEncoded,
29};
30
31trait WeighAssets {
32 fn weigh_assets(&self, weight: Weight) -> Weight;
33}
34
35const MAX_ASSETS: u64 = 100;
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 BridgeHubRococoXcmWeight<Call>(core::marker::PhantomData<Call>);
64impl<Call> XcmWeightInfo<Call> for BridgeHubRococoXcmWeight<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 claim_asset(_assets: &Assets, _ticket: &Location) -> Weight {
182 XcmGeneric::<Runtime>::claim_asset()
183 }
184 fn trap(_code: &u64) -> Weight {
185 XcmGeneric::<Runtime>::trap()
186 }
187 fn subscribe_version(_query_id: &QueryId, _max_response_weight: &Weight) -> Weight {
188 XcmGeneric::<Runtime>::subscribe_version()
189 }
190 fn unsubscribe_version() -> Weight {
191 XcmGeneric::<Runtime>::unsubscribe_version()
192 }
193 fn burn_asset(assets: &Assets) -> Weight {
194 assets.weigh_assets(XcmGeneric::<Runtime>::burn_asset())
195 }
196 fn expect_asset(assets: &Assets) -> Weight {
197 assets.weigh_assets(XcmGeneric::<Runtime>::expect_asset())
198 }
199 fn expect_origin(_origin: &Option<Location>) -> Weight {
200 XcmGeneric::<Runtime>::expect_origin()
201 }
202 fn expect_error(_error: &Option<(u32, XcmError)>) -> Weight {
203 XcmGeneric::<Runtime>::expect_error()
204 }
205 fn expect_transact_status(_transact_status: &MaybeErrorCode) -> Weight {
206 XcmGeneric::<Runtime>::expect_transact_status()
207 }
208 fn query_pallet(_module_name: &Vec<u8>, _response_info: &QueryResponseInfo) -> Weight {
209 XcmGeneric::<Runtime>::query_pallet()
210 }
211 fn expect_pallet(
212 _index: &u32,
213 _name: &Vec<u8>,
214 _module_name: &Vec<u8>,
215 _crate_major: &u32,
216 _min_crate_minor: &u32,
217 ) -> Weight {
218 XcmGeneric::<Runtime>::expect_pallet()
219 }
220 fn report_transact_status(_response_info: &QueryResponseInfo) -> Weight {
221 XcmGeneric::<Runtime>::report_transact_status()
222 }
223 fn clear_transact_status() -> Weight {
224 XcmGeneric::<Runtime>::clear_transact_status()
225 }
226 fn universal_origin(_: &Junction) -> Weight {
227 Weight::MAX
228 }
229 fn export_message(_: &NetworkId, _: &Junctions, inner: &Xcm<()>) -> Weight {
230 let inner_encoded_len = inner.encode().len() as u32;
231 XcmGeneric::<Runtime>::export_message(inner_encoded_len)
232 }
233 fn lock_asset(_: &Asset, _: &Location) -> Weight {
234 Weight::MAX
235 }
236 fn unlock_asset(_: &Asset, _: &Location) -> Weight {
237 Weight::MAX
238 }
239 fn note_unlockable(_: &Asset, _: &Location) -> Weight {
240 Weight::MAX
241 }
242 fn request_unlock(_: &Asset, _: &Location) -> Weight {
243 Weight::MAX
244 }
245 fn set_fees_mode(_: &bool) -> Weight {
246 XcmGeneric::<Runtime>::set_fees_mode()
247 }
248 fn set_topic(_topic: &[u8; 32]) -> Weight {
249 XcmGeneric::<Runtime>::set_topic()
250 }
251 fn clear_topic() -> Weight {
252 XcmGeneric::<Runtime>::clear_topic()
253 }
254 fn alias_origin(_: &Location) -> Weight {
255 Weight::MAX
257 }
258 fn unpaid_execution(_: &WeightLimit, _: &Option<Location>) -> Weight {
259 XcmGeneric::<Runtime>::unpaid_execution()
260 }
261 fn set_hints(hints: &BoundedVec<Hint, HintNumVariants>) -> Weight {
262 let mut weight = Weight::zero();
263 for hint in hints {
264 match hint {
265 AssetClaimer { .. } => {
266 weight = weight.saturating_add(XcmGeneric::<Runtime>::asset_claimer());
267 },
268 }
269 }
270 weight
271 }
272 fn execute_with_origin(_: &Option<InteriorLocation>, _: &Xcm<Call>) -> Weight {
273 XcmGeneric::<Runtime>::execute_with_origin()
274 }
275}