Skip to main content

fuel_tx/transaction/consensus_parameters/
gas.rs

1//! Tools for gas instrumentalization
2
3use core::ops::Deref;
4
5#[cfg(feature = "alloc")]
6use alloc::sync::Arc;
7
8use fuel_asm::PanicReason;
9use fuel_types::Word;
10
11/// Default gas costs are generated from the
12/// `fuel-core` repo using the `collect` bin
13/// in the `fuel-core-benches` crate.
14/// The git sha is included in the file to
15/// show what version of `fuel-core` was used
16/// to generate the costs.
17#[allow(dead_code)]
18mod default_gas_costs;
19
20/// Gas costings for every op.
21/// The inner values are wrapped in an [`Arc`]
22/// so this is cheap to clone.
23#[derive(Debug, Clone, PartialEq, Eq, Hash)]
24#[cfg(feature = "alloc")]
25pub struct GasCosts(Arc<GasCostsValues>);
26
27#[cfg(feature = "alloc")]
28impl<'de> serde::Deserialize<'de> for GasCosts {
29    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
30    where
31        D: serde::Deserializer<'de>,
32    {
33        Ok(GasCosts(Arc::new(serde::Deserialize::deserialize(
34            deserializer,
35        )?)))
36    }
37}
38
39#[cfg(feature = "alloc")]
40impl serde::Serialize for GasCosts {
41    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
42    where
43        S: serde::Serializer,
44    {
45        serde::Serialize::serialize(self.0.as_ref(), serializer)
46    }
47}
48
49#[cfg(feature = "alloc")]
50impl GasCosts {
51    /// Create new cost values wrapped in an [`Arc`].
52    pub fn new(costs: GasCostsValues) -> Self {
53        Self(Arc::new(costs))
54    }
55}
56
57#[cfg(feature = "alloc")]
58impl Default for GasCosts {
59    fn default() -> Self {
60        Self(Arc::new(GasCostsValues::default()))
61    }
62}
63
64impl Default for GasCostsValues {
65    fn default() -> Self {
66        // The default values for gas costs
67        // are generated from fuel-core-benches.
68        default_gas_costs::default_gas_costs()
69    }
70}
71
72/// The versioned gas costs for every op.
73#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
74pub enum GasCostsValues {
75    /// Version 1 of the gas costs.
76    V1(GasCostsValuesV1),
77    /// Version 2 of the gas costs.
78    V2(GasCostsValuesV2),
79    /// Version 3 of the gas costs.
80    V3(GasCostsValuesV3),
81    /// Version 4 of the gas costs.
82    V4(GasCostsValuesV4),
83    /// Version 5 of the gas costs.
84    V5(GasCostsValuesV5),
85    /// Version 6 of the gas costs.
86    V6(GasCostsValuesV6),
87    /// Version 7 of the gas costs.
88    V7(GasCostsValuesV7),
89}
90
91/// Gas cost for this instruction is not defined for this version.
92pub struct GasCostNotDefined;
93
94impl From<GasCostNotDefined> for PanicReason {
95    fn from(_: GasCostNotDefined) -> PanicReason {
96        PanicReason::GasCostNotDefined
97    }
98}
99
100#[allow(missing_docs)]
101impl GasCostsValues {
102    pub fn add(&self) -> Word {
103        match self {
104            GasCostsValues::V1(v1) => v1.add,
105            GasCostsValues::V2(v2) => v2.add,
106            GasCostsValues::V3(v3) => v3.add,
107            GasCostsValues::V4(v4) => v4.add,
108            GasCostsValues::V5(v5) => v5.add,
109            GasCostsValues::V6(v6) => v6.add,
110            GasCostsValues::V7(v7) => v7.add,
111        }
112    }
113
114    pub fn addi(&self) -> Word {
115        match self {
116            GasCostsValues::V1(v1) => v1.addi,
117            GasCostsValues::V2(v2) => v2.addi,
118            GasCostsValues::V3(v3) => v3.addi,
119            GasCostsValues::V4(v4) => v4.addi,
120            GasCostsValues::V5(v5) => v5.addi,
121            GasCostsValues::V6(v6) => v6.addi,
122            GasCostsValues::V7(v7) => v7.addi,
123        }
124    }
125
126    pub fn and(&self) -> Word {
127        match self {
128            GasCostsValues::V1(v1) => v1.and,
129            GasCostsValues::V2(v2) => v2.and,
130            GasCostsValues::V3(v3) => v3.and,
131            GasCostsValues::V4(v4) => v4.and,
132            GasCostsValues::V5(v5) => v5.and,
133            GasCostsValues::V6(v6) => v6.and,
134            GasCostsValues::V7(v7) => v7.and,
135        }
136    }
137
138    pub fn andi(&self) -> Word {
139        match self {
140            GasCostsValues::V1(v1) => v1.andi,
141            GasCostsValues::V2(v2) => v2.andi,
142            GasCostsValues::V3(v3) => v3.andi,
143            GasCostsValues::V4(v4) => v4.andi,
144            GasCostsValues::V5(v5) => v5.andi,
145            GasCostsValues::V6(v6) => v6.andi,
146            GasCostsValues::V7(v7) => v7.andi,
147        }
148    }
149
150    pub fn bal(&self) -> Word {
151        match self {
152            GasCostsValues::V1(v1) => v1.bal,
153            GasCostsValues::V2(v2) => v2.bal,
154            GasCostsValues::V3(v3) => v3.bal,
155            GasCostsValues::V4(v4) => v4.bal,
156            GasCostsValues::V5(v5) => v5.bal,
157            GasCostsValues::V6(v6) => v6.bal,
158            GasCostsValues::V7(v7) => v7.bal,
159        }
160    }
161
162    pub fn bhei(&self) -> Word {
163        match self {
164            GasCostsValues::V1(v1) => v1.bhei,
165            GasCostsValues::V2(v2) => v2.bhei,
166            GasCostsValues::V3(v3) => v3.bhei,
167            GasCostsValues::V4(v4) => v4.bhei,
168            GasCostsValues::V5(v5) => v5.bhei,
169            GasCostsValues::V6(v6) => v6.bhei,
170            GasCostsValues::V7(v7) => v7.bhei,
171        }
172    }
173
174    pub fn bhsh(&self) -> Word {
175        match self {
176            GasCostsValues::V1(v1) => v1.bhsh,
177            GasCostsValues::V2(v2) => v2.bhsh,
178            GasCostsValues::V3(v3) => v3.bhsh,
179            GasCostsValues::V4(v4) => v4.bhsh,
180            GasCostsValues::V5(v5) => v5.bhsh,
181            GasCostsValues::V6(v6) => v6.bhsh,
182            GasCostsValues::V7(v7) => v7.bhsh,
183        }
184    }
185
186    pub fn burn(&self) -> Word {
187        match self {
188            GasCostsValues::V1(v1) => v1.burn,
189            GasCostsValues::V2(v2) => v2.burn,
190            GasCostsValues::V3(v3) => v3.burn,
191            GasCostsValues::V4(v4) => v4.burn,
192            GasCostsValues::V5(v5) => v5.burn,
193            GasCostsValues::V6(v6) => v6.burn,
194            GasCostsValues::V7(v7) => v7.burn,
195        }
196    }
197
198    pub fn cb(&self) -> Word {
199        match self {
200            GasCostsValues::V1(v1) => v1.cb,
201            GasCostsValues::V2(v2) => v2.cb,
202            GasCostsValues::V3(v3) => v3.cb,
203            GasCostsValues::V4(v4) => v4.cb,
204            GasCostsValues::V5(v5) => v5.cb,
205            GasCostsValues::V6(v6) => v6.cb,
206            GasCostsValues::V7(v7) => v7.cb,
207        }
208    }
209
210    pub fn cfsi(&self) -> Word {
211        match self {
212            GasCostsValues::V1(v1) => v1.cfsi,
213            GasCostsValues::V2(v2) => v2.cfsi,
214            GasCostsValues::V3(v3) => v3.cfsi,
215            GasCostsValues::V4(v4) => v4.cfsi,
216            GasCostsValues::V5(v5) => v5.cfsi,
217            GasCostsValues::V6(v6) => v6.cfsi,
218            GasCostsValues::V7(v7) => v7.cfsi,
219        }
220    }
221
222    pub fn div(&self) -> Word {
223        match self {
224            GasCostsValues::V1(v1) => v1.div,
225            GasCostsValues::V2(v2) => v2.div,
226            GasCostsValues::V3(v3) => v3.div,
227            GasCostsValues::V4(v4) => v4.div,
228            GasCostsValues::V5(v5) => v5.div,
229            GasCostsValues::V6(v6) => v6.div,
230            GasCostsValues::V7(v7) => v7.div,
231        }
232    }
233
234    pub fn divi(&self) -> Word {
235        match self {
236            GasCostsValues::V1(v1) => v1.divi,
237            GasCostsValues::V2(v2) => v2.divi,
238            GasCostsValues::V3(v3) => v3.divi,
239            GasCostsValues::V4(v4) => v4.divi,
240            GasCostsValues::V5(v5) => v5.divi,
241            GasCostsValues::V6(v6) => v6.divi,
242            GasCostsValues::V7(v7) => v7.divi,
243        }
244    }
245
246    pub fn eck1(&self) -> Word {
247        match self {
248            GasCostsValues::V1(v1) => v1.eck1,
249            GasCostsValues::V2(v2) => v2.eck1,
250            GasCostsValues::V3(v3) => v3.eck1,
251            GasCostsValues::V4(v4) => v4.eck1,
252            GasCostsValues::V5(v5) => v5.eck1,
253            GasCostsValues::V6(v6) => v6.eck1,
254            GasCostsValues::V7(v7) => v7.eck1,
255        }
256    }
257
258    pub fn ecr1(&self) -> Word {
259        match self {
260            GasCostsValues::V1(v1) => v1.ecr1,
261            GasCostsValues::V2(v2) => v2.ecr1,
262            GasCostsValues::V3(v3) => v3.ecr1,
263            GasCostsValues::V4(v4) => v4.ecr1,
264            GasCostsValues::V5(v5) => v5.ecr1,
265            GasCostsValues::V6(v6) => v6.ecr1,
266            GasCostsValues::V7(v7) => v7.ecr1,
267        }
268    }
269
270    pub fn eq_(&self) -> Word {
271        match self {
272            GasCostsValues::V1(v1) => v1.eq,
273            GasCostsValues::V2(v2) => v2.eq,
274            GasCostsValues::V3(v3) => v3.eq,
275            GasCostsValues::V4(v4) => v4.eq,
276            GasCostsValues::V5(v5) => v5.eq,
277            GasCostsValues::V6(v6) => v6.eq,
278            GasCostsValues::V7(v7) => v7.eq,
279        }
280    }
281
282    pub fn exp(&self) -> Word {
283        match self {
284            GasCostsValues::V1(v1) => v1.exp,
285            GasCostsValues::V2(v2) => v2.exp,
286            GasCostsValues::V3(v3) => v3.exp,
287            GasCostsValues::V4(v4) => v4.exp,
288            GasCostsValues::V5(v5) => v5.exp,
289            GasCostsValues::V6(v6) => v6.exp,
290            GasCostsValues::V7(v7) => v7.exp,
291        }
292    }
293
294    pub fn expi(&self) -> Word {
295        match self {
296            GasCostsValues::V1(v1) => v1.expi,
297            GasCostsValues::V2(v2) => v2.expi,
298            GasCostsValues::V3(v3) => v3.expi,
299            GasCostsValues::V4(v4) => v4.expi,
300            GasCostsValues::V5(v5) => v5.expi,
301            GasCostsValues::V6(v6) => v6.expi,
302            GasCostsValues::V7(v7) => v7.expi,
303        }
304    }
305
306    pub fn flag(&self) -> Word {
307        match self {
308            GasCostsValues::V1(v1) => v1.flag,
309            GasCostsValues::V2(v2) => v2.flag,
310            GasCostsValues::V3(v3) => v3.flag,
311            GasCostsValues::V4(v4) => v4.flag,
312            GasCostsValues::V5(v5) => v5.flag,
313            GasCostsValues::V6(v6) => v6.flag,
314            GasCostsValues::V7(v7) => v7.flag,
315        }
316    }
317
318    pub fn gm(&self) -> Word {
319        match self {
320            GasCostsValues::V1(v1) => v1.gm,
321            GasCostsValues::V2(v2) => v2.gm,
322            GasCostsValues::V3(v3) => v3.gm,
323            GasCostsValues::V4(v4) => v4.gm,
324            GasCostsValues::V5(v5) => v5.gm,
325            GasCostsValues::V6(v6) => v6.gm,
326            GasCostsValues::V7(v7) => v7.gm,
327        }
328    }
329
330    pub fn gt(&self) -> Word {
331        match self {
332            GasCostsValues::V1(v1) => v1.gt,
333            GasCostsValues::V2(v2) => v2.gt,
334            GasCostsValues::V3(v3) => v3.gt,
335            GasCostsValues::V4(v4) => v4.gt,
336            GasCostsValues::V5(v5) => v5.gt,
337            GasCostsValues::V6(v6) => v6.gt,
338            GasCostsValues::V7(v7) => v7.gt,
339        }
340    }
341
342    pub fn gtf(&self) -> Word {
343        match self {
344            GasCostsValues::V1(v1) => v1.gtf,
345            GasCostsValues::V2(v2) => v2.gtf,
346            GasCostsValues::V3(v3) => v3.gtf,
347            GasCostsValues::V4(v4) => v4.gtf,
348            GasCostsValues::V5(v5) => v5.gtf,
349            GasCostsValues::V6(v6) => v6.gtf,
350            GasCostsValues::V7(v7) => v7.gtf,
351        }
352    }
353
354    pub fn ji(&self) -> Word {
355        match self {
356            GasCostsValues::V1(v1) => v1.ji,
357            GasCostsValues::V2(v2) => v2.ji,
358            GasCostsValues::V3(v3) => v3.ji,
359            GasCostsValues::V4(v4) => v4.ji,
360            GasCostsValues::V5(v5) => v5.ji,
361            GasCostsValues::V6(v6) => v6.ji,
362            GasCostsValues::V7(v7) => v7.ji,
363        }
364    }
365
366    pub fn jmp(&self) -> Word {
367        match self {
368            GasCostsValues::V1(v1) => v1.jmp,
369            GasCostsValues::V2(v2) => v2.jmp,
370            GasCostsValues::V3(v3) => v3.jmp,
371            GasCostsValues::V4(v4) => v4.jmp,
372            GasCostsValues::V5(v5) => v5.jmp,
373            GasCostsValues::V6(v6) => v6.jmp,
374            GasCostsValues::V7(v7) => v7.jmp,
375        }
376    }
377
378    pub fn jne(&self) -> Word {
379        match self {
380            GasCostsValues::V1(v1) => v1.jne,
381            GasCostsValues::V2(v2) => v2.jne,
382            GasCostsValues::V3(v3) => v3.jne,
383            GasCostsValues::V4(v4) => v4.jne,
384            GasCostsValues::V5(v5) => v5.jne,
385            GasCostsValues::V6(v6) => v6.jne,
386            GasCostsValues::V7(v7) => v7.jne,
387        }
388    }
389
390    pub fn jnei(&self) -> Word {
391        match self {
392            GasCostsValues::V1(v1) => v1.jnei,
393            GasCostsValues::V2(v2) => v2.jnei,
394            GasCostsValues::V3(v3) => v3.jnei,
395            GasCostsValues::V4(v4) => v4.jnei,
396            GasCostsValues::V5(v5) => v5.jnei,
397            GasCostsValues::V6(v6) => v6.jnei,
398            GasCostsValues::V7(v7) => v7.jnei,
399        }
400    }
401
402    pub fn jnzi(&self) -> Word {
403        match self {
404            GasCostsValues::V1(v1) => v1.jnzi,
405            GasCostsValues::V2(v2) => v2.jnzi,
406            GasCostsValues::V3(v3) => v3.jnzi,
407            GasCostsValues::V4(v4) => v4.jnzi,
408            GasCostsValues::V5(v5) => v5.jnzi,
409            GasCostsValues::V6(v6) => v6.jnzi,
410            GasCostsValues::V7(v7) => v7.jnzi,
411        }
412    }
413
414    pub fn jmpf(&self) -> Word {
415        match self {
416            GasCostsValues::V1(v1) => v1.jmpf,
417            GasCostsValues::V2(v2) => v2.jmpf,
418            GasCostsValues::V3(v3) => v3.jmpf,
419            GasCostsValues::V4(v4) => v4.jmpf,
420            GasCostsValues::V5(v5) => v5.jmpf,
421            GasCostsValues::V6(v6) => v6.jmpf,
422            GasCostsValues::V7(v7) => v7.jmpf,
423        }
424    }
425
426    pub fn jmpb(&self) -> Word {
427        match self {
428            GasCostsValues::V1(v1) => v1.jmpb,
429            GasCostsValues::V2(v2) => v2.jmpb,
430            GasCostsValues::V3(v3) => v3.jmpb,
431            GasCostsValues::V4(v4) => v4.jmpb,
432            GasCostsValues::V5(v5) => v5.jmpb,
433            GasCostsValues::V6(v6) => v6.jmpb,
434            GasCostsValues::V7(v7) => v7.jmpb,
435        }
436    }
437
438    pub fn jnzf(&self) -> Word {
439        match self {
440            GasCostsValues::V1(v1) => v1.jnzf,
441            GasCostsValues::V2(v2) => v2.jnzf,
442            GasCostsValues::V3(v3) => v3.jnzf,
443            GasCostsValues::V4(v4) => v4.jnzf,
444            GasCostsValues::V5(v5) => v5.jnzf,
445            GasCostsValues::V6(v6) => v6.jnzf,
446            GasCostsValues::V7(v7) => v7.jnzf,
447        }
448    }
449
450    pub fn jnzb(&self) -> Word {
451        match self {
452            GasCostsValues::V1(v1) => v1.jnzb,
453            GasCostsValues::V2(v2) => v2.jnzb,
454            GasCostsValues::V3(v3) => v3.jnzb,
455            GasCostsValues::V4(v4) => v4.jnzb,
456            GasCostsValues::V5(v5) => v5.jnzb,
457            GasCostsValues::V6(v6) => v6.jnzb,
458            GasCostsValues::V7(v7) => v7.jnzb,
459        }
460    }
461
462    pub fn jnef(&self) -> Word {
463        match self {
464            GasCostsValues::V1(v1) => v1.jnef,
465            GasCostsValues::V2(v2) => v2.jnef,
466            GasCostsValues::V3(v3) => v3.jnef,
467            GasCostsValues::V4(v4) => v4.jnef,
468            GasCostsValues::V5(v5) => v5.jnef,
469            GasCostsValues::V6(v6) => v6.jnef,
470            GasCostsValues::V7(v7) => v7.jnef,
471        }
472    }
473
474    pub fn jneb(&self) -> Word {
475        match self {
476            GasCostsValues::V1(v1) => v1.jneb,
477            GasCostsValues::V2(v2) => v2.jneb,
478            GasCostsValues::V3(v3) => v3.jneb,
479            GasCostsValues::V4(v4) => v4.jneb,
480            GasCostsValues::V5(v5) => v5.jneb,
481            GasCostsValues::V6(v6) => v6.jneb,
482            GasCostsValues::V7(v7) => v7.jneb,
483        }
484    }
485
486    pub fn lb(&self) -> Word {
487        match self {
488            GasCostsValues::V1(v1) => v1.lb,
489            GasCostsValues::V2(v2) => v2.lb,
490            GasCostsValues::V3(v3) => v3.lb,
491            GasCostsValues::V4(v4) => v4.lb,
492            GasCostsValues::V5(v5) => v5.lb,
493            GasCostsValues::V6(v6) => v6.lb,
494            GasCostsValues::V7(v7) => v7.lb,
495        }
496    }
497
498    pub fn log(&self) -> Word {
499        match self {
500            GasCostsValues::V1(v1) => v1.log,
501            GasCostsValues::V2(v2) => v2.log,
502            GasCostsValues::V3(v3) => v3.log,
503            GasCostsValues::V4(v4) => v4.log,
504            GasCostsValues::V5(v5) => v5.log,
505            GasCostsValues::V6(v6) => v6.log,
506            GasCostsValues::V7(v7) => v7.log,
507        }
508    }
509
510    pub fn lt(&self) -> Word {
511        match self {
512            GasCostsValues::V1(v1) => v1.lt,
513            GasCostsValues::V2(v2) => v2.lt,
514            GasCostsValues::V3(v3) => v3.lt,
515            GasCostsValues::V4(v4) => v4.lt,
516            GasCostsValues::V5(v5) => v5.lt,
517            GasCostsValues::V6(v6) => v6.lt,
518            GasCostsValues::V7(v7) => v7.lt,
519        }
520    }
521
522    pub fn lw(&self) -> Word {
523        match self {
524            GasCostsValues::V1(v1) => v1.lw,
525            GasCostsValues::V2(v2) => v2.lw,
526            GasCostsValues::V3(v3) => v3.lw,
527            GasCostsValues::V4(v4) => v4.lw,
528            GasCostsValues::V5(v5) => v5.lw,
529            GasCostsValues::V6(v6) => v6.lw,
530            GasCostsValues::V7(v7) => v7.lw,
531        }
532    }
533
534    pub fn mint(&self) -> Word {
535        match self {
536            GasCostsValues::V1(v1) => v1.mint,
537            GasCostsValues::V2(v2) => v2.mint,
538            GasCostsValues::V3(v3) => v3.mint,
539            GasCostsValues::V4(v4) => v4.mint,
540            GasCostsValues::V5(v5) => v5.mint,
541            GasCostsValues::V6(v6) => v6.mint,
542            GasCostsValues::V7(v7) => v7.mint,
543        }
544    }
545
546    pub fn mlog(&self) -> Word {
547        match self {
548            GasCostsValues::V1(v1) => v1.mlog,
549            GasCostsValues::V2(v2) => v2.mlog,
550            GasCostsValues::V3(v3) => v3.mlog,
551            GasCostsValues::V4(v4) => v4.mlog,
552            GasCostsValues::V5(v5) => v5.mlog,
553            GasCostsValues::V6(v6) => v6.mlog,
554            GasCostsValues::V7(v7) => v7.mlog,
555        }
556    }
557
558    pub fn mod_op(&self) -> Word {
559        match self {
560            GasCostsValues::V1(v1) => v1.mod_op,
561            GasCostsValues::V2(v2) => v2.mod_op,
562            GasCostsValues::V3(v3) => v3.mod_op,
563            GasCostsValues::V4(v4) => v4.mod_op,
564            GasCostsValues::V5(v5) => v5.mod_op,
565            GasCostsValues::V6(v6) => v6.mod_op,
566            GasCostsValues::V7(v7) => v7.mod_op,
567        }
568    }
569
570    pub fn modi(&self) -> Word {
571        match self {
572            GasCostsValues::V1(v1) => v1.modi,
573            GasCostsValues::V2(v2) => v2.modi,
574            GasCostsValues::V3(v3) => v3.modi,
575            GasCostsValues::V4(v4) => v4.modi,
576            GasCostsValues::V5(v5) => v5.modi,
577            GasCostsValues::V6(v6) => v6.modi,
578            GasCostsValues::V7(v7) => v7.modi,
579        }
580    }
581
582    pub fn move_op(&self) -> Word {
583        match self {
584            GasCostsValues::V1(v1) => v1.move_op,
585            GasCostsValues::V2(v2) => v2.move_op,
586            GasCostsValues::V3(v3) => v3.move_op,
587            GasCostsValues::V4(v4) => v4.move_op,
588            GasCostsValues::V5(v5) => v5.move_op,
589            GasCostsValues::V6(v6) => v6.move_op,
590            GasCostsValues::V7(v7) => v7.move_op,
591        }
592    }
593
594    pub fn movi(&self) -> Word {
595        match self {
596            GasCostsValues::V1(v1) => v1.movi,
597            GasCostsValues::V2(v2) => v2.movi,
598            GasCostsValues::V3(v3) => v3.movi,
599            GasCostsValues::V4(v4) => v4.movi,
600            GasCostsValues::V5(v5) => v5.movi,
601            GasCostsValues::V6(v6) => v6.movi,
602            GasCostsValues::V7(v7) => v7.movi,
603        }
604    }
605
606    pub fn mroo(&self) -> Word {
607        match self {
608            GasCostsValues::V1(v1) => v1.mroo,
609            GasCostsValues::V2(v2) => v2.mroo,
610            GasCostsValues::V3(v3) => v3.mroo,
611            GasCostsValues::V4(v4) => v4.mroo,
612            GasCostsValues::V5(v5) => v5.mroo,
613            GasCostsValues::V6(v6) => v6.mroo,
614            GasCostsValues::V7(v7) => v7.mroo,
615        }
616    }
617
618    pub fn mul(&self) -> Word {
619        match self {
620            GasCostsValues::V1(v1) => v1.mul,
621            GasCostsValues::V2(v2) => v2.mul,
622            GasCostsValues::V3(v3) => v3.mul,
623            GasCostsValues::V4(v4) => v4.mul,
624            GasCostsValues::V5(v5) => v5.mul,
625            GasCostsValues::V6(v6) => v6.mul,
626            GasCostsValues::V7(v7) => v7.mul,
627        }
628    }
629
630    pub fn muli(&self) -> Word {
631        match self {
632            GasCostsValues::V1(v1) => v1.muli,
633            GasCostsValues::V2(v2) => v2.muli,
634            GasCostsValues::V3(v3) => v3.muli,
635            GasCostsValues::V4(v4) => v4.muli,
636            GasCostsValues::V5(v5) => v5.muli,
637            GasCostsValues::V6(v6) => v6.muli,
638            GasCostsValues::V7(v7) => v7.muli,
639        }
640    }
641
642    pub fn mldv(&self) -> Word {
643        match self {
644            GasCostsValues::V1(v1) => v1.mldv,
645            GasCostsValues::V2(v2) => v2.mldv,
646            GasCostsValues::V3(v3) => v3.mldv,
647            GasCostsValues::V4(v4) => v4.mldv,
648            GasCostsValues::V5(v5) => v5.mldv,
649            GasCostsValues::V6(v6) => v6.mldv,
650            GasCostsValues::V7(v7) => v7.mldv,
651        }
652    }
653
654    pub fn niop(&self) -> Result<Word, GasCostNotDefined> {
655        match self {
656            GasCostsValues::V1(_) => Err(GasCostNotDefined),
657            GasCostsValues::V2(_) => Err(GasCostNotDefined),
658            GasCostsValues::V3(_) => Err(GasCostNotDefined),
659            GasCostsValues::V4(_) => Err(GasCostNotDefined),
660            GasCostsValues::V5(_) => Err(GasCostNotDefined),
661            GasCostsValues::V6(v6) => Ok(v6.niop),
662            GasCostsValues::V7(v7) => Ok(v7.niop),
663        }
664    }
665
666    pub fn noop(&self) -> Word {
667        match self {
668            GasCostsValues::V1(v1) => v1.noop,
669            GasCostsValues::V2(v2) => v2.noop,
670            GasCostsValues::V3(v3) => v3.noop,
671            GasCostsValues::V4(v4) => v4.noop,
672            GasCostsValues::V5(v5) => v5.noop,
673            GasCostsValues::V6(v6) => v6.noop,
674            GasCostsValues::V7(v7) => v7.noop,
675        }
676    }
677
678    pub fn not(&self) -> Word {
679        match self {
680            GasCostsValues::V1(v1) => v1.not,
681            GasCostsValues::V2(v2) => v2.not,
682            GasCostsValues::V3(v3) => v3.not,
683            GasCostsValues::V4(v4) => v4.not,
684            GasCostsValues::V5(v5) => v5.not,
685            GasCostsValues::V6(v6) => v6.not,
686            GasCostsValues::V7(v7) => v7.not,
687        }
688    }
689
690    pub fn or(&self) -> Word {
691        match self {
692            GasCostsValues::V1(v1) => v1.or,
693            GasCostsValues::V2(v2) => v2.or,
694            GasCostsValues::V3(v3) => v3.or,
695            GasCostsValues::V4(v4) => v4.or,
696            GasCostsValues::V5(v5) => v5.or,
697            GasCostsValues::V6(v6) => v6.or,
698            GasCostsValues::V7(v7) => v7.or,
699        }
700    }
701
702    pub fn ori(&self) -> Word {
703        match self {
704            GasCostsValues::V1(v1) => v1.ori,
705            GasCostsValues::V2(v2) => v2.ori,
706            GasCostsValues::V3(v3) => v3.ori,
707            GasCostsValues::V4(v4) => v4.ori,
708            GasCostsValues::V5(v5) => v5.ori,
709            GasCostsValues::V6(v6) => v6.ori,
710            GasCostsValues::V7(v7) => v7.ori,
711        }
712    }
713
714    pub fn poph(&self) -> Word {
715        match self {
716            GasCostsValues::V1(v1) => v1.poph,
717            GasCostsValues::V2(v2) => v2.poph,
718            GasCostsValues::V3(v3) => v3.poph,
719            GasCostsValues::V4(v4) => v4.poph,
720            GasCostsValues::V5(v5) => v5.poph,
721            GasCostsValues::V6(v6) => v6.poph,
722            GasCostsValues::V7(v7) => v7.poph,
723        }
724    }
725
726    pub fn popl(&self) -> Word {
727        match self {
728            GasCostsValues::V1(v1) => v1.popl,
729            GasCostsValues::V2(v2) => v2.popl,
730            GasCostsValues::V3(v3) => v3.popl,
731            GasCostsValues::V4(v4) => v4.popl,
732            GasCostsValues::V5(v5) => v5.popl,
733            GasCostsValues::V6(v6) => v6.popl,
734            GasCostsValues::V7(v7) => v7.popl,
735        }
736    }
737
738    pub fn pshh(&self) -> Word {
739        match self {
740            GasCostsValues::V1(v1) => v1.pshh,
741            GasCostsValues::V2(v2) => v2.pshh,
742            GasCostsValues::V3(v3) => v3.pshh,
743            GasCostsValues::V4(v4) => v4.pshh,
744            GasCostsValues::V5(v5) => v5.pshh,
745            GasCostsValues::V6(v6) => v6.pshh,
746            GasCostsValues::V7(v7) => v7.pshh,
747        }
748    }
749
750    pub fn pshl(&self) -> Word {
751        match self {
752            GasCostsValues::V1(v1) => v1.pshl,
753            GasCostsValues::V2(v2) => v2.pshl,
754            GasCostsValues::V3(v3) => v3.pshl,
755            GasCostsValues::V4(v4) => v4.pshl,
756            GasCostsValues::V5(v5) => v5.pshl,
757            GasCostsValues::V6(v6) => v6.pshl,
758            GasCostsValues::V7(v7) => v7.pshl,
759        }
760    }
761
762    pub fn ret(&self) -> Word {
763        match self {
764            GasCostsValues::V1(v1) => v1.ret,
765            GasCostsValues::V2(v2) => v2.ret,
766            GasCostsValues::V3(v3) => v3.ret,
767            GasCostsValues::V4(v4) => v4.ret,
768            GasCostsValues::V5(v5) => v5.ret,
769            GasCostsValues::V6(v6) => v6.ret,
770            GasCostsValues::V7(v7) => v7.ret,
771        }
772    }
773
774    pub fn rvrt(&self) -> Word {
775        match self {
776            GasCostsValues::V1(v1) => v1.rvrt,
777            GasCostsValues::V2(v2) => v2.rvrt,
778            GasCostsValues::V3(v3) => v3.rvrt,
779            GasCostsValues::V4(v4) => v4.rvrt,
780            GasCostsValues::V5(v5) => v5.rvrt,
781            GasCostsValues::V6(v6) => v6.rvrt,
782            GasCostsValues::V7(v7) => v7.rvrt,
783        }
784    }
785
786    pub fn sb(&self) -> Word {
787        match self {
788            GasCostsValues::V1(v1) => v1.sb,
789            GasCostsValues::V2(v2) => v2.sb,
790            GasCostsValues::V3(v3) => v3.sb,
791            GasCostsValues::V4(v4) => v4.sb,
792            GasCostsValues::V5(v5) => v5.sb,
793            GasCostsValues::V6(v6) => v6.sb,
794            GasCostsValues::V7(v7) => v7.sb,
795        }
796    }
797
798    pub fn sll(&self) -> Word {
799        match self {
800            GasCostsValues::V1(v1) => v1.sll,
801            GasCostsValues::V2(v2) => v2.sll,
802            GasCostsValues::V3(v3) => v3.sll,
803            GasCostsValues::V4(v4) => v4.sll,
804            GasCostsValues::V5(v5) => v5.sll,
805            GasCostsValues::V6(v6) => v6.sll,
806            GasCostsValues::V7(v7) => v7.sll,
807        }
808    }
809
810    pub fn slli(&self) -> Word {
811        match self {
812            GasCostsValues::V1(v1) => v1.slli,
813            GasCostsValues::V2(v2) => v2.slli,
814            GasCostsValues::V3(v3) => v3.slli,
815            GasCostsValues::V4(v4) => v4.slli,
816            GasCostsValues::V5(v5) => v5.slli,
817            GasCostsValues::V6(v6) => v6.slli,
818            GasCostsValues::V7(v7) => v7.slli,
819        }
820    }
821
822    pub fn srl(&self) -> Word {
823        match self {
824            GasCostsValues::V1(v1) => v1.srl,
825            GasCostsValues::V2(v2) => v2.srl,
826            GasCostsValues::V3(v3) => v3.srl,
827            GasCostsValues::V4(v4) => v4.srl,
828            GasCostsValues::V5(v5) => v5.srl,
829            GasCostsValues::V6(v6) => v6.srl,
830            GasCostsValues::V7(v7) => v7.srl,
831        }
832    }
833
834    pub fn srli(&self) -> Word {
835        match self {
836            GasCostsValues::V1(v1) => v1.srli,
837            GasCostsValues::V2(v2) => v2.srli,
838            GasCostsValues::V3(v3) => v3.srli,
839            GasCostsValues::V4(v4) => v4.srli,
840            GasCostsValues::V5(v5) => v5.srli,
841            GasCostsValues::V6(v6) => v6.srli,
842            GasCostsValues::V7(v7) => v7.srli,
843        }
844    }
845
846    pub fn srw(&self) -> Result<Word, GasCostNotDefined> {
847        match self {
848            GasCostsValues::V1(v1) => Ok(v1.srw),
849            GasCostsValues::V2(v2) => Ok(v2.srw),
850            GasCostsValues::V3(v3) => Ok(v3.srw),
851            GasCostsValues::V4(v4) => Ok(v4.srw),
852            GasCostsValues::V5(v5) => Ok(v5.srw),
853            GasCostsValues::V6(v6) => Ok(v6.srw),
854            GasCostsValues::V7(_) => Err(GasCostNotDefined),
855        }
856    }
857
858    pub fn sub(&self) -> Word {
859        match self {
860            GasCostsValues::V1(v1) => v1.sub,
861            GasCostsValues::V2(v2) => v2.sub,
862            GasCostsValues::V3(v3) => v3.sub,
863            GasCostsValues::V4(v4) => v4.sub,
864            GasCostsValues::V5(v5) => v5.sub,
865            GasCostsValues::V6(v6) => v6.sub,
866            GasCostsValues::V7(v7) => v7.sub,
867        }
868    }
869
870    pub fn subi(&self) -> Word {
871        match self {
872            GasCostsValues::V1(v1) => v1.subi,
873            GasCostsValues::V2(v2) => v2.subi,
874            GasCostsValues::V3(v3) => v3.subi,
875            GasCostsValues::V4(v4) => v4.subi,
876            GasCostsValues::V5(v5) => v5.subi,
877            GasCostsValues::V6(v6) => v6.subi,
878            GasCostsValues::V7(v7) => v7.subi,
879        }
880    }
881
882    pub fn sw(&self) -> Word {
883        match self {
884            GasCostsValues::V1(v1) => v1.sw,
885            GasCostsValues::V2(v2) => v2.sw,
886            GasCostsValues::V3(v3) => v3.sw,
887            GasCostsValues::V4(v4) => v4.sw,
888            GasCostsValues::V5(v5) => v5.sw,
889            GasCostsValues::V6(v6) => v6.sw,
890            GasCostsValues::V7(v7) => v7.sw,
891        }
892    }
893
894    pub fn sww(&self) -> Result<Word, GasCostNotDefined> {
895        match self {
896            GasCostsValues::V1(v1) => Ok(v1.sww),
897            GasCostsValues::V2(v2) => Ok(v2.sww),
898            GasCostsValues::V3(v3) => Ok(v3.sww),
899            GasCostsValues::V4(v4) => Ok(v4.sww),
900            GasCostsValues::V5(v5) => Ok(v5.sww),
901            GasCostsValues::V6(v6) => Ok(v6.sww),
902            GasCostsValues::V7(_) => Err(GasCostNotDefined),
903        }
904    }
905
906    pub fn time(&self) -> Word {
907        match self {
908            GasCostsValues::V1(v1) => v1.time,
909            GasCostsValues::V2(v2) => v2.time,
910            GasCostsValues::V3(v3) => v3.time,
911            GasCostsValues::V4(v4) => v4.time,
912            GasCostsValues::V5(v5) => v5.time,
913            GasCostsValues::V6(v6) => v6.time,
914            GasCostsValues::V7(v7) => v7.time,
915        }
916    }
917
918    pub fn tr(&self) -> Word {
919        match self {
920            GasCostsValues::V1(v1) => v1.tr,
921            GasCostsValues::V2(v2) => v2.tr,
922            GasCostsValues::V3(v3) => v3.tr,
923            GasCostsValues::V4(v4) => v4.tr,
924            GasCostsValues::V5(v5) => v5.tr,
925            GasCostsValues::V6(v6) => v6.tr,
926            GasCostsValues::V7(v7) => v7.tr,
927        }
928    }
929
930    pub fn tro(&self) -> Word {
931        match self {
932            GasCostsValues::V1(v1) => v1.tro,
933            GasCostsValues::V2(v2) => v2.tro,
934            GasCostsValues::V3(v3) => v3.tro,
935            GasCostsValues::V4(v4) => v4.tro,
936            GasCostsValues::V5(v5) => v5.tro,
937            GasCostsValues::V6(v6) => v6.tro,
938            GasCostsValues::V7(v7) => v7.tro,
939        }
940    }
941
942    pub fn wdcm(&self) -> Word {
943        match self {
944            GasCostsValues::V1(v1) => v1.wdcm,
945            GasCostsValues::V2(v2) => v2.wdcm,
946            GasCostsValues::V3(v3) => v3.wdcm,
947            GasCostsValues::V4(v4) => v4.wdcm,
948            GasCostsValues::V5(v5) => v5.wdcm,
949            GasCostsValues::V6(v6) => v6.wdcm,
950            GasCostsValues::V7(v7) => v7.wdcm,
951        }
952    }
953
954    pub fn wqcm(&self) -> Word {
955        match self {
956            GasCostsValues::V1(v1) => v1.wqcm,
957            GasCostsValues::V2(v2) => v2.wqcm,
958            GasCostsValues::V3(v3) => v3.wqcm,
959            GasCostsValues::V4(v4) => v4.wqcm,
960            GasCostsValues::V5(v5) => v5.wqcm,
961            GasCostsValues::V6(v6) => v6.wqcm,
962            GasCostsValues::V7(v7) => v7.wqcm,
963        }
964    }
965
966    pub fn wdop(&self) -> Word {
967        match self {
968            GasCostsValues::V1(v1) => v1.wdop,
969            GasCostsValues::V2(v2) => v2.wdop,
970            GasCostsValues::V3(v3) => v3.wdop,
971            GasCostsValues::V4(v4) => v4.wdop,
972            GasCostsValues::V5(v5) => v5.wdop,
973            GasCostsValues::V6(v6) => v6.wdop,
974            GasCostsValues::V7(v7) => v7.wdop,
975        }
976    }
977
978    pub fn wqop(&self) -> Word {
979        match self {
980            GasCostsValues::V1(v1) => v1.wqop,
981            GasCostsValues::V2(v2) => v2.wqop,
982            GasCostsValues::V3(v3) => v3.wqop,
983            GasCostsValues::V4(v4) => v4.wqop,
984            GasCostsValues::V5(v5) => v5.wqop,
985            GasCostsValues::V6(v6) => v6.wqop,
986            GasCostsValues::V7(v7) => v7.wqop,
987        }
988    }
989
990    pub fn wdml(&self) -> Word {
991        match self {
992            GasCostsValues::V1(v1) => v1.wdml,
993            GasCostsValues::V2(v2) => v2.wdml,
994            GasCostsValues::V3(v3) => v3.wdml,
995            GasCostsValues::V4(v4) => v4.wdml,
996            GasCostsValues::V5(v5) => v5.wdml,
997            GasCostsValues::V6(v6) => v6.wdml,
998            GasCostsValues::V7(v7) => v7.wdml,
999        }
1000    }
1001
1002    pub fn wqml(&self) -> Word {
1003        match self {
1004            GasCostsValues::V1(v1) => v1.wqml,
1005            GasCostsValues::V2(v2) => v2.wqml,
1006            GasCostsValues::V3(v3) => v3.wqml,
1007            GasCostsValues::V4(v4) => v4.wqml,
1008            GasCostsValues::V5(v5) => v5.wqml,
1009            GasCostsValues::V6(v6) => v6.wqml,
1010            GasCostsValues::V7(v7) => v7.wqml,
1011        }
1012    }
1013
1014    pub fn wddv(&self) -> Word {
1015        match self {
1016            GasCostsValues::V1(v1) => v1.wddv,
1017            GasCostsValues::V2(v2) => v2.wddv,
1018            GasCostsValues::V3(v3) => v3.wddv,
1019            GasCostsValues::V4(v4) => v4.wddv,
1020            GasCostsValues::V5(v5) => v5.wddv,
1021            GasCostsValues::V6(v6) => v6.wddv,
1022            GasCostsValues::V7(v7) => v7.wddv,
1023        }
1024    }
1025
1026    pub fn wqdv(&self) -> Word {
1027        match self {
1028            GasCostsValues::V1(v1) => v1.wqdv,
1029            GasCostsValues::V2(v2) => v2.wqdv,
1030            GasCostsValues::V3(v3) => v3.wqdv,
1031            GasCostsValues::V4(v4) => v4.wqdv,
1032            GasCostsValues::V5(v5) => v5.wqdv,
1033            GasCostsValues::V6(v6) => v6.wqdv,
1034            GasCostsValues::V7(v7) => v7.wqdv,
1035        }
1036    }
1037
1038    pub fn wdmd(&self) -> Word {
1039        match self {
1040            GasCostsValues::V1(v1) => v1.wdmd,
1041            GasCostsValues::V2(v2) => v2.wdmd,
1042            GasCostsValues::V3(v3) => v3.wdmd,
1043            GasCostsValues::V4(v4) => v4.wdmd,
1044            GasCostsValues::V5(v5) => v5.wdmd,
1045            GasCostsValues::V6(v6) => v6.wdmd,
1046            GasCostsValues::V7(v7) => v7.wdmd,
1047        }
1048    }
1049
1050    pub fn wqmd(&self) -> Word {
1051        match self {
1052            GasCostsValues::V1(v1) => v1.wqmd,
1053            GasCostsValues::V2(v2) => v2.wqmd,
1054            GasCostsValues::V3(v3) => v3.wqmd,
1055            GasCostsValues::V4(v4) => v4.wqmd,
1056            GasCostsValues::V5(v5) => v5.wqmd,
1057            GasCostsValues::V6(v6) => v6.wqmd,
1058            GasCostsValues::V7(v7) => v7.wqmd,
1059        }
1060    }
1061
1062    pub fn wdam(&self) -> Word {
1063        match self {
1064            GasCostsValues::V1(v1) => v1.wdam,
1065            GasCostsValues::V2(v2) => v2.wdam,
1066            GasCostsValues::V3(v3) => v3.wdam,
1067            GasCostsValues::V4(v4) => v4.wdam,
1068            GasCostsValues::V5(v5) => v5.wdam,
1069            GasCostsValues::V6(v6) => v6.wdam,
1070            GasCostsValues::V7(v7) => v7.wdam,
1071        }
1072    }
1073
1074    pub fn wqam(&self) -> Word {
1075        match self {
1076            GasCostsValues::V1(v1) => v1.wqam,
1077            GasCostsValues::V2(v2) => v2.wqam,
1078            GasCostsValues::V3(v3) => v3.wqam,
1079            GasCostsValues::V4(v4) => v4.wqam,
1080            GasCostsValues::V5(v5) => v5.wqam,
1081            GasCostsValues::V6(v6) => v6.wqam,
1082            GasCostsValues::V7(v7) => v7.wqam,
1083        }
1084    }
1085
1086    pub fn wdmm(&self) -> Word {
1087        match self {
1088            GasCostsValues::V1(v1) => v1.wdmm,
1089            GasCostsValues::V2(v2) => v2.wdmm,
1090            GasCostsValues::V3(v3) => v3.wdmm,
1091            GasCostsValues::V4(v4) => v4.wdmm,
1092            GasCostsValues::V5(v5) => v5.wdmm,
1093            GasCostsValues::V6(v6) => v6.wdmm,
1094            GasCostsValues::V7(v7) => v7.wdmm,
1095        }
1096    }
1097
1098    pub fn wqmm(&self) -> Word {
1099        match self {
1100            GasCostsValues::V1(v1) => v1.wqmm,
1101            GasCostsValues::V2(v2) => v2.wqmm,
1102            GasCostsValues::V3(v3) => v3.wqmm,
1103            GasCostsValues::V4(v4) => v4.wqmm,
1104            GasCostsValues::V5(v5) => v5.wqmm,
1105            GasCostsValues::V6(v6) => v6.wqmm,
1106            GasCostsValues::V7(v7) => v7.wqmm,
1107        }
1108    }
1109
1110    pub fn xor(&self) -> Word {
1111        match self {
1112            GasCostsValues::V1(v1) => v1.xor,
1113            GasCostsValues::V2(v2) => v2.xor,
1114            GasCostsValues::V3(v3) => v3.xor,
1115            GasCostsValues::V4(v4) => v4.xor,
1116            GasCostsValues::V5(v5) => v5.xor,
1117            GasCostsValues::V6(v6) => v6.xor,
1118            GasCostsValues::V7(v7) => v7.xor,
1119        }
1120    }
1121
1122    pub fn xori(&self) -> Word {
1123        match self {
1124            GasCostsValues::V1(v1) => v1.xori,
1125            GasCostsValues::V2(v2) => v2.xori,
1126            GasCostsValues::V3(v3) => v3.xori,
1127            GasCostsValues::V4(v4) => v4.xori,
1128            GasCostsValues::V5(v5) => v5.xori,
1129            GasCostsValues::V6(v6) => v6.xori,
1130            GasCostsValues::V7(v7) => v7.xori,
1131        }
1132    }
1133
1134    pub fn ecop(&self) -> Result<Word, GasCostNotDefined> {
1135        match self {
1136            GasCostsValues::V1(_) => Err(GasCostNotDefined),
1137            GasCostsValues::V2(_) => Err(GasCostNotDefined),
1138            GasCostsValues::V3(_) => Err(GasCostNotDefined),
1139            GasCostsValues::V4(_) => Err(GasCostNotDefined),
1140            GasCostsValues::V5(v5) => Ok(v5.ecop),
1141            GasCostsValues::V6(v6) => Ok(v6.ecop),
1142            GasCostsValues::V7(v7) => Ok(v7.ecop),
1143        }
1144    }
1145
1146    pub fn aloc(&self) -> DependentCost {
1147        match self {
1148            GasCostsValues::V1(v1) => DependentCost::HeavyOperation {
1149                base: v1.aloc,
1150                gas_per_unit: 0,
1151            },
1152            GasCostsValues::V2(v2) => v2.aloc,
1153            GasCostsValues::V3(v3) => v3.aloc,
1154            GasCostsValues::V4(v4) => v4.aloc,
1155            GasCostsValues::V5(v5) => v5.aloc,
1156            GasCostsValues::V6(v6) => v6.aloc,
1157            GasCostsValues::V7(v7) => v7.aloc,
1158        }
1159    }
1160
1161    pub fn cfe(&self) -> DependentCost {
1162        match self {
1163            GasCostsValues::V1(v1) => DependentCost::HeavyOperation {
1164                base: v1.cfei,
1165                gas_per_unit: 0,
1166            },
1167            GasCostsValues::V2(v2) => DependentCost::HeavyOperation {
1168                base: v2.cfei,
1169                gas_per_unit: 0,
1170            },
1171            GasCostsValues::V3(v3) => v3.cfe,
1172            GasCostsValues::V4(v4) => v4.cfe,
1173            GasCostsValues::V5(v5) => v5.cfe,
1174            GasCostsValues::V6(v6) => v6.cfe,
1175            GasCostsValues::V7(v7) => v7.cfe,
1176        }
1177    }
1178
1179    pub fn cfei(&self) -> DependentCost {
1180        match self {
1181            GasCostsValues::V1(v1) => DependentCost::HeavyOperation {
1182                base: v1.cfei,
1183                gas_per_unit: 0,
1184            },
1185            GasCostsValues::V2(v2) => DependentCost::HeavyOperation {
1186                base: v2.cfei,
1187                gas_per_unit: 0,
1188            },
1189            GasCostsValues::V3(v3) => v3.cfei,
1190            GasCostsValues::V4(v4) => v4.cfei,
1191            GasCostsValues::V5(v5) => v5.cfei,
1192            GasCostsValues::V6(v6) => v6.cfei,
1193            GasCostsValues::V7(v7) => v7.cfei,
1194        }
1195    }
1196
1197    pub fn call(&self) -> DependentCost {
1198        match self {
1199            GasCostsValues::V1(v1) => v1.call,
1200            GasCostsValues::V2(v2) => v2.call,
1201            GasCostsValues::V3(v3) => v3.call,
1202            GasCostsValues::V4(v4) => v4.call,
1203            GasCostsValues::V5(v5) => v5.call,
1204            GasCostsValues::V6(v6) => v6.call,
1205            GasCostsValues::V7(v7) => v7.call,
1206        }
1207    }
1208
1209    pub fn ccp(&self) -> DependentCost {
1210        match self {
1211            GasCostsValues::V1(v1) => v1.ccp,
1212            GasCostsValues::V2(v2) => v2.ccp,
1213            GasCostsValues::V3(v3) => v3.ccp,
1214            GasCostsValues::V4(v4) => v4.ccp,
1215            GasCostsValues::V5(v5) => v5.ccp,
1216            GasCostsValues::V6(v6) => v6.ccp,
1217            GasCostsValues::V7(v7) => v7.ccp,
1218        }
1219    }
1220
1221    pub fn croo(&self) -> DependentCost {
1222        match self {
1223            GasCostsValues::V1(v1) => v1.croo,
1224            GasCostsValues::V2(v2) => v2.croo,
1225            GasCostsValues::V3(v3) => v3.croo,
1226            GasCostsValues::V4(v4) => v4.croo,
1227            GasCostsValues::V5(v5) => v5.croo,
1228            GasCostsValues::V6(v6) => v6.croo,
1229            GasCostsValues::V7(v7) => v7.croo,
1230        }
1231    }
1232
1233    pub fn csiz(&self) -> DependentCost {
1234        match self {
1235            GasCostsValues::V1(v1) => v1.csiz,
1236            GasCostsValues::V2(v2) => v2.csiz,
1237            GasCostsValues::V3(v3) => v3.csiz,
1238            GasCostsValues::V4(v4) => v4.csiz,
1239            GasCostsValues::V5(v5) => v5.csiz,
1240            GasCostsValues::V6(v6) => v6.csiz,
1241            GasCostsValues::V7(v7) => v7.csiz,
1242        }
1243    }
1244
1245    pub fn ed19(&self) -> DependentCost {
1246        match self {
1247            GasCostsValues::V1(v1) => DependentCost::HeavyOperation {
1248                base: v1.ed19,
1249                gas_per_unit: 0,
1250            },
1251            GasCostsValues::V2(v2) => DependentCost::HeavyOperation {
1252                base: v2.ed19,
1253                gas_per_unit: 0,
1254            },
1255            GasCostsValues::V3(v3) => DependentCost::HeavyOperation {
1256                base: v3.ed19,
1257                gas_per_unit: 0,
1258            },
1259            GasCostsValues::V4(v4) => v4.ed19,
1260            GasCostsValues::V5(v5) => v5.ed19,
1261            GasCostsValues::V6(v6) => v6.ed19,
1262            GasCostsValues::V7(v7) => v7.ed19,
1263        }
1264    }
1265
1266    pub fn k256(&self) -> DependentCost {
1267        match self {
1268            GasCostsValues::V1(v1) => v1.k256,
1269            GasCostsValues::V2(v2) => v2.k256,
1270            GasCostsValues::V3(v3) => v3.k256,
1271            GasCostsValues::V4(v4) => v4.k256,
1272            GasCostsValues::V5(v5) => v5.k256,
1273            GasCostsValues::V6(v6) => v6.k256,
1274            GasCostsValues::V7(v7) => v7.k256,
1275        }
1276    }
1277
1278    pub fn ldc(&self) -> DependentCost {
1279        match self {
1280            GasCostsValues::V1(v1) => v1.ldc,
1281            GasCostsValues::V2(v2) => v2.ldc,
1282            GasCostsValues::V3(v3) => v3.ldc,
1283            GasCostsValues::V4(v4) => v4.ldc,
1284            GasCostsValues::V5(v5) => v5.ldc,
1285            GasCostsValues::V6(v6) => v6.ldc,
1286            GasCostsValues::V7(v7) => v7.ldc,
1287        }
1288    }
1289
1290    pub fn logd(&self) -> DependentCost {
1291        match self {
1292            GasCostsValues::V1(v1) => v1.logd,
1293            GasCostsValues::V2(v2) => v2.logd,
1294            GasCostsValues::V3(v3) => v3.logd,
1295            GasCostsValues::V4(v4) => v4.logd,
1296            GasCostsValues::V5(v5) => v5.logd,
1297            GasCostsValues::V6(v6) => v6.logd,
1298            GasCostsValues::V7(v7) => v7.logd,
1299        }
1300    }
1301
1302    pub fn mcl(&self) -> DependentCost {
1303        match self {
1304            GasCostsValues::V1(v1) => v1.mcl,
1305            GasCostsValues::V2(v2) => v2.mcl,
1306            GasCostsValues::V3(v3) => v3.mcl,
1307            GasCostsValues::V4(v4) => v4.mcl,
1308            GasCostsValues::V5(v5) => v5.mcl,
1309            GasCostsValues::V6(v6) => v6.mcl,
1310            GasCostsValues::V7(v7) => v7.mcl,
1311        }
1312    }
1313
1314    pub fn mcli(&self) -> DependentCost {
1315        match self {
1316            GasCostsValues::V1(v1) => v1.mcli,
1317            GasCostsValues::V2(v2) => v2.mcli,
1318            GasCostsValues::V3(v3) => v3.mcli,
1319            GasCostsValues::V4(v4) => v4.mcli,
1320            GasCostsValues::V5(v5) => v5.mcli,
1321            GasCostsValues::V6(v6) => v6.mcli,
1322            GasCostsValues::V7(v7) => v7.mcli,
1323        }
1324    }
1325
1326    pub fn mcp(&self) -> DependentCost {
1327        match self {
1328            GasCostsValues::V1(v1) => v1.mcp,
1329            GasCostsValues::V2(v2) => v2.mcp,
1330            GasCostsValues::V3(v3) => v3.mcp,
1331            GasCostsValues::V4(v4) => v4.mcp,
1332            GasCostsValues::V5(v5) => v5.mcp,
1333            GasCostsValues::V6(v6) => v6.mcp,
1334            GasCostsValues::V7(v7) => v7.mcp,
1335        }
1336    }
1337
1338    pub fn mcpi(&self) -> DependentCost {
1339        match self {
1340            GasCostsValues::V1(v1) => v1.mcpi,
1341            GasCostsValues::V2(v2) => v2.mcpi,
1342            GasCostsValues::V3(v3) => v3.mcpi,
1343            GasCostsValues::V4(v4) => v4.mcpi,
1344            GasCostsValues::V5(v5) => v5.mcpi,
1345            GasCostsValues::V6(v6) => v6.mcpi,
1346            GasCostsValues::V7(v7) => v7.mcpi,
1347        }
1348    }
1349
1350    pub fn meq(&self) -> DependentCost {
1351        match self {
1352            GasCostsValues::V1(v1) => v1.meq,
1353            GasCostsValues::V2(v2) => v2.meq,
1354            GasCostsValues::V3(v3) => v3.meq,
1355            GasCostsValues::V4(v4) => v4.meq,
1356            GasCostsValues::V5(v5) => v5.meq,
1357            GasCostsValues::V6(v6) => v6.meq,
1358            GasCostsValues::V7(v7) => v7.meq,
1359        }
1360    }
1361
1362    pub fn retd(&self) -> DependentCost {
1363        match self {
1364            GasCostsValues::V1(v1) => v1.retd,
1365            GasCostsValues::V2(v2) => v2.retd,
1366            GasCostsValues::V3(v3) => v3.retd,
1367            GasCostsValues::V4(v4) => v4.retd,
1368            GasCostsValues::V5(v5) => v5.retd,
1369            GasCostsValues::V6(v6) => v6.retd,
1370            GasCostsValues::V7(v7) => v7.retd,
1371        }
1372    }
1373
1374    pub fn s256(&self) -> DependentCost {
1375        match self {
1376            GasCostsValues::V1(v1) => v1.s256,
1377            GasCostsValues::V2(v2) => v2.s256,
1378            GasCostsValues::V3(v3) => v3.s256,
1379            GasCostsValues::V4(v4) => v4.s256,
1380            GasCostsValues::V5(v5) => v5.s256,
1381            GasCostsValues::V6(v6) => v6.s256,
1382            GasCostsValues::V7(v7) => v7.s256,
1383        }
1384    }
1385
1386    pub fn scwq(&self) -> Result<DependentCost, GasCostNotDefined> {
1387        match self {
1388            GasCostsValues::V1(v1) => Ok(v1.scwq),
1389            GasCostsValues::V2(v2) => Ok(v2.scwq),
1390            GasCostsValues::V3(v3) => Ok(v3.scwq),
1391            GasCostsValues::V4(v4) => Ok(v4.scwq),
1392            GasCostsValues::V5(v5) => Ok(v5.scwq),
1393            GasCostsValues::V6(v6) => Ok(v6.scwq),
1394            GasCostsValues::V7(_) => Err(GasCostNotDefined),
1395        }
1396    }
1397
1398    pub fn smo(&self) -> DependentCost {
1399        match self {
1400            GasCostsValues::V1(v1) => v1.smo,
1401            GasCostsValues::V2(v2) => v2.smo,
1402            GasCostsValues::V3(v3) => v3.smo,
1403            GasCostsValues::V4(v4) => v4.smo,
1404            GasCostsValues::V5(v5) => v5.smo,
1405            GasCostsValues::V6(v6) => v6.smo,
1406            GasCostsValues::V7(v7) => v7.smo,
1407        }
1408    }
1409
1410    pub fn srwq(&self) -> Result<DependentCost, GasCostNotDefined> {
1411        match self {
1412            GasCostsValues::V1(v1) => Ok(v1.srwq),
1413            GasCostsValues::V2(v2) => Ok(v2.srwq),
1414            GasCostsValues::V3(v3) => Ok(v3.srwq),
1415            GasCostsValues::V4(v4) => Ok(v4.srwq),
1416            GasCostsValues::V5(v5) => Ok(v5.srwq),
1417            GasCostsValues::V6(v6) => Ok(v6.srwq),
1418            GasCostsValues::V7(_) => Err(GasCostNotDefined),
1419        }
1420    }
1421
1422    pub fn swwq(&self) -> Result<DependentCost, GasCostNotDefined> {
1423        match self {
1424            GasCostsValues::V1(v1) => Ok(v1.swwq),
1425            GasCostsValues::V2(v2) => Ok(v2.swwq),
1426            GasCostsValues::V3(v3) => Ok(v3.swwq),
1427            GasCostsValues::V4(v4) => Ok(v4.swwq),
1428            GasCostsValues::V5(v5) => Ok(v5.swwq),
1429            GasCostsValues::V6(v6) => Ok(v6.swwq),
1430            GasCostsValues::V7(_) => Err(GasCostNotDefined),
1431        }
1432    }
1433
1434    pub fn bsiz(&self) -> Result<DependentCost, GasCostNotDefined> {
1435        match self {
1436            GasCostsValues::V1(_v1) => Err(GasCostNotDefined),
1437            GasCostsValues::V2(_v2) => Err(GasCostNotDefined),
1438            GasCostsValues::V3(_v3) => Err(GasCostNotDefined),
1439            GasCostsValues::V4(v4) => Ok(v4.bsiz),
1440            GasCostsValues::V5(v5) => Ok(v5.bsiz),
1441            GasCostsValues::V6(v6) => Ok(v6.bsiz),
1442            GasCostsValues::V7(v7) => Ok(v7.bsiz),
1443        }
1444    }
1445
1446    pub fn bldd(&self) -> Result<DependentCost, GasCostNotDefined> {
1447        match self {
1448            GasCostsValues::V1(_v1) => Err(GasCostNotDefined),
1449            GasCostsValues::V2(_v2) => Err(GasCostNotDefined),
1450            GasCostsValues::V3(_v3) => Err(GasCostNotDefined),
1451            GasCostsValues::V4(v4) => Ok(v4.bldd),
1452            GasCostsValues::V5(v5) => Ok(v5.bldd),
1453            GasCostsValues::V6(v6) => Ok(v6.bldd),
1454            GasCostsValues::V7(v7) => Ok(v7.bldd),
1455        }
1456    }
1457
1458    pub fn epar(&self) -> Result<DependentCost, GasCostNotDefined> {
1459        match self {
1460            GasCostsValues::V1(_v1) => Err(GasCostNotDefined),
1461            GasCostsValues::V2(_v2) => Err(GasCostNotDefined),
1462            GasCostsValues::V3(_v3) => Err(GasCostNotDefined),
1463            GasCostsValues::V4(_v4) => Err(GasCostNotDefined),
1464            GasCostsValues::V5(v5) => Ok(v5.epar),
1465            GasCostsValues::V6(v6) => Ok(v6.epar),
1466            GasCostsValues::V7(v7) => Ok(v7.epar),
1467        }
1468    }
1469
1470    pub fn storage_read_cold(&self) -> Result<DependentCost, GasCostNotDefined> {
1471        match self {
1472            GasCostsValues::V1(_) => Err(GasCostNotDefined),
1473            GasCostsValues::V2(_) => Err(GasCostNotDefined),
1474            GasCostsValues::V3(_) => Err(GasCostNotDefined),
1475            GasCostsValues::V4(_) => Err(GasCostNotDefined),
1476            GasCostsValues::V5(_) => Err(GasCostNotDefined),
1477            GasCostsValues::V6(_) => Err(GasCostNotDefined),
1478            GasCostsValues::V7(v7) => Ok(v7.storage_read_cold),
1479        }
1480    }
1481
1482    pub fn storage_read_hot(&self) -> Result<DependentCost, GasCostNotDefined> {
1483        match self {
1484            GasCostsValues::V1(_) => Err(GasCostNotDefined),
1485            GasCostsValues::V2(_) => Err(GasCostNotDefined),
1486            GasCostsValues::V3(_) => Err(GasCostNotDefined),
1487            GasCostsValues::V4(_) => Err(GasCostNotDefined),
1488            GasCostsValues::V5(_) => Err(GasCostNotDefined),
1489            GasCostsValues::V6(_) => Err(GasCostNotDefined),
1490            GasCostsValues::V7(v7) => Ok(v7.storage_read_hot),
1491        }
1492    }
1493
1494    pub fn storage_write(&self) -> Result<DependentCost, GasCostNotDefined> {
1495        match self {
1496            GasCostsValues::V1(_) => Err(GasCostNotDefined),
1497            GasCostsValues::V2(_) => Err(GasCostNotDefined),
1498            GasCostsValues::V3(_) => Err(GasCostNotDefined),
1499            GasCostsValues::V4(_) => Err(GasCostNotDefined),
1500            GasCostsValues::V5(_) => Err(GasCostNotDefined),
1501            GasCostsValues::V6(_) => Err(GasCostNotDefined),
1502            GasCostsValues::V7(v7) => Ok(v7.storage_write),
1503        }
1504    }
1505
1506    pub fn storage_clear(&self) -> Result<DependentCost, GasCostNotDefined> {
1507        match self {
1508            GasCostsValues::V1(_) => Err(GasCostNotDefined),
1509            GasCostsValues::V2(_) => Err(GasCostNotDefined),
1510            GasCostsValues::V3(_) => Err(GasCostNotDefined),
1511            GasCostsValues::V4(_) => Err(GasCostNotDefined),
1512            GasCostsValues::V5(_) => Err(GasCostNotDefined),
1513            GasCostsValues::V6(_) => Err(GasCostNotDefined),
1514            GasCostsValues::V7(v7) => Ok(v7.storage_clear),
1515        }
1516    }
1517
1518    pub fn contract_root(&self) -> DependentCost {
1519        match self {
1520            GasCostsValues::V1(v1) => v1.contract_root,
1521            GasCostsValues::V2(v2) => v2.contract_root,
1522            GasCostsValues::V3(v3) => v3.contract_root,
1523            GasCostsValues::V4(v4) => v4.contract_root,
1524            GasCostsValues::V5(v5) => v5.contract_root,
1525            GasCostsValues::V6(v6) => v6.contract_root,
1526            GasCostsValues::V7(v7) => v7.contract_root,
1527        }
1528    }
1529
1530    pub fn state_root(&self) -> DependentCost {
1531        match self {
1532            GasCostsValues::V1(v1) => v1.state_root,
1533            GasCostsValues::V2(v2) => v2.state_root,
1534            GasCostsValues::V3(v3) => v3.state_root,
1535            GasCostsValues::V4(v4) => v4.state_root,
1536            GasCostsValues::V5(v5) => v5.state_root,
1537            GasCostsValues::V6(v6) => v6.state_root,
1538            GasCostsValues::V7(v7) => v7.state_root,
1539        }
1540    }
1541
1542    pub fn new_storage_per_byte(&self) -> Word {
1543        match self {
1544            GasCostsValues::V1(v1) => v1.new_storage_per_byte,
1545            GasCostsValues::V2(v2) => v2.new_storage_per_byte,
1546            GasCostsValues::V3(v3) => v3.new_storage_per_byte,
1547            GasCostsValues::V4(v4) => v4.new_storage_per_byte,
1548            GasCostsValues::V5(v5) => v5.new_storage_per_byte,
1549            GasCostsValues::V6(v6) => v6.new_storage_per_byte,
1550            GasCostsValues::V7(v7) => v7.new_storage_per_byte,
1551        }
1552    }
1553
1554    pub fn vm_initialization(&self) -> DependentCost {
1555        match self {
1556            GasCostsValues::V1(v1) => v1.vm_initialization,
1557            GasCostsValues::V2(v2) => v2.vm_initialization,
1558            GasCostsValues::V3(v3) => v3.vm_initialization,
1559            GasCostsValues::V4(v4) => v4.vm_initialization,
1560            GasCostsValues::V5(v5) => v5.vm_initialization,
1561            GasCostsValues::V6(v6) => v6.vm_initialization,
1562            GasCostsValues::V7(v7) => v7.vm_initialization,
1563        }
1564    }
1565}
1566
1567/// Gas costs for every op.
1568#[allow(missing_docs)]
1569#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
1570#[serde(default = "GasCostsValuesV1::unit")]
1571pub struct GasCostsValuesV1 {
1572    pub add: Word,
1573    pub addi: Word,
1574    pub aloc: Word,
1575    pub and: Word,
1576    pub andi: Word,
1577    pub bal: Word,
1578    pub bhei: Word,
1579    pub bhsh: Word,
1580    pub burn: Word,
1581    pub cb: Word,
1582    pub cfei: Word,
1583    pub cfsi: Word,
1584    pub div: Word,
1585    pub divi: Word,
1586    pub eck1: Word,
1587    pub ecr1: Word,
1588    pub ed19: Word,
1589    pub eq: Word,
1590    pub exp: Word,
1591    pub expi: Word,
1592    pub flag: Word,
1593    pub gm: Word,
1594    pub gt: Word,
1595    pub gtf: Word,
1596    pub ji: Word,
1597    pub jmp: Word,
1598    pub jne: Word,
1599    pub jnei: Word,
1600    pub jnzi: Word,
1601    pub jmpf: Word,
1602    pub jmpb: Word,
1603    pub jnzf: Word,
1604    pub jnzb: Word,
1605    pub jnef: Word,
1606    pub jneb: Word,
1607    pub lb: Word,
1608    pub log: Word,
1609    pub lt: Word,
1610    pub lw: Word,
1611    pub mint: Word,
1612    pub mlog: Word,
1613    #[serde(rename = "mod")]
1614    pub mod_op: Word,
1615    pub modi: Word,
1616    #[serde(rename = "move")]
1617    pub move_op: Word,
1618    pub movi: Word,
1619    pub mroo: Word,
1620    pub mul: Word,
1621    pub muli: Word,
1622    pub mldv: Word,
1623    pub noop: Word,
1624    pub not: Word,
1625    pub or: Word,
1626    pub ori: Word,
1627    pub poph: Word,
1628    pub popl: Word,
1629    pub pshh: Word,
1630    pub pshl: Word,
1631    #[serde(rename = "ret_contract")]
1632    pub ret: Word,
1633    #[serde(rename = "rvrt_contract")]
1634    pub rvrt: Word,
1635    pub sb: Word,
1636    pub sll: Word,
1637    pub slli: Word,
1638    pub srl: Word,
1639    pub srli: Word,
1640    pub srw: Word,
1641    pub sub: Word,
1642    pub subi: Word,
1643    pub sw: Word,
1644    pub sww: Word,
1645    pub time: Word,
1646    pub tr: Word,
1647    pub tro: Word,
1648    pub wdcm: Word,
1649    pub wqcm: Word,
1650    pub wdop: Word,
1651    pub wqop: Word,
1652    pub wdml: Word,
1653    pub wqml: Word,
1654    pub wddv: Word,
1655    pub wqdv: Word,
1656    pub wdmd: Word,
1657    pub wqmd: Word,
1658    pub wdam: Word,
1659    pub wqam: Word,
1660    pub wdmm: Word,
1661    pub wqmm: Word,
1662    pub xor: Word,
1663    pub xori: Word,
1664
1665    // Dependent
1666    pub call: DependentCost,
1667    pub ccp: DependentCost,
1668    pub croo: DependentCost,
1669    pub csiz: DependentCost,
1670    pub k256: DependentCost,
1671    pub ldc: DependentCost,
1672    pub logd: DependentCost,
1673    pub mcl: DependentCost,
1674    pub mcli: DependentCost,
1675    pub mcp: DependentCost,
1676    pub mcpi: DependentCost,
1677    pub meq: DependentCost,
1678    #[serde(rename = "retd_contract")]
1679    pub retd: DependentCost,
1680    pub s256: DependentCost,
1681    pub scwq: DependentCost,
1682    pub smo: DependentCost,
1683    pub srwq: DependentCost,
1684    pub swwq: DependentCost,
1685
1686    // Non-opcode costs
1687    pub contract_root: DependentCost,
1688    pub state_root: DependentCost,
1689    pub new_storage_per_byte: Word,
1690    pub vm_initialization: DependentCost,
1691}
1692
1693/// Gas costs for every op.
1694/// The difference with [`GasCostsValuesV1`]:
1695/// - `aloc` is a [`DependentCost`] instead of a [`Word`]
1696#[allow(missing_docs)]
1697#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
1698#[serde(default = "GasCostsValuesV2::unit")]
1699pub struct GasCostsValuesV2 {
1700    pub add: Word,
1701    pub addi: Word,
1702    pub and: Word,
1703    pub andi: Word,
1704    pub bal: Word,
1705    pub bhei: Word,
1706    pub bhsh: Word,
1707    pub burn: Word,
1708    pub cb: Word,
1709    pub cfei: Word,
1710    pub cfsi: Word,
1711    pub div: Word,
1712    pub divi: Word,
1713    pub eck1: Word,
1714    pub ecr1: Word,
1715    pub ed19: Word,
1716    pub eq: Word,
1717    pub exp: Word,
1718    pub expi: Word,
1719    pub flag: Word,
1720    pub gm: Word,
1721    pub gt: Word,
1722    pub gtf: Word,
1723    pub ji: Word,
1724    pub jmp: Word,
1725    pub jne: Word,
1726    pub jnei: Word,
1727    pub jnzi: Word,
1728    pub jmpf: Word,
1729    pub jmpb: Word,
1730    pub jnzf: Word,
1731    pub jnzb: Word,
1732    pub jnef: Word,
1733    pub jneb: Word,
1734    pub lb: Word,
1735    pub log: Word,
1736    pub lt: Word,
1737    pub lw: Word,
1738    pub mint: Word,
1739    pub mlog: Word,
1740    #[serde(rename = "mod")]
1741    pub mod_op: Word,
1742    pub modi: Word,
1743    #[serde(rename = "move")]
1744    pub move_op: Word,
1745    pub movi: Word,
1746    pub mroo: Word,
1747    pub mul: Word,
1748    pub muli: Word,
1749    pub mldv: Word,
1750    pub noop: Word,
1751    pub not: Word,
1752    pub or: Word,
1753    pub ori: Word,
1754    pub poph: Word,
1755    pub popl: Word,
1756    pub pshh: Word,
1757    pub pshl: Word,
1758    #[serde(rename = "ret_contract")]
1759    pub ret: Word,
1760    #[serde(rename = "rvrt_contract")]
1761    pub rvrt: Word,
1762    pub sb: Word,
1763    pub sll: Word,
1764    pub slli: Word,
1765    pub srl: Word,
1766    pub srli: Word,
1767    pub srw: Word,
1768    pub sub: Word,
1769    pub subi: Word,
1770    pub sw: Word,
1771    pub sww: Word,
1772    pub time: Word,
1773    pub tr: Word,
1774    pub tro: Word,
1775    pub wdcm: Word,
1776    pub wqcm: Word,
1777    pub wdop: Word,
1778    pub wqop: Word,
1779    pub wdml: Word,
1780    pub wqml: Word,
1781    pub wddv: Word,
1782    pub wqdv: Word,
1783    pub wdmd: Word,
1784    pub wqmd: Word,
1785    pub wdam: Word,
1786    pub wqam: Word,
1787    pub wdmm: Word,
1788    pub wqmm: Word,
1789    pub xor: Word,
1790    pub xori: Word,
1791
1792    // Dependent
1793    pub aloc: DependentCost,
1794    pub call: DependentCost,
1795    pub ccp: DependentCost,
1796    pub croo: DependentCost,
1797    pub csiz: DependentCost,
1798    pub k256: DependentCost,
1799    pub ldc: DependentCost,
1800    pub logd: DependentCost,
1801    pub mcl: DependentCost,
1802    pub mcli: DependentCost,
1803    pub mcp: DependentCost,
1804    pub mcpi: DependentCost,
1805    pub meq: DependentCost,
1806    #[serde(rename = "retd_contract")]
1807    pub retd: DependentCost,
1808    pub s256: DependentCost,
1809    pub scwq: DependentCost,
1810    pub smo: DependentCost,
1811    pub srwq: DependentCost,
1812    pub swwq: DependentCost,
1813
1814    // Non-opcode costs
1815    pub contract_root: DependentCost,
1816    pub state_root: DependentCost,
1817    pub new_storage_per_byte: Word,
1818    pub vm_initialization: DependentCost,
1819}
1820
1821/// Gas costs for every op.
1822/// The difference with [`GasCostsValuesV2`]:
1823/// - Added `cfe` as a [`DependentCost`]
1824/// - `cfei` is a [`DependentCost`] instead of a [`Word`]
1825#[allow(missing_docs)]
1826#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
1827#[serde(default = "GasCostsValuesV3::unit")]
1828pub struct GasCostsValuesV3 {
1829    pub add: Word,
1830    pub addi: Word,
1831    pub and: Word,
1832    pub andi: Word,
1833    pub bal: Word,
1834    pub bhei: Word,
1835    pub bhsh: Word,
1836    pub burn: Word,
1837    pub cb: Word,
1838    pub cfsi: Word,
1839    pub div: Word,
1840    pub divi: Word,
1841    pub eck1: Word,
1842    pub ecr1: Word,
1843    pub ed19: Word,
1844    pub eq: Word,
1845    pub exp: Word,
1846    pub expi: Word,
1847    pub flag: Word,
1848    pub gm: Word,
1849    pub gt: Word,
1850    pub gtf: Word,
1851    pub ji: Word,
1852    pub jmp: Word,
1853    pub jne: Word,
1854    pub jnei: Word,
1855    pub jnzi: Word,
1856    pub jmpf: Word,
1857    pub jmpb: Word,
1858    pub jnzf: Word,
1859    pub jnzb: Word,
1860    pub jnef: Word,
1861    pub jneb: Word,
1862    pub lb: Word,
1863    pub log: Word,
1864    pub lt: Word,
1865    pub lw: Word,
1866    pub mint: Word,
1867    pub mlog: Word,
1868    #[serde(rename = "mod")]
1869    pub mod_op: Word,
1870    pub modi: Word,
1871    #[serde(rename = "move")]
1872    pub move_op: Word,
1873    pub movi: Word,
1874    pub mroo: Word,
1875    pub mul: Word,
1876    pub muli: Word,
1877    pub mldv: Word,
1878    pub noop: Word,
1879    pub not: Word,
1880    pub or: Word,
1881    pub ori: Word,
1882    pub poph: Word,
1883    pub popl: Word,
1884    pub pshh: Word,
1885    pub pshl: Word,
1886    #[serde(rename = "ret_contract")]
1887    pub ret: Word,
1888    #[serde(rename = "rvrt_contract")]
1889    pub rvrt: Word,
1890    pub sb: Word,
1891    pub sll: Word,
1892    pub slli: Word,
1893    pub srl: Word,
1894    pub srli: Word,
1895    pub srw: Word,
1896    pub sub: Word,
1897    pub subi: Word,
1898    pub sw: Word,
1899    pub sww: Word,
1900    pub time: Word,
1901    pub tr: Word,
1902    pub tro: Word,
1903    pub wdcm: Word,
1904    pub wqcm: Word,
1905    pub wdop: Word,
1906    pub wqop: Word,
1907    pub wdml: Word,
1908    pub wqml: Word,
1909    pub wddv: Word,
1910    pub wqdv: Word,
1911    pub wdmd: Word,
1912    pub wqmd: Word,
1913    pub wdam: Word,
1914    pub wqam: Word,
1915    pub wdmm: Word,
1916    pub wqmm: Word,
1917    pub xor: Word,
1918    pub xori: Word,
1919
1920    // Dependent
1921    pub aloc: DependentCost,
1922    pub cfe: DependentCost,
1923    pub cfei: DependentCost,
1924    pub call: DependentCost,
1925    pub ccp: DependentCost,
1926    pub croo: DependentCost,
1927    pub csiz: DependentCost,
1928    pub k256: DependentCost,
1929    pub ldc: DependentCost,
1930    pub logd: DependentCost,
1931    pub mcl: DependentCost,
1932    pub mcli: DependentCost,
1933    pub mcp: DependentCost,
1934    pub mcpi: DependentCost,
1935    pub meq: DependentCost,
1936    #[serde(rename = "retd_contract")]
1937    pub retd: DependentCost,
1938    pub s256: DependentCost,
1939    pub scwq: DependentCost,
1940    pub smo: DependentCost,
1941    pub srwq: DependentCost,
1942    pub swwq: DependentCost,
1943
1944    // Non-opcode costs
1945    pub contract_root: DependentCost,
1946    pub state_root: DependentCost,
1947    pub new_storage_per_byte: Word,
1948    pub vm_initialization: DependentCost,
1949}
1950
1951/// Gas costs for every op.
1952/// The difference with [`GasCostsValuesV3`]:
1953/// - Added `bsiz`, `bldd` instructions
1954/// - Changed `ed19` to be `DependentCost`
1955#[allow(missing_docs)]
1956#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
1957#[serde(default = "GasCostsValuesV4::unit")]
1958pub struct GasCostsValuesV4 {
1959    pub add: Word,
1960    pub addi: Word,
1961    pub and: Word,
1962    pub andi: Word,
1963    pub bal: Word,
1964    pub bhei: Word,
1965    pub bhsh: Word,
1966    pub burn: Word,
1967    pub cb: Word,
1968    pub cfsi: Word,
1969    pub div: Word,
1970    pub divi: Word,
1971    pub eck1: Word,
1972    pub ecr1: Word,
1973    pub eq: Word,
1974    pub exp: Word,
1975    pub expi: Word,
1976    pub flag: Word,
1977    pub gm: Word,
1978    pub gt: Word,
1979    pub gtf: Word,
1980    pub ji: Word,
1981    pub jmp: Word,
1982    pub jne: Word,
1983    pub jnei: Word,
1984    pub jnzi: Word,
1985    pub jmpf: Word,
1986    pub jmpb: Word,
1987    pub jnzf: Word,
1988    pub jnzb: Word,
1989    pub jnef: Word,
1990    pub jneb: Word,
1991    pub lb: Word,
1992    pub log: Word,
1993    pub lt: Word,
1994    pub lw: Word,
1995    pub mint: Word,
1996    pub mlog: Word,
1997    #[serde(rename = "mod")]
1998    pub mod_op: Word,
1999    pub modi: Word,
2000    #[serde(rename = "move")]
2001    pub move_op: Word,
2002    pub movi: Word,
2003    pub mroo: Word,
2004    pub mul: Word,
2005    pub muli: Word,
2006    pub mldv: Word,
2007    pub noop: Word,
2008    pub not: Word,
2009    pub or: Word,
2010    pub ori: Word,
2011    pub poph: Word,
2012    pub popl: Word,
2013    pub pshh: Word,
2014    pub pshl: Word,
2015    #[serde(rename = "ret_contract")]
2016    pub ret: Word,
2017    #[serde(rename = "rvrt_contract")]
2018    pub rvrt: Word,
2019    pub sb: Word,
2020    pub sll: Word,
2021    pub slli: Word,
2022    pub srl: Word,
2023    pub srli: Word,
2024    pub srw: Word,
2025    pub sub: Word,
2026    pub subi: Word,
2027    pub sw: Word,
2028    pub sww: Word,
2029    pub time: Word,
2030    pub tr: Word,
2031    pub tro: Word,
2032    pub wdcm: Word,
2033    pub wqcm: Word,
2034    pub wdop: Word,
2035    pub wqop: Word,
2036    pub wdml: Word,
2037    pub wqml: Word,
2038    pub wddv: Word,
2039    pub wqdv: Word,
2040    pub wdmd: Word,
2041    pub wqmd: Word,
2042    pub wdam: Word,
2043    pub wqam: Word,
2044    pub wdmm: Word,
2045    pub wqmm: Word,
2046    pub xor: Word,
2047    pub xori: Word,
2048
2049    // Dependent
2050    pub aloc: DependentCost,
2051    pub bsiz: DependentCost,
2052    pub bldd: DependentCost,
2053    pub cfe: DependentCost,
2054    pub cfei: DependentCost,
2055    pub call: DependentCost,
2056    pub ccp: DependentCost,
2057    pub croo: DependentCost,
2058    pub csiz: DependentCost,
2059    pub ed19: DependentCost,
2060    pub k256: DependentCost,
2061    pub ldc: DependentCost,
2062    pub logd: DependentCost,
2063    pub mcl: DependentCost,
2064    pub mcli: DependentCost,
2065    pub mcp: DependentCost,
2066    pub mcpi: DependentCost,
2067    pub meq: DependentCost,
2068    #[serde(rename = "retd_contract")]
2069    pub retd: DependentCost,
2070    pub s256: DependentCost,
2071    pub scwq: DependentCost,
2072    pub smo: DependentCost,
2073    pub srwq: DependentCost,
2074    pub swwq: DependentCost,
2075
2076    // Non-opcode costs
2077    pub contract_root: DependentCost,
2078    pub state_root: DependentCost,
2079    pub new_storage_per_byte: Word,
2080    pub vm_initialization: DependentCost,
2081}
2082
2083/// Gas costs for every op.
2084/// The difference with [`GasCostsValuesV4`]:
2085/// - Added `ecop` and `epar` instructions
2086#[allow(missing_docs)]
2087#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
2088#[serde(default = "GasCostsValuesV5::unit")]
2089pub struct GasCostsValuesV5 {
2090    pub add: Word,
2091    pub addi: Word,
2092    pub and: Word,
2093    pub andi: Word,
2094    pub bal: Word,
2095    pub bhei: Word,
2096    pub bhsh: Word,
2097    pub burn: Word,
2098    pub cb: Word,
2099    pub cfsi: Word,
2100    pub div: Word,
2101    pub divi: Word,
2102    pub eck1: Word,
2103    pub ecr1: Word,
2104    pub eq: Word,
2105    pub exp: Word,
2106    pub expi: Word,
2107    pub flag: Word,
2108    pub gm: Word,
2109    pub gt: Word,
2110    pub gtf: Word,
2111    pub ji: Word,
2112    pub jmp: Word,
2113    pub jne: Word,
2114    pub jnei: Word,
2115    pub jnzi: Word,
2116    pub jmpf: Word,
2117    pub jmpb: Word,
2118    pub jnzf: Word,
2119    pub jnzb: Word,
2120    pub jnef: Word,
2121    pub jneb: Word,
2122    pub lb: Word,
2123    pub log: Word,
2124    pub lt: Word,
2125    pub lw: Word,
2126    pub mint: Word,
2127    pub mlog: Word,
2128    #[serde(rename = "mod")]
2129    pub mod_op: Word,
2130    pub modi: Word,
2131    #[serde(rename = "move")]
2132    pub move_op: Word,
2133    pub movi: Word,
2134    pub mroo: Word,
2135    pub mul: Word,
2136    pub muli: Word,
2137    pub mldv: Word,
2138    pub noop: Word,
2139    pub not: Word,
2140    pub or: Word,
2141    pub ori: Word,
2142    pub poph: Word,
2143    pub popl: Word,
2144    pub pshh: Word,
2145    pub pshl: Word,
2146    #[serde(rename = "ret_contract")]
2147    pub ret: Word,
2148    #[serde(rename = "rvrt_contract")]
2149    pub rvrt: Word,
2150    pub sb: Word,
2151    pub sll: Word,
2152    pub slli: Word,
2153    pub srl: Word,
2154    pub srli: Word,
2155    pub srw: Word,
2156    pub sub: Word,
2157    pub subi: Word,
2158    pub sw: Word,
2159    pub sww: Word,
2160    pub time: Word,
2161    pub tr: Word,
2162    pub tro: Word,
2163    pub wdcm: Word,
2164    pub wqcm: Word,
2165    pub wdop: Word,
2166    pub wqop: Word,
2167    pub wdml: Word,
2168    pub wqml: Word,
2169    pub wddv: Word,
2170    pub wqdv: Word,
2171    pub wdmd: Word,
2172    pub wqmd: Word,
2173    pub wdam: Word,
2174    pub wqam: Word,
2175    pub wdmm: Word,
2176    pub wqmm: Word,
2177    pub xor: Word,
2178    pub xori: Word,
2179    pub ecop: Word,
2180
2181    // Dependent
2182    pub aloc: DependentCost,
2183    pub bsiz: DependentCost,
2184    pub bldd: DependentCost,
2185    pub cfe: DependentCost,
2186    pub cfei: DependentCost,
2187    pub call: DependentCost,
2188    pub ccp: DependentCost,
2189    pub croo: DependentCost,
2190    pub csiz: DependentCost,
2191    pub ed19: DependentCost,
2192    pub k256: DependentCost,
2193    pub ldc: DependentCost,
2194    pub logd: DependentCost,
2195    pub mcl: DependentCost,
2196    pub mcli: DependentCost,
2197    pub mcp: DependentCost,
2198    pub mcpi: DependentCost,
2199    pub meq: DependentCost,
2200    #[serde(rename = "retd_contract")]
2201    pub retd: DependentCost,
2202    pub s256: DependentCost,
2203    pub scwq: DependentCost,
2204    pub smo: DependentCost,
2205    pub srwq: DependentCost,
2206    pub swwq: DependentCost,
2207    pub epar: DependentCost,
2208
2209    // Non-opcode costs
2210    pub contract_root: DependentCost,
2211    pub state_root: DependentCost,
2212    pub new_storage_per_byte: Word,
2213    pub vm_initialization: DependentCost,
2214}
2215
2216/// Gas costs for every op.
2217/// The difference with [`GasCostsValuesV5`]:
2218/// - Added `niop` instruction
2219#[allow(missing_docs)]
2220#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
2221#[serde(default = "GasCostsValuesV6::unit")]
2222pub struct GasCostsValuesV6 {
2223    pub add: Word,
2224    pub addi: Word,
2225    pub and: Word,
2226    pub andi: Word,
2227    pub bal: Word,
2228    pub bhei: Word,
2229    pub bhsh: Word,
2230    pub burn: Word,
2231    pub cb: Word,
2232    pub cfsi: Word,
2233    pub div: Word,
2234    pub divi: Word,
2235    pub eck1: Word,
2236    pub ecr1: Word,
2237    pub eq: Word,
2238    pub exp: Word,
2239    pub expi: Word,
2240    pub flag: Word,
2241    pub gm: Word,
2242    pub gt: Word,
2243    pub gtf: Word,
2244    pub ji: Word,
2245    pub jmp: Word,
2246    pub jne: Word,
2247    pub jnei: Word,
2248    pub jnzi: Word,
2249    pub jmpf: Word,
2250    pub jmpb: Word,
2251    pub jnzf: Word,
2252    pub jnzb: Word,
2253    pub jnef: Word,
2254    pub jneb: Word,
2255    pub lb: Word,
2256    pub log: Word,
2257    pub lt: Word,
2258    pub lw: Word,
2259    pub mint: Word,
2260    pub mlog: Word,
2261    #[serde(rename = "mod")]
2262    pub mod_op: Word,
2263    pub modi: Word,
2264    #[serde(rename = "move")]
2265    pub move_op: Word,
2266    pub movi: Word,
2267    pub mroo: Word,
2268    pub mul: Word,
2269    pub muli: Word,
2270    pub mldv: Word,
2271    pub niop: Word,
2272    pub noop: Word,
2273    pub not: Word,
2274    pub or: Word,
2275    pub ori: Word,
2276    pub poph: Word,
2277    pub popl: Word,
2278    pub pshh: Word,
2279    pub pshl: Word,
2280    #[serde(rename = "ret_contract")]
2281    pub ret: Word,
2282    #[serde(rename = "rvrt_contract")]
2283    pub rvrt: Word,
2284    pub sb: Word,
2285    pub sll: Word,
2286    pub slli: Word,
2287    pub srl: Word,
2288    pub srli: Word,
2289    pub srw: Word,
2290    pub sub: Word,
2291    pub subi: Word,
2292    pub sw: Word,
2293    pub sww: Word,
2294    pub time: Word,
2295    pub tr: Word,
2296    pub tro: Word,
2297    pub wdcm: Word,
2298    pub wqcm: Word,
2299    pub wdop: Word,
2300    pub wqop: Word,
2301    pub wdml: Word,
2302    pub wqml: Word,
2303    pub wddv: Word,
2304    pub wqdv: Word,
2305    pub wdmd: Word,
2306    pub wqmd: Word,
2307    pub wdam: Word,
2308    pub wqam: Word,
2309    pub wdmm: Word,
2310    pub wqmm: Word,
2311    pub xor: Word,
2312    pub xori: Word,
2313    pub ecop: Word,
2314
2315    // Dependent
2316    pub aloc: DependentCost,
2317    pub bsiz: DependentCost,
2318    pub bldd: DependentCost,
2319    pub cfe: DependentCost,
2320    pub cfei: DependentCost,
2321    pub call: DependentCost,
2322    pub ccp: DependentCost,
2323    pub croo: DependentCost,
2324    pub csiz: DependentCost,
2325    pub ed19: DependentCost,
2326    pub k256: DependentCost,
2327    pub ldc: DependentCost,
2328    pub logd: DependentCost,
2329    pub mcl: DependentCost,
2330    pub mcli: DependentCost,
2331    pub mcp: DependentCost,
2332    pub mcpi: DependentCost,
2333    pub meq: DependentCost,
2334    #[serde(rename = "retd_contract")]
2335    pub retd: DependentCost,
2336    pub s256: DependentCost,
2337    pub scwq: DependentCost,
2338    pub smo: DependentCost,
2339    pub srwq: DependentCost,
2340    pub swwq: DependentCost,
2341    pub epar: DependentCost,
2342
2343    // Non-opcode costs
2344    pub contract_root: DependentCost,
2345    pub state_root: DependentCost,
2346    pub new_storage_per_byte: Word,
2347    pub vm_initialization: DependentCost,
2348}
2349
2350/// Gas costs for every op.
2351/// The difference with [`GasCostsValuesV6`]:
2352/// - New storage operations
2353#[allow(missing_docs)]
2354#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
2355#[serde(default = "GasCostsValuesV7::unit")]
2356pub struct GasCostsValuesV7 {
2357    pub add: Word,
2358    pub addi: Word,
2359    pub and: Word,
2360    pub andi: Word,
2361    pub bal: Word,
2362    pub bhei: Word,
2363    pub bhsh: Word,
2364    pub burn: Word,
2365    pub cb: Word,
2366    pub cfsi: Word,
2367    pub div: Word,
2368    pub divi: Word,
2369    pub eck1: Word,
2370    pub ecr1: Word,
2371    pub eq: Word,
2372    pub exp: Word,
2373    pub expi: Word,
2374    pub flag: Word,
2375    pub gm: Word,
2376    pub gt: Word,
2377    pub gtf: Word,
2378    pub ji: Word,
2379    pub jmp: Word,
2380    pub jne: Word,
2381    pub jnei: Word,
2382    pub jnzi: Word,
2383    pub jmpf: Word,
2384    pub jmpb: Word,
2385    pub jnzf: Word,
2386    pub jnzb: Word,
2387    pub jnef: Word,
2388    pub jneb: Word,
2389    pub lb: Word,
2390    pub log: Word,
2391    pub lt: Word,
2392    pub lw: Word,
2393    pub mint: Word,
2394    pub mlog: Word,
2395    #[serde(rename = "mod")]
2396    pub mod_op: Word,
2397    pub modi: Word,
2398    #[serde(rename = "move")]
2399    pub move_op: Word,
2400    pub movi: Word,
2401    pub mroo: Word,
2402    pub mul: Word,
2403    pub muli: Word,
2404    pub mldv: Word,
2405    pub niop: Word,
2406    pub noop: Word,
2407    pub not: Word,
2408    pub or: Word,
2409    pub ori: Word,
2410    pub poph: Word,
2411    pub popl: Word,
2412    pub pshh: Word,
2413    pub pshl: Word,
2414    #[serde(rename = "ret_contract")]
2415    pub ret: Word,
2416    #[serde(rename = "rvrt_contract")]
2417    pub rvrt: Word,
2418    pub sb: Word,
2419    pub sll: Word,
2420    pub slli: Word,
2421    pub srl: Word,
2422    pub srli: Word,
2423    pub sub: Word,
2424    pub subi: Word,
2425    pub sw: Word,
2426    pub time: Word,
2427    pub tr: Word,
2428    pub tro: Word,
2429    pub wdcm: Word,
2430    pub wqcm: Word,
2431    pub wdop: Word,
2432    pub wqop: Word,
2433    pub wdml: Word,
2434    pub wqml: Word,
2435    pub wddv: Word,
2436    pub wqdv: Word,
2437    pub wdmd: Word,
2438    pub wqmd: Word,
2439    pub wdam: Word,
2440    pub wqam: Word,
2441    pub wdmm: Word,
2442    pub wqmm: Word,
2443    pub xor: Word,
2444    pub xori: Word,
2445    pub ecop: Word,
2446
2447    // Dependent
2448    pub aloc: DependentCost,
2449    pub bsiz: DependentCost,
2450    pub bldd: DependentCost,
2451    pub cfe: DependentCost,
2452    pub cfei: DependentCost,
2453    pub call: DependentCost,
2454    pub ccp: DependentCost,
2455    pub croo: DependentCost,
2456    pub csiz: DependentCost,
2457    pub ed19: DependentCost,
2458    pub k256: DependentCost,
2459    pub ldc: DependentCost,
2460    pub logd: DependentCost,
2461    pub mcl: DependentCost,
2462    pub mcli: DependentCost,
2463    pub mcp: DependentCost,
2464    pub mcpi: DependentCost,
2465    pub meq: DependentCost,
2466    #[serde(rename = "retd_contract")]
2467    pub retd: DependentCost,
2468    pub s256: DependentCost,
2469    pub smo: DependentCost,
2470    pub epar: DependentCost,
2471
2472    // Storage operation costs
2473    pub storage_read_cold: DependentCost,
2474    pub storage_read_hot: DependentCost,
2475    pub storage_write: DependentCost,
2476    pub storage_clear: DependentCost,
2477
2478    // Non-opcode costs
2479    pub contract_root: DependentCost,
2480    pub state_root: DependentCost,
2481    pub new_storage_per_byte: Word,
2482    pub vm_initialization: DependentCost,
2483}
2484
2485/// Dependent cost is a cost that depends on the number of units.
2486#[derive(
2487    Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize,
2488)]
2489pub enum DependentCost {
2490    /// When an operation is dependent on the magnitude of its inputs, and the
2491    /// time per unit of input is less than a single no-op operation
2492    LightOperation {
2493        /// The minimum that this operation can cost.
2494        base: Word,
2495        /// How many elements can be processed with a single gas. The
2496        /// higher the `units_per_gas`, the less additional cost you will incur
2497        /// for a given number of units, because you need more units to increase
2498        /// the total cost.
2499        /// This must be nonzero.
2500        units_per_gas: Word,
2501    },
2502
2503    /// When an operation is dependent on the magnitude of its inputs, and the
2504    /// time per unit of input is greater than a single no-op operation
2505    HeavyOperation {
2506        /// The minimum that this operation can cost.
2507        base: Word,
2508        /// How much gas is required to process a single unit.
2509        gas_per_unit: Word,
2510    },
2511}
2512
2513#[cfg(feature = "alloc")]
2514impl GasCosts {
2515    /// Create costs that are all set to zero.
2516    pub fn free() -> Self {
2517        Self(Arc::new(GasCostsValues::free()))
2518    }
2519
2520    /// Create costs that are all set to one.
2521    pub fn unit() -> Self {
2522        Self(Arc::new(GasCostsValues::unit()))
2523    }
2524}
2525
2526impl GasCostsValues {
2527    /// Create costs that are all set to zero.
2528    pub fn free() -> Self {
2529        GasCostsValuesV7::free().into()
2530    }
2531
2532    /// Create costs that are all set to one.
2533    pub fn unit() -> Self {
2534        GasCostsValuesV7::unit().into()
2535    }
2536}
2537
2538impl GasCostsValuesV1 {
2539    /// Create costs that are all set to zero.
2540    pub fn free() -> Self {
2541        Self {
2542            add: 0,
2543            addi: 0,
2544            aloc: 0,
2545            and: 0,
2546            andi: 0,
2547            bal: 0,
2548            bhei: 0,
2549            bhsh: 0,
2550            burn: 0,
2551            cb: 0,
2552            cfei: 0,
2553            cfsi: 0,
2554            div: 0,
2555            divi: 0,
2556            eck1: 0,
2557            ecr1: 0,
2558            ed19: 0,
2559            eq: 0,
2560            exp: 0,
2561            expi: 0,
2562            flag: 0,
2563            gm: 0,
2564            gt: 0,
2565            gtf: 0,
2566            ji: 0,
2567            jmp: 0,
2568            jne: 0,
2569            jnei: 0,
2570            jnzi: 0,
2571            jmpf: 0,
2572            jmpb: 0,
2573            jnzf: 0,
2574            jnzb: 0,
2575            jnef: 0,
2576            jneb: 0,
2577            lb: 0,
2578            log: 0,
2579            lt: 0,
2580            lw: 0,
2581            mint: 0,
2582            mlog: 0,
2583            mod_op: 0,
2584            modi: 0,
2585            move_op: 0,
2586            movi: 0,
2587            mroo: 0,
2588            mul: 0,
2589            muli: 0,
2590            mldv: 0,
2591            noop: 0,
2592            not: 0,
2593            or: 0,
2594            ori: 0,
2595            poph: 0,
2596            popl: 0,
2597            pshh: 0,
2598            pshl: 0,
2599            ret: 0,
2600            rvrt: 0,
2601            sb: 0,
2602            sll: 0,
2603            slli: 0,
2604            srl: 0,
2605            srli: 0,
2606            srw: 0,
2607            sub: 0,
2608            subi: 0,
2609            sw: 0,
2610            sww: 0,
2611            time: 0,
2612            tr: 0,
2613            tro: 0,
2614            wdcm: 0,
2615            wqcm: 0,
2616            wdop: 0,
2617            wqop: 0,
2618            wdml: 0,
2619            wqml: 0,
2620            wddv: 0,
2621            wqdv: 0,
2622            wdmd: 0,
2623            wqmd: 0,
2624            wdam: 0,
2625            wqam: 0,
2626            wdmm: 0,
2627            wqmm: 0,
2628            xor: 0,
2629            xori: 0,
2630            call: DependentCost::free(),
2631            ccp: DependentCost::free(),
2632            croo: DependentCost::free(),
2633            csiz: DependentCost::free(),
2634            k256: DependentCost::free(),
2635            ldc: DependentCost::free(),
2636            logd: DependentCost::free(),
2637            mcl: DependentCost::free(),
2638            mcli: DependentCost::free(),
2639            mcp: DependentCost::free(),
2640            mcpi: DependentCost::free(),
2641            meq: DependentCost::free(),
2642            retd: DependentCost::free(),
2643            s256: DependentCost::free(),
2644            scwq: DependentCost::free(),
2645            smo: DependentCost::free(),
2646            srwq: DependentCost::free(),
2647            swwq: DependentCost::free(),
2648
2649            // Non-opcode costs
2650            contract_root: DependentCost::free(),
2651            state_root: DependentCost::free(),
2652            new_storage_per_byte: 0,
2653            vm_initialization: DependentCost::free(),
2654        }
2655    }
2656
2657    /// Create costs that are all set to one.
2658    pub fn unit() -> Self {
2659        Self {
2660            add: 1,
2661            addi: 1,
2662            aloc: 1,
2663            and: 1,
2664            andi: 1,
2665            bal: 1,
2666            bhei: 1,
2667            bhsh: 1,
2668            burn: 1,
2669            cb: 1,
2670            cfei: 1,
2671            cfsi: 1,
2672            div: 1,
2673            divi: 1,
2674            eck1: 1,
2675            ecr1: 1,
2676            ed19: 1,
2677            eq: 1,
2678            exp: 1,
2679            expi: 1,
2680            flag: 1,
2681            gm: 1,
2682            gt: 1,
2683            gtf: 1,
2684            ji: 1,
2685            jmp: 1,
2686            jne: 1,
2687            jnei: 1,
2688            jnzi: 1,
2689            jmpf: 1,
2690            jmpb: 1,
2691            jnzf: 1,
2692            jnzb: 1,
2693            jnef: 1,
2694            jneb: 1,
2695            lb: 1,
2696            log: 1,
2697            lt: 1,
2698            lw: 1,
2699            mint: 1,
2700            mlog: 1,
2701            mod_op: 1,
2702            modi: 1,
2703            move_op: 1,
2704            movi: 1,
2705            mroo: 1,
2706            mul: 1,
2707            muli: 1,
2708            mldv: 1,
2709            noop: 1,
2710            not: 1,
2711            or: 1,
2712            ori: 1,
2713            ret: 1,
2714            poph: 1,
2715            popl: 1,
2716            pshh: 1,
2717            pshl: 1,
2718            rvrt: 1,
2719            sb: 1,
2720            sll: 1,
2721            slli: 1,
2722            srl: 1,
2723            srli: 1,
2724            srw: 1,
2725            sub: 1,
2726            subi: 1,
2727            sw: 1,
2728            sww: 1,
2729            time: 1,
2730            tr: 1,
2731            tro: 1,
2732            wdcm: 1,
2733            wqcm: 1,
2734            wdop: 1,
2735            wqop: 1,
2736            wdml: 1,
2737            wqml: 1,
2738            wddv: 1,
2739            wqdv: 1,
2740            wdmd: 1,
2741            wqmd: 1,
2742            wdam: 1,
2743            wqam: 1,
2744            wdmm: 1,
2745            wqmm: 1,
2746            xor: 1,
2747            xori: 1,
2748            call: DependentCost::unit(),
2749            ccp: DependentCost::unit(),
2750            croo: DependentCost::unit(),
2751            csiz: DependentCost::unit(),
2752            k256: DependentCost::unit(),
2753            ldc: DependentCost::unit(),
2754            logd: DependentCost::unit(),
2755            mcl: DependentCost::unit(),
2756            mcli: DependentCost::unit(),
2757            mcp: DependentCost::unit(),
2758            mcpi: DependentCost::unit(),
2759            meq: DependentCost::unit(),
2760            retd: DependentCost::unit(),
2761            s256: DependentCost::unit(),
2762            scwq: DependentCost::unit(),
2763            smo: DependentCost::unit(),
2764            srwq: DependentCost::unit(),
2765            swwq: DependentCost::unit(),
2766
2767            // Non-opcode costs
2768            contract_root: DependentCost::unit(),
2769            state_root: DependentCost::unit(),
2770            new_storage_per_byte: 1,
2771            vm_initialization: DependentCost::unit(),
2772        }
2773    }
2774}
2775
2776impl GasCostsValuesV2 {
2777    /// Create costs that are all set to zero.
2778    pub fn free() -> Self {
2779        Self {
2780            add: 0,
2781            addi: 0,
2782            and: 0,
2783            andi: 0,
2784            bal: 0,
2785            bhei: 0,
2786            bhsh: 0,
2787            burn: 0,
2788            cb: 0,
2789            cfei: 0,
2790            cfsi: 0,
2791            div: 0,
2792            divi: 0,
2793            eck1: 0,
2794            ecr1: 0,
2795            ed19: 0,
2796            eq: 0,
2797            exp: 0,
2798            expi: 0,
2799            flag: 0,
2800            gm: 0,
2801            gt: 0,
2802            gtf: 0,
2803            ji: 0,
2804            jmp: 0,
2805            jne: 0,
2806            jnei: 0,
2807            jnzi: 0,
2808            jmpf: 0,
2809            jmpb: 0,
2810            jnzf: 0,
2811            jnzb: 0,
2812            jnef: 0,
2813            jneb: 0,
2814            lb: 0,
2815            log: 0,
2816            lt: 0,
2817            lw: 0,
2818            mint: 0,
2819            mlog: 0,
2820            mod_op: 0,
2821            modi: 0,
2822            move_op: 0,
2823            movi: 0,
2824            mroo: 0,
2825            mul: 0,
2826            muli: 0,
2827            mldv: 0,
2828            noop: 0,
2829            not: 0,
2830            or: 0,
2831            ori: 0,
2832            poph: 0,
2833            popl: 0,
2834            pshh: 0,
2835            pshl: 0,
2836            ret: 0,
2837            rvrt: 0,
2838            sb: 0,
2839            sll: 0,
2840            slli: 0,
2841            srl: 0,
2842            srli: 0,
2843            srw: 0,
2844            sub: 0,
2845            subi: 0,
2846            sw: 0,
2847            sww: 0,
2848            time: 0,
2849            tr: 0,
2850            tro: 0,
2851            wdcm: 0,
2852            wqcm: 0,
2853            wdop: 0,
2854            wqop: 0,
2855            wdml: 0,
2856            wqml: 0,
2857            wddv: 0,
2858            wqdv: 0,
2859            wdmd: 0,
2860            wqmd: 0,
2861            wdam: 0,
2862            wqam: 0,
2863            wdmm: 0,
2864            wqmm: 0,
2865            xor: 0,
2866            xori: 0,
2867            aloc: DependentCost::free(),
2868            call: DependentCost::free(),
2869            ccp: DependentCost::free(),
2870            croo: DependentCost::free(),
2871            csiz: DependentCost::free(),
2872            k256: DependentCost::free(),
2873            ldc: DependentCost::free(),
2874            logd: DependentCost::free(),
2875            mcl: DependentCost::free(),
2876            mcli: DependentCost::free(),
2877            mcp: DependentCost::free(),
2878            mcpi: DependentCost::free(),
2879            meq: DependentCost::free(),
2880            retd: DependentCost::free(),
2881            s256: DependentCost::free(),
2882            scwq: DependentCost::free(),
2883            smo: DependentCost::free(),
2884            srwq: DependentCost::free(),
2885            swwq: DependentCost::free(),
2886
2887            // Non-opcode costs
2888            contract_root: DependentCost::free(),
2889            state_root: DependentCost::free(),
2890            new_storage_per_byte: 0,
2891            vm_initialization: DependentCost::free(),
2892        }
2893    }
2894
2895    /// Create costs that are all set to one.
2896    pub fn unit() -> Self {
2897        Self {
2898            add: 1,
2899            addi: 1,
2900            and: 1,
2901            andi: 1,
2902            bal: 1,
2903            bhei: 1,
2904            bhsh: 1,
2905            burn: 1,
2906            cb: 1,
2907            cfei: 1,
2908            cfsi: 1,
2909            div: 1,
2910            divi: 1,
2911            eck1: 1,
2912            ecr1: 1,
2913            ed19: 1,
2914            eq: 1,
2915            exp: 1,
2916            expi: 1,
2917            flag: 1,
2918            gm: 1,
2919            gt: 1,
2920            gtf: 1,
2921            ji: 1,
2922            jmp: 1,
2923            jne: 1,
2924            jnei: 1,
2925            jnzi: 1,
2926            jmpf: 1,
2927            jmpb: 1,
2928            jnzf: 1,
2929            jnzb: 1,
2930            jnef: 1,
2931            jneb: 1,
2932            lb: 1,
2933            log: 1,
2934            lt: 1,
2935            lw: 1,
2936            mint: 1,
2937            mlog: 1,
2938            mod_op: 1,
2939            modi: 1,
2940            move_op: 1,
2941            movi: 1,
2942            mroo: 1,
2943            mul: 1,
2944            muli: 1,
2945            mldv: 1,
2946            noop: 1,
2947            not: 1,
2948            or: 1,
2949            ori: 1,
2950            ret: 1,
2951            poph: 1,
2952            popl: 1,
2953            pshh: 1,
2954            pshl: 1,
2955            rvrt: 1,
2956            sb: 1,
2957            sll: 1,
2958            slli: 1,
2959            srl: 1,
2960            srli: 1,
2961            srw: 1,
2962            sub: 1,
2963            subi: 1,
2964            sw: 1,
2965            sww: 1,
2966            time: 1,
2967            tr: 1,
2968            tro: 1,
2969            wdcm: 1,
2970            wqcm: 1,
2971            wdop: 1,
2972            wqop: 1,
2973            wdml: 1,
2974            wqml: 1,
2975            wddv: 1,
2976            wqdv: 1,
2977            wdmd: 1,
2978            wqmd: 1,
2979            wdam: 1,
2980            wqam: 1,
2981            wdmm: 1,
2982            wqmm: 1,
2983            xor: 1,
2984            xori: 1,
2985            aloc: DependentCost::unit(),
2986            call: DependentCost::unit(),
2987            ccp: DependentCost::unit(),
2988            croo: DependentCost::unit(),
2989            csiz: DependentCost::unit(),
2990            k256: DependentCost::unit(),
2991            ldc: DependentCost::unit(),
2992            logd: DependentCost::unit(),
2993            mcl: DependentCost::unit(),
2994            mcli: DependentCost::unit(),
2995            mcp: DependentCost::unit(),
2996            mcpi: DependentCost::unit(),
2997            meq: DependentCost::unit(),
2998            retd: DependentCost::unit(),
2999            s256: DependentCost::unit(),
3000            scwq: DependentCost::unit(),
3001            smo: DependentCost::unit(),
3002            srwq: DependentCost::unit(),
3003            swwq: DependentCost::unit(),
3004
3005            // Non-opcode costs
3006            contract_root: DependentCost::unit(),
3007            state_root: DependentCost::unit(),
3008            new_storage_per_byte: 1,
3009            vm_initialization: DependentCost::unit(),
3010        }
3011    }
3012}
3013
3014impl GasCostsValuesV3 {
3015    /// Create costs that are all set to zero.
3016    pub fn free() -> Self {
3017        Self {
3018            add: 0,
3019            addi: 0,
3020            and: 0,
3021            andi: 0,
3022            bal: 0,
3023            bhei: 0,
3024            bhsh: 0,
3025            burn: 0,
3026            cb: 0,
3027            cfsi: 0,
3028            div: 0,
3029            divi: 0,
3030            eck1: 0,
3031            ecr1: 0,
3032            ed19: 0,
3033            eq: 0,
3034            exp: 0,
3035            expi: 0,
3036            flag: 0,
3037            gm: 0,
3038            gt: 0,
3039            gtf: 0,
3040            ji: 0,
3041            jmp: 0,
3042            jne: 0,
3043            jnei: 0,
3044            jnzi: 0,
3045            jmpf: 0,
3046            jmpb: 0,
3047            jnzf: 0,
3048            jnzb: 0,
3049            jnef: 0,
3050            jneb: 0,
3051            lb: 0,
3052            log: 0,
3053            lt: 0,
3054            lw: 0,
3055            mint: 0,
3056            mlog: 0,
3057            mod_op: 0,
3058            modi: 0,
3059            move_op: 0,
3060            movi: 0,
3061            mroo: 0,
3062            mul: 0,
3063            muli: 0,
3064            mldv: 0,
3065            noop: 0,
3066            not: 0,
3067            or: 0,
3068            ori: 0,
3069            poph: 0,
3070            popl: 0,
3071            pshh: 0,
3072            pshl: 0,
3073            ret: 0,
3074            rvrt: 0,
3075            sb: 0,
3076            sll: 0,
3077            slli: 0,
3078            srl: 0,
3079            srli: 0,
3080            srw: 0,
3081            sub: 0,
3082            subi: 0,
3083            sw: 0,
3084            sww: 0,
3085            time: 0,
3086            tr: 0,
3087            tro: 0,
3088            wdcm: 0,
3089            wqcm: 0,
3090            wdop: 0,
3091            wqop: 0,
3092            wdml: 0,
3093            wqml: 0,
3094            wddv: 0,
3095            wqdv: 0,
3096            wdmd: 0,
3097            wqmd: 0,
3098            wdam: 0,
3099            wqam: 0,
3100            wdmm: 0,
3101            wqmm: 0,
3102            xor: 0,
3103            xori: 0,
3104            aloc: DependentCost::free(),
3105            cfe: DependentCost::free(),
3106            cfei: DependentCost::free(),
3107            call: DependentCost::free(),
3108            ccp: DependentCost::free(),
3109            croo: DependentCost::free(),
3110            csiz: DependentCost::free(),
3111            k256: DependentCost::free(),
3112            ldc: DependentCost::free(),
3113            logd: DependentCost::free(),
3114            mcl: DependentCost::free(),
3115            mcli: DependentCost::free(),
3116            mcp: DependentCost::free(),
3117            mcpi: DependentCost::free(),
3118            meq: DependentCost::free(),
3119            retd: DependentCost::free(),
3120            s256: DependentCost::free(),
3121            scwq: DependentCost::free(),
3122            smo: DependentCost::free(),
3123            srwq: DependentCost::free(),
3124            swwq: DependentCost::free(),
3125
3126            // Non-opcode costs
3127            contract_root: DependentCost::free(),
3128            state_root: DependentCost::free(),
3129            new_storage_per_byte: 0,
3130            vm_initialization: DependentCost::free(),
3131        }
3132    }
3133
3134    /// Create costs that are all set to one.
3135    pub fn unit() -> Self {
3136        Self {
3137            add: 1,
3138            addi: 1,
3139            and: 1,
3140            andi: 1,
3141            bal: 1,
3142            bhei: 1,
3143            bhsh: 1,
3144            burn: 1,
3145            cb: 1,
3146            cfsi: 1,
3147            div: 1,
3148            divi: 1,
3149            eck1: 1,
3150            ecr1: 1,
3151            ed19: 1,
3152            eq: 1,
3153            exp: 1,
3154            expi: 1,
3155            flag: 1,
3156            gm: 1,
3157            gt: 1,
3158            gtf: 1,
3159            ji: 1,
3160            jmp: 1,
3161            jne: 1,
3162            jnei: 1,
3163            jnzi: 1,
3164            jmpf: 1,
3165            jmpb: 1,
3166            jnzf: 1,
3167            jnzb: 1,
3168            jnef: 1,
3169            jneb: 1,
3170            lb: 1,
3171            log: 1,
3172            lt: 1,
3173            lw: 1,
3174            mint: 1,
3175            mlog: 1,
3176            mod_op: 1,
3177            modi: 1,
3178            move_op: 1,
3179            movi: 1,
3180            mroo: 1,
3181            mul: 1,
3182            muli: 1,
3183            mldv: 1,
3184            noop: 1,
3185            not: 1,
3186            or: 1,
3187            ori: 1,
3188            ret: 1,
3189            poph: 1,
3190            popl: 1,
3191            pshh: 1,
3192            pshl: 1,
3193            rvrt: 1,
3194            sb: 1,
3195            sll: 1,
3196            slli: 1,
3197            srl: 1,
3198            srli: 1,
3199            srw: 1,
3200            sub: 1,
3201            subi: 1,
3202            sw: 1,
3203            sww: 1,
3204            time: 1,
3205            tr: 1,
3206            tro: 1,
3207            wdcm: 1,
3208            wqcm: 1,
3209            wdop: 1,
3210            wqop: 1,
3211            wdml: 1,
3212            wqml: 1,
3213            wddv: 1,
3214            wqdv: 1,
3215            wdmd: 1,
3216            wqmd: 1,
3217            wdam: 1,
3218            wqam: 1,
3219            wdmm: 1,
3220            wqmm: 1,
3221            xor: 1,
3222            xori: 1,
3223            aloc: DependentCost::unit(),
3224            cfe: DependentCost::unit(),
3225            cfei: DependentCost::unit(),
3226            call: DependentCost::unit(),
3227            ccp: DependentCost::unit(),
3228            croo: DependentCost::unit(),
3229            csiz: DependentCost::unit(),
3230            k256: DependentCost::unit(),
3231            ldc: DependentCost::unit(),
3232            logd: DependentCost::unit(),
3233            mcl: DependentCost::unit(),
3234            mcli: DependentCost::unit(),
3235            mcp: DependentCost::unit(),
3236            mcpi: DependentCost::unit(),
3237            meq: DependentCost::unit(),
3238            retd: DependentCost::unit(),
3239            s256: DependentCost::unit(),
3240            scwq: DependentCost::unit(),
3241            smo: DependentCost::unit(),
3242            srwq: DependentCost::unit(),
3243            swwq: DependentCost::unit(),
3244
3245            // Non-opcode costs
3246            contract_root: DependentCost::unit(),
3247            state_root: DependentCost::unit(),
3248            new_storage_per_byte: 1,
3249            vm_initialization: DependentCost::unit(),
3250        }
3251    }
3252}
3253
3254impl GasCostsValuesV4 {
3255    /// Create costs that are all set to zero.
3256    pub fn free() -> Self {
3257        Self {
3258            add: 0,
3259            addi: 0,
3260            and: 0,
3261            andi: 0,
3262            bal: 0,
3263            bhei: 0,
3264            bhsh: 0,
3265            burn: 0,
3266            cb: 0,
3267            cfsi: 0,
3268            div: 0,
3269            divi: 0,
3270            eck1: 0,
3271            ecr1: 0,
3272            eq: 0,
3273            exp: 0,
3274            expi: 0,
3275            flag: 0,
3276            gm: 0,
3277            gt: 0,
3278            gtf: 0,
3279            ji: 0,
3280            jmp: 0,
3281            jne: 0,
3282            jnei: 0,
3283            jnzi: 0,
3284            jmpf: 0,
3285            jmpb: 0,
3286            jnzf: 0,
3287            jnzb: 0,
3288            jnef: 0,
3289            jneb: 0,
3290            lb: 0,
3291            log: 0,
3292            lt: 0,
3293            lw: 0,
3294            mint: 0,
3295            mlog: 0,
3296            mod_op: 0,
3297            modi: 0,
3298            move_op: 0,
3299            movi: 0,
3300            mroo: 0,
3301            mul: 0,
3302            muli: 0,
3303            mldv: 0,
3304            noop: 0,
3305            not: 0,
3306            or: 0,
3307            ori: 0,
3308            poph: 0,
3309            popl: 0,
3310            pshh: 0,
3311            pshl: 0,
3312            ret: 0,
3313            rvrt: 0,
3314            sb: 0,
3315            sll: 0,
3316            slli: 0,
3317            srl: 0,
3318            srli: 0,
3319            srw: 0,
3320            sub: 0,
3321            subi: 0,
3322            sw: 0,
3323            sww: 0,
3324            time: 0,
3325            tr: 0,
3326            tro: 0,
3327            wdcm: 0,
3328            wqcm: 0,
3329            wdop: 0,
3330            wqop: 0,
3331            wdml: 0,
3332            wqml: 0,
3333            wddv: 0,
3334            wqdv: 0,
3335            wdmd: 0,
3336            wqmd: 0,
3337            wdam: 0,
3338            wqam: 0,
3339            wdmm: 0,
3340            wqmm: 0,
3341            xor: 0,
3342            xori: 0,
3343            aloc: DependentCost::free(),
3344            bsiz: DependentCost::free(),
3345            bldd: DependentCost::free(),
3346            cfe: DependentCost::free(),
3347            cfei: DependentCost::free(),
3348            call: DependentCost::free(),
3349            ccp: DependentCost::free(),
3350            croo: DependentCost::free(),
3351            csiz: DependentCost::free(),
3352            ed19: DependentCost::free(),
3353            k256: DependentCost::free(),
3354            ldc: DependentCost::free(),
3355            logd: DependentCost::free(),
3356            mcl: DependentCost::free(),
3357            mcli: DependentCost::free(),
3358            mcp: DependentCost::free(),
3359            mcpi: DependentCost::free(),
3360            meq: DependentCost::free(),
3361            retd: DependentCost::free(),
3362            s256: DependentCost::free(),
3363            scwq: DependentCost::free(),
3364            smo: DependentCost::free(),
3365            srwq: DependentCost::free(),
3366            swwq: DependentCost::free(),
3367
3368            // Non-opcode costs
3369            contract_root: DependentCost::free(),
3370            state_root: DependentCost::free(),
3371            new_storage_per_byte: 0,
3372            vm_initialization: DependentCost::free(),
3373        }
3374    }
3375
3376    /// Create costs that are all set to one.
3377    pub fn unit() -> Self {
3378        Self {
3379            add: 1,
3380            addi: 1,
3381            and: 1,
3382            andi: 1,
3383            bal: 1,
3384            bhei: 1,
3385            bhsh: 1,
3386            burn: 1,
3387            cb: 1,
3388            cfsi: 1,
3389            div: 1,
3390            divi: 1,
3391            eck1: 1,
3392            ecr1: 1,
3393            eq: 1,
3394            exp: 1,
3395            expi: 1,
3396            flag: 1,
3397            gm: 1,
3398            gt: 1,
3399            gtf: 1,
3400            ji: 1,
3401            jmp: 1,
3402            jne: 1,
3403            jnei: 1,
3404            jnzi: 1,
3405            jmpf: 1,
3406            jmpb: 1,
3407            jnzf: 1,
3408            jnzb: 1,
3409            jnef: 1,
3410            jneb: 1,
3411            lb: 1,
3412            log: 1,
3413            lt: 1,
3414            lw: 1,
3415            mint: 1,
3416            mlog: 1,
3417            mod_op: 1,
3418            modi: 1,
3419            move_op: 1,
3420            movi: 1,
3421            mroo: 1,
3422            mul: 1,
3423            muli: 1,
3424            mldv: 1,
3425            noop: 1,
3426            not: 1,
3427            or: 1,
3428            ori: 1,
3429            ret: 1,
3430            poph: 1,
3431            popl: 1,
3432            pshh: 1,
3433            pshl: 1,
3434            rvrt: 1,
3435            sb: 1,
3436            sll: 1,
3437            slli: 1,
3438            srl: 1,
3439            srli: 1,
3440            srw: 1,
3441            sub: 1,
3442            subi: 1,
3443            sw: 1,
3444            sww: 1,
3445            time: 1,
3446            tr: 1,
3447            tro: 1,
3448            wdcm: 1,
3449            wqcm: 1,
3450            wdop: 1,
3451            wqop: 1,
3452            wdml: 1,
3453            wqml: 1,
3454            wddv: 1,
3455            wqdv: 1,
3456            wdmd: 1,
3457            wqmd: 1,
3458            wdam: 1,
3459            wqam: 1,
3460            wdmm: 1,
3461            wqmm: 1,
3462            xor: 1,
3463            xori: 1,
3464            aloc: DependentCost::unit(),
3465            bsiz: DependentCost::unit(),
3466            bldd: DependentCost::unit(),
3467            cfe: DependentCost::unit(),
3468            cfei: DependentCost::unit(),
3469            call: DependentCost::unit(),
3470            ccp: DependentCost::unit(),
3471            croo: DependentCost::unit(),
3472            csiz: DependentCost::unit(),
3473            ed19: DependentCost::unit(),
3474            k256: DependentCost::unit(),
3475            ldc: DependentCost::unit(),
3476            logd: DependentCost::unit(),
3477            mcl: DependentCost::unit(),
3478            mcli: DependentCost::unit(),
3479            mcp: DependentCost::unit(),
3480            mcpi: DependentCost::unit(),
3481            meq: DependentCost::unit(),
3482            retd: DependentCost::unit(),
3483            s256: DependentCost::unit(),
3484            scwq: DependentCost::unit(),
3485            smo: DependentCost::unit(),
3486            srwq: DependentCost::unit(),
3487            swwq: DependentCost::unit(),
3488
3489            // Non-opcode costs
3490            contract_root: DependentCost::unit(),
3491            state_root: DependentCost::unit(),
3492            new_storage_per_byte: 1,
3493            vm_initialization: DependentCost::unit(),
3494        }
3495    }
3496}
3497
3498impl GasCostsValuesV5 {
3499    /// Create costs that are all set to zero.
3500    pub fn free() -> Self {
3501        Self {
3502            add: 0,
3503            addi: 0,
3504            and: 0,
3505            andi: 0,
3506            bal: 0,
3507            bhei: 0,
3508            bhsh: 0,
3509            burn: 0,
3510            cb: 0,
3511            cfsi: 0,
3512            div: 0,
3513            divi: 0,
3514            eck1: 0,
3515            ecr1: 0,
3516            eq: 0,
3517            exp: 0,
3518            expi: 0,
3519            flag: 0,
3520            gm: 0,
3521            gt: 0,
3522            gtf: 0,
3523            ji: 0,
3524            jmp: 0,
3525            jne: 0,
3526            jnei: 0,
3527            jnzi: 0,
3528            jmpf: 0,
3529            jmpb: 0,
3530            jnzf: 0,
3531            jnzb: 0,
3532            jnef: 0,
3533            jneb: 0,
3534            lb: 0,
3535            log: 0,
3536            lt: 0,
3537            lw: 0,
3538            mint: 0,
3539            mlog: 0,
3540            mod_op: 0,
3541            modi: 0,
3542            move_op: 0,
3543            movi: 0,
3544            mroo: 0,
3545            mul: 0,
3546            muli: 0,
3547            mldv: 0,
3548            noop: 0,
3549            not: 0,
3550            or: 0,
3551            ori: 0,
3552            poph: 0,
3553            popl: 0,
3554            pshh: 0,
3555            pshl: 0,
3556            ret: 0,
3557            rvrt: 0,
3558            sb: 0,
3559            sll: 0,
3560            slli: 0,
3561            srl: 0,
3562            srli: 0,
3563            srw: 0,
3564            sub: 0,
3565            subi: 0,
3566            sw: 0,
3567            sww: 0,
3568            time: 0,
3569            tr: 0,
3570            tro: 0,
3571            wdcm: 0,
3572            wqcm: 0,
3573            wdop: 0,
3574            wqop: 0,
3575            wdml: 0,
3576            wqml: 0,
3577            wddv: 0,
3578            wqdv: 0,
3579            wdmd: 0,
3580            wqmd: 0,
3581            wdam: 0,
3582            wqam: 0,
3583            wdmm: 0,
3584            wqmm: 0,
3585            xor: 0,
3586            xori: 0,
3587            ecop: 0,
3588            aloc: DependentCost::free(),
3589            bsiz: DependentCost::free(),
3590            bldd: DependentCost::free(),
3591            cfe: DependentCost::free(),
3592            cfei: DependentCost::free(),
3593            call: DependentCost::free(),
3594            ccp: DependentCost::free(),
3595            croo: DependentCost::free(),
3596            csiz: DependentCost::free(),
3597            ed19: DependentCost::free(),
3598            k256: DependentCost::free(),
3599            ldc: DependentCost::free(),
3600            logd: DependentCost::free(),
3601            mcl: DependentCost::free(),
3602            mcli: DependentCost::free(),
3603            mcp: DependentCost::free(),
3604            mcpi: DependentCost::free(),
3605            meq: DependentCost::free(),
3606            retd: DependentCost::free(),
3607            s256: DependentCost::free(),
3608            scwq: DependentCost::free(),
3609            smo: DependentCost::free(),
3610            srwq: DependentCost::free(),
3611            swwq: DependentCost::free(),
3612            epar: DependentCost::free(),
3613
3614            // Non-opcode costs
3615            contract_root: DependentCost::free(),
3616            state_root: DependentCost::free(),
3617            new_storage_per_byte: 0,
3618            vm_initialization: DependentCost::free(),
3619        }
3620    }
3621
3622    /// Create costs that are all set to one.
3623    pub fn unit() -> Self {
3624        Self {
3625            add: 1,
3626            addi: 1,
3627            and: 1,
3628            andi: 1,
3629            bal: 1,
3630            bhei: 1,
3631            bhsh: 1,
3632            burn: 1,
3633            cb: 1,
3634            cfsi: 1,
3635            div: 1,
3636            divi: 1,
3637            eck1: 1,
3638            ecr1: 1,
3639            eq: 1,
3640            exp: 1,
3641            expi: 1,
3642            flag: 1,
3643            gm: 1,
3644            gt: 1,
3645            gtf: 1,
3646            ji: 1,
3647            jmp: 1,
3648            jne: 1,
3649            jnei: 1,
3650            jnzi: 1,
3651            jmpf: 1,
3652            jmpb: 1,
3653            jnzf: 1,
3654            jnzb: 1,
3655            jnef: 1,
3656            jneb: 1,
3657            lb: 1,
3658            log: 1,
3659            lt: 1,
3660            lw: 1,
3661            mint: 1,
3662            mlog: 1,
3663            mod_op: 1,
3664            modi: 1,
3665            move_op: 1,
3666            movi: 1,
3667            mroo: 1,
3668            mul: 1,
3669            muli: 1,
3670            mldv: 1,
3671            noop: 1,
3672            not: 1,
3673            or: 1,
3674            ori: 1,
3675            ret: 1,
3676            poph: 1,
3677            popl: 1,
3678            pshh: 1,
3679            pshl: 1,
3680            rvrt: 1,
3681            sb: 1,
3682            sll: 1,
3683            slli: 1,
3684            srl: 1,
3685            srli: 1,
3686            srw: 1,
3687            sub: 1,
3688            subi: 1,
3689            sw: 1,
3690            sww: 1,
3691            time: 1,
3692            tr: 1,
3693            tro: 1,
3694            wdcm: 1,
3695            wqcm: 1,
3696            wdop: 1,
3697            wqop: 1,
3698            wdml: 1,
3699            wqml: 1,
3700            wddv: 1,
3701            wqdv: 1,
3702            wdmd: 1,
3703            wqmd: 1,
3704            wdam: 1,
3705            wqam: 1,
3706            wdmm: 1,
3707            wqmm: 1,
3708            xor: 1,
3709            xori: 1,
3710            ecop: 1,
3711            aloc: DependentCost::unit(),
3712            bsiz: DependentCost::unit(),
3713            bldd: DependentCost::unit(),
3714            cfe: DependentCost::unit(),
3715            cfei: DependentCost::unit(),
3716            call: DependentCost::unit(),
3717            ccp: DependentCost::unit(),
3718            croo: DependentCost::unit(),
3719            csiz: DependentCost::unit(),
3720            ed19: DependentCost::unit(),
3721            k256: DependentCost::unit(),
3722            ldc: DependentCost::unit(),
3723            logd: DependentCost::unit(),
3724            mcl: DependentCost::unit(),
3725            mcli: DependentCost::unit(),
3726            mcp: DependentCost::unit(),
3727            mcpi: DependentCost::unit(),
3728            meq: DependentCost::unit(),
3729            retd: DependentCost::unit(),
3730            s256: DependentCost::unit(),
3731            scwq: DependentCost::unit(),
3732            smo: DependentCost::unit(),
3733            srwq: DependentCost::unit(),
3734            swwq: DependentCost::unit(),
3735            epar: DependentCost::unit(),
3736
3737            // Non-opcode costs
3738            contract_root: DependentCost::unit(),
3739            state_root: DependentCost::unit(),
3740            new_storage_per_byte: 1,
3741            vm_initialization: DependentCost::unit(),
3742        }
3743    }
3744}
3745
3746impl GasCostsValuesV6 {
3747    /// Create costs that are all set to zero.
3748    pub fn free() -> Self {
3749        Self {
3750            add: 0,
3751            addi: 0,
3752            and: 0,
3753            andi: 0,
3754            bal: 0,
3755            bhei: 0,
3756            bhsh: 0,
3757            burn: 0,
3758            cb: 0,
3759            cfsi: 0,
3760            div: 0,
3761            divi: 0,
3762            eck1: 0,
3763            ecr1: 0,
3764            eq: 0,
3765            exp: 0,
3766            expi: 0,
3767            flag: 0,
3768            gm: 0,
3769            gt: 0,
3770            gtf: 0,
3771            ji: 0,
3772            jmp: 0,
3773            jne: 0,
3774            jnei: 0,
3775            jnzi: 0,
3776            jmpf: 0,
3777            jmpb: 0,
3778            jnzf: 0,
3779            jnzb: 0,
3780            jnef: 0,
3781            jneb: 0,
3782            lb: 0,
3783            log: 0,
3784            lt: 0,
3785            lw: 0,
3786            mint: 0,
3787            mlog: 0,
3788            mod_op: 0,
3789            modi: 0,
3790            move_op: 0,
3791            movi: 0,
3792            mroo: 0,
3793            mul: 0,
3794            muli: 0,
3795            mldv: 0,
3796            niop: 0,
3797            noop: 0,
3798            not: 0,
3799            or: 0,
3800            ori: 0,
3801            poph: 0,
3802            popl: 0,
3803            pshh: 0,
3804            pshl: 0,
3805            ret: 0,
3806            rvrt: 0,
3807            sb: 0,
3808            sll: 0,
3809            slli: 0,
3810            srl: 0,
3811            srli: 0,
3812            srw: 0,
3813            sub: 0,
3814            subi: 0,
3815            sw: 0,
3816            sww: 0,
3817            time: 0,
3818            tr: 0,
3819            tro: 0,
3820            wdcm: 0,
3821            wqcm: 0,
3822            wdop: 0,
3823            wqop: 0,
3824            wdml: 0,
3825            wqml: 0,
3826            wddv: 0,
3827            wqdv: 0,
3828            wdmd: 0,
3829            wqmd: 0,
3830            wdam: 0,
3831            wqam: 0,
3832            wdmm: 0,
3833            wqmm: 0,
3834            xor: 0,
3835            xori: 0,
3836            ecop: 0,
3837            aloc: DependentCost::free(),
3838            bsiz: DependentCost::free(),
3839            bldd: DependentCost::free(),
3840            cfe: DependentCost::free(),
3841            cfei: DependentCost::free(),
3842            call: DependentCost::free(),
3843            ccp: DependentCost::free(),
3844            croo: DependentCost::free(),
3845            csiz: DependentCost::free(),
3846            ed19: DependentCost::free(),
3847            k256: DependentCost::free(),
3848            ldc: DependentCost::free(),
3849            logd: DependentCost::free(),
3850            mcl: DependentCost::free(),
3851            mcli: DependentCost::free(),
3852            mcp: DependentCost::free(),
3853            mcpi: DependentCost::free(),
3854            meq: DependentCost::free(),
3855            retd: DependentCost::free(),
3856            s256: DependentCost::free(),
3857            scwq: DependentCost::free(),
3858            smo: DependentCost::free(),
3859            srwq: DependentCost::free(),
3860            swwq: DependentCost::free(),
3861            epar: DependentCost::free(),
3862
3863            // Non-opcode costs
3864            contract_root: DependentCost::free(),
3865            state_root: DependentCost::free(),
3866            new_storage_per_byte: 0,
3867            vm_initialization: DependentCost::free(),
3868        }
3869    }
3870
3871    /// Create costs that are all set to one.
3872    pub fn unit() -> Self {
3873        Self {
3874            add: 1,
3875            addi: 1,
3876            and: 1,
3877            andi: 1,
3878            bal: 1,
3879            bhei: 1,
3880            bhsh: 1,
3881            burn: 1,
3882            cb: 1,
3883            cfsi: 1,
3884            div: 1,
3885            divi: 1,
3886            eck1: 1,
3887            ecr1: 1,
3888            eq: 1,
3889            exp: 1,
3890            expi: 1,
3891            flag: 1,
3892            gm: 1,
3893            gt: 1,
3894            gtf: 1,
3895            ji: 1,
3896            jmp: 1,
3897            jne: 1,
3898            jnei: 1,
3899            jnzi: 1,
3900            jmpf: 1,
3901            jmpb: 1,
3902            jnzf: 1,
3903            jnzb: 1,
3904            jnef: 1,
3905            jneb: 1,
3906            lb: 1,
3907            log: 1,
3908            lt: 1,
3909            lw: 1,
3910            mint: 1,
3911            mlog: 1,
3912            mod_op: 1,
3913            modi: 1,
3914            move_op: 1,
3915            movi: 1,
3916            mroo: 1,
3917            mul: 1,
3918            muli: 1,
3919            mldv: 1,
3920            niop: 1,
3921            noop: 1,
3922            not: 1,
3923            or: 1,
3924            ori: 1,
3925            ret: 1,
3926            poph: 1,
3927            popl: 1,
3928            pshh: 1,
3929            pshl: 1,
3930            rvrt: 1,
3931            sb: 1,
3932            sll: 1,
3933            slli: 1,
3934            srl: 1,
3935            srli: 1,
3936            srw: 1,
3937            sub: 1,
3938            subi: 1,
3939            sw: 1,
3940            sww: 1,
3941            time: 1,
3942            tr: 1,
3943            tro: 1,
3944            wdcm: 1,
3945            wqcm: 1,
3946            wdop: 1,
3947            wqop: 1,
3948            wdml: 1,
3949            wqml: 1,
3950            wddv: 1,
3951            wqdv: 1,
3952            wdmd: 1,
3953            wqmd: 1,
3954            wdam: 1,
3955            wqam: 1,
3956            wdmm: 1,
3957            wqmm: 1,
3958            xor: 1,
3959            xori: 1,
3960            ecop: 1,
3961            aloc: DependentCost::unit(),
3962            bsiz: DependentCost::unit(),
3963            bldd: DependentCost::unit(),
3964            cfe: DependentCost::unit(),
3965            cfei: DependentCost::unit(),
3966            call: DependentCost::unit(),
3967            ccp: DependentCost::unit(),
3968            croo: DependentCost::unit(),
3969            csiz: DependentCost::unit(),
3970            ed19: DependentCost::unit(),
3971            k256: DependentCost::unit(),
3972            ldc: DependentCost::unit(),
3973            logd: DependentCost::unit(),
3974            mcl: DependentCost::unit(),
3975            mcli: DependentCost::unit(),
3976            mcp: DependentCost::unit(),
3977            mcpi: DependentCost::unit(),
3978            meq: DependentCost::unit(),
3979            retd: DependentCost::unit(),
3980            s256: DependentCost::unit(),
3981            scwq: DependentCost::unit(),
3982            smo: DependentCost::unit(),
3983            srwq: DependentCost::unit(),
3984            swwq: DependentCost::unit(),
3985            epar: DependentCost::unit(),
3986
3987            // Non-opcode costs
3988            contract_root: DependentCost::unit(),
3989            state_root: DependentCost::unit(),
3990            new_storage_per_byte: 1,
3991            vm_initialization: DependentCost::unit(),
3992        }
3993    }
3994}
3995
3996impl GasCostsValuesV7 {
3997    /// Create costs that are all set to zero.
3998    pub fn free() -> Self {
3999        Self {
4000            add: 0,
4001            addi: 0,
4002            and: 0,
4003            andi: 0,
4004            bal: 0,
4005            bhei: 0,
4006            bhsh: 0,
4007            burn: 0,
4008            cb: 0,
4009            cfsi: 0,
4010            div: 0,
4011            divi: 0,
4012            eck1: 0,
4013            ecr1: 0,
4014            eq: 0,
4015            exp: 0,
4016            expi: 0,
4017            flag: 0,
4018            gm: 0,
4019            gt: 0,
4020            gtf: 0,
4021            ji: 0,
4022            jmp: 0,
4023            jne: 0,
4024            jnei: 0,
4025            jnzi: 0,
4026            jmpf: 0,
4027            jmpb: 0,
4028            jnzf: 0,
4029            jnzb: 0,
4030            jnef: 0,
4031            jneb: 0,
4032            lb: 0,
4033            log: 0,
4034            lt: 0,
4035            lw: 0,
4036            mint: 0,
4037            mlog: 0,
4038            mod_op: 0,
4039            modi: 0,
4040            move_op: 0,
4041            movi: 0,
4042            mroo: 0,
4043            mul: 0,
4044            muli: 0,
4045            mldv: 0,
4046            niop: 0,
4047            noop: 0,
4048            not: 0,
4049            or: 0,
4050            ori: 0,
4051            poph: 0,
4052            popl: 0,
4053            pshh: 0,
4054            pshl: 0,
4055            ret: 0,
4056            rvrt: 0,
4057            sb: 0,
4058            sll: 0,
4059            slli: 0,
4060            srl: 0,
4061            srli: 0,
4062            sub: 0,
4063            subi: 0,
4064            sw: 0,
4065            time: 0,
4066            tr: 0,
4067            tro: 0,
4068            wdcm: 0,
4069            wqcm: 0,
4070            wdop: 0,
4071            wqop: 0,
4072            wdml: 0,
4073            wqml: 0,
4074            wddv: 0,
4075            wqdv: 0,
4076            wdmd: 0,
4077            wqmd: 0,
4078            wdam: 0,
4079            wqam: 0,
4080            wdmm: 0,
4081            wqmm: 0,
4082            xor: 0,
4083            xori: 0,
4084            ecop: 0,
4085            aloc: DependentCost::free(),
4086            bsiz: DependentCost::free(),
4087            bldd: DependentCost::free(),
4088            cfe: DependentCost::free(),
4089            cfei: DependentCost::free(),
4090            call: DependentCost::free(),
4091            ccp: DependentCost::free(),
4092            croo: DependentCost::free(),
4093            csiz: DependentCost::free(),
4094            ed19: DependentCost::free(),
4095            k256: DependentCost::free(),
4096            ldc: DependentCost::free(),
4097            logd: DependentCost::free(),
4098            mcl: DependentCost::free(),
4099            mcli: DependentCost::free(),
4100            mcp: DependentCost::free(),
4101            mcpi: DependentCost::free(),
4102            meq: DependentCost::free(),
4103            retd: DependentCost::free(),
4104            s256: DependentCost::free(),
4105            smo: DependentCost::free(),
4106            epar: DependentCost::free(),
4107
4108            // Storage internals
4109            storage_read_cold: DependentCost::free(),
4110            storage_read_hot: DependentCost::free(),
4111            storage_write: DependentCost::free(),
4112            storage_clear: DependentCost::free(),
4113
4114            // Non-opcode costs
4115            contract_root: DependentCost::free(),
4116            state_root: DependentCost::free(),
4117            new_storage_per_byte: 0,
4118            vm_initialization: DependentCost::free(),
4119        }
4120    }
4121
4122    /// Create costs that are all set to one.
4123    pub fn unit() -> Self {
4124        Self {
4125            add: 1,
4126            addi: 1,
4127            and: 1,
4128            andi: 1,
4129            bal: 1,
4130            bhei: 1,
4131            bhsh: 1,
4132            burn: 1,
4133            cb: 1,
4134            cfsi: 1,
4135            div: 1,
4136            divi: 1,
4137            eck1: 1,
4138            ecr1: 1,
4139            eq: 1,
4140            exp: 1,
4141            expi: 1,
4142            flag: 1,
4143            gm: 1,
4144            gt: 1,
4145            gtf: 1,
4146            ji: 1,
4147            jmp: 1,
4148            jne: 1,
4149            jnei: 1,
4150            jnzi: 1,
4151            jmpf: 1,
4152            jmpb: 1,
4153            jnzf: 1,
4154            jnzb: 1,
4155            jnef: 1,
4156            jneb: 1,
4157            lb: 1,
4158            log: 1,
4159            lt: 1,
4160            lw: 1,
4161            mint: 1,
4162            mlog: 1,
4163            mod_op: 1,
4164            modi: 1,
4165            move_op: 1,
4166            movi: 1,
4167            mroo: 1,
4168            mul: 1,
4169            muli: 1,
4170            mldv: 1,
4171            niop: 1,
4172            noop: 1,
4173            not: 1,
4174            or: 1,
4175            ori: 1,
4176            ret: 1,
4177            poph: 1,
4178            popl: 1,
4179            pshh: 1,
4180            pshl: 1,
4181            rvrt: 1,
4182            sb: 1,
4183            sll: 1,
4184            slli: 1,
4185            srl: 1,
4186            srli: 1,
4187            sub: 1,
4188            subi: 1,
4189            sw: 1,
4190            time: 1,
4191            tr: 1,
4192            tro: 1,
4193            wdcm: 1,
4194            wqcm: 1,
4195            wdop: 1,
4196            wqop: 1,
4197            wdml: 1,
4198            wqml: 1,
4199            wddv: 1,
4200            wqdv: 1,
4201            wdmd: 1,
4202            wqmd: 1,
4203            wdam: 1,
4204            wqam: 1,
4205            wdmm: 1,
4206            wqmm: 1,
4207            xor: 1,
4208            xori: 1,
4209            ecop: 1,
4210            aloc: DependentCost::unit(),
4211            bsiz: DependentCost::unit(),
4212            bldd: DependentCost::unit(),
4213            cfe: DependentCost::unit(),
4214            cfei: DependentCost::unit(),
4215            call: DependentCost::unit(),
4216            ccp: DependentCost::unit(),
4217            croo: DependentCost::unit(),
4218            csiz: DependentCost::unit(),
4219            ed19: DependentCost::unit(),
4220            k256: DependentCost::unit(),
4221            ldc: DependentCost::unit(),
4222            logd: DependentCost::unit(),
4223            mcl: DependentCost::unit(),
4224            mcli: DependentCost::unit(),
4225            mcp: DependentCost::unit(),
4226            mcpi: DependentCost::unit(),
4227            meq: DependentCost::unit(),
4228            retd: DependentCost::unit(),
4229            s256: DependentCost::unit(),
4230            smo: DependentCost::unit(),
4231            epar: DependentCost::unit(),
4232
4233            // Storage internals
4234            storage_read_cold: DependentCost::unit(),
4235            storage_read_hot: DependentCost::unit(),
4236            storage_write: DependentCost::unit(),
4237            storage_clear: DependentCost::unit(),
4238
4239            // Non-opcode costs
4240            contract_root: DependentCost::unit(),
4241            state_root: DependentCost::unit(),
4242            new_storage_per_byte: 1,
4243            vm_initialization: DependentCost::unit(),
4244        }
4245    }
4246}
4247
4248impl DependentCost {
4249    /// Create costs that make operations free.
4250    pub fn free() -> Self {
4251        Self::HeavyOperation {
4252            base: 0,
4253            gas_per_unit: 0,
4254        }
4255    }
4256
4257    /// Create costs that make operations cost `1`.
4258    pub fn unit() -> Self {
4259        Self::HeavyOperation {
4260            base: 1,
4261            gas_per_unit: 0,
4262        }
4263    }
4264
4265    pub fn from_units_per_gas(base: Word, units_per_gas: Word) -> Self {
4266        debug_assert!(
4267            units_per_gas > 0,
4268            "Cannot create dependent gas cost with per-0-gas ratio"
4269        );
4270        DependentCost::LightOperation {
4271            base,
4272            units_per_gas,
4273        }
4274    }
4275
4276    pub fn from_gas_per_unit(base: Word, gas_per_unit: Word) -> Self {
4277        DependentCost::HeavyOperation { base, gas_per_unit }
4278    }
4279
4280    pub fn base(&self) -> Word {
4281        match self {
4282            DependentCost::LightOperation { base, .. } => *base,
4283            DependentCost::HeavyOperation { base, .. } => *base,
4284        }
4285    }
4286
4287    pub fn set_base(&mut self, value: Word) {
4288        match self {
4289            DependentCost::LightOperation { base, .. } => *base = value,
4290            DependentCost::HeavyOperation { base, .. } => *base = value,
4291        };
4292    }
4293
4294    pub fn resolve(&self, units: Word) -> Word {
4295        let base = self.base();
4296        let dependent_value = self.resolve_without_base(units);
4297        base.saturating_add(dependent_value)
4298    }
4299
4300    pub fn resolve_without_base(&self, units: Word) -> Word {
4301        match self {
4302            DependentCost::LightOperation { units_per_gas, .. } => {
4303                // Apply the linear transformation:
4304                //   f(x) = 1/m * x = x/m
4305                // where:
4306                //   x is the number of units
4307                //   1/m is the gas_per_unit
4308                units
4309                    .checked_div(*units_per_gas)
4310                    .expect("units_per_gas cannot be zero")
4311            }
4312            DependentCost::HeavyOperation { gas_per_unit, .. } => {
4313                // Apply the linear transformation:
4314                //   f(x) = mx
4315                // where:
4316                //   x is the number of units
4317                //   m is the gas per unit
4318                units.saturating_mul(*gas_per_unit)
4319            }
4320        }
4321    }
4322}
4323
4324#[cfg(feature = "alloc")]
4325impl Deref for GasCosts {
4326    type Target = GasCostsValues;
4327
4328    fn deref(&self) -> &Self::Target {
4329        &(self.0)
4330    }
4331}
4332
4333impl From<GasCostsValues> for GasCosts {
4334    fn from(i: GasCostsValues) -> Self {
4335        Self(Arc::new(i))
4336    }
4337}
4338
4339impl From<GasCosts> for GasCostsValues {
4340    fn from(i: GasCosts) -> Self {
4341        (*i.0).clone()
4342    }
4343}
4344
4345impl From<GasCostsValuesV1> for GasCostsValues {
4346    fn from(i: GasCostsValuesV1) -> Self {
4347        GasCostsValues::V1(i)
4348    }
4349}
4350
4351impl From<GasCostsValuesV2> for GasCostsValues {
4352    fn from(i: GasCostsValuesV2) -> Self {
4353        GasCostsValues::V2(i)
4354    }
4355}
4356
4357impl From<GasCostsValuesV3> for GasCostsValues {
4358    fn from(i: GasCostsValuesV3) -> Self {
4359        GasCostsValues::V3(i)
4360    }
4361}
4362impl From<GasCostsValuesV4> for GasCostsValues {
4363    fn from(i: GasCostsValuesV4) -> Self {
4364        GasCostsValues::V4(i)
4365    }
4366}
4367
4368impl From<GasCostsValuesV5> for GasCostsValues {
4369    fn from(i: GasCostsValuesV5) -> Self {
4370        GasCostsValues::V5(i)
4371    }
4372}
4373
4374impl From<GasCostsValuesV6> for GasCostsValues {
4375    fn from(i: GasCostsValuesV6) -> Self {
4376        GasCostsValues::V6(i)
4377    }
4378}
4379
4380impl From<GasCostsValuesV7> for GasCostsValues {
4381    fn from(i: GasCostsValuesV7) -> Self {
4382        GasCostsValues::V7(i)
4383    }
4384}
4385
4386#[cfg(test)]
4387mod tests {
4388    use crate::DependentCost;
4389
4390    #[test]
4391    fn light_operation_gas_cost_resolves_correctly() {
4392        // Create a linear gas cost function with a slope of 1/10
4393        let cost = DependentCost::from_units_per_gas(0, 10);
4394        let total = cost.resolve(0);
4395        assert_eq!(total, 0);
4396
4397        let total = cost.resolve(5);
4398        assert_eq!(total, 0);
4399
4400        let total = cost.resolve(10);
4401        assert_eq!(total, 1);
4402
4403        let total = cost.resolve(100);
4404        assert_eq!(total, 10);
4405
4406        let total = cost.resolve(721);
4407        assert_eq!(total, 72);
4408    }
4409
4410    #[test]
4411    fn heavy_operation_gas_cost_resolves_correctly() {
4412        // Create a linear gas cost function with a slope of 10
4413        let cost = DependentCost::from_gas_per_unit(0, 10);
4414        let total = cost.resolve(0);
4415        assert_eq!(total, 0);
4416
4417        let total = cost.resolve(5);
4418        assert_eq!(total, 50);
4419
4420        let total = cost.resolve(10);
4421        assert_eq!(total, 100);
4422
4423        let total = cost.resolve(100);
4424        assert_eq!(total, 1_000);
4425
4426        let total = cost.resolve(721);
4427        assert_eq!(total, 7_210);
4428    }
4429}