radix_engine/vm/wasm/
weights.rs

1/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands).
2 *
3 * Licensed under the Radix License, Version 1.0 (the "License"); you may not use this
4 * file except in compliance with the License. You may obtain a copy of the License at:
5 *
6 * radixfoundation.org/licenses/LICENSE-v1
7 *
8 * The Licensor hereby grants permission for the Canonical version of the Work to be
9 * published, distributed and used under or by reference to the Licensor's trademark
10 * Radix ® and use of any unregistered trade names, logos or get-up.
11 *
12 * The Licensor provides the Work (and each Contributor provides its Contributions) on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
14 * including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
15 * MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
16 *
17 * Whilst the Work is capable of being deployed, used and adopted (instantiated) to create
18 * a distributed ledger it is your responsibility to test and validate the code, together
19 * with all logic and performance of that code under all foreseeable scenarios.
20 *
21 * The Licensor does not make or purport to make and hereby excludes liability for all
22 * and any representation, warranty or undertaking in any form whatsoever, whether express
23 * or implied, to any entity or person, including any representation, warranty or
24 * undertaking, as to the functionality security use, value or other characteristics of
25 * any distributed ledger nor in respect the functioning or value of any tokens which may
26 * be created stored or transferred using the Work. The Licensor does not warrant that the
27 * Work or any use of the Work complies with any law or regulation in any territory where
28 * it may be implemented or used or that it will be appropriate for any specific purpose.
29 *
30 * Neither the licensor nor any current or former employees, officers, directors, partners,
31 * trustees, representatives, agents, advisors, contractors, or volunteers of the Licensor
32 * shall be liable for any direct or indirect, special, incidental, consequential or other
33 * losses of any kind, in tort, contract or otherwise (including but not limited to loss
34 * of revenue, income or profits, or loss of use or data, or loss of reputation, or loss
35 * of any economic or other opportunity of whatsoever nature or howsoever arising), arising
36 * out of or in connection with (without limitation of any use, misuse, of any ledger system
37 * or use made or its functionality or any performance or operation of any code or protocol
38 * caused by bugs or programming or logic errors or otherwise);
39 *
40 * A. any offer, purchase, holding, use, sale, exchange or transmission of any
41 * cryptographic keys, tokens or assets created, exchanged, stored or arising from any
42 * interaction with the Work;
43 *
44 * B. any failure in a transmission or loss of any token or assets keys or other digital
45 * artefacts due to errors in transmission;
46 *
47 * C. bugs, hacks, logic errors or faults in the Work or any communication;
48 *
49 * D. system software or apparatus including but not limited to losses caused by errors
50 * in holding or transmitting tokens by any third-party;
51 *
52 * E. breaches or failure of security including hacker attacks, loss or disclosure of
53 * password, loss of private key, unauthorised use or misuse of such passwords or keys;
54 *
55 * F. any losses including loss of anticipated savings or other benefits resulting from
56 * use of the Work or any changes to the Work (however implemented).
57 *
58 * You are solely responsible for; testing, validating and evaluation of all operation
59 * logic, functionality, security and appropriateness of using the Work for any commercial
60 * or non-commercial purpose and for any reproduction or redistribution by You of the
61 * Work. You assume all risks associated with Your use of the Work and the exercise of
62 * permissions under this License.
63 */
64
65// This file contains code sourced from https://github.com/paritytech/substrate/tree/monthly-2023-06
66// This original source is licensed under https://github.com/paritytech/substrate/blob/monthly-2023-06/LICENSE-APACHE2
67//
68// The code in this file has been implemented by Radix® pursuant to an Apache 2 licence and has
69// been modified by Radix® and is now licensed pursuant to the Radix® Open-Source Licence.
70//
71// Each sourced code fragment includes an inline attribution to the original source file in a
72// comment starting "SOURCE: ..."
73//
74// Modifications from the original source are captured in two places:
75// * Initial changes to get the code functional/integrated are marked by inline "INITIAL-MODIFICATION: ..." comments
76// * Subsequent changes to the code are captured in the git commit history
77//
78// The following notice is retained from the original source
79// Copyright (C) Parity Technologies (UK) Ltd.
80// SPDX-License-Identifier: Apache-2.0
81
82// SOURCE: https://github.com/paritytech/substrate/blob/monthly-2023-06/primitives/weights/src/weight_v2.rs#L29
83pub struct Weight {
84    /// The weight of computational time used based on some reference hardware.
85    ref_time: u64,
86    /// The weight of storage space used by proof of validity.
87    proof_size: u64,
88}
89
90// SOURCE: https://github.com/paritytech/substrate/blob/monthly-2023-06/primitives/weights/src/weight_v2.rs#L38
91impl Weight {
92    /// Construct [`Weight`] from weight parts, namely reference time and proof size weights.
93    pub const fn from_parts(ref_time: u64, proof_size: u64) -> Self {
94        Self {
95            ref_time,
96            proof_size,
97        }
98    }
99
100    /// Return the reference time part of the weight.
101    pub const fn ref_time(&self) -> u64 {
102        self.ref_time
103    }
104
105    /// Return the storage size part of the weight.
106    pub const fn proof_size(&self) -> u64 {
107        self.proof_size
108    }
109
110    /// Saturating [`Weight`] addition. Computes `self + rhs`, saturating at the numeric bounds of
111    /// all fields instead of overflowing.
112    pub const fn saturating_add(self, rhs: Self) -> Self {
113        Self {
114            ref_time: self.ref_time.saturating_add(rhs.ref_time),
115            proof_size: self.proof_size.saturating_add(rhs.proof_size),
116        }
117    }
118
119    /// Saturating [`Weight`] subtraction. Computes `self - rhs`, saturating at the numeric bounds
120    /// of all fields instead of overflowing.
121    pub const fn saturating_sub(self, rhs: Self) -> Self {
122        Self {
123            ref_time: self.ref_time.saturating_sub(rhs.ref_time),
124            proof_size: self.proof_size.saturating_sub(rhs.proof_size),
125        }
126    }
127
128    /// Saturating [`Weight`] scalar multiplication. Computes `self.field * scalar` for all fields,
129    /// saturating at the numeric bounds of all fields instead of overflowing.
130    pub const fn saturating_mul(self, scalar: u64) -> Self {
131        Self {
132            ref_time: self.ref_time.saturating_mul(scalar),
133            proof_size: self.proof_size.saturating_mul(scalar),
134        }
135    }
136}
137
138// SOURCE: https://github.com/paritytech/substrate/blob/monthly-2023-06/frame/contracts/src/schedule.rs#L143
139/// Describes the weight for all categories of supported wasm instructions.
140///
141/// There there is one field for each wasm instruction that describes the weight to
142/// execute one instruction of that name. There are a few exceptions:
143///
144/// 1. If there is a i64 and a i32 variant of an instruction we use the weight
145///    of the former for both.
146/// 2. The following instructions are free of charge because they merely structure the
147///    wasm module and cannot be spammed without making the module invalid (and rejected):
148///    End, Unreachable, Return, Else
149/// 3. The following instructions cannot be benchmarked because they are removed by any
150///    real world execution engine as a preprocessing step and therefore don't yield a
151///    meaningful benchmark result. However, in contrast to the instructions mentioned
152///    in 2. they can be spammed. We price them with the same weight as the "default"
153///    instruction (i64.const): Block, Loop, Nop
154/// 4. We price both i64.const and drop as InstructionWeights.i64const / 2. The reason
155///    for that is that we cannot benchmark either of them on its own but we need their
156///    individual values to derive (by subtraction) the weight of all other instructions
157///    that use them as supporting instructions. Supporting means mainly pushing arguments
158///    and dropping return values in order to maintain a valid module.
159#[derive(Debug, Clone, PartialEq, Eq)]
160pub struct InstructionWeights {
161    /// Version of the instruction weights.
162    ///
163    /// # Note
164    ///
165    /// Should be incremented whenever any instruction weight is changed. The
166    /// reason is that changes to instruction weights require a re-instrumentation
167    /// in order to apply the changes to an already deployed code. The re-instrumentation
168    /// is triggered by comparing the version of the current schedule with the version the code was
169    /// instrumented with. Changes usually happen when pallet_contracts is re-benchmarked.
170    ///
171    /// Changes to other parts of the schedule should not increment the version in
172    /// order to avoid unnecessary re-instrumentations.
173    pub version: u32,
174    /// Weight to be used for instructions which don't have benchmarks assigned.
175    ///
176    /// This weight is used whenever a code is uploaded with [`Determinism::Relaxed`]
177    /// and an instruction (usually a float instruction) is encountered. This weight is **not**
178    /// used if a contract is uploaded with [`Determinism::Enforced`]. If this field is set to
179    /// `0` (the default) only deterministic codes are allowed to be uploaded.
180    pub fallback: u32,
181    pub i64const: u32,
182    pub i64load: u32,
183    pub i64store: u32,
184    pub select: u32,
185    pub r#if: u32,
186    pub br: u32,
187    pub br_if: u32,
188    pub br_table: u32,
189    pub br_table_per_entry: u32,
190    pub call: u32,
191    pub call_indirect: u32,
192    pub call_per_local: u32,
193    pub local_get: u32,
194    pub local_set: u32,
195    pub local_tee: u32,
196    pub global_get: u32,
197    pub global_set: u32,
198    pub memory_size: u32,
199    pub memory_grow: u32,
200    pub i64clz: u32,
201    pub i64ctz: u32,
202    pub i64popcnt: u32,
203    pub i64eqz: u32,
204    pub i64extendsi32: u32,
205    pub i64extendui32: u32,
206    pub i32wrapi64: u32,
207    pub i64eq: u32,
208    pub i64ne: u32,
209    pub i64lts: u32,
210    pub i64ltu: u32,
211    pub i64gts: u32,
212    pub i64gtu: u32,
213    pub i64les: u32,
214    pub i64leu: u32,
215    pub i64ges: u32,
216    pub i64geu: u32,
217    pub i64add: u32,
218    pub i64sub: u32,
219    pub i64mul: u32,
220    pub i64divs: u32,
221    pub i64divu: u32,
222    pub i64rems: u32,
223    pub i64remu: u32,
224    pub i64and: u32,
225    pub i64or: u32,
226    pub i64xor: u32,
227    pub i64shl: u32,
228    pub i64shrs: u32,
229    pub i64shru: u32,
230    pub i64rotl: u32,
231    pub i64rotr: u32,
232}
233
234macro_rules! replace_token {
235    ($_in:tt $replacement:tt) => {
236        $replacement
237    };
238}
239
240macro_rules! call_zero {
241	($name:ident, $( $arg:expr ),*) => {
242		InstructionWeights::$name($( replace_token!($arg 0) ),*)
243	};
244}
245
246macro_rules! cost_args {
247	($name:ident, $( $arg: expr ),+) => {
248		(InstructionWeights::$name($( $arg ),+).saturating_sub(call_zero!($name, $( $arg ),+)))
249	}
250}
251
252macro_rules! cost_instr_no_params {
253    ($name:ident) => {
254        cost_args!($name, 1).ref_time() as u32
255    };
256}
257
258macro_rules! cost_instr {
259    ($name:ident, $num_params:expr) => {
260        cost_instr_no_params!($name)
261            .saturating_sub((cost_instr_no_params!(instr_i64const) / 2).saturating_mul($num_params))
262    };
263}
264
265// SOURCE: https://github.com/paritytech/substrate/blob/monthly-2023-06/frame/contracts/src/schedule.rs#L494
266impl Default for InstructionWeights {
267    fn default() -> Self {
268        Self {
269            version: 4,
270            fallback: 0,
271            i64const: cost_instr!(instr_i64const, 1),
272            i64load: cost_instr!(instr_i64load, 2),
273            i64store: cost_instr!(instr_i64store, 2),
274            select: cost_instr!(instr_select, 4),
275            r#if: cost_instr!(instr_if, 3),
276            br: cost_instr!(instr_br, 2),
277            br_if: cost_instr!(instr_br_if, 3),
278            br_table: cost_instr!(instr_br_table, 3),
279            br_table_per_entry: cost_instr!(instr_br_table_per_entry, 0),
280            call: cost_instr!(instr_call, 2),
281            call_indirect: cost_instr!(instr_call_indirect, 3),
282            call_per_local: cost_instr!(instr_call_per_local, 0),
283            local_get: cost_instr!(instr_local_get, 1),
284            local_set: cost_instr!(instr_local_set, 1),
285            local_tee: cost_instr!(instr_local_tee, 2),
286            global_get: cost_instr!(instr_global_get, 1),
287            global_set: cost_instr!(instr_global_set, 1),
288            memory_size: cost_instr!(instr_memory_size, 1),
289            memory_grow: cost_instr!(instr_memory_grow, 1),
290            i64clz: cost_instr!(instr_i64clz, 2),
291            i64ctz: cost_instr!(instr_i64ctz, 2),
292            i64popcnt: cost_instr!(instr_i64popcnt, 2),
293            i64eqz: cost_instr!(instr_i64eqz, 2),
294            i64extendsi32: cost_instr!(instr_i64extendsi32, 2),
295            i64extendui32: cost_instr!(instr_i64extendui32, 2),
296            i32wrapi64: cost_instr!(instr_i32wrapi64, 2),
297            i64eq: cost_instr!(instr_i64eq, 3),
298            i64ne: cost_instr!(instr_i64ne, 3),
299            i64lts: cost_instr!(instr_i64lts, 3),
300            i64ltu: cost_instr!(instr_i64ltu, 3),
301            i64gts: cost_instr!(instr_i64gts, 3),
302            i64gtu: cost_instr!(instr_i64gtu, 3),
303            i64les: cost_instr!(instr_i64les, 3),
304            i64leu: cost_instr!(instr_i64leu, 3),
305            i64ges: cost_instr!(instr_i64ges, 3),
306            i64geu: cost_instr!(instr_i64geu, 3),
307            i64add: cost_instr!(instr_i64add, 3),
308            i64sub: cost_instr!(instr_i64sub, 3),
309            i64mul: cost_instr!(instr_i64mul, 3),
310            i64divs: cost_instr!(instr_i64divs, 3),
311            i64divu: cost_instr!(instr_i64divu, 3),
312            i64rems: cost_instr!(instr_i64rems, 3),
313            i64remu: cost_instr!(instr_i64remu, 3),
314            i64and: cost_instr!(instr_i64and, 3),
315            i64or: cost_instr!(instr_i64or, 3),
316            i64xor: cost_instr!(instr_i64xor, 3),
317            i64shl: cost_instr!(instr_i64shl, 3),
318            i64shrs: cost_instr!(instr_i64shrs, 3),
319            i64shru: cost_instr!(instr_i64shru, 3),
320            i64rotl: cost_instr!(instr_i64rotl, 3),
321            i64rotr: cost_instr!(instr_i64rotr, 3),
322        }
323    }
324}
325
326// SOURCE: https://github.com/paritytech/substrate/blob/monthly-2023-06/frame/contracts/src/weights.rs#L52
327/// Weight functions needed for pallet_contracts.
328pub trait WeightInfo {
329    fn instr_i64const(r: u32) -> Weight;
330    fn instr_i64load(r: u32) -> Weight;
331    fn instr_i64store(r: u32) -> Weight;
332    fn instr_select(r: u32) -> Weight;
333    fn instr_if(r: u32) -> Weight;
334    fn instr_br(r: u32) -> Weight;
335    fn instr_br_if(r: u32) -> Weight;
336    fn instr_br_table(r: u32) -> Weight;
337    fn instr_br_table_per_entry(e: u32) -> Weight;
338    fn instr_call(r: u32) -> Weight;
339    fn instr_call_indirect(r: u32) -> Weight;
340    fn instr_call_per_local(l: u32) -> Weight;
341    fn instr_local_get(r: u32) -> Weight;
342    fn instr_local_set(r: u32) -> Weight;
343    fn instr_local_tee(r: u32) -> Weight;
344    fn instr_global_get(r: u32) -> Weight;
345    fn instr_global_set(r: u32) -> Weight;
346    fn instr_memory_size(r: u32) -> Weight;
347    fn instr_memory_grow(r: u32) -> Weight;
348    fn instr_i64clz(r: u32) -> Weight;
349    fn instr_i64ctz(r: u32) -> Weight;
350    fn instr_i64popcnt(r: u32) -> Weight;
351    fn instr_i64eqz(r: u32) -> Weight;
352    fn instr_i64extendsi32(r: u32) -> Weight;
353    fn instr_i64extendui32(r: u32) -> Weight;
354    fn instr_i32wrapi64(r: u32) -> Weight;
355    fn instr_i64eq(r: u32) -> Weight;
356    fn instr_i64ne(r: u32) -> Weight;
357    fn instr_i64lts(r: u32) -> Weight;
358    fn instr_i64ltu(r: u32) -> Weight;
359    fn instr_i64gts(r: u32) -> Weight;
360    fn instr_i64gtu(r: u32) -> Weight;
361    fn instr_i64les(r: u32) -> Weight;
362    fn instr_i64leu(r: u32) -> Weight;
363    fn instr_i64ges(r: u32) -> Weight;
364    fn instr_i64geu(r: u32) -> Weight;
365    fn instr_i64add(r: u32) -> Weight;
366    fn instr_i64sub(r: u32) -> Weight;
367    fn instr_i64mul(r: u32) -> Weight;
368    fn instr_i64divs(r: u32) -> Weight;
369    fn instr_i64divu(r: u32) -> Weight;
370    fn instr_i64rems(r: u32) -> Weight;
371    fn instr_i64remu(r: u32) -> Weight;
372    fn instr_i64and(r: u32) -> Weight;
373    fn instr_i64or(r: u32) -> Weight;
374    fn instr_i64xor(r: u32) -> Weight;
375    fn instr_i64shl(r: u32) -> Weight;
376    fn instr_i64shrs(r: u32) -> Weight;
377    fn instr_i64shru(r: u32) -> Weight;
378    fn instr_i64rotl(r: u32) -> Weight;
379    fn instr_i64rotr(r: u32) -> Weight;
380}
381
382// SOURCE: https://github.com/paritytech/substrate/blob/monthly-2023-06/frame/contracts/src/weights.rs#L184
383impl WeightInfo for InstructionWeights {
384    /// The range of component `r` is `[0, 5000]`.
385    fn instr_i64const(r: u32) -> Weight {
386        // Proof Size summary in bytes:
387        //  Measured:  `0`
388        //  Estimated: `0`
389        // Minimum execution time: 1_405_000 picoseconds.
390        Weight::from_parts(1_583_300, 0)
391            // Standard Error: 1
392            .saturating_add(Weight::from_parts(2_743, 0).saturating_mul(r.into()))
393    }
394    /// The range of component `r` is `[0, 5000]`.
395    fn instr_i64load(r: u32) -> Weight {
396        // Proof Size summary in bytes:
397        //  Measured:  `0`
398        //  Estimated: `0`
399        // Minimum execution time: 1_796_000 picoseconds.
400        Weight::from_parts(2_279_812, 0)
401            // Standard Error: 7
402            .saturating_add(Weight::from_parts(6_339, 0).saturating_mul(r.into()))
403    }
404    /// The range of component `r` is `[0, 5000]`.
405    fn instr_i64store(r: u32) -> Weight {
406        // Proof Size summary in bytes:
407        //  Measured:  `0`
408        //  Estimated: `0`
409        // Minimum execution time: 1_768_000 picoseconds.
410        Weight::from_parts(2_274_070, 0)
411            // Standard Error: 4
412            .saturating_add(Weight::from_parts(6_647, 0).saturating_mul(r.into()))
413    }
414    /// The range of component `r` is `[0, 5000]`.
415    fn instr_select(r: u32) -> Weight {
416        // Proof Size summary in bytes:
417        //  Measured:  `0`
418        //  Estimated: `0`
419        // Minimum execution time: 1_396_000 picoseconds.
420        Weight::from_parts(1_730_388, 0)
421            // Standard Error: 5
422            .saturating_add(Weight::from_parts(8_918, 0).saturating_mul(r.into()))
423    }
424    /// The range of component `r` is `[0, 5000]`.
425    fn instr_if(r: u32) -> Weight {
426        // Proof Size summary in bytes:
427        //  Measured:  `0`
428        //  Estimated: `0`
429        // Minimum execution time: 1_383_000 picoseconds.
430        Weight::from_parts(1_473_000, 0)
431            // Standard Error: 22
432            .saturating_add(Weight::from_parts(12_167, 0).saturating_mul(r.into()))
433    }
434    /// The range of component `r` is `[0, 5000]`.
435    fn instr_br(r: u32) -> Weight {
436        // Proof Size summary in bytes:
437        //  Measured:  `0`
438        //  Estimated: `0`
439        // Minimum execution time: 1_418_000 picoseconds.
440        Weight::from_parts(1_490_208, 0)
441            // Standard Error: 18
442            .saturating_add(Weight::from_parts(6_271, 0).saturating_mul(r.into()))
443    }
444    /// The range of component `r` is `[0, 5000]`.
445    fn instr_br_if(r: u32) -> Weight {
446        // Proof Size summary in bytes:
447        //  Measured:  `0`
448        //  Estimated: `0`
449        // Minimum execution time: 1_396_000 picoseconds.
450        Weight::from_parts(1_584_684, 0)
451            // Standard Error: 61
452            .saturating_add(Weight::from_parts(8_819, 0).saturating_mul(r.into()))
453    }
454    /// The range of component `r` is `[0, 5000]`.
455    fn instr_br_table(r: u32) -> Weight {
456        // Proof Size summary in bytes:
457        //  Measured:  `0`
458        //  Estimated: `0`
459        // Minimum execution time: 1_384_000 picoseconds.
460        Weight::from_parts(1_501_244, 0)
461            // Standard Error: 17
462            .saturating_add(Weight::from_parts(12_311, 0).saturating_mul(r.into()))
463    }
464    /// The range of component `e` is `[1, 256]`.
465    fn instr_br_table_per_entry(e: u32) -> Weight {
466        // Proof Size summary in bytes:
467        //  Measured:  `0`
468        //  Estimated: `0`
469        // Minimum execution time: 1_433_000 picoseconds.
470        Weight::from_parts(1_594_462, 0)
471            // Standard Error: 19
472            .saturating_add(Weight::from_parts(29, 0).saturating_mul(e.into()))
473    }
474    /// The range of component `r` is `[0, 5000]`.
475    fn instr_call(r: u32) -> Weight {
476        // Proof Size summary in bytes:
477        //  Measured:  `0`
478        //  Estimated: `0`
479        // Minimum execution time: 1_420_000 picoseconds.
480        Weight::from_parts(1_602_036, 0)
481            // Standard Error: 16
482            .saturating_add(Weight::from_parts(17_082, 0).saturating_mul(r.into()))
483    }
484    /// The range of component `r` is `[0, 5000]`.
485    fn instr_call_indirect(r: u32) -> Weight {
486        // Proof Size summary in bytes:
487        //  Measured:  `0`
488        //  Estimated: `0`
489        // Minimum execution time: 1_619_000 picoseconds.
490        Weight::from_parts(2_069_590, 0)
491            // Standard Error: 20
492            .saturating_add(Weight::from_parts(24_049, 0).saturating_mul(r.into()))
493    }
494    /// The range of component `l` is `[0, 1024]`.
495    fn instr_call_per_local(l: u32) -> Weight {
496        // Proof Size summary in bytes:
497        //  Measured:  `0`
498        //  Estimated: `0`
499        // Minimum execution time: 1_478_000 picoseconds.
500        Weight::from_parts(1_699_579, 0)
501            // Standard Error: 13
502            .saturating_add(Weight::from_parts(1_651, 0).saturating_mul(l.into()))
503    }
504    /// The range of component `r` is `[0, 5000]`.
505    fn instr_local_get(r: u32) -> Weight {
506        // Proof Size summary in bytes:
507        //  Measured:  `0`
508        //  Estimated: `0`
509        // Minimum execution time: 3_123_000 picoseconds.
510        Weight::from_parts(3_200_824, 0)
511            // Standard Error: 12
512            .saturating_add(Weight::from_parts(4_187, 0).saturating_mul(r.into()))
513    }
514    /// The range of component `r` is `[0, 5000]`.
515    fn instr_local_set(r: u32) -> Weight {
516        // Proof Size summary in bytes:
517        //  Measured:  `0`
518        //  Estimated: `0`
519        // Minimum execution time: 3_121_000 picoseconds.
520        Weight::from_parts(3_302_628, 0)
521            // Standard Error: 2
522            .saturating_add(Weight::from_parts(4_193, 0).saturating_mul(r.into()))
523    }
524    /// The range of component `r` is `[0, 5000]`.
525    fn instr_local_tee(r: u32) -> Weight {
526        // Proof Size summary in bytes:
527        //  Measured:  `0`
528        //  Estimated: `0`
529        // Minimum execution time: 3_155_000 picoseconds.
530        Weight::from_parts(3_359_832, 0)
531            // Standard Error: 2
532            .saturating_add(Weight::from_parts(4_829, 0).saturating_mul(r.into()))
533    }
534    /// The range of component `r` is `[0, 5000]`.
535    fn instr_global_get(r: u32) -> Weight {
536        // Proof Size summary in bytes:
537        //  Measured:  `0`
538        //  Estimated: `0`
539        // Minimum execution time: 1_547_000 picoseconds.
540        Weight::from_parts(1_899_252, 0)
541            // Standard Error: 13
542            .saturating_add(Weight::from_parts(8_373, 0).saturating_mul(r.into()))
543    }
544    /// The range of component `r` is `[0, 5000]`.
545    fn instr_global_set(r: u32) -> Weight {
546        // Proof Size summary in bytes:
547        //  Measured:  `0`
548        //  Estimated: `0`
549        // Minimum execution time: 1_513_000 picoseconds.
550        Weight::from_parts(1_892_537, 0)
551            // Standard Error: 15
552            .saturating_add(Weight::from_parts(9_177, 0).saturating_mul(r.into()))
553    }
554    /// The range of component `r` is `[0, 5000]`.
555    fn instr_memory_size(r: u32) -> Weight {
556        // Proof Size summary in bytes:
557        //  Measured:  `0`
558        //  Estimated: `0`
559        // Minimum execution time: 1_904_000 picoseconds.
560        Weight::from_parts(2_140_940, 0)
561            // Standard Error: 5
562            .saturating_add(Weight::from_parts(3_926, 0).saturating_mul(r.into()))
563    }
564    /// The range of component `r` is `[0, 16]`.
565    fn instr_memory_grow(r: u32) -> Weight {
566        // Proof Size summary in bytes:
567        //  Measured:  `0`
568        //  Estimated: `0`
569        // Minimum execution time: 1_437_000 picoseconds.
570        Weight::from_parts(4_481, 0)
571            // Standard Error: 131_975
572            .saturating_add(Weight::from_parts(14_765_592, 0).saturating_mul(r.into()))
573    }
574    /// The range of component `r` is `[0, 5000]`.
575    fn instr_i64clz(r: u32) -> Weight {
576        // Proof Size summary in bytes:
577        //  Measured:  `0`
578        //  Estimated: `0`
579        // Minimum execution time: 1_443_000 picoseconds.
580        Weight::from_parts(1_596_467, 0)
581            // Standard Error: 1
582            .saturating_add(Weight::from_parts(4_251, 0).saturating_mul(r.into()))
583    }
584    /// The range of component `r` is `[0, 5000]`.
585    fn instr_i64ctz(r: u32) -> Weight {
586        // Proof Size summary in bytes:
587        //  Measured:  `0`
588        //  Estimated: `0`
589        // Minimum execution time: 1_372_000 picoseconds.
590        Weight::from_parts(1_569_760, 0)
591            // Standard Error: 7
592            .saturating_add(Weight::from_parts(4_777, 0).saturating_mul(r.into()))
593    }
594    /// The range of component `r` is `[0, 5000]`.
595    fn instr_i64popcnt(r: u32) -> Weight {
596        // Proof Size summary in bytes:
597        //  Measured:  `0`
598        //  Estimated: `0`
599        // Minimum execution time: 1_411_000 picoseconds.
600        Weight::from_parts(1_642_163, 0)
601            // Standard Error: 2
602            .saturating_add(Weight::from_parts(4_241, 0).saturating_mul(r.into()))
603    }
604    /// The range of component `r` is `[0, 5000]`.
605    fn instr_i64eqz(r: u32) -> Weight {
606        // Proof Size summary in bytes:
607        //  Measured:  `0`
608        //  Estimated: `0`
609        // Minimum execution time: 1_395_000 picoseconds.
610        Weight::from_parts(1_726_615, 0)
611            // Standard Error: 10
612            .saturating_add(Weight::from_parts(4_631, 0).saturating_mul(r.into()))
613    }
614    /// The range of component `r` is `[0, 5000]`.
615    fn instr_i64extendsi32(r: u32) -> Weight {
616        // Proof Size summary in bytes:
617        //  Measured:  `0`
618        //  Estimated: `0`
619        // Minimum execution time: 1_373_000 picoseconds.
620        Weight::from_parts(1_620_217, 0)
621            // Standard Error: 1
622            .saturating_add(Weight::from_parts(4_220, 0).saturating_mul(r.into()))
623    }
624    /// The range of component `r` is `[0, 5000]`.
625    fn instr_i64extendui32(r: u32) -> Weight {
626        // Proof Size summary in bytes:
627        //  Measured:  `0`
628        //  Estimated: `0`
629        // Minimum execution time: 1_423_000 picoseconds.
630        Weight::from_parts(1_611_025, 0)
631            // Standard Error: 11
632            .saturating_add(Weight::from_parts(4_681, 0).saturating_mul(r.into()))
633    }
634    /// The range of component `r` is `[0, 5000]`.
635    fn instr_i32wrapi64(r: u32) -> Weight {
636        // Proof Size summary in bytes:
637        //  Measured:  `0`
638        //  Estimated: `0`
639        // Minimum execution time: 1_402_000 picoseconds.
640        Weight::from_parts(1_616_506, 0)
641            // Standard Error: 2
642            .saturating_add(Weight::from_parts(4_247, 0).saturating_mul(r.into()))
643    }
644    /// The range of component `r` is `[0, 5000]`.
645    fn instr_i64eq(r: u32) -> Weight {
646        // Proof Size summary in bytes:
647        //  Measured:  `0`
648        //  Estimated: `0`
649        // Minimum execution time: 1_464_000 picoseconds.
650        Weight::from_parts(1_641_492, 0)
651            // Standard Error: 8
652            .saturating_add(Weight::from_parts(6_262, 0).saturating_mul(r.into()))
653    }
654    /// The range of component `r` is `[0, 5000]`.
655    fn instr_i64ne(r: u32) -> Weight {
656        // Proof Size summary in bytes:
657        //  Measured:  `0`
658        //  Estimated: `0`
659        // Minimum execution time: 1_401_000 picoseconds.
660        Weight::from_parts(1_673_299, 0)
661            // Standard Error: 2
662            .saturating_add(Weight::from_parts(5_741, 0).saturating_mul(r.into()))
663    }
664    /// The range of component `r` is `[0, 5000]`.
665    fn instr_i64lts(r: u32) -> Weight {
666        // Proof Size summary in bytes:
667        //  Measured:  `0`
668        //  Estimated: `0`
669        // Minimum execution time: 1_414_000 picoseconds.
670        Weight::from_parts(1_615_167, 0)
671            // Standard Error: 2
672            .saturating_add(Weight::from_parts(5_767, 0).saturating_mul(r.into()))
673    }
674    /// The range of component `r` is `[0, 5000]`.
675    fn instr_i64ltu(r: u32) -> Weight {
676        // Proof Size summary in bytes:
677        //  Measured:  `0`
678        //  Estimated: `0`
679        // Minimum execution time: 1_445_000 picoseconds.
680        Weight::from_parts(1_687_595, 0)
681            // Standard Error: 10
682            .saturating_add(Weight::from_parts(6_201, 0).saturating_mul(r.into()))
683    }
684    /// The range of component `r` is `[0, 5000]`.
685    fn instr_i64gts(r: u32) -> Weight {
686        // Proof Size summary in bytes:
687        //  Measured:  `0`
688        //  Estimated: `0`
689        // Minimum execution time: 1_415_000 picoseconds.
690        Weight::from_parts(1_629_044, 0)
691            // Standard Error: 3
692            .saturating_add(Weight::from_parts(6_318, 0).saturating_mul(r.into()))
693    }
694    /// The range of component `r` is `[0, 5000]`.
695    fn instr_i64gtu(r: u32) -> Weight {
696        // Proof Size summary in bytes:
697        //  Measured:  `0`
698        //  Estimated: `0`
699        // Minimum execution time: 1_377_000 picoseconds.
700        Weight::from_parts(1_660_178, 0)
701            // Standard Error: 3
702            .saturating_add(Weight::from_parts(5_774, 0).saturating_mul(r.into()))
703    }
704    /// The range of component `r` is `[0, 5000]`.
705    fn instr_i64les(r: u32) -> Weight {
706        // Proof Size summary in bytes:
707        //  Measured:  `0`
708        //  Estimated: `0`
709        // Minimum execution time: 1_467_000 picoseconds.
710        Weight::from_parts(1_619_688, 0)
711            // Standard Error: 2
712            .saturating_add(Weight::from_parts(5_761, 0).saturating_mul(r.into()))
713    }
714    /// The range of component `r` is `[0, 5000]`.
715    fn instr_i64leu(r: u32) -> Weight {
716        // Proof Size summary in bytes:
717        //  Measured:  `0`
718        //  Estimated: `0`
719        // Minimum execution time: 1_485_000 picoseconds.
720        Weight::from_parts(1_619_756, 0)
721            // Standard Error: 10
722            .saturating_add(Weight::from_parts(6_248, 0).saturating_mul(r.into()))
723    }
724    /// The range of component `r` is `[0, 5000]`.
725    fn instr_i64ges(r: u32) -> Weight {
726        // Proof Size summary in bytes:
727        //  Measured:  `0`
728        //  Estimated: `0`
729        // Minimum execution time: 1_391_000 picoseconds.
730        Weight::from_parts(1_629_993, 0)
731            // Standard Error: 3
732            .saturating_add(Weight::from_parts(6_339, 0).saturating_mul(r.into()))
733    }
734    /// The range of component `r` is `[0, 5000]`.
735    fn instr_i64geu(r: u32) -> Weight {
736        // Proof Size summary in bytes:
737        //  Measured:  `0`
738        //  Estimated: `0`
739        // Minimum execution time: 1_413_000 picoseconds.
740        Weight::from_parts(1_605_123, 0)
741            // Standard Error: 2
742            .saturating_add(Weight::from_parts(5_774, 0).saturating_mul(r.into()))
743    }
744    /// The range of component `r` is `[0, 5000]`.
745    fn instr_i64add(r: u32) -> Weight {
746        // Proof Size summary in bytes:
747        //  Measured:  `0`
748        //  Estimated: `0`
749        // Minimum execution time: 1_470_000 picoseconds.
750        Weight::from_parts(1_699_382, 0)
751            // Standard Error: 2
752            .saturating_add(Weight::from_parts(5_736, 0).saturating_mul(r.into()))
753    }
754    /// The range of component `r` is `[0, 5000]`.
755    fn instr_i64sub(r: u32) -> Weight {
756        // Proof Size summary in bytes:
757        //  Measured:  `0`
758        //  Estimated: `0`
759        // Minimum execution time: 1_394_000 picoseconds.
760        Weight::from_parts(1_599_038, 0)
761            // Standard Error: 5
762            .saturating_add(Weight::from_parts(6_325, 0).saturating_mul(r.into()))
763    }
764    /// The range of component `r` is `[0, 5000]`.
765    fn instr_i64mul(r: u32) -> Weight {
766        // Proof Size summary in bytes:
767        //  Measured:  `0`
768        //  Estimated: `0`
769        // Minimum execution time: 1_422_000 picoseconds.
770        Weight::from_parts(1_655_350, 0)
771            // Standard Error: 2
772            .saturating_add(Weight::from_parts(5_753, 0).saturating_mul(r.into()))
773    }
774    /// The range of component `r` is `[0, 5000]`.
775    fn instr_i64divs(r: u32) -> Weight {
776        // Proof Size summary in bytes:
777        //  Measured:  `0`
778        //  Estimated: `0`
779        // Minimum execution time: 1_407_000 picoseconds.
780        Weight::from_parts(1_710_195, 0)
781            // Standard Error: 8
782            .saturating_add(Weight::from_parts(6_791, 0).saturating_mul(r.into()))
783    }
784    /// The range of component `r` is `[0, 5000]`.
785    fn instr_i64divu(r: u32) -> Weight {
786        // Proof Size summary in bytes:
787        //  Measured:  `0`
788        //  Estimated: `0`
789        // Minimum execution time: 1_406_000 picoseconds.
790        Weight::from_parts(2_022_275, 0)
791            // Standard Error: 13
792            .saturating_add(Weight::from_parts(5_864, 0).saturating_mul(r.into()))
793    }
794    /// The range of component `r` is `[0, 5000]`.
795    fn instr_i64rems(r: u32) -> Weight {
796        // Proof Size summary in bytes:
797        //  Measured:  `0`
798        //  Estimated: `0`
799        // Minimum execution time: 1_424_000 picoseconds.
800        Weight::from_parts(1_735_622, 0)
801            // Standard Error: 8
802            .saturating_add(Weight::from_parts(6_772, 0).saturating_mul(r.into()))
803    }
804    /// The range of component `r` is `[0, 5000]`.
805    fn instr_i64remu(r: u32) -> Weight {
806        // Proof Size summary in bytes:
807        //  Measured:  `0`
808        //  Estimated: `0`
809        // Minimum execution time: 1_457_000 picoseconds.
810        Weight::from_parts(1_636_788, 0)
811            // Standard Error: 4
812            .saturating_add(Weight::from_parts(5_794, 0).saturating_mul(r.into()))
813    }
814    /// The range of component `r` is `[0, 5000]`.
815    fn instr_i64and(r: u32) -> Weight {
816        // Proof Size summary in bytes:
817        //  Measured:  `0`
818        //  Estimated: `0`
819        // Minimum execution time: 1_423_000 picoseconds.
820        Weight::from_parts(1_703_832, 0)
821            // Standard Error: 11
822            .saturating_add(Weight::from_parts(6_158, 0).saturating_mul(r.into()))
823    }
824    /// The range of component `r` is `[0, 5000]`.
825    fn instr_i64or(r: u32) -> Weight {
826        // Proof Size summary in bytes:
827        //  Measured:  `0`
828        //  Estimated: `0`
829        // Minimum execution time: 1_401_000 picoseconds.
830        Weight::from_parts(1_653_216, 0)
831            // Standard Error: 2
832            .saturating_add(Weight::from_parts(5_754, 0).saturating_mul(r.into()))
833    }
834    /// The range of component `r` is `[0, 5000]`.
835    fn instr_i64xor(r: u32) -> Weight {
836        // Proof Size summary in bytes:
837        //  Measured:  `0`
838        //  Estimated: `0`
839        // Minimum execution time: 1_419_000 picoseconds.
840        Weight::from_parts(1_685_121, 0)
841            // Standard Error: 2
842            .saturating_add(Weight::from_parts(6_309, 0).saturating_mul(r.into()))
843    }
844    /// The range of component `r` is `[0, 5000]`.
845    fn instr_i64shl(r: u32) -> Weight {
846        // Proof Size summary in bytes:
847        //  Measured:  `0`
848        //  Estimated: `0`
849        // Minimum execution time: 1_395_000 picoseconds.
850        Weight::from_parts(1_580_918, 0)
851            // Standard Error: 2
852            .saturating_add(Weight::from_parts(5_775, 0).saturating_mul(r.into()))
853    }
854    /// The range of component `r` is `[0, 5000]`.
855    fn instr_i64shrs(r: u32) -> Weight {
856        // Proof Size summary in bytes:
857        //  Measured:  `0`
858        //  Estimated: `0`
859        // Minimum execution time: 1_408_000 picoseconds.
860        Weight::from_parts(1_646_493, 0)
861            // Standard Error: 9
862            .saturating_add(Weight::from_parts(6_237, 0).saturating_mul(r.into()))
863    }
864    /// The range of component `r` is `[0, 5000]`.
865    fn instr_i64shru(r: u32) -> Weight {
866        // Proof Size summary in bytes:
867        //  Measured:  `0`
868        //  Estimated: `0`
869        // Minimum execution time: 1_446_000 picoseconds.
870        Weight::from_parts(1_633_531, 0)
871            // Standard Error: 7
872            .saturating_add(Weight::from_parts(5_759, 0).saturating_mul(r.into()))
873    }
874    /// The range of component `r` is `[0, 5000]`.
875    fn instr_i64rotl(r: u32) -> Weight {
876        // Proof Size summary in bytes:
877        //  Measured:  `0`
878        //  Estimated: `0`
879        // Minimum execution time: 1_478_000 picoseconds.
880        Weight::from_parts(1_634_023, 0)
881            // Standard Error: 2
882            .saturating_add(Weight::from_parts(5_771, 0).saturating_mul(r.into()))
883    }
884    /// The range of component `r` is `[0, 5000]`.
885    fn instr_i64rotr(r: u32) -> Weight {
886        // Proof Size summary in bytes:
887        //  Measured:  `0`
888        //  Estimated: `0`
889        // Minimum execution time: 1_389_000 picoseconds.
890        Weight::from_parts(1_627_867, 0)
891            // Standard Error: 10
892            .saturating_add(Weight::from_parts(6_175, 0).saturating_mul(r.into()))
893    }
894}