1use super::{Error, Value};
2use crate::builtins::DefaultFunction;
3use num_traits::Signed;
4use pallas_primitives::conway::Language;
5use std::collections::HashMap;
6
7use strum::{Display, EnumIter};
8
9macro_rules! hashmap {
10 ($($k:expr => $v:expr),* $(,)?) => {{
12 core::convert::From::from([$(($k, $v),)*])
13 }};
14 ($($v:expr),* $(,)?) => {{
16 core::convert::From::from([$($v,)*])
17 }};
18}
19
20#[derive(Debug, Clone, PartialEq, Eq, Copy, serde::Serialize)]
22pub struct ExBudget {
23 pub mem: i64,
24 pub cpu: i64,
25}
26
27impl ExBudget {
28 pub fn occurrences(&mut self, n: i64) {
29 self.mem *= n;
30 self.cpu *= n;
31 }
32
33 pub fn max() -> Self {
34 ExBudget {
35 mem: 14000000000000,
36 cpu: 10000000000000,
37 }
38 }
39}
40
41impl Default for ExBudget {
42 fn default() -> Self {
43 ExBudget {
44 mem: 14000000,
45 cpu: 10000000000,
46 }
47 }
48}
49
50impl std::ops::Sub for ExBudget {
51 type Output = Self;
52
53 fn sub(self, rhs: Self) -> Self::Output {
54 ExBudget {
55 mem: self.mem - rhs.mem,
56 cpu: self.cpu - rhs.cpu,
57 }
58 }
59}
60
61#[derive(Default, Debug, PartialEq)]
62pub struct CostModel {
63 pub machine_costs: MachineCosts,
64 pub builtin_costs: BuiltinCosts,
65}
66
67impl CostModel {
68 pub fn v1() -> Self {
69 Self {
70 machine_costs: MachineCosts::v1(),
71 builtin_costs: BuiltinCosts::v1(),
72 }
73 }
74
75 pub fn v2() -> Self {
76 Self {
77 machine_costs: MachineCosts::v2(),
78 builtin_costs: BuiltinCosts::v2(),
79 }
80 }
81
82 pub fn v3() -> Self {
83 Self {
84 machine_costs: MachineCosts::v3(),
85 builtin_costs: BuiltinCosts::v3(),
86 }
87 }
88}
89
90#[derive(Debug, PartialEq)]
93pub struct MachineCosts {
94 startup: ExBudget,
95 var: ExBudget,
96 constant: ExBudget,
97 lambda: ExBudget,
98 delay: ExBudget,
99 force: ExBudget,
100 apply: ExBudget,
101 constr: ExBudget,
102 case: ExBudget,
103 builtin: ExBudget,
105}
106
107impl MachineCosts {
108 pub fn get(&self, step: StepKind) -> ExBudget {
110 match step {
111 StepKind::Constant => self.constant,
112 StepKind::Var => self.var,
113 StepKind::Lambda => self.lambda,
114 StepKind::Apply => self.apply,
115 StepKind::Delay => self.delay,
116 StepKind::Force => self.force,
117 StepKind::Builtin => self.builtin,
118 StepKind::Constr => self.constr,
119 StepKind::Case => self.case,
120 StepKind::StartUp => self.startup,
121 }
122 }
123
124 pub fn v1() -> Self {
125 Self {
126 startup: ExBudget { mem: 100, cpu: 100 },
127 var: ExBudget {
128 mem: 100,
129 cpu: 16000,
130 },
131 constant: ExBudget {
132 mem: 100,
133 cpu: 16000,
134 },
135 lambda: ExBudget {
136 mem: 100,
137 cpu: 16000,
138 },
139 delay: ExBudget {
140 mem: 100,
141 cpu: 16000,
142 },
143 force: ExBudget {
144 mem: 100,
145 cpu: 16000,
146 },
147 apply: ExBudget {
148 mem: 100,
149 cpu: 16000,
150 },
151 builtin: ExBudget {
152 mem: 100,
153 cpu: 16000,
154 },
155 constr: ExBudget {
157 mem: 30000000000,
158 cpu: 30000000000,
159 },
160 case: ExBudget {
161 mem: 30000000000,
162 cpu: 30000000000,
163 },
164 }
165 }
166
167 pub fn v2() -> Self {
168 Self {
169 startup: ExBudget { mem: 100, cpu: 100 },
170 var: ExBudget {
171 mem: 100,
172 cpu: 16000,
173 },
174 constant: ExBudget {
175 mem: 100,
176 cpu: 16000,
177 },
178 lambda: ExBudget {
179 mem: 100,
180 cpu: 16000,
181 },
182 delay: ExBudget {
183 mem: 100,
184 cpu: 16000,
185 },
186 force: ExBudget {
187 mem: 100,
188 cpu: 16000,
189 },
190 apply: ExBudget {
191 mem: 100,
192 cpu: 16000,
193 },
194 builtin: ExBudget {
195 mem: 100,
196 cpu: 16000,
197 },
198 constr: ExBudget {
200 mem: 30000000000,
201 cpu: 30000000000,
202 },
203 case: ExBudget {
204 mem: 30000000000,
205 cpu: 30000000000,
206 },
207 }
208 }
209
210 pub fn v3() -> Self {
211 Self {
212 startup: ExBudget { mem: 100, cpu: 100 },
213 var: ExBudget {
214 mem: 100,
215 cpu: 16000,
216 },
217 constant: ExBudget {
218 mem: 100,
219 cpu: 16000,
220 },
221 lambda: ExBudget {
222 mem: 100,
223 cpu: 16000,
224 },
225 delay: ExBudget {
226 mem: 100,
227 cpu: 16000,
228 },
229 force: ExBudget {
230 mem: 100,
231 cpu: 16000,
232 },
233 apply: ExBudget {
234 mem: 100,
235 cpu: 16000,
236 },
237 builtin: ExBudget {
238 mem: 100,
239 cpu: 16000,
240 },
241 constr: ExBudget {
242 mem: 100,
243 cpu: 16000,
244 },
245 case: ExBudget {
246 mem: 100,
247 cpu: 16000,
248 },
249 }
250 }
251}
252
253impl Default for MachineCosts {
254 fn default() -> Self {
255 MachineCosts::v3()
256 }
257}
258
259#[derive(Debug, PartialEq)]
260pub struct BuiltinCosts {
261 pub add_integer: CostingFun<TwoArguments>,
262 pub subtract_integer: CostingFun<TwoArguments>,
263 pub multiply_integer: CostingFun<TwoArguments>,
264 pub divide_integer: CostingFun<TwoArguments>,
265 pub quotient_integer: CostingFun<TwoArguments>,
266 pub remainder_integer: CostingFun<TwoArguments>,
267 pub mod_integer: CostingFun<TwoArguments>,
268 pub equals_integer: CostingFun<TwoArguments>,
269 pub less_than_integer: CostingFun<TwoArguments>,
270 pub less_than_equals_integer: CostingFun<TwoArguments>,
271 pub append_byte_string: CostingFun<TwoArguments>,
273 pub cons_byte_string: CostingFun<TwoArguments>,
274 pub slice_byte_string: CostingFun<ThreeArguments>,
275 pub length_of_byte_string: CostingFun<OneArgument>,
276 pub index_byte_string: CostingFun<TwoArguments>,
277 pub equals_byte_string: CostingFun<TwoArguments>,
278 pub less_than_byte_string: CostingFun<TwoArguments>,
279 pub less_than_equals_byte_string: CostingFun<TwoArguments>,
280 pub sha2_256: CostingFun<OneArgument>,
282 pub sha3_256: CostingFun<OneArgument>,
283 pub blake2b_224: CostingFun<OneArgument>,
284 pub blake2b_256: CostingFun<OneArgument>,
285 pub keccak_256: CostingFun<OneArgument>,
286 pub verify_ed25519_signature: CostingFun<ThreeArguments>,
287 pub verify_ecdsa_secp256k1_signature: CostingFun<ThreeArguments>,
288 pub verify_schnorr_secp256k1_signature: CostingFun<ThreeArguments>,
289 pub append_string: CostingFun<TwoArguments>,
291 pub equals_string: CostingFun<TwoArguments>,
292 pub encode_utf8: CostingFun<OneArgument>,
293 pub decode_utf8: CostingFun<OneArgument>,
294 pub if_then_else: CostingFun<ThreeArguments>,
296 pub choose_unit: CostingFun<TwoArguments>,
298 pub trace: CostingFun<TwoArguments>,
300 pub fst_pair: CostingFun<OneArgument>,
302 pub snd_pair: CostingFun<OneArgument>,
303 pub choose_list: CostingFun<ThreeArguments>,
305 pub mk_cons: CostingFun<TwoArguments>,
306 pub head_list: CostingFun<OneArgument>,
307 pub tail_list: CostingFun<OneArgument>,
308 pub null_list: CostingFun<OneArgument>,
309 pub choose_data: CostingFun<SixArguments>,
311 pub constr_data: CostingFun<TwoArguments>,
312 pub map_data: CostingFun<OneArgument>,
313 pub list_data: CostingFun<OneArgument>,
314 pub i_data: CostingFun<OneArgument>,
315 pub b_data: CostingFun<OneArgument>,
316 pub un_constr_data: CostingFun<OneArgument>,
317 pub un_map_data: CostingFun<OneArgument>,
318 pub un_list_data: CostingFun<OneArgument>,
319 pub un_i_data: CostingFun<OneArgument>,
320 pub un_b_data: CostingFun<OneArgument>,
321 pub equals_data: CostingFun<TwoArguments>,
322 pub mk_pair_data: CostingFun<TwoArguments>,
324 pub mk_nil_data: CostingFun<OneArgument>,
325 pub mk_nil_pair_data: CostingFun<OneArgument>,
326 pub serialise_data: CostingFun<OneArgument>,
327 bls12_381_g1_add: CostingFun<TwoArguments>,
329 bls12_381_g1_neg: CostingFun<OneArgument>,
330 bls12_381_g1_scalar_mul: CostingFun<TwoArguments>,
331 bls12_381_g1_equal: CostingFun<TwoArguments>,
332 bls12_381_g1_compress: CostingFun<OneArgument>,
333 bls12_381_g1_uncompress: CostingFun<OneArgument>,
334 bls12_381_g1_hash_to_group: CostingFun<TwoArguments>,
335 bls12_381_g2_add: CostingFun<TwoArguments>,
336 bls12_381_g2_neg: CostingFun<OneArgument>,
337 bls12_381_g2_scalar_mul: CostingFun<TwoArguments>,
338 bls12_381_g2_equal: CostingFun<TwoArguments>,
339 bls12_381_g2_compress: CostingFun<OneArgument>,
340 bls12_381_g2_uncompress: CostingFun<OneArgument>,
341 bls12_381_g2_hash_to_group: CostingFun<TwoArguments>,
342 bls12_381_miller_loop: CostingFun<TwoArguments>,
343 bls12_381_mul_ml_result: CostingFun<TwoArguments>,
344 bls12_381_final_verify: CostingFun<TwoArguments>,
345 integer_to_byte_string: CostingFun<ThreeArguments>,
347 byte_string_to_integer: CostingFun<TwoArguments>,
348 and_byte_string: CostingFun<ThreeArguments>,
349 or_byte_string: CostingFun<ThreeArguments>,
350 xor_byte_string: CostingFun<ThreeArguments>,
351 complement_byte_string: CostingFun<OneArgument>,
352 read_bit: CostingFun<TwoArguments>,
353 write_bits: CostingFun<ThreeArguments>,
354 replicate_byte: CostingFun<TwoArguments>,
355 shift_byte_string: CostingFun<TwoArguments>,
356 rotate_byte_string: CostingFun<TwoArguments>,
357 count_set_bits: CostingFun<OneArgument>,
358 find_first_set_bit: CostingFun<OneArgument>,
359 ripemd_160: CostingFun<OneArgument>,
360 exp_mod_int: CostingFun<ThreeArguments>,
361}
362
363impl BuiltinCosts {
364 pub fn v1() -> Self {
365 Self {
366 add_integer: CostingFun {
367 mem: TwoArguments::MaxSize(MaxSize {
368 intercept: 1,
369 slope: 1,
370 }),
371 cpu: TwoArguments::MaxSize(MaxSize {
372 intercept: 100788,
373 slope: 420,
374 }),
375 },
376 subtract_integer: CostingFun {
377 mem: TwoArguments::MaxSize(MaxSize {
378 intercept: 1,
379 slope: 1,
380 }),
381 cpu: TwoArguments::MaxSize(MaxSize {
382 intercept: 100788,
383 slope: 420,
384 }),
385 },
386 multiply_integer: CostingFun {
387 mem: TwoArguments::AddedSizes(AddedSizes {
388 intercept: 0,
389 slope: 1,
390 }),
391 cpu: TwoArguments::MultipliedSizes(MultipliedSizes {
392 intercept: 90434,
393 slope: 519,
394 }),
395 },
396 divide_integer: CostingFun {
397 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
398 intercept: 0,
399 slope: 1,
400 minimum: 1,
401 }),
402 cpu: TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
403 constant: 85848,
404 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
405 intercept: 228465,
406 slope: 122,
407 })),
408 }),
409 },
410 quotient_integer: CostingFun {
411 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
412 intercept: 0,
413 slope: 1,
414 minimum: 1,
415 }),
416 cpu: TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
417 constant: 85848,
418 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
419 intercept: 228465,
420 slope: 122,
421 })),
422 }),
423 },
424 remainder_integer: CostingFun {
425 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
426 intercept: 0,
427 slope: 1,
428 minimum: 1,
429 }),
430 cpu: TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
431 constant: 85848,
432 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
433 intercept: 228465,
434 slope: 122,
435 })),
436 }),
437 },
438 mod_integer: CostingFun {
439 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
440 intercept: 0,
441 slope: 1,
442 minimum: 1,
443 }),
444 cpu: TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
445 constant: 85848,
446 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
447 intercept: 228465,
448 slope: 122,
449 })),
450 }),
451 },
452 equals_integer: CostingFun {
453 mem: TwoArguments::ConstantCost(1),
454 cpu: TwoArguments::MinSize(MinSize {
455 intercept: 51775,
456 slope: 558,
457 }),
458 },
459 less_than_integer: CostingFun {
460 mem: TwoArguments::ConstantCost(1),
461 cpu: TwoArguments::MinSize(MinSize {
462 intercept: 44749,
463 slope: 541,
464 }),
465 },
466 less_than_equals_integer: CostingFun {
467 mem: TwoArguments::ConstantCost(1),
468 cpu: TwoArguments::MinSize(MinSize {
469 intercept: 43285,
470 slope: 552,
471 }),
472 },
473 append_byte_string: CostingFun {
474 mem: TwoArguments::AddedSizes(AddedSizes {
475 intercept: 0,
476 slope: 1,
477 }),
478 cpu: TwoArguments::AddedSizes(AddedSizes {
479 intercept: 1000,
480 slope: 173,
481 }),
482 },
483 cons_byte_string: CostingFun {
484 mem: TwoArguments::AddedSizes(AddedSizes {
485 intercept: 0,
486 slope: 1,
487 }),
488 cpu: TwoArguments::LinearInY(LinearSize {
489 intercept: 72010,
490 slope: 178,
491 }),
492 },
493 slice_byte_string: CostingFun {
494 mem: ThreeArguments::LinearInZ(LinearSize {
495 intercept: 4,
496 slope: 0,
497 }),
498 cpu: ThreeArguments::LinearInZ(LinearSize {
499 intercept: 20467,
500 slope: 1,
501 }),
502 },
503 length_of_byte_string: CostingFun {
504 mem: OneArgument::ConstantCost(10),
505 cpu: OneArgument::ConstantCost(22100),
506 },
507 index_byte_string: CostingFun {
508 mem: TwoArguments::ConstantCost(4),
509 cpu: TwoArguments::ConstantCost(13169),
510 },
511 equals_byte_string: CostingFun {
512 mem: TwoArguments::ConstantCost(1),
513 cpu: TwoArguments::LinearOnDiagonal(ConstantOrLinear {
514 constant: 24548,
515 intercept: 29498,
516 slope: 38,
517 }),
518 },
519 less_than_byte_string: CostingFun {
520 mem: TwoArguments::ConstantCost(1),
521 cpu: TwoArguments::MinSize(MinSize {
522 intercept: 28999,
523 slope: 74,
524 }),
525 },
526 less_than_equals_byte_string: CostingFun {
527 mem: TwoArguments::ConstantCost(1),
528 cpu: TwoArguments::MinSize(MinSize {
529 intercept: 28999,
530 slope: 74,
531 }),
532 },
533 sha2_256: CostingFun {
534 mem: OneArgument::ConstantCost(4),
535 cpu: OneArgument::LinearCost(LinearSize {
536 intercept: 270652,
537 slope: 22588,
538 }),
539 },
540 sha3_256: CostingFun {
541 mem: OneArgument::ConstantCost(4),
542 cpu: OneArgument::LinearCost(LinearSize {
543 intercept: 1457325,
544 slope: 64566,
545 }),
546 },
547 blake2b_224: CostingFun {
548 mem: OneArgument::ConstantCost(30000000000),
549 cpu: OneArgument::ConstantCost(30000000000),
550 },
551 blake2b_256: CostingFun {
552 mem: OneArgument::ConstantCost(4),
553 cpu: OneArgument::LinearCost(LinearSize {
554 intercept: 201305,
555 slope: 8356,
556 }),
557 },
558 keccak_256: CostingFun {
559 mem: OneArgument::ConstantCost(30000000000),
560 cpu: OneArgument::ConstantCost(30000000000),
561 },
562 verify_ed25519_signature: CostingFun {
563 mem: ThreeArguments::ConstantCost(10),
564 cpu: ThreeArguments::LinearInY(LinearSize {
565 intercept: 53384111,
566 slope: 14333,
567 }),
568 },
569 verify_ecdsa_secp256k1_signature: CostingFun {
570 mem: ThreeArguments::ConstantCost(30000000000),
571 cpu: ThreeArguments::ConstantCost(30000000000),
572 },
573 verify_schnorr_secp256k1_signature: CostingFun {
574 mem: ThreeArguments::ConstantCost(30000000000),
575 cpu: ThreeArguments::LinearInY(LinearSize {
576 intercept: 30000000000,
577 slope: 30000000000,
578 }),
579 },
580 append_string: CostingFun {
581 mem: TwoArguments::AddedSizes(AddedSizes {
582 intercept: 4,
583 slope: 1,
584 }),
585 cpu: TwoArguments::AddedSizes(AddedSizes {
586 intercept: 1000,
587 slope: 59957,
588 }),
589 },
590 equals_string: CostingFun {
591 mem: TwoArguments::ConstantCost(1),
592 cpu: TwoArguments::LinearOnDiagonal(ConstantOrLinear {
593 constant: 39184,
594 intercept: 1000,
595 slope: 60594,
596 }),
597 },
598 encode_utf8: CostingFun {
599 mem: OneArgument::LinearCost(LinearSize {
600 intercept: 4,
601 slope: 2,
602 }),
603 cpu: OneArgument::LinearCost(LinearSize {
604 intercept: 1000,
605 slope: 42921,
606 }),
607 },
608 decode_utf8: CostingFun {
609 mem: OneArgument::LinearCost(LinearSize {
610 intercept: 4,
611 slope: 2,
612 }),
613 cpu: OneArgument::LinearCost(LinearSize {
614 intercept: 91189,
615 slope: 769,
616 }),
617 },
618 if_then_else: CostingFun {
619 mem: ThreeArguments::ConstantCost(1),
620 cpu: ThreeArguments::ConstantCost(76049),
621 },
622 choose_unit: CostingFun {
623 mem: TwoArguments::ConstantCost(4),
624 cpu: TwoArguments::ConstantCost(61462),
625 },
626 trace: CostingFun {
627 mem: TwoArguments::ConstantCost(32),
628 cpu: TwoArguments::ConstantCost(59498),
629 },
630 fst_pair: CostingFun {
631 mem: OneArgument::ConstantCost(32),
632 cpu: OneArgument::ConstantCost(141895),
633 },
634 snd_pair: CostingFun {
635 mem: OneArgument::ConstantCost(32),
636 cpu: OneArgument::ConstantCost(141992),
637 },
638 choose_list: CostingFun {
639 mem: ThreeArguments::ConstantCost(32),
640 cpu: ThreeArguments::ConstantCost(132994),
641 },
642 mk_cons: CostingFun {
643 mem: TwoArguments::ConstantCost(32),
644 cpu: TwoArguments::ConstantCost(72362),
645 },
646 head_list: CostingFun {
647 mem: OneArgument::ConstantCost(32),
648 cpu: OneArgument::ConstantCost(83150),
649 },
650 tail_list: CostingFun {
651 mem: OneArgument::ConstantCost(32),
652 cpu: OneArgument::ConstantCost(81663),
653 },
654 null_list: CostingFun {
655 mem: OneArgument::ConstantCost(32),
656 cpu: OneArgument::ConstantCost(74433),
657 },
658 choose_data: CostingFun {
659 mem: SixArguments::ConstantCost(32),
660 cpu: SixArguments::ConstantCost(94375),
661 },
662 constr_data: CostingFun {
663 mem: TwoArguments::ConstantCost(32),
664 cpu: TwoArguments::ConstantCost(22151),
665 },
666 map_data: CostingFun {
667 mem: OneArgument::ConstantCost(32),
668 cpu: OneArgument::ConstantCost(68246),
669 },
670 list_data: CostingFun {
671 mem: OneArgument::ConstantCost(32),
672 cpu: OneArgument::ConstantCost(33852),
673 },
674 i_data: CostingFun {
675 mem: OneArgument::ConstantCost(32),
676 cpu: OneArgument::ConstantCost(15299),
677 },
678 b_data: CostingFun {
679 mem: OneArgument::ConstantCost(32),
680 cpu: OneArgument::ConstantCost(11183),
681 },
682 un_constr_data: CostingFun {
683 mem: OneArgument::ConstantCost(32),
684 cpu: OneArgument::ConstantCost(24588),
685 },
686 un_map_data: CostingFun {
687 mem: OneArgument::ConstantCost(32),
688 cpu: OneArgument::ConstantCost(24623),
689 },
690 un_list_data: CostingFun {
691 mem: OneArgument::ConstantCost(32),
692 cpu: OneArgument::ConstantCost(25933),
693 },
694 un_i_data: CostingFun {
695 mem: OneArgument::ConstantCost(32),
696 cpu: OneArgument::ConstantCost(20744),
697 },
698 un_b_data: CostingFun {
699 mem: OneArgument::ConstantCost(32),
700 cpu: OneArgument::ConstantCost(20142),
701 },
702 equals_data: CostingFun {
703 mem: TwoArguments::ConstantCost(1),
704 cpu: TwoArguments::MinSize(MinSize {
705 intercept: 898148,
706 slope: 27279,
707 }),
708 },
709 mk_pair_data: CostingFun {
710 mem: TwoArguments::ConstantCost(32),
711 cpu: TwoArguments::ConstantCost(11546),
712 },
713 mk_nil_data: CostingFun {
714 mem: OneArgument::ConstantCost(32),
715 cpu: OneArgument::ConstantCost(7243),
716 },
717 mk_nil_pair_data: CostingFun {
718 mem: OneArgument::ConstantCost(32),
719 cpu: OneArgument::ConstantCost(7391),
720 },
721 serialise_data: CostingFun {
722 mem: OneArgument::LinearCost(LinearSize {
723 intercept: 30000000000,
724 slope: 30000000000,
725 }),
726 cpu: OneArgument::LinearCost(LinearSize {
727 intercept: 30000000000,
728 slope: 30000000000,
729 }),
730 },
731 bls12_381_g1_add: CostingFun {
732 cpu: TwoArguments::ConstantCost(30000000000),
733 mem: TwoArguments::ConstantCost(30000000000),
734 },
735 bls12_381_g1_neg: CostingFun {
736 cpu: OneArgument::ConstantCost(30000000000),
737 mem: OneArgument::ConstantCost(30000000000),
738 },
739 bls12_381_g1_scalar_mul: CostingFun {
740 mem: TwoArguments::ConstantCost(30000000000),
741 cpu: TwoArguments::ConstantCost(30000000000),
742 },
743 bls12_381_g1_equal: CostingFun {
744 cpu: TwoArguments::ConstantCost(30000000000),
745 mem: TwoArguments::ConstantCost(30000000000),
746 },
747 bls12_381_g1_compress: CostingFun {
748 cpu: OneArgument::ConstantCost(30000000000),
749 mem: OneArgument::ConstantCost(30000000000),
750 },
751 bls12_381_g1_uncompress: CostingFun {
752 cpu: OneArgument::ConstantCost(30000000000),
753 mem: OneArgument::ConstantCost(30000000000),
754 },
755 bls12_381_g1_hash_to_group: CostingFun {
756 mem: TwoArguments::ConstantCost(30000000000),
757 cpu: TwoArguments::ConstantCost(30000000000),
758 },
759 bls12_381_g2_add: CostingFun {
760 cpu: TwoArguments::ConstantCost(30000000000),
761 mem: TwoArguments::ConstantCost(30000000000),
762 },
763 bls12_381_g2_neg: CostingFun {
764 cpu: OneArgument::ConstantCost(30000000000),
765 mem: OneArgument::ConstantCost(30000000000),
766 },
767 bls12_381_g2_scalar_mul: CostingFun {
768 cpu: TwoArguments::ConstantCost(30000000000),
769 mem: TwoArguments::ConstantCost(30000000000),
770 },
771 bls12_381_g2_equal: CostingFun {
772 cpu: TwoArguments::ConstantCost(30000000000),
773 mem: TwoArguments::ConstantCost(30000000000),
774 },
775 bls12_381_g2_compress: CostingFun {
776 cpu: OneArgument::ConstantCost(30000000000),
777 mem: OneArgument::ConstantCost(30000000000),
778 },
779 bls12_381_g2_uncompress: CostingFun {
780 cpu: OneArgument::ConstantCost(30000000000),
781 mem: OneArgument::ConstantCost(30000000000),
782 },
783 bls12_381_g2_hash_to_group: CostingFun {
784 mem: TwoArguments::ConstantCost(30000000000),
785 cpu: TwoArguments::ConstantCost(30000000000),
786 },
787 bls12_381_miller_loop: CostingFun {
788 cpu: TwoArguments::ConstantCost(30000000000),
789 mem: TwoArguments::ConstantCost(30000000000),
790 },
791 bls12_381_mul_ml_result: CostingFun {
792 cpu: TwoArguments::ConstantCost(30000000000),
793 mem: TwoArguments::ConstantCost(30000000000),
794 },
795 bls12_381_final_verify: CostingFun {
796 cpu: TwoArguments::ConstantCost(30000000000),
797 mem: TwoArguments::ConstantCost(30000000000),
798 },
799 integer_to_byte_string: CostingFun {
800 cpu: ThreeArguments::ConstantCost(30000000000),
801 mem: ThreeArguments::ConstantCost(30000000000),
802 },
803 byte_string_to_integer: CostingFun {
804 cpu: TwoArguments::ConstantCost(30000000000),
805 mem: TwoArguments::ConstantCost(30000000000),
806 },
807 and_byte_string: CostingFun {
808 cpu: ThreeArguments::ConstantCost(30000000000),
809 mem: ThreeArguments::ConstantCost(30000000000),
810 },
811 or_byte_string: CostingFun {
812 cpu: ThreeArguments::ConstantCost(30000000000),
813 mem: ThreeArguments::ConstantCost(30000000000),
814 },
815 xor_byte_string: CostingFun {
816 cpu: ThreeArguments::ConstantCost(30000000000),
817 mem: ThreeArguments::ConstantCost(30000000000),
818 },
819 complement_byte_string: CostingFun {
820 cpu: OneArgument::ConstantCost(30000000000),
821 mem: OneArgument::ConstantCost(30000000000),
822 },
823 read_bit: CostingFun {
824 cpu: TwoArguments::ConstantCost(30000000000),
825 mem: TwoArguments::ConstantCost(30000000000),
826 },
827 write_bits: CostingFun {
828 cpu: ThreeArguments::ConstantCost(30000000000),
829 mem: ThreeArguments::ConstantCost(30000000000),
830 },
831 replicate_byte: CostingFun {
832 cpu: TwoArguments::ConstantCost(30000000000),
833 mem: TwoArguments::ConstantCost(30000000000),
834 },
835 shift_byte_string: CostingFun {
836 cpu: TwoArguments::ConstantCost(30000000000),
837 mem: TwoArguments::ConstantCost(30000000000),
838 },
839 rotate_byte_string: CostingFun {
840 cpu: TwoArguments::ConstantCost(30000000000),
841 mem: TwoArguments::ConstantCost(30000000000),
842 },
843 count_set_bits: CostingFun {
844 cpu: OneArgument::ConstantCost(30000000000),
845 mem: OneArgument::ConstantCost(30000000000),
846 },
847 find_first_set_bit: CostingFun {
848 cpu: OneArgument::ConstantCost(30000000000),
849 mem: OneArgument::ConstantCost(30000000000),
850 },
851 ripemd_160: CostingFun {
852 cpu: OneArgument::ConstantCost(30000000000),
853 mem: OneArgument::ConstantCost(30000000000),
854 },
855 exp_mod_int: CostingFun {
856 cpu: ThreeArguments::ConstantCost(30000000000),
857 mem: ThreeArguments::ConstantCost(30000000000),
858 },
859 }
860 }
861
862 pub fn v2() -> Self {
863 Self {
864 add_integer: CostingFun {
865 mem: TwoArguments::MaxSize(MaxSize {
866 intercept: 1,
867 slope: 1,
868 }),
869 cpu: TwoArguments::MaxSize(MaxSize {
870 intercept: 100788,
871 slope: 420,
872 }),
873 },
874 subtract_integer: CostingFun {
875 mem: TwoArguments::MaxSize(MaxSize {
876 intercept: 1,
877 slope: 1,
878 }),
879 cpu: TwoArguments::MaxSize(MaxSize {
880 intercept: 100788,
881 slope: 420,
882 }),
883 },
884 multiply_integer: CostingFun {
885 mem: TwoArguments::AddedSizes(AddedSizes {
886 intercept: 0,
887 slope: 1,
888 }),
889 cpu: TwoArguments::MultipliedSizes(MultipliedSizes {
890 intercept: 90434,
891 slope: 519,
892 }),
893 },
894 divide_integer: CostingFun {
895 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
896 intercept: 0,
897 slope: 1,
898 minimum: 1,
899 }),
900 cpu: TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
901 constant: 85848,
902 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
903 intercept: 228465,
904 slope: 122,
905 })),
906 }),
907 },
908 quotient_integer: CostingFun {
909 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
910 intercept: 0,
911 slope: 1,
912 minimum: 1,
913 }),
914 cpu: TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
915 constant: 85848,
916 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
917 intercept: 228465,
918 slope: 122,
919 })),
920 }),
921 },
922 remainder_integer: CostingFun {
923 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
924 intercept: 0,
925 slope: 1,
926 minimum: 1,
927 }),
928 cpu: TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
929 constant: 85848,
930 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
931 intercept: 228465,
932 slope: 122,
933 })),
934 }),
935 },
936 mod_integer: CostingFun {
937 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
938 intercept: 0,
939 slope: 1,
940 minimum: 1,
941 }),
942 cpu: TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
943 constant: 85848,
944 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
945 intercept: 228465,
946 slope: 122,
947 })),
948 }),
949 },
950 equals_integer: CostingFun {
951 mem: TwoArguments::ConstantCost(1),
952 cpu: TwoArguments::MinSize(MinSize {
953 intercept: 51775,
954 slope: 558,
955 }),
956 },
957 less_than_integer: CostingFun {
958 mem: TwoArguments::ConstantCost(1),
959 cpu: TwoArguments::MinSize(MinSize {
960 intercept: 44749,
961 slope: 541,
962 }),
963 },
964 less_than_equals_integer: CostingFun {
965 mem: TwoArguments::ConstantCost(1),
966 cpu: TwoArguments::MinSize(MinSize {
967 intercept: 43285,
968 slope: 552,
969 }),
970 },
971 append_byte_string: CostingFun {
972 mem: TwoArguments::AddedSizes(AddedSizes {
973 intercept: 0,
974 slope: 1,
975 }),
976 cpu: TwoArguments::AddedSizes(AddedSizes {
977 intercept: 1000,
978 slope: 173,
979 }),
980 },
981 cons_byte_string: CostingFun {
982 mem: TwoArguments::AddedSizes(AddedSizes {
983 intercept: 0,
984 slope: 1,
985 }),
986 cpu: TwoArguments::LinearInY(LinearSize {
987 intercept: 72010,
988 slope: 178,
989 }),
990 },
991 slice_byte_string: CostingFun {
992 mem: ThreeArguments::LinearInZ(LinearSize {
993 intercept: 4,
994 slope: 0,
995 }),
996 cpu: ThreeArguments::LinearInZ(LinearSize {
997 intercept: 20467,
998 slope: 1,
999 }),
1000 },
1001 length_of_byte_string: CostingFun {
1002 mem: OneArgument::ConstantCost(10),
1003 cpu: OneArgument::ConstantCost(22100),
1004 },
1005 index_byte_string: CostingFun {
1006 mem: TwoArguments::ConstantCost(4),
1007 cpu: TwoArguments::ConstantCost(13169),
1008 },
1009 equals_byte_string: CostingFun {
1010 mem: TwoArguments::ConstantCost(1),
1011 cpu: TwoArguments::LinearOnDiagonal(ConstantOrLinear {
1012 constant: 24548,
1013 intercept: 29498,
1014 slope: 38,
1015 }),
1016 },
1017 less_than_byte_string: CostingFun {
1018 mem: TwoArguments::ConstantCost(1),
1019 cpu: TwoArguments::MinSize(MinSize {
1020 intercept: 28999,
1021 slope: 74,
1022 }),
1023 },
1024 less_than_equals_byte_string: CostingFun {
1025 mem: TwoArguments::ConstantCost(1),
1026 cpu: TwoArguments::MinSize(MinSize {
1027 intercept: 28999,
1028 slope: 74,
1029 }),
1030 },
1031 sha2_256: CostingFun {
1032 mem: OneArgument::ConstantCost(4),
1033 cpu: OneArgument::LinearCost(LinearSize {
1034 intercept: 270652,
1035 slope: 22588,
1036 }),
1037 },
1038 sha3_256: CostingFun {
1039 mem: OneArgument::ConstantCost(4),
1040 cpu: OneArgument::LinearCost(LinearSize {
1041 intercept: 1457325,
1042 slope: 64566,
1043 }),
1044 },
1045 blake2b_256: CostingFun {
1046 mem: OneArgument::ConstantCost(4),
1047 cpu: OneArgument::LinearCost(LinearSize {
1048 intercept: 201305,
1049 slope: 8356,
1050 }),
1051 },
1052 verify_ed25519_signature: CostingFun {
1053 mem: ThreeArguments::ConstantCost(10),
1054 cpu: ThreeArguments::LinearInY(LinearSize {
1055 intercept: 53384111,
1056 slope: 14333,
1057 }),
1058 },
1059 verify_ecdsa_secp256k1_signature: CostingFun {
1060 mem: ThreeArguments::ConstantCost(10),
1061 cpu: ThreeArguments::ConstantCost(43053543),
1062 },
1063 verify_schnorr_secp256k1_signature: CostingFun {
1064 mem: ThreeArguments::ConstantCost(10),
1065 cpu: ThreeArguments::LinearInY(LinearSize {
1066 intercept: 43574283,
1067 slope: 26308,
1068 }),
1069 },
1070 append_string: CostingFun {
1071 mem: TwoArguments::AddedSizes(AddedSizes {
1072 intercept: 4,
1073 slope: 1,
1074 }),
1075 cpu: TwoArguments::AddedSizes(AddedSizes {
1076 intercept: 1000,
1077 slope: 59957,
1078 }),
1079 },
1080 equals_string: CostingFun {
1081 mem: TwoArguments::ConstantCost(1),
1082 cpu: TwoArguments::LinearOnDiagonal(ConstantOrLinear {
1083 constant: 39184,
1084 intercept: 1000,
1085 slope: 60594,
1086 }),
1087 },
1088 encode_utf8: CostingFun {
1089 mem: OneArgument::LinearCost(LinearSize {
1090 intercept: 4,
1091 slope: 2,
1092 }),
1093 cpu: OneArgument::LinearCost(LinearSize {
1094 intercept: 1000,
1095 slope: 42921,
1096 }),
1097 },
1098 decode_utf8: CostingFun {
1099 mem: OneArgument::LinearCost(LinearSize {
1100 intercept: 4,
1101 slope: 2,
1102 }),
1103 cpu: OneArgument::LinearCost(LinearSize {
1104 intercept: 91189,
1105 slope: 769,
1106 }),
1107 },
1108 if_then_else: CostingFun {
1109 mem: ThreeArguments::ConstantCost(1),
1110 cpu: ThreeArguments::ConstantCost(76049),
1111 },
1112 choose_unit: CostingFun {
1113 mem: TwoArguments::ConstantCost(4),
1114 cpu: TwoArguments::ConstantCost(61462),
1115 },
1116 trace: CostingFun {
1117 mem: TwoArguments::ConstantCost(32),
1118 cpu: TwoArguments::ConstantCost(59498),
1119 },
1120 fst_pair: CostingFun {
1121 mem: OneArgument::ConstantCost(32),
1122 cpu: OneArgument::ConstantCost(141895),
1123 },
1124 snd_pair: CostingFun {
1125 mem: OneArgument::ConstantCost(32),
1126 cpu: OneArgument::ConstantCost(141992),
1127 },
1128 choose_list: CostingFun {
1129 mem: ThreeArguments::ConstantCost(32),
1130 cpu: ThreeArguments::ConstantCost(132994),
1131 },
1132 mk_cons: CostingFun {
1133 mem: TwoArguments::ConstantCost(32),
1134 cpu: TwoArguments::ConstantCost(72362),
1135 },
1136 head_list: CostingFun {
1137 mem: OneArgument::ConstantCost(32),
1138 cpu: OneArgument::ConstantCost(83150),
1139 },
1140 tail_list: CostingFun {
1141 mem: OneArgument::ConstantCost(32),
1142 cpu: OneArgument::ConstantCost(81663),
1143 },
1144 null_list: CostingFun {
1145 mem: OneArgument::ConstantCost(32),
1146 cpu: OneArgument::ConstantCost(74433),
1147 },
1148 choose_data: CostingFun {
1149 mem: SixArguments::ConstantCost(32),
1150 cpu: SixArguments::ConstantCost(94375),
1151 },
1152 constr_data: CostingFun {
1153 mem: TwoArguments::ConstantCost(32),
1154 cpu: TwoArguments::ConstantCost(22151),
1155 },
1156 map_data: CostingFun {
1157 mem: OneArgument::ConstantCost(32),
1158 cpu: OneArgument::ConstantCost(68246),
1159 },
1160 list_data: CostingFun {
1161 mem: OneArgument::ConstantCost(32),
1162 cpu: OneArgument::ConstantCost(33852),
1163 },
1164 i_data: CostingFun {
1165 mem: OneArgument::ConstantCost(32),
1166 cpu: OneArgument::ConstantCost(15299),
1167 },
1168 b_data: CostingFun {
1169 mem: OneArgument::ConstantCost(32),
1170 cpu: OneArgument::ConstantCost(11183),
1171 },
1172 un_constr_data: CostingFun {
1173 mem: OneArgument::ConstantCost(32),
1174 cpu: OneArgument::ConstantCost(24588),
1175 },
1176 un_map_data: CostingFun {
1177 mem: OneArgument::ConstantCost(32),
1178 cpu: OneArgument::ConstantCost(24623),
1179 },
1180 un_list_data: CostingFun {
1181 mem: OneArgument::ConstantCost(32),
1182 cpu: OneArgument::ConstantCost(25933),
1183 },
1184 un_i_data: CostingFun {
1185 mem: OneArgument::ConstantCost(32),
1186 cpu: OneArgument::ConstantCost(20744),
1187 },
1188 un_b_data: CostingFun {
1189 mem: OneArgument::ConstantCost(32),
1190 cpu: OneArgument::ConstantCost(20142),
1191 },
1192 equals_data: CostingFun {
1193 mem: TwoArguments::ConstantCost(1),
1194 cpu: TwoArguments::MinSize(MinSize {
1195 intercept: 898148,
1196 slope: 27279,
1197 }),
1198 },
1199 mk_pair_data: CostingFun {
1200 mem: TwoArguments::ConstantCost(32),
1201 cpu: TwoArguments::ConstantCost(11546),
1202 },
1203 mk_nil_data: CostingFun {
1204 mem: OneArgument::ConstantCost(32),
1205 cpu: OneArgument::ConstantCost(7243),
1206 },
1207 mk_nil_pair_data: CostingFun {
1208 mem: OneArgument::ConstantCost(32),
1209 cpu: OneArgument::ConstantCost(7391),
1210 },
1211 serialise_data: CostingFun {
1212 mem: OneArgument::LinearCost(LinearSize {
1213 intercept: 0,
1214 slope: 2,
1215 }),
1216 cpu: OneArgument::LinearCost(LinearSize {
1217 intercept: 955506,
1218 slope: 213312,
1219 }),
1220 },
1221 blake2b_224: CostingFun {
1222 cpu: OneArgument::ConstantCost(30000000000),
1223 mem: OneArgument::ConstantCost(30000000000),
1224 },
1225 keccak_256: CostingFun {
1226 cpu: OneArgument::ConstantCost(30000000000),
1227 mem: OneArgument::ConstantCost(30000000000),
1228 },
1229 bls12_381_g1_add: CostingFun {
1230 cpu: TwoArguments::ConstantCost(30000000000),
1231 mem: TwoArguments::ConstantCost(30000000000),
1232 },
1233 bls12_381_g1_neg: CostingFun {
1234 cpu: OneArgument::ConstantCost(30000000000),
1235 mem: OneArgument::ConstantCost(30000000000),
1236 },
1237 bls12_381_g1_scalar_mul: CostingFun {
1238 cpu: TwoArguments::ConstantCost(30000000000),
1239 mem: TwoArguments::ConstantCost(30000000000),
1240 },
1241 bls12_381_g1_equal: CostingFun {
1242 cpu: TwoArguments::ConstantCost(30000000000),
1243 mem: TwoArguments::ConstantCost(30000000000),
1244 },
1245 bls12_381_g1_compress: CostingFun {
1246 cpu: OneArgument::ConstantCost(30000000000),
1247 mem: OneArgument::ConstantCost(30000000000),
1248 },
1249 bls12_381_g1_uncompress: CostingFun {
1250 cpu: OneArgument::ConstantCost(30000000000),
1251 mem: OneArgument::ConstantCost(30000000000),
1252 },
1253 bls12_381_g1_hash_to_group: CostingFun {
1254 cpu: TwoArguments::ConstantCost(30000000000),
1255 mem: TwoArguments::ConstantCost(30000000000),
1256 },
1257 bls12_381_g2_add: CostingFun {
1258 cpu: TwoArguments::ConstantCost(30000000000),
1259 mem: TwoArguments::ConstantCost(30000000000),
1260 },
1261 bls12_381_g2_neg: CostingFun {
1262 cpu: OneArgument::ConstantCost(30000000000),
1263 mem: OneArgument::ConstantCost(30000000000),
1264 },
1265 bls12_381_g2_scalar_mul: CostingFun {
1266 cpu: TwoArguments::ConstantCost(30000000000),
1267 mem: TwoArguments::ConstantCost(30000000000),
1268 },
1269 bls12_381_g2_equal: CostingFun {
1270 cpu: TwoArguments::ConstantCost(30000000000),
1271 mem: TwoArguments::ConstantCost(30000000000),
1272 },
1273 bls12_381_g2_compress: CostingFun {
1274 cpu: OneArgument::ConstantCost(30000000000),
1275 mem: OneArgument::ConstantCost(30000000000),
1276 },
1277 bls12_381_g2_uncompress: CostingFun {
1278 cpu: OneArgument::ConstantCost(30000000000),
1279 mem: OneArgument::ConstantCost(30000000000),
1280 },
1281 bls12_381_g2_hash_to_group: CostingFun {
1282 cpu: TwoArguments::ConstantCost(30000000000),
1283 mem: TwoArguments::ConstantCost(30000000000),
1284 },
1285 bls12_381_miller_loop: CostingFun {
1286 cpu: TwoArguments::ConstantCost(30000000000),
1287 mem: TwoArguments::ConstantCost(30000000000),
1288 },
1289 bls12_381_mul_ml_result: CostingFun {
1290 cpu: TwoArguments::ConstantCost(30000000000),
1291 mem: TwoArguments::ConstantCost(30000000000),
1292 },
1293 bls12_381_final_verify: CostingFun {
1294 cpu: TwoArguments::ConstantCost(30000000000),
1295 mem: TwoArguments::ConstantCost(30000000000),
1296 },
1297 integer_to_byte_string: CostingFun {
1298 cpu: ThreeArguments::ConstantCost(30000000000),
1299 mem: ThreeArguments::ConstantCost(30000000000),
1300 },
1301 byte_string_to_integer: CostingFun {
1302 cpu: TwoArguments::ConstantCost(30000000000),
1303 mem: TwoArguments::ConstantCost(30000000000),
1304 },
1305 and_byte_string: CostingFun {
1306 cpu: ThreeArguments::ConstantCost(30000000000),
1307 mem: ThreeArguments::ConstantCost(30000000000),
1308 },
1309 or_byte_string: CostingFun {
1310 cpu: ThreeArguments::ConstantCost(30000000000),
1311 mem: ThreeArguments::ConstantCost(30000000000),
1312 },
1313 xor_byte_string: CostingFun {
1314 cpu: ThreeArguments::ConstantCost(30000000000),
1315 mem: ThreeArguments::ConstantCost(30000000000),
1316 },
1317 complement_byte_string: CostingFun {
1318 cpu: OneArgument::ConstantCost(30000000000),
1319 mem: OneArgument::ConstantCost(30000000000),
1320 },
1321 read_bit: CostingFun {
1322 cpu: TwoArguments::ConstantCost(30000000000),
1323 mem: TwoArguments::ConstantCost(30000000000),
1324 },
1325 write_bits: CostingFun {
1326 cpu: ThreeArguments::ConstantCost(30000000000),
1327 mem: ThreeArguments::ConstantCost(30000000000),
1328 },
1329 replicate_byte: CostingFun {
1330 cpu: TwoArguments::ConstantCost(30000000000),
1331 mem: TwoArguments::ConstantCost(30000000000),
1332 },
1333 shift_byte_string: CostingFun {
1334 cpu: TwoArguments::ConstantCost(30000000000),
1335 mem: TwoArguments::ConstantCost(30000000000),
1336 },
1337 rotate_byte_string: CostingFun {
1338 cpu: TwoArguments::ConstantCost(30000000000),
1339 mem: TwoArguments::ConstantCost(30000000000),
1340 },
1341 count_set_bits: CostingFun {
1342 cpu: OneArgument::ConstantCost(30000000000),
1343 mem: OneArgument::ConstantCost(30000000000),
1344 },
1345 find_first_set_bit: CostingFun {
1346 cpu: OneArgument::ConstantCost(30000000000),
1347 mem: OneArgument::ConstantCost(30000000000),
1348 },
1349 ripemd_160: CostingFun {
1350 cpu: OneArgument::ConstantCost(30000000000),
1351 mem: OneArgument::ConstantCost(30000000000),
1352 },
1353 exp_mod_int: CostingFun {
1354 cpu: ThreeArguments::ConstantCost(30000000000),
1355 mem: ThreeArguments::ConstantCost(30000000000),
1356 },
1357 }
1358 }
1359
1360 pub fn v3() -> Self {
1361 Self {
1362 add_integer: CostingFun {
1363 mem: TwoArguments::MaxSize(MaxSize {
1364 intercept: 1,
1365 slope: 1,
1366 }),
1367 cpu: TwoArguments::MaxSize(MaxSize {
1368 intercept: 100788,
1369 slope: 420,
1370 }),
1371 },
1372 subtract_integer: CostingFun {
1373 mem: TwoArguments::MaxSize(MaxSize {
1374 intercept: 1,
1375 slope: 1,
1376 }),
1377 cpu: TwoArguments::MaxSize(MaxSize {
1378 intercept: 100788,
1379 slope: 420,
1380 }),
1381 },
1382 multiply_integer: CostingFun {
1383 mem: TwoArguments::AddedSizes(AddedSizes {
1384 intercept: 0,
1385 slope: 1,
1386 }),
1387 cpu: TwoArguments::MultipliedSizes(MultipliedSizes {
1388 intercept: 90434,
1389 slope: 519,
1390 }),
1391 },
1392 divide_integer: CostingFun {
1393 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
1394 intercept: 0,
1395 slope: 1,
1396 minimum: 1,
1397 }),
1398 cpu: TwoArguments::ConstAboveDiagonalIntoQuadraticXAndY(
1399 85848,
1400 TwoArgumentsQuadraticFunction {
1401 minimum: 85848,
1402 coeff_00: 123203,
1403 coeff_01: 7305,
1404 coeff_02: -900,
1405 coeff_10: 1716,
1406 coeff_11: 549,
1407 coeff_20: 57,
1408 },
1409 ),
1410 },
1411 quotient_integer: CostingFun {
1412 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
1413 intercept: 0,
1414 slope: 1,
1415 minimum: 1,
1416 }),
1417 cpu: TwoArguments::ConstAboveDiagonalIntoQuadraticXAndY(
1418 85848,
1419 TwoArgumentsQuadraticFunction {
1420 minimum: 85848,
1421 coeff_00: 123203,
1422 coeff_01: 7305,
1423 coeff_02: -900,
1424 coeff_10: 1716,
1425 coeff_11: 549,
1426 coeff_20: 57,
1427 },
1428 ),
1429 },
1430 remainder_integer: CostingFun {
1431 mem: TwoArguments::LinearInY(LinearSize {
1432 intercept: 0,
1433 slope: 1,
1434 }),
1435 cpu: TwoArguments::ConstAboveDiagonalIntoQuadraticXAndY(
1436 85848,
1437 TwoArgumentsQuadraticFunction {
1438 minimum: 85848,
1439 coeff_00: 123203,
1440 coeff_01: 7305,
1441 coeff_02: -900,
1442 coeff_10: 1716,
1443 coeff_11: 549,
1444 coeff_20: 57,
1445 },
1446 ),
1447 },
1448 mod_integer: CostingFun {
1449 mem: TwoArguments::LinearInY(LinearSize {
1450 intercept: 0,
1451 slope: 1,
1452 }),
1453 cpu: TwoArguments::ConstAboveDiagonalIntoQuadraticXAndY(
1454 85848,
1455 TwoArgumentsQuadraticFunction {
1456 minimum: 85848,
1457 coeff_00: 123203,
1458 coeff_01: 7305,
1459 coeff_02: -900,
1460 coeff_10: 1716,
1461 coeff_11: 549,
1462 coeff_20: 57,
1463 },
1464 ),
1465 },
1466 equals_integer: CostingFun {
1467 mem: TwoArguments::ConstantCost(1),
1468 cpu: TwoArguments::MinSize(MinSize {
1469 intercept: 51775,
1470 slope: 558,
1471 }),
1472 },
1473 less_than_integer: CostingFun {
1474 mem: TwoArguments::ConstantCost(1),
1475 cpu: TwoArguments::MinSize(MinSize {
1476 intercept: 44749,
1477 slope: 541,
1478 }),
1479 },
1480 less_than_equals_integer: CostingFun {
1481 mem: TwoArguments::ConstantCost(1),
1482 cpu: TwoArguments::MinSize(MinSize {
1483 intercept: 43285,
1484 slope: 552,
1485 }),
1486 },
1487 append_byte_string: CostingFun {
1488 mem: TwoArguments::AddedSizes(AddedSizes {
1489 intercept: 0,
1490 slope: 1,
1491 }),
1492 cpu: TwoArguments::AddedSizes(AddedSizes {
1493 intercept: 1000,
1494 slope: 173,
1495 }),
1496 },
1497 cons_byte_string: CostingFun {
1498 mem: TwoArguments::AddedSizes(AddedSizes {
1499 intercept: 0,
1500 slope: 1,
1501 }),
1502 cpu: TwoArguments::LinearInY(LinearSize {
1503 intercept: 72010,
1504 slope: 178,
1505 }),
1506 },
1507 slice_byte_string: CostingFun {
1508 mem: ThreeArguments::LinearInZ(LinearSize {
1509 intercept: 4,
1510 slope: 0,
1511 }),
1512 cpu: ThreeArguments::LinearInZ(LinearSize {
1513 intercept: 20467,
1514 slope: 1,
1515 }),
1516 },
1517 length_of_byte_string: CostingFun {
1518 mem: OneArgument::ConstantCost(10),
1519 cpu: OneArgument::ConstantCost(22100),
1520 },
1521 index_byte_string: CostingFun {
1522 mem: TwoArguments::ConstantCost(4),
1523 cpu: TwoArguments::ConstantCost(13169),
1524 },
1525 equals_byte_string: CostingFun {
1526 mem: TwoArguments::ConstantCost(1),
1527 cpu: TwoArguments::LinearOnDiagonal(ConstantOrLinear {
1528 constant: 24548,
1529 intercept: 29498,
1530 slope: 38,
1531 }),
1532 },
1533 less_than_byte_string: CostingFun {
1534 mem: TwoArguments::ConstantCost(1),
1535 cpu: TwoArguments::MinSize(MinSize {
1536 intercept: 28999,
1537 slope: 74,
1538 }),
1539 },
1540 less_than_equals_byte_string: CostingFun {
1541 mem: TwoArguments::ConstantCost(1),
1542 cpu: TwoArguments::MinSize(MinSize {
1543 intercept: 28999,
1544 slope: 74,
1545 }),
1546 },
1547 sha2_256: CostingFun {
1548 mem: OneArgument::ConstantCost(4),
1549 cpu: OneArgument::LinearCost(LinearSize {
1550 intercept: 270652,
1551 slope: 22588,
1552 }),
1553 },
1554 sha3_256: CostingFun {
1555 mem: OneArgument::ConstantCost(4),
1556 cpu: OneArgument::LinearCost(LinearSize {
1557 intercept: 1457325,
1558 slope: 64566,
1559 }),
1560 },
1561 blake2b_256: CostingFun {
1562 mem: OneArgument::ConstantCost(4),
1563 cpu: OneArgument::LinearCost(LinearSize {
1564 intercept: 201305,
1565 slope: 8356,
1566 }),
1567 },
1568 verify_ed25519_signature: CostingFun {
1569 mem: ThreeArguments::ConstantCost(10),
1570 cpu: ThreeArguments::LinearInY(LinearSize {
1571 intercept: 53384111,
1572 slope: 14333,
1573 }),
1574 },
1575 verify_ecdsa_secp256k1_signature: CostingFun {
1576 mem: ThreeArguments::ConstantCost(10),
1577 cpu: ThreeArguments::ConstantCost(43053543),
1578 },
1579 verify_schnorr_secp256k1_signature: CostingFun {
1580 mem: ThreeArguments::ConstantCost(10),
1581 cpu: ThreeArguments::LinearInY(LinearSize {
1582 intercept: 43574283,
1583 slope: 26308,
1584 }),
1585 },
1586 append_string: CostingFun {
1587 mem: TwoArguments::AddedSizes(AddedSizes {
1588 intercept: 4,
1589 slope: 1,
1590 }),
1591 cpu: TwoArguments::AddedSizes(AddedSizes {
1592 intercept: 1000,
1593 slope: 59957,
1594 }),
1595 },
1596 equals_string: CostingFun {
1597 mem: TwoArguments::ConstantCost(1),
1598 cpu: TwoArguments::LinearOnDiagonal(ConstantOrLinear {
1599 constant: 39184,
1600 intercept: 1000,
1601 slope: 60594,
1602 }),
1603 },
1604 encode_utf8: CostingFun {
1605 mem: OneArgument::LinearCost(LinearSize {
1606 intercept: 4,
1607 slope: 2,
1608 }),
1609 cpu: OneArgument::LinearCost(LinearSize {
1610 intercept: 1000,
1611 slope: 42921,
1612 }),
1613 },
1614 decode_utf8: CostingFun {
1615 mem: OneArgument::LinearCost(LinearSize {
1616 intercept: 4,
1617 slope: 2,
1618 }),
1619 cpu: OneArgument::LinearCost(LinearSize {
1620 intercept: 91189,
1621 slope: 769,
1622 }),
1623 },
1624 if_then_else: CostingFun {
1625 mem: ThreeArguments::ConstantCost(1),
1626 cpu: ThreeArguments::ConstantCost(76049),
1627 },
1628 choose_unit: CostingFun {
1629 mem: TwoArguments::ConstantCost(4),
1630 cpu: TwoArguments::ConstantCost(61462),
1631 },
1632 trace: CostingFun {
1633 mem: TwoArguments::ConstantCost(32),
1634 cpu: TwoArguments::ConstantCost(59498),
1635 },
1636 fst_pair: CostingFun {
1637 mem: OneArgument::ConstantCost(32),
1638 cpu: OneArgument::ConstantCost(141895),
1639 },
1640 snd_pair: CostingFun {
1641 mem: OneArgument::ConstantCost(32),
1642 cpu: OneArgument::ConstantCost(141992),
1643 },
1644 choose_list: CostingFun {
1645 mem: ThreeArguments::ConstantCost(32),
1646 cpu: ThreeArguments::ConstantCost(132994),
1647 },
1648 mk_cons: CostingFun {
1649 mem: TwoArguments::ConstantCost(32),
1650 cpu: TwoArguments::ConstantCost(72362),
1651 },
1652 head_list: CostingFun {
1653 mem: OneArgument::ConstantCost(32),
1654 cpu: OneArgument::ConstantCost(83150),
1655 },
1656 tail_list: CostingFun {
1657 mem: OneArgument::ConstantCost(32),
1658 cpu: OneArgument::ConstantCost(81663),
1659 },
1660 null_list: CostingFun {
1661 mem: OneArgument::ConstantCost(32),
1662 cpu: OneArgument::ConstantCost(74433),
1663 },
1664 choose_data: CostingFun {
1665 mem: SixArguments::ConstantCost(32),
1666 cpu: SixArguments::ConstantCost(94375),
1667 },
1668 constr_data: CostingFun {
1669 mem: TwoArguments::ConstantCost(32),
1670 cpu: TwoArguments::ConstantCost(22151),
1671 },
1672 map_data: CostingFun {
1673 mem: OneArgument::ConstantCost(32),
1674 cpu: OneArgument::ConstantCost(68246),
1675 },
1676 list_data: CostingFun {
1677 mem: OneArgument::ConstantCost(32),
1678 cpu: OneArgument::ConstantCost(33852),
1679 },
1680 i_data: CostingFun {
1681 mem: OneArgument::ConstantCost(32),
1682 cpu: OneArgument::ConstantCost(15299),
1683 },
1684 b_data: CostingFun {
1685 mem: OneArgument::ConstantCost(32),
1686 cpu: OneArgument::ConstantCost(11183),
1687 },
1688 un_constr_data: CostingFun {
1689 mem: OneArgument::ConstantCost(32),
1690 cpu: OneArgument::ConstantCost(24588),
1691 },
1692 un_map_data: CostingFun {
1693 mem: OneArgument::ConstantCost(32),
1694 cpu: OneArgument::ConstantCost(24623),
1695 },
1696 un_list_data: CostingFun {
1697 mem: OneArgument::ConstantCost(32),
1698 cpu: OneArgument::ConstantCost(25933),
1699 },
1700 un_i_data: CostingFun {
1701 mem: OneArgument::ConstantCost(32),
1702 cpu: OneArgument::ConstantCost(20744),
1703 },
1704 un_b_data: CostingFun {
1705 mem: OneArgument::ConstantCost(32),
1706 cpu: OneArgument::ConstantCost(20142),
1707 },
1708 equals_data: CostingFun {
1709 mem: TwoArguments::ConstantCost(1),
1710 cpu: TwoArguments::MinSize(MinSize {
1711 intercept: 898148,
1712 slope: 27279,
1713 }),
1714 },
1715 mk_pair_data: CostingFun {
1716 mem: TwoArguments::ConstantCost(32),
1717 cpu: TwoArguments::ConstantCost(11546),
1718 },
1719 mk_nil_data: CostingFun {
1720 mem: OneArgument::ConstantCost(32),
1721 cpu: OneArgument::ConstantCost(7243),
1722 },
1723 mk_nil_pair_data: CostingFun {
1724 mem: OneArgument::ConstantCost(32),
1725 cpu: OneArgument::ConstantCost(7391),
1726 },
1727 serialise_data: CostingFun {
1728 mem: OneArgument::LinearCost(LinearSize {
1729 intercept: 0,
1730 slope: 2,
1731 }),
1732 cpu: OneArgument::LinearCost(LinearSize {
1733 intercept: 955506,
1734 slope: 213312,
1735 }),
1736 },
1737 blake2b_224: CostingFun {
1738 cpu: OneArgument::LinearCost(LinearSize {
1739 intercept: 207616,
1740 slope: 8310,
1741 }),
1742 mem: OneArgument::ConstantCost(4),
1743 },
1744 keccak_256: CostingFun {
1745 cpu: OneArgument::LinearCost(LinearSize {
1746 intercept: 2261318,
1747 slope: 64571,
1748 }),
1749 mem: OneArgument::ConstantCost(4),
1750 },
1751 bls12_381_g1_add: CostingFun {
1752 cpu: TwoArguments::ConstantCost(962335),
1753 mem: TwoArguments::ConstantCost(18),
1754 },
1755 bls12_381_g1_neg: CostingFun {
1756 cpu: OneArgument::ConstantCost(267929),
1757 mem: OneArgument::ConstantCost(18),
1758 },
1759 bls12_381_g1_scalar_mul: CostingFun {
1760 cpu: TwoArguments::LinearInX(LinearSize {
1761 intercept: 76433006,
1762 slope: 8868,
1763 }),
1764 mem: TwoArguments::ConstantCost(18),
1765 },
1766 bls12_381_g1_equal: CostingFun {
1767 cpu: TwoArguments::ConstantCost(442008),
1768 mem: TwoArguments::ConstantCost(1),
1769 },
1770 bls12_381_g1_compress: CostingFun {
1771 cpu: OneArgument::ConstantCost(2780678),
1772 mem: OneArgument::ConstantCost(6),
1773 },
1774 bls12_381_g1_uncompress: CostingFun {
1775 cpu: OneArgument::ConstantCost(52948122),
1776 mem: OneArgument::ConstantCost(18),
1777 },
1778 bls12_381_g1_hash_to_group: CostingFun {
1779 cpu: TwoArguments::LinearInX(LinearSize {
1780 intercept: 52538055,
1781 slope: 3756,
1782 }),
1783 mem: TwoArguments::ConstantCost(18),
1784 },
1785 bls12_381_g2_add: CostingFun {
1786 cpu: TwoArguments::ConstantCost(1995836),
1787 mem: TwoArguments::ConstantCost(36),
1788 },
1789 bls12_381_g2_neg: CostingFun {
1790 cpu: OneArgument::ConstantCost(284546),
1791 mem: OneArgument::ConstantCost(36),
1792 },
1793 bls12_381_g2_scalar_mul: CostingFun {
1794 cpu: TwoArguments::LinearInX(LinearSize {
1795 intercept: 158221314,
1796 slope: 26549,
1797 }),
1798 mem: TwoArguments::ConstantCost(36),
1799 },
1800 bls12_381_g2_equal: CostingFun {
1801 cpu: TwoArguments::ConstantCost(901022),
1802 mem: TwoArguments::ConstantCost(1),
1803 },
1804 bls12_381_g2_compress: CostingFun {
1805 cpu: OneArgument::ConstantCost(3227919),
1806 mem: OneArgument::ConstantCost(12),
1807 },
1808 bls12_381_g2_uncompress: CostingFun {
1809 cpu: OneArgument::ConstantCost(74698472),
1810 mem: OneArgument::ConstantCost(36),
1811 },
1812 bls12_381_g2_hash_to_group: CostingFun {
1813 cpu: TwoArguments::LinearInX(LinearSize {
1814 intercept: 166917843,
1815 slope: 4307,
1816 }),
1817 mem: TwoArguments::ConstantCost(36),
1818 },
1819 bls12_381_miller_loop: CostingFun {
1820 cpu: TwoArguments::ConstantCost(254006273),
1821 mem: TwoArguments::ConstantCost(72),
1822 },
1823 bls12_381_mul_ml_result: CostingFun {
1824 cpu: TwoArguments::ConstantCost(2174038),
1825 mem: TwoArguments::ConstantCost(72),
1826 },
1827 bls12_381_final_verify: CostingFun {
1828 cpu: TwoArguments::ConstantCost(333849714),
1829 mem: TwoArguments::ConstantCost(1),
1830 },
1831 integer_to_byte_string: CostingFun {
1832 cpu: ThreeArguments::QuadraticInZ(QuadraticFunction {
1833 coeff_0: 1293828,
1834 coeff_1: 28716,
1835 coeff_2: 63,
1836 }),
1837 mem: ThreeArguments::LiteralInYorLinearInZ(LinearSize {
1838 intercept: 0,
1839 slope: 1,
1840 }),
1841 },
1842 byte_string_to_integer: CostingFun {
1843 cpu: TwoArguments::QuadraticInY(QuadraticFunction {
1844 coeff_0: 1006041,
1845 coeff_1: 43623,
1846 coeff_2: 251,
1847 }),
1848 mem: TwoArguments::LinearInY(LinearSize {
1849 intercept: 0,
1850 slope: 1,
1851 }),
1852 },
1853 and_byte_string: CostingFun {
1854 cpu: ThreeArguments::LinearInYandZ(TwoVariableLinearSize {
1855 intercept: 100181,
1856 slope1: 726,
1857 slope2: 719,
1858 }),
1859 mem: ThreeArguments::LinearInMaxYZ(LinearSize {
1860 intercept: 0,
1861 slope: 1,
1862 }),
1863 },
1864 or_byte_string: CostingFun {
1865 cpu: ThreeArguments::LinearInYandZ(TwoVariableLinearSize {
1866 intercept: 100181,
1867 slope1: 726,
1868 slope2: 719,
1869 }),
1870 mem: ThreeArguments::LinearInMaxYZ(LinearSize {
1871 intercept: 0,
1872 slope: 1,
1873 }),
1874 },
1875 xor_byte_string: CostingFun {
1876 cpu: ThreeArguments::LinearInYandZ(TwoVariableLinearSize {
1877 intercept: 100181,
1878 slope1: 726,
1879 slope2: 719,
1880 }),
1881 mem: ThreeArguments::LinearInMaxYZ(LinearSize {
1882 intercept: 0,
1883 slope: 1,
1884 }),
1885 },
1886 complement_byte_string: CostingFun {
1887 cpu: OneArgument::LinearCost(LinearSize {
1888 intercept: 107878,
1889 slope: 680,
1890 }),
1891 mem: OneArgument::LinearCost(LinearSize {
1892 intercept: 0,
1893 slope: 1,
1894 }),
1895 },
1896 read_bit: CostingFun {
1897 cpu: TwoArguments::ConstantCost(95336),
1898 mem: TwoArguments::ConstantCost(1),
1899 },
1900 write_bits: CostingFun {
1901 cpu: ThreeArguments::LinearInY(LinearSize {
1902 intercept: 281145,
1903 slope: 18848,
1904 }),
1905 mem: ThreeArguments::LinearInX(LinearSize {
1906 intercept: 0,
1907 slope: 1,
1908 }),
1909 },
1910 replicate_byte: CostingFun {
1911 cpu: TwoArguments::LinearInX(LinearSize {
1912 intercept: 180194,
1913 slope: 159,
1914 }),
1915 mem: TwoArguments::LinearInX(LinearSize {
1916 intercept: 1,
1917 slope: 1,
1918 }),
1919 },
1920 shift_byte_string: CostingFun {
1921 cpu: TwoArguments::LinearInX(LinearSize {
1922 intercept: 158519,
1923 slope: 8942,
1924 }),
1925 mem: TwoArguments::LinearInX(LinearSize {
1926 intercept: 0,
1927 slope: 1,
1928 }),
1929 },
1930 rotate_byte_string: CostingFun {
1931 cpu: TwoArguments::LinearInX(LinearSize {
1932 intercept: 159378,
1933 slope: 8813,
1934 }),
1935 mem: TwoArguments::LinearInX(LinearSize {
1936 intercept: 0,
1937 slope: 1,
1938 }),
1939 },
1940 count_set_bits: CostingFun {
1941 cpu: OneArgument::LinearCost(LinearSize {
1942 intercept: 107490,
1943 slope: 3298,
1944 }),
1945 mem: OneArgument::ConstantCost(1),
1946 },
1947 find_first_set_bit: CostingFun {
1948 cpu: OneArgument::LinearCost(LinearSize {
1949 intercept: 106057,
1950 slope: 655,
1951 }),
1952 mem: OneArgument::ConstantCost(1),
1953 },
1954 ripemd_160: CostingFun {
1955 cpu: OneArgument::LinearCost(LinearSize {
1956 intercept: 1964219,
1957 slope: 24520,
1958 }),
1959 mem: OneArgument::ConstantCost(3),
1960 },
1961 exp_mod_int: CostingFun {
1963 cpu: ThreeArguments::ConstantCost(30000000000),
1964 mem: ThreeArguments::ConstantCost(30000000000),
1965 },
1966 }
1967 }
1968}
1969
1970impl Default for BuiltinCosts {
1971 fn default() -> Self {
1972 BuiltinCosts::v3()
1973 }
1974}
1975
1976impl BuiltinCosts {
1977 pub fn to_ex_budget(&self, fun: DefaultFunction, args: &[Value]) -> Result<ExBudget, Error> {
1978 Ok(match fun {
1979 DefaultFunction::AddInteger => ExBudget {
1980 mem: self
1981 .add_integer
1982 .mem
1983 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
1984 cpu: self
1985 .add_integer
1986 .cpu
1987 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
1988 },
1989 DefaultFunction::SubtractInteger => ExBudget {
1990 mem: self
1991 .subtract_integer
1992 .mem
1993 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
1994 cpu: self
1995 .subtract_integer
1996 .cpu
1997 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
1998 },
1999 DefaultFunction::MultiplyInteger => ExBudget {
2000 mem: self
2001 .multiply_integer
2002 .mem
2003 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2004 cpu: self
2005 .multiply_integer
2006 .cpu
2007 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2008 },
2009 DefaultFunction::DivideInteger => ExBudget {
2010 mem: self
2011 .divide_integer
2012 .mem
2013 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2014 cpu: self
2015 .divide_integer
2016 .cpu
2017 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2018 },
2019 DefaultFunction::QuotientInteger => ExBudget {
2020 mem: self
2021 .quotient_integer
2022 .mem
2023 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2024 cpu: self
2025 .quotient_integer
2026 .cpu
2027 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2028 },
2029 DefaultFunction::RemainderInteger => ExBudget {
2030 mem: self
2031 .remainder_integer
2032 .mem
2033 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2034 cpu: self
2035 .remainder_integer
2036 .cpu
2037 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2038 },
2039 DefaultFunction::ModInteger => ExBudget {
2040 mem: self
2041 .mod_integer
2042 .mem
2043 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2044 cpu: self
2045 .mod_integer
2046 .cpu
2047 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2048 },
2049 DefaultFunction::EqualsInteger => ExBudget {
2050 mem: self
2051 .equals_integer
2052 .mem
2053 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2054 cpu: self
2055 .equals_integer
2056 .cpu
2057 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2058 },
2059 DefaultFunction::LessThanInteger => ExBudget {
2060 mem: self
2061 .less_than_integer
2062 .mem
2063 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2064 cpu: self
2065 .less_than_integer
2066 .cpu
2067 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2068 },
2069 DefaultFunction::LessThanEqualsInteger => ExBudget {
2070 mem: self
2071 .less_than_equals_integer
2072 .mem
2073 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2074 cpu: self
2075 .less_than_equals_integer
2076 .cpu
2077 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2078 },
2079 DefaultFunction::AppendByteString => ExBudget {
2080 mem: self
2081 .append_byte_string
2082 .mem
2083 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2084 cpu: self
2085 .append_byte_string
2086 .cpu
2087 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2088 },
2089 DefaultFunction::ConsByteString => ExBudget {
2090 mem: self
2091 .cons_byte_string
2092 .mem
2093 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2094 cpu: self
2095 .cons_byte_string
2096 .cpu
2097 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2098 },
2099 DefaultFunction::SliceByteString => ExBudget {
2100 mem: self.slice_byte_string.mem.cost(
2101 args[0].to_ex_mem(),
2102 args[1].to_ex_mem(),
2103 args[2].to_ex_mem(),
2104 ),
2105 cpu: self.slice_byte_string.cpu.cost(
2106 args[0].to_ex_mem(),
2107 args[1].to_ex_mem(),
2108 args[2].to_ex_mem(),
2109 ),
2110 },
2111 DefaultFunction::LengthOfByteString => ExBudget {
2112 mem: self.length_of_byte_string.mem.cost(args[0].to_ex_mem()),
2113 cpu: self.length_of_byte_string.cpu.cost(args[0].to_ex_mem()),
2114 },
2115 DefaultFunction::IndexByteString => ExBudget {
2116 mem: self
2117 .index_byte_string
2118 .mem
2119 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2120 cpu: self
2121 .index_byte_string
2122 .cpu
2123 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2124 },
2125 DefaultFunction::EqualsByteString => ExBudget {
2126 mem: self
2127 .equals_byte_string
2128 .mem
2129 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2130 cpu: self
2131 .equals_byte_string
2132 .cpu
2133 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2134 },
2135 DefaultFunction::LessThanByteString => ExBudget {
2136 mem: self
2137 .less_than_byte_string
2138 .mem
2139 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2140 cpu: self
2141 .less_than_byte_string
2142 .cpu
2143 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2144 },
2145 DefaultFunction::LessThanEqualsByteString => ExBudget {
2146 mem: self
2147 .less_than_equals_byte_string
2148 .mem
2149 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2150 cpu: self
2151 .less_than_equals_byte_string
2152 .cpu
2153 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2154 },
2155 DefaultFunction::Sha2_256 => ExBudget {
2156 mem: self.sha2_256.mem.cost(args[0].to_ex_mem()),
2157 cpu: self.sha2_256.cpu.cost(args[0].to_ex_mem()),
2158 },
2159 DefaultFunction::Sha3_256 => ExBudget {
2160 mem: self.sha3_256.mem.cost(args[0].to_ex_mem()),
2161 cpu: self.sha3_256.cpu.cost(args[0].to_ex_mem()),
2162 },
2163 DefaultFunction::Blake2b_256 => ExBudget {
2164 mem: self.blake2b_256.mem.cost(args[0].to_ex_mem()),
2165 cpu: self.blake2b_256.cpu.cost(args[0].to_ex_mem()),
2166 },
2167 DefaultFunction::VerifyEd25519Signature => ExBudget {
2168 mem: self.verify_ed25519_signature.mem.cost(
2169 args[0].to_ex_mem(),
2170 args[1].to_ex_mem(),
2171 args[2].to_ex_mem(),
2172 ),
2173 cpu: self.verify_ed25519_signature.cpu.cost(
2174 args[0].to_ex_mem(),
2175 args[1].to_ex_mem(),
2176 args[2].to_ex_mem(),
2177 ),
2178 },
2179 DefaultFunction::VerifyEcdsaSecp256k1Signature => ExBudget {
2180 mem: self.verify_ecdsa_secp256k1_signature.mem.cost(
2181 args[0].to_ex_mem(),
2182 args[1].to_ex_mem(),
2183 args[2].to_ex_mem(),
2184 ),
2185 cpu: self.verify_ecdsa_secp256k1_signature.cpu.cost(
2186 args[0].to_ex_mem(),
2187 args[1].to_ex_mem(),
2188 args[2].to_ex_mem(),
2189 ),
2190 },
2191 DefaultFunction::VerifySchnorrSecp256k1Signature => ExBudget {
2192 mem: self.verify_schnorr_secp256k1_signature.mem.cost(
2193 args[0].to_ex_mem(),
2194 args[1].to_ex_mem(),
2195 args[2].to_ex_mem(),
2196 ),
2197 cpu: self.verify_schnorr_secp256k1_signature.cpu.cost(
2198 args[0].to_ex_mem(),
2199 args[1].to_ex_mem(),
2200 args[2].to_ex_mem(),
2201 ),
2202 },
2203 DefaultFunction::AppendString => ExBudget {
2204 mem: self
2205 .append_string
2206 .mem
2207 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2208 cpu: self
2209 .append_string
2210 .cpu
2211 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2212 },
2213 DefaultFunction::EqualsString => ExBudget {
2214 mem: self
2215 .equals_string
2216 .mem
2217 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2218 cpu: self
2219 .equals_string
2220 .cpu
2221 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2222 },
2223 DefaultFunction::EncodeUtf8 => ExBudget {
2224 mem: self.encode_utf8.mem.cost(args[0].to_ex_mem()),
2225 cpu: self.encode_utf8.cpu.cost(args[0].to_ex_mem()),
2226 },
2227 DefaultFunction::DecodeUtf8 => ExBudget {
2228 mem: self.decode_utf8.mem.cost(args[0].to_ex_mem()),
2229 cpu: self.decode_utf8.cpu.cost(args[0].to_ex_mem()),
2230 },
2231 DefaultFunction::IfThenElse => ExBudget {
2232 mem: self.if_then_else.mem.cost(
2233 args[0].to_ex_mem(),
2234 args[1].to_ex_mem(),
2235 args[2].to_ex_mem(),
2236 ),
2237 cpu: self.if_then_else.cpu.cost(
2238 args[0].to_ex_mem(),
2239 args[1].to_ex_mem(),
2240 args[2].to_ex_mem(),
2241 ),
2242 },
2243 DefaultFunction::ChooseUnit => ExBudget {
2244 mem: self
2245 .choose_unit
2246 .mem
2247 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2248 cpu: self
2249 .choose_unit
2250 .cpu
2251 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2252 },
2253 DefaultFunction::Trace => ExBudget {
2254 mem: self
2255 .trace
2256 .mem
2257 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2258 cpu: self
2259 .trace
2260 .cpu
2261 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2262 },
2263 DefaultFunction::FstPair => ExBudget {
2264 mem: self.fst_pair.mem.cost(args[0].to_ex_mem()),
2265 cpu: self.fst_pair.cpu.cost(args[0].to_ex_mem()),
2266 },
2267 DefaultFunction::SndPair => ExBudget {
2268 mem: self.snd_pair.mem.cost(args[0].to_ex_mem()),
2269 cpu: self.snd_pair.cpu.cost(args[0].to_ex_mem()),
2270 },
2271 DefaultFunction::ChooseList => ExBudget {
2272 mem: self.choose_list.mem.cost(
2273 args[0].to_ex_mem(),
2274 args[1].to_ex_mem(),
2275 args[2].to_ex_mem(),
2276 ),
2277 cpu: self.choose_list.cpu.cost(
2278 args[0].to_ex_mem(),
2279 args[1].to_ex_mem(),
2280 args[2].to_ex_mem(),
2281 ),
2282 },
2283 DefaultFunction::MkCons => ExBudget {
2284 mem: self
2285 .mk_cons
2286 .mem
2287 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2288 cpu: self
2289 .mk_cons
2290 .cpu
2291 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2292 },
2293 DefaultFunction::HeadList => ExBudget {
2294 mem: self.head_list.mem.cost(args[0].to_ex_mem()),
2295 cpu: self.head_list.cpu.cost(args[0].to_ex_mem()),
2296 },
2297 DefaultFunction::TailList => ExBudget {
2298 mem: self.tail_list.mem.cost(args[0].to_ex_mem()),
2299 cpu: self.tail_list.cpu.cost(args[0].to_ex_mem()),
2300 },
2301 DefaultFunction::NullList => ExBudget {
2302 mem: self.null_list.mem.cost(args[0].to_ex_mem()),
2303 cpu: self.null_list.cpu.cost(args[0].to_ex_mem()),
2304 },
2305 DefaultFunction::ChooseData => ExBudget {
2306 mem: self.choose_data.mem.cost(
2307 args[0].to_ex_mem(),
2308 args[1].to_ex_mem(),
2309 args[2].to_ex_mem(),
2310 args[3].to_ex_mem(),
2311 args[4].to_ex_mem(),
2312 args[5].to_ex_mem(),
2313 ),
2314 cpu: self.choose_data.cpu.cost(
2315 args[0].to_ex_mem(),
2316 args[1].to_ex_mem(),
2317 args[2].to_ex_mem(),
2318 args[3].to_ex_mem(),
2319 args[4].to_ex_mem(),
2320 args[5].to_ex_mem(),
2321 ),
2322 },
2323 DefaultFunction::ConstrData => ExBudget {
2324 mem: self
2325 .constr_data
2326 .mem
2327 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2328 cpu: self
2329 .constr_data
2330 .cpu
2331 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2332 },
2333 DefaultFunction::MapData => ExBudget {
2334 mem: self.map_data.mem.cost(args[0].to_ex_mem()),
2335 cpu: self.map_data.cpu.cost(args[0].to_ex_mem()),
2336 },
2337 DefaultFunction::ListData => ExBudget {
2338 mem: self.list_data.mem.cost(args[0].to_ex_mem()),
2339 cpu: self.list_data.cpu.cost(args[0].to_ex_mem()),
2340 },
2341 DefaultFunction::IData => ExBudget {
2342 mem: self.i_data.mem.cost(args[0].to_ex_mem()),
2343 cpu: self.i_data.cpu.cost(args[0].to_ex_mem()),
2344 },
2345 DefaultFunction::BData => ExBudget {
2346 mem: self.b_data.mem.cost(args[0].to_ex_mem()),
2347 cpu: self.b_data.cpu.cost(args[0].to_ex_mem()),
2348 },
2349 DefaultFunction::UnConstrData => ExBudget {
2350 mem: self.un_constr_data.mem.cost(args[0].to_ex_mem()),
2351 cpu: self.un_constr_data.cpu.cost(args[0].to_ex_mem()),
2352 },
2353 DefaultFunction::UnMapData => ExBudget {
2354 mem: self.un_map_data.mem.cost(args[0].to_ex_mem()),
2355 cpu: self.un_map_data.cpu.cost(args[0].to_ex_mem()),
2356 },
2357 DefaultFunction::UnListData => ExBudget {
2358 mem: self.un_list_data.mem.cost(args[0].to_ex_mem()),
2359 cpu: self.un_list_data.cpu.cost(args[0].to_ex_mem()),
2360 },
2361 DefaultFunction::UnIData => ExBudget {
2362 mem: self.un_i_data.mem.cost(args[0].to_ex_mem()),
2363 cpu: self.un_i_data.cpu.cost(args[0].to_ex_mem()),
2364 },
2365 DefaultFunction::UnBData => ExBudget {
2366 mem: self.un_b_data.mem.cost(args[0].to_ex_mem()),
2367 cpu: self.un_b_data.cpu.cost(args[0].to_ex_mem()),
2368 },
2369 DefaultFunction::EqualsData => ExBudget {
2370 mem: self
2371 .equals_data
2372 .mem
2373 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2374 cpu: self
2375 .equals_data
2376 .cpu
2377 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2378 },
2379 DefaultFunction::SerialiseData => ExBudget {
2380 mem: self.serialise_data.mem.cost(args[0].to_ex_mem()),
2381 cpu: self.serialise_data.cpu.cost(args[0].to_ex_mem()),
2382 },
2383 DefaultFunction::MkPairData => ExBudget {
2384 mem: self
2385 .mk_pair_data
2386 .mem
2387 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2388 cpu: self
2389 .mk_pair_data
2390 .cpu
2391 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2392 },
2393 DefaultFunction::MkNilData => ExBudget {
2394 mem: self.mk_nil_data.mem.cost(args[0].to_ex_mem()),
2395 cpu: self.mk_nil_data.cpu.cost(args[0].to_ex_mem()),
2396 },
2397 DefaultFunction::MkNilPairData => ExBudget {
2398 mem: self.mk_nil_pair_data.mem.cost(args[0].to_ex_mem()),
2399 cpu: self.mk_nil_pair_data.cpu.cost(args[0].to_ex_mem()),
2400 },
2401 DefaultFunction::Keccak_256 => ExBudget {
2402 mem: self.keccak_256.mem.cost(args[0].to_ex_mem()),
2403 cpu: self.keccak_256.cpu.cost(args[0].to_ex_mem()),
2404 },
2405 DefaultFunction::Blake2b_224 => ExBudget {
2406 mem: self.blake2b_224.mem.cost(args[0].to_ex_mem()),
2407 cpu: self.blake2b_224.cpu.cost(args[0].to_ex_mem()),
2408 },
2409 DefaultFunction::Bls12_381_G1_Add => ExBudget {
2410 mem: self
2411 .bls12_381_g1_add
2412 .mem
2413 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2414 cpu: self
2415 .bls12_381_g1_add
2416 .cpu
2417 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2418 },
2419 DefaultFunction::Bls12_381_G1_Neg => ExBudget {
2420 mem: self.bls12_381_g1_neg.mem.cost(args[0].to_ex_mem()),
2421 cpu: self.bls12_381_g1_neg.cpu.cost(args[0].to_ex_mem()),
2422 },
2423 DefaultFunction::Bls12_381_G1_ScalarMul => ExBudget {
2424 mem: self
2425 .bls12_381_g1_scalar_mul
2426 .mem
2427 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2428 cpu: self
2429 .bls12_381_g1_scalar_mul
2430 .cpu
2431 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2432 },
2433 DefaultFunction::Bls12_381_G1_Equal => ExBudget {
2434 mem: self
2435 .bls12_381_g1_equal
2436 .mem
2437 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2438 cpu: self
2439 .bls12_381_g1_equal
2440 .cpu
2441 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2442 },
2443 DefaultFunction::Bls12_381_G1_Compress => ExBudget {
2444 mem: self.bls12_381_g1_compress.mem.cost(args[0].to_ex_mem()),
2445 cpu: self.bls12_381_g1_compress.cpu.cost(args[0].to_ex_mem()),
2446 },
2447 DefaultFunction::Bls12_381_G1_Uncompress => ExBudget {
2448 mem: self.bls12_381_g1_uncompress.mem.cost(args[0].to_ex_mem()),
2449 cpu: self.bls12_381_g1_uncompress.cpu.cost(args[0].to_ex_mem()),
2450 },
2451 DefaultFunction::Bls12_381_G1_HashToGroup => ExBudget {
2452 mem: self
2453 .bls12_381_g1_hash_to_group
2454 .mem
2455 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2456 cpu: self
2457 .bls12_381_g1_hash_to_group
2458 .cpu
2459 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2460 },
2461 DefaultFunction::Bls12_381_G2_Add => ExBudget {
2462 mem: self
2463 .bls12_381_g2_add
2464 .mem
2465 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2466 cpu: self
2467 .bls12_381_g2_add
2468 .cpu
2469 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2470 },
2471 DefaultFunction::Bls12_381_G2_Neg => ExBudget {
2472 mem: self.bls12_381_g2_neg.mem.cost(args[0].to_ex_mem()),
2473 cpu: self.bls12_381_g2_neg.cpu.cost(args[0].to_ex_mem()),
2474 },
2475 DefaultFunction::Bls12_381_G2_ScalarMul => ExBudget {
2476 mem: self
2477 .bls12_381_g2_scalar_mul
2478 .mem
2479 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2480 cpu: self
2481 .bls12_381_g2_scalar_mul
2482 .cpu
2483 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2484 },
2485 DefaultFunction::Bls12_381_G2_Equal => ExBudget {
2486 mem: self
2487 .bls12_381_g2_equal
2488 .mem
2489 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2490 cpu: self
2491 .bls12_381_g2_equal
2492 .cpu
2493 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2494 },
2495 DefaultFunction::Bls12_381_G2_Compress => ExBudget {
2496 mem: self.bls12_381_g2_compress.mem.cost(args[0].to_ex_mem()),
2497 cpu: self.bls12_381_g2_compress.cpu.cost(args[0].to_ex_mem()),
2498 },
2499 DefaultFunction::Bls12_381_G2_Uncompress => ExBudget {
2500 mem: self.bls12_381_g2_uncompress.mem.cost(args[0].to_ex_mem()),
2501 cpu: self.bls12_381_g2_uncompress.cpu.cost(args[0].to_ex_mem()),
2502 },
2503 DefaultFunction::Bls12_381_G2_HashToGroup => ExBudget {
2504 mem: self
2505 .bls12_381_g2_hash_to_group
2506 .mem
2507 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2508 cpu: self
2509 .bls12_381_g2_hash_to_group
2510 .cpu
2511 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2512 },
2513 DefaultFunction::Bls12_381_MillerLoop => ExBudget {
2514 mem: self
2515 .bls12_381_miller_loop
2516 .mem
2517 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2518 cpu: self
2519 .bls12_381_miller_loop
2520 .cpu
2521 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2522 },
2523 DefaultFunction::Bls12_381_MulMlResult => ExBudget {
2524 mem: self
2525 .bls12_381_mul_ml_result
2526 .mem
2527 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2528 cpu: self
2529 .bls12_381_mul_ml_result
2530 .cpu
2531 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2532 },
2533 DefaultFunction::Bls12_381_FinalVerify => ExBudget {
2534 mem: self
2535 .bls12_381_final_verify
2536 .mem
2537 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2538 cpu: self
2539 .bls12_381_final_verify
2540 .cpu
2541 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2542 },
2543 d @ DefaultFunction::IntegerToByteString => {
2544 let size = args[1].cost_as_size(d)?;
2545
2546 ExBudget {
2547 mem: self.integer_to_byte_string.mem.cost(
2548 args[0].to_ex_mem(),
2549 size,
2550 args[2].to_ex_mem(),
2551 ),
2552 cpu: self.integer_to_byte_string.cpu.cost(
2553 args[0].to_ex_mem(),
2554 size,
2555 args[2].to_ex_mem(),
2556 ),
2557 }
2558 }
2559 DefaultFunction::ByteStringToInteger => ExBudget {
2560 mem: self
2561 .byte_string_to_integer
2562 .mem
2563 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2564 cpu: self
2565 .byte_string_to_integer
2566 .cpu
2567 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2568 },
2569 DefaultFunction::AndByteString => ExBudget {
2570 mem: self.and_byte_string.mem.cost(
2571 args[0].to_ex_mem(),
2572 args[1].to_ex_mem(),
2573 args[2].to_ex_mem(),
2574 ),
2575 cpu: self.and_byte_string.cpu.cost(
2576 args[0].to_ex_mem(),
2577 args[1].to_ex_mem(),
2578 args[2].to_ex_mem(),
2579 ),
2580 },
2581 DefaultFunction::OrByteString => ExBudget {
2582 mem: self.or_byte_string.mem.cost(
2583 args[0].to_ex_mem(),
2584 args[1].to_ex_mem(),
2585 args[2].to_ex_mem(),
2586 ),
2587 cpu: self.or_byte_string.cpu.cost(
2588 args[0].to_ex_mem(),
2589 args[1].to_ex_mem(),
2590 args[2].to_ex_mem(),
2591 ),
2592 },
2593 DefaultFunction::XorByteString => ExBudget {
2594 mem: self.xor_byte_string.mem.cost(
2595 args[0].to_ex_mem(),
2596 args[1].to_ex_mem(),
2597 args[2].to_ex_mem(),
2598 ),
2599 cpu: self.xor_byte_string.cpu.cost(
2600 args[0].to_ex_mem(),
2601 args[1].to_ex_mem(),
2602 args[2].to_ex_mem(),
2603 ),
2604 },
2605 DefaultFunction::ComplementByteString => ExBudget {
2606 mem: self.complement_byte_string.mem.cost(args[0].to_ex_mem()),
2607 cpu: self.complement_byte_string.cpu.cost(args[0].to_ex_mem()),
2608 },
2609 DefaultFunction::ReadBit => ExBudget {
2610 mem: self
2611 .read_bit
2612 .mem
2613 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2614 cpu: self
2615 .read_bit
2616 .cpu
2617 .cost(args[0].to_ex_mem(), args[1].to_ex_mem()),
2618 },
2619 DefaultFunction::WriteBits => {
2620 let list = args[1].unwrap_list().unwrap();
2621
2622 ExBudget {
2623 mem: self.write_bits.mem.cost(
2624 args[0].to_ex_mem(),
2625 list.1.len() as i64,
2626 args[2].to_ex_mem(),
2627 ),
2628 cpu: self.write_bits.cpu.cost(
2629 args[0].to_ex_mem(),
2630 list.1.len() as i64,
2631 args[2].to_ex_mem(),
2632 ),
2633 }
2634 }
2635 d @ DefaultFunction::ReplicateByte => {
2636 let size = args[0].cost_as_size(d)?;
2637
2638 ExBudget {
2639 mem: self.replicate_byte.mem.cost(size, args[1].to_ex_mem()),
2640 cpu: self.replicate_byte.cpu.cost(size, args[1].to_ex_mem()),
2641 }
2642 }
2643 DefaultFunction::ShiftByteString => {
2644 let literal = args[1].unwrap_integer()?;
2645
2646 let arg1: i64 = u64::try_from(literal.abs())
2647 .unwrap()
2648 .try_into()
2649 .unwrap_or(i64::MAX);
2650
2651 ExBudget {
2652 mem: self.shift_byte_string.mem.cost(args[0].to_ex_mem(), arg1),
2653 cpu: self.shift_byte_string.cpu.cost(args[0].to_ex_mem(), arg1),
2654 }
2655 }
2656 DefaultFunction::RotateByteString => {
2657 let literal = args[1].unwrap_integer()?;
2658
2659 let arg1: i64 = u64::try_from(literal.abs())
2660 .unwrap()
2661 .try_into()
2662 .unwrap_or(i64::MAX);
2663
2664 ExBudget {
2665 mem: self.rotate_byte_string.mem.cost(args[0].to_ex_mem(), arg1),
2666 cpu: self.rotate_byte_string.cpu.cost(args[0].to_ex_mem(), arg1),
2667 }
2668 }
2669 DefaultFunction::CountSetBits => ExBudget {
2670 mem: self.count_set_bits.mem.cost(args[0].to_ex_mem()),
2671 cpu: self.count_set_bits.cpu.cost(args[0].to_ex_mem()),
2672 },
2673 DefaultFunction::FindFirstSetBit => ExBudget {
2674 mem: self.find_first_set_bit.mem.cost(args[0].to_ex_mem()),
2675 cpu: self.find_first_set_bit.cpu.cost(args[0].to_ex_mem()),
2676 },
2677 DefaultFunction::Ripemd_160 => ExBudget {
2678 mem: self.ripemd_160.mem.cost(args[0].to_ex_mem()),
2679 cpu: self.ripemd_160.cpu.cost(args[0].to_ex_mem()),
2680 },
2681 })
2707 }
2708}
2709
2710pub fn initialize_cost_model(version: &Language, costs: &[i64]) -> CostModel {
2711 let cost_map: HashMap<&str, i64> = match version {
2712 Language::PlutusV1 => {
2713 hashmap! {
2714 "add_integer-cpu-arguments-intercept" => costs[0],
2715 "add_integer-cpu-arguments-slope" => costs[1],
2716 "add_integer-mem-arguments-intercept" => costs[2],
2717 "add_integer-mem-arguments-slope" => costs[3],
2718 "append_byte_string-cpu-arguments-intercept" => costs[4],
2719 "append_byte_string-cpu-arguments-slope" => costs[5],
2720 "append_byte_string-mem-arguments-intercept" => costs[6],
2721 "append_byte_string-mem-arguments-slope" => costs[7],
2722 "append_string-cpu-arguments-intercept" => costs[8],
2723 "append_string-cpu-arguments-slope" => costs[9],
2724 "append_string-mem-arguments-intercept" => costs[10],
2725 "append_string-mem-arguments-slope" => costs[11],
2726 "b_data-cpu-arguments" => costs[12],
2727 "b_data-mem-arguments" => costs[13],
2728 "blake2b_256-cpu-arguments-intercept" => costs[14],
2729 "blake2b_256-cpu-arguments-slope" => costs[15],
2730 "blake2b_256-mem-arguments" => costs[16],
2731 "cek_apply_cost-exBudgetCPU" => costs[17],
2732 "cek_apply_cost-exBudgetmem" => costs[18],
2733 "cek_builtin_cost-exBudgetCPU" => costs[19],
2734 "cek_builtin_cost-exBudgetmem" => costs[20],
2735 "cek_const_cost-exBudgetCPU" => costs[21],
2736 "cek_const_cost-exBudgetmem" => costs[22],
2737 "cek_delay_cost-exBudgetCPU" => costs[23],
2738 "cek_delay_cost-exBudgetmem" => costs[24],
2739 "cek_force_cost-exBudgetCPU" => costs[25],
2740 "cek_force_cost-exBudgetmem" => costs[26],
2741 "cek_lam_cost-exBudgetCPU" => costs[27],
2742 "cek_lam_cost-exBudgetmem" => costs[28],
2743 "cek_startup_cost-exBudgetCPU" => costs[29],
2744 "cek_startup_cost-exBudgetmem" => costs[30],
2745 "cek_var_cost-exBudgetCPU" => costs[31],
2746 "cek_var_cost-exBudgetmem" => costs[32],
2747 "choose_data-cpu-arguments" => costs[33],
2748 "choose_data-mem-arguments" => costs[34],
2749 "choose_list-cpu-arguments" => costs[35],
2750 "choose_list-mem-arguments" => costs[36],
2751 "choose_unit-cpu-arguments" => costs[37],
2752 "choose_unit-mem-arguments" => costs[38],
2753 "cons_byte_string-cpu-arguments-intercept" => costs[39],
2754 "cons_byte_string-cpu-arguments-slope" => costs[40],
2755 "cons_byte_string-mem-arguments-intercept" => costs[41],
2756 "cons_byte_string-mem-arguments-slope" => costs[42],
2757 "constr_data-cpu-arguments" => costs[43],
2758 "constr_data-mem-arguments" => costs[44],
2759 "decode_utf8-cpu-arguments-intercept" => costs[45],
2760 "decode_utf8-cpu-arguments-slope" => costs[46],
2761 "decode_utf8-mem-arguments-intercept" => costs[47],
2762 "decode_utf8-mem-arguments-slope" => costs[48],
2763 "divide_integer-cpu-arguments-constant" => costs[49],
2764 "divide_integer-cpu-arguments-model-arguments-intercept" => costs[50],
2765 "divide_integer-cpu-arguments-model-arguments-slope" => costs[51],
2766 "divide_integer-mem-arguments-intercept" => costs[52],
2767 "divide_integer-mem-arguments-minimum" => costs[53],
2768 "divide_integer-mem-arguments-slope" => costs[54],
2769 "encode_utf8-cpu-arguments-intercept" => costs[55],
2770 "encode_utf8-cpu-arguments-slope" => costs[56],
2771 "encode_utf8-mem-arguments-intercept" => costs[57],
2772 "encode_utf8-mem-arguments-slope" => costs[58],
2773 "equals_byte_string-cpu-arguments-constant" => costs[59],
2774 "equals_byte_string-cpu-arguments-intercept" => costs[60],
2775 "equals_byte_string-cpu-arguments-slope" => costs[61],
2776 "equals_byte_string-mem-arguments" => costs[62],
2777 "equals_data-cpu-arguments-intercept" => costs[63],
2778 "equals_data-cpu-arguments-slope" => costs[64],
2779 "equals_data-mem-arguments" => costs[65],
2780 "equals_integer-cpu-arguments-intercept" => costs[66],
2781 "equals_integer-cpu-arguments-slope" => costs[67],
2782 "equals_integer-mem-arguments" => costs[68],
2783 "equals_string-cpu-arguments-constant" => costs[69],
2784 "equals_string-cpu-arguments-intercept" => costs[70],
2785 "equals_string-cpu-arguments-slope" => costs[71],
2786 "equals_string-mem-arguments" => costs[72],
2787 "fst_pair-cpu-arguments" => costs[73],
2788 "fst_pair-mem-arguments" => costs[74],
2789 "head_list-cpu-arguments" => costs[75],
2790 "head_list-mem-arguments" => costs[76],
2791 "i_data-cpu-arguments" => costs[77],
2792 "i_data-mem-arguments" => costs[78],
2793 "if_then_else-cpu-arguments" => costs[79],
2794 "if_then_else-mem-arguments" => costs[80],
2795 "index_byte_string-cpu-arguments" => costs[81],
2796 "index_byte_string-mem-arguments" => costs[82],
2797 "length_of_byte_string-cpu-arguments" => costs[83],
2798 "length_of_byte_string-mem-arguments" => costs[84],
2799 "less_than_byte_string-cpu-arguments-intercept" => costs[85],
2800 "less_than_byte_string-cpu-arguments-slope" => costs[86],
2801 "less_than_byte_string-mem-arguments" => costs[87],
2802 "less_than_equals_byte_string-cpu-arguments-intercept" => costs[88],
2803 "less_than_equals_byte_string-cpu-arguments-slope" => costs[89],
2804 "less_than_equals_byte_string-mem-arguments" => costs[90],
2805 "less_than_equals_integer-cpu-arguments-intercept" => costs[91],
2806 "less_than_equals_integer-cpu-arguments-slope" => costs[92],
2807 "less_than_equals_integer-mem-arguments" => costs[93],
2808 "less_than_integer-cpu-arguments-intercept" => costs[94],
2809 "less_than_integer-cpu-arguments-slope" => costs[95],
2810 "less_than_integer-mem-arguments" => costs[96],
2811 "list_data-cpu-arguments" => costs[97],
2812 "list_data-mem-arguments" => costs[98],
2813 "map_data-cpu-arguments" => costs[99],
2814 "map_data-mem-arguments" => costs[100],
2815 "mk_cons-cpu-arguments" => costs[101],
2816 "mk_cons-mem-arguments" => costs[102],
2817 "mk_nil_data-cpu-arguments" => costs[103],
2818 "mk_nil_data-mem-arguments" => costs[104],
2819 "mk_nil_pair_data-cpu-arguments" => costs[105],
2820 "mk_nil_pair_data-mem-arguments" => costs[106],
2821 "mk_pair_data-cpu-arguments" => costs[107],
2822 "mk_pair_data-mem-arguments" => costs[108],
2823 "mod_integer-cpu-arguments-constant" => costs[109],
2824 "mod_integer-cpu-arguments-model-arguments-intercept" => costs[110],
2825 "mod_integer-cpu-arguments-model-arguments-slope" => costs[111],
2826 "mod_integer-mem-arguments-intercept" => costs[112],
2827 "mod_integer-mem-arguments-minimum" => costs[113],
2828 "mod_integer-mem-arguments-slope" => costs[114],
2829 "multiply_integer-cpu-arguments-intercept" => costs[115],
2830 "multiply_integer-cpu-arguments-slope" => costs[116],
2831 "multiply_integer-mem-arguments-intercept" => costs[117],
2832 "multiply_integer-mem-arguments-slope" => costs[118],
2833 "null_list-cpu-arguments" => costs[119],
2834 "null_list-mem-arguments" => costs[120],
2835 "quotient_integer-cpu-arguments-constant" => costs[121],
2836 "quotient_integer-cpu-arguments-model-arguments-intercept" => costs[122],
2837 "quotient_integer-cpu-arguments-model-arguments-slope" => costs[123],
2838 "quotient_integer-mem-arguments-intercept" => costs[124],
2839 "quotient_integer-mem-arguments-minimum" => costs[125],
2840 "quotient_integer-mem-arguments-slope" => costs[126],
2841 "remainder_integer-cpu-arguments-constant" => costs[127],
2842 "remainder_integer-cpu-arguments-model-arguments-intercept" => costs[128],
2843 "remainder_integer-cpu-arguments-model-arguments-slope" => costs[129],
2844 "remainder_integer-mem-arguments-intercept" => costs[130],
2845 "remainder_integer-mem-arguments-minimum" => costs[131],
2846 "remainder_integer-mem-arguments-slope" => costs[132],
2847 "sha2_256-cpu-arguments-intercept" => costs[133],
2848 "sha2_256-cpu-arguments-slope" => costs[134],
2849 "sha2_256-mem-arguments" => costs[135],
2850 "sha3_256-cpu-arguments-intercept" => costs[136],
2851 "sha3_256-cpu-arguments-slope" => costs[137],
2852 "sha3_256-mem-arguments" => costs[138],
2853 "slice_byte_string-cpu-arguments-intercept" => costs[139],
2854 "slice_byte_string-cpu-arguments-slope" => costs[140],
2855 "slice_byte_string-mem-arguments-intercept" => costs[141],
2856 "slice_byte_string-mem-arguments-slope" => costs[142],
2857 "snd_pair-cpu-arguments" => costs[143],
2858 "snd_pair-mem-arguments" => costs[144],
2859 "subtract_integer-cpu-arguments-intercept" => costs[145],
2860 "subtract_integer-cpu-arguments-slope" => costs[146],
2861 "subtract_integer-mem-arguments-intercept" => costs[147],
2862 "subtract_integer-mem-arguments-slope" => costs[148],
2863 "tail_list-cpu-arguments" => costs[149],
2864 "tail_list-mem-arguments" => costs[150],
2865 "trace-cpu-arguments" => costs[151],
2866 "trace-mem-arguments" => costs[152],
2867 "un_b_data-cpu-arguments" => costs[153],
2868 "un_b_data-mem-arguments" => costs[154],
2869 "un_constr_data-cpu-arguments" => costs[155],
2870 "un_constr_data-mem-arguments" => costs[156],
2871 "un_i_data-cpu-arguments" => costs[157],
2872 "un_i_data-mem-arguments" => costs[158],
2873 "un_list_data-cpu-arguments" => costs[159],
2874 "un_list_data-mem-arguments" => costs[160],
2875 "un_map_data-cpu-arguments" => costs[161],
2876 "un_map_data-mem-arguments" => costs[162],
2877 "verify_ed25519_signature-cpu-arguments-intercept" => costs[163],
2878 "verify_ed25519_signature-cpu-arguments-slope" => costs[164],
2879 "verify_ed25519_signature-mem-arguments" => costs[165]
2880 }
2881 }
2882 Language::PlutusV2 => {
2883 hashmap! {
2884 "add_integer-cpu-arguments-intercept"=> costs[0],
2885 "add_integer-cpu-arguments-slope"=> costs[1],
2886 "add_integer-mem-arguments-intercept"=> costs[2],
2887 "add_integer-mem-arguments-slope"=> costs[3],
2888 "append_byte_string-cpu-arguments-intercept"=> costs[4],
2889 "append_byte_string-cpu-arguments-slope"=> costs[5],
2890 "append_byte_string-mem-arguments-intercept"=> costs[6],
2891 "append_byte_string-mem-arguments-slope"=> costs[7],
2892 "append_string-cpu-arguments-intercept"=> costs[8],
2893 "append_string-cpu-arguments-slope"=> costs[9],
2894 "append_string-mem-arguments-intercept"=> costs[10],
2895 "append_string-mem-arguments-slope"=> costs[11],
2896 "b_data-cpu-arguments"=> costs[12],
2897 "b_data-mem-arguments"=> costs[13],
2898 "blake2b_256-cpu-arguments-intercept"=> costs[14],
2899 "blake2b_256-cpu-arguments-slope"=> costs[15],
2900 "blake2b_256-mem-arguments"=> costs[16],
2901 "cek_apply_cost-exBudgetCPU"=> costs[17],
2902 "cek_apply_cost-exBudgetmem"=> costs[18],
2903 "cek_builtin_cost-exBudgetCPU"=> costs[19],
2904 "cek_builtin_cost-exBudgetmem"=> costs[20],
2905 "cek_const_cost-exBudgetCPU"=> costs[21],
2906 "cek_const_cost-exBudgetmem"=> costs[22],
2907 "cek_delay_cost-exBudgetCPU"=> costs[23],
2908 "cek_delay_cost-exBudgetmem"=> costs[24],
2909 "cek_force_cost-exBudgetCPU"=> costs[25],
2910 "cek_force_cost-exBudgetmem"=> costs[26],
2911 "cek_lam_cost-exBudgetCPU"=> costs[27],
2912 "cek_lam_cost-exBudgetmem"=> costs[28],
2913 "cek_startup_cost-exBudgetCPU"=> costs[29],
2914 "cek_startup_cost-exBudgetmem"=> costs[30],
2915 "cek_var_cost-exBudgetCPU"=> costs[31],
2916 "cek_var_cost-exBudgetmem"=> costs[32],
2917 "choose_data-cpu-arguments"=> costs[33],
2918 "choose_data-mem-arguments"=> costs[34],
2919 "choose_list-cpu-arguments"=> costs[35],
2920 "choose_list-mem-arguments"=> costs[36],
2921 "choose_unit-cpu-arguments"=> costs[37],
2922 "choose_unit-mem-arguments"=> costs[38],
2923 "cons_byte_string-cpu-arguments-intercept"=> costs[39],
2924 "cons_byte_string-cpu-arguments-slope"=> costs[40],
2925 "cons_byte_string-mem-arguments-intercept"=> costs[41],
2926 "cons_byte_string-mem-arguments-slope"=> costs[42],
2927 "constr_data-cpu-arguments"=> costs[43],
2928 "constr_data-mem-arguments"=> costs[44],
2929 "decode_utf8-cpu-arguments-intercept"=> costs[45],
2930 "decode_utf8-cpu-arguments-slope"=> costs[46],
2931 "decode_utf8-mem-arguments-intercept"=> costs[47],
2932 "decode_utf8-mem-arguments-slope"=> costs[48],
2933 "divide_integer-cpu-arguments-constant"=> costs[49],
2934 "divide_integer-cpu-arguments-model-arguments-intercept"=> costs[50],
2935 "divide_integer-cpu-arguments-model-arguments-slope"=> costs[51],
2936 "divide_integer-mem-arguments-intercept"=> costs[52],
2937 "divide_integer-mem-arguments-minimum"=> costs[53],
2938 "divide_integer-mem-arguments-slope"=> costs[54],
2939 "encode_utf8-cpu-arguments-intercept"=> costs[55],
2940 "encode_utf8-cpu-arguments-slope"=> costs[56],
2941 "encode_utf8-mem-arguments-intercept"=> costs[57],
2942 "encode_utf8-mem-arguments-slope"=> costs[58],
2943 "equals_byte_string-cpu-arguments-constant"=> costs[59],
2944 "equals_byte_string-cpu-arguments-intercept"=> costs[60],
2945 "equals_byte_string-cpu-arguments-slope"=> costs[61],
2946 "equals_byte_string-mem-arguments"=> costs[62],
2947 "equals_data-cpu-arguments-intercept"=> costs[63],
2948 "equals_data-cpu-arguments-slope"=> costs[64],
2949 "equals_data-mem-arguments"=> costs[65],
2950 "equals_integer-cpu-arguments-intercept"=> costs[66],
2951 "equals_integer-cpu-arguments-slope"=> costs[67],
2952 "equals_integer-mem-arguments"=> costs[68],
2953 "equals_string-cpu-arguments-constant"=> costs[69],
2954 "equals_string-cpu-arguments-intercept"=> costs[70],
2955 "equals_string-cpu-arguments-slope"=> costs[71],
2956 "equals_string-mem-arguments"=> costs[72],
2957 "fst_pair-cpu-arguments"=> costs[73],
2958 "fst_pair-mem-arguments"=> costs[74],
2959 "head_list-cpu-arguments"=> costs[75],
2960 "head_list-mem-arguments"=> costs[76],
2961 "i_data-cpu-arguments"=> costs[77],
2962 "i_data-mem-arguments"=> costs[78],
2963 "if_then_else-cpu-arguments"=> costs[79],
2964 "if_then_else-mem-arguments"=> costs[80],
2965 "index_byte_string-cpu-arguments"=> costs[81],
2966 "index_byte_string-mem-arguments"=> costs[82],
2967 "length_of_byte_string-cpu-arguments"=> costs[83],
2968 "length_of_byte_string-mem-arguments"=> costs[84],
2969 "less_than_byte_string-cpu-arguments-intercept"=> costs[85],
2970 "less_than_byte_string-cpu-arguments-slope"=> costs[86],
2971 "less_than_byte_string-mem-arguments"=> costs[87],
2972 "less_than_equals_byte_string-cpu-arguments-intercept"=> costs[88],
2973 "less_than_equals_byte_string-cpu-arguments-slope"=> costs[89],
2974 "less_than_equals_byte_string-mem-arguments"=> costs[90],
2975 "less_than_equals_integer-cpu-arguments-intercept"=> costs[91],
2976 "less_than_equals_integer-cpu-arguments-slope"=> costs[92],
2977 "less_than_equals_integer-mem-arguments"=> costs[93],
2978 "less_than_integer-cpu-arguments-intercept"=> costs[94],
2979 "less_than_integer-cpu-arguments-slope"=> costs[95],
2980 "less_than_integer-mem-arguments"=> costs[96],
2981 "list_data-cpu-arguments"=> costs[97],
2982 "list_data-mem-arguments"=> costs[98],
2983 "map_data-cpu-arguments"=> costs[99],
2984 "map_data-mem-arguments"=> costs[100],
2985 "mk_cons-cpu-arguments"=> costs[101],
2986 "mk_cons-mem-arguments"=> costs[102],
2987 "mk_nil_data-cpu-arguments"=> costs[103],
2988 "mk_nil_data-mem-arguments"=> costs[104],
2989 "mk_nil_pair_data-cpu-arguments"=> costs[105],
2990 "mk_nil_pair_data-mem-arguments"=> costs[106],
2991 "mk_pair_data-cpu-arguments"=> costs[107],
2992 "mk_pair_data-mem-arguments"=> costs[108],
2993 "mod_integer-cpu-arguments-constant"=> costs[109],
2994 "mod_integer-cpu-arguments-model-arguments-intercept"=> costs[110],
2995 "mod_integer-cpu-arguments-model-arguments-slope"=> costs[111],
2996 "mod_integer-mem-arguments-intercept"=> costs[112],
2997 "mod_integer-mem-arguments-minimum"=> costs[113],
2998 "mod_integer-mem-arguments-slope"=> costs[114],
2999 "multiply_integer-cpu-arguments-intercept"=> costs[115],
3000 "multiply_integer-cpu-arguments-slope"=> costs[116],
3001 "multiply_integer-mem-arguments-intercept"=> costs[117],
3002 "multiply_integer-mem-arguments-slope"=> costs[118],
3003 "null_list-cpu-arguments"=> costs[119],
3004 "null_list-mem-arguments"=> costs[120],
3005 "quotient_integer-cpu-arguments-constant"=> costs[121],
3006 "quotient_integer-cpu-arguments-model-arguments-intercept"=> costs[122],
3007 "quotient_integer-cpu-arguments-model-arguments-slope"=> costs[123],
3008 "quotient_integer-mem-arguments-intercept"=> costs[124],
3009 "quotient_integer-mem-arguments-minimum"=> costs[125],
3010 "quotient_integer-mem-arguments-slope"=> costs[126],
3011 "remainder_integer-cpu-arguments-constant"=> costs[127],
3012 "remainder_integer-cpu-arguments-model-arguments-intercept"=> costs[128],
3013 "remainder_integer-cpu-arguments-model-arguments-slope"=> costs[129],
3014 "remainder_integer-mem-arguments-intercept"=> costs[130],
3015 "remainder_integer-mem-arguments-minimum"=> costs[131],
3016 "remainder_integer-mem-arguments-slope"=> costs[132],
3017 "serialise_data-cpu-arguments-intercept"=> costs[133],
3018 "serialise_data-cpu-arguments-slope"=> costs[134],
3019 "serialise_data-mem-arguments-intercept"=> costs[135],
3020 "serialise_data-mem-arguments-slope"=> costs[136],
3021 "sha2_256-cpu-arguments-intercept"=> costs[137],
3022 "sha2_256-cpu-arguments-slope"=> costs[138],
3023 "sha2_256-mem-arguments"=> costs[139],
3024 "sha3_256-cpu-arguments-intercept"=> costs[140],
3025 "sha3_256-cpu-arguments-slope"=> costs[141],
3026 "sha3_256-mem-arguments"=> costs[142],
3027 "slice_byte_string-cpu-arguments-intercept"=> costs[143],
3028 "slice_byte_string-cpu-arguments-slope"=> costs[144],
3029 "slice_byte_string-mem-arguments-intercept"=> costs[145],
3030 "slice_byte_string-mem-arguments-slope"=> costs[146],
3031 "snd_pair-cpu-arguments"=> costs[147],
3032 "snd_pair-mem-arguments"=> costs[148],
3033 "subtract_integer-cpu-arguments-intercept"=> costs[149],
3034 "subtract_integer-cpu-arguments-slope"=> costs[150],
3035 "subtract_integer-mem-arguments-intercept"=> costs[151],
3036 "subtract_integer-mem-arguments-slope"=> costs[152],
3037 "tail_list-cpu-arguments"=> costs[153],
3038 "tail_list-mem-arguments"=> costs[154],
3039 "trace-cpu-arguments"=> costs[155],
3040 "trace-mem-arguments"=> costs[156],
3041 "un_b_data-cpu-arguments"=> costs[157],
3042 "un_b_data-mem-arguments"=> costs[158],
3043 "un_constr_data-cpu-arguments"=> costs[159],
3044 "un_constr_data-mem-arguments"=> costs[160],
3045 "un_i_data-cpu-arguments"=> costs[161],
3046 "un_i_data-mem-arguments"=> costs[162],
3047 "un_list_data-cpu-arguments"=> costs[163],
3048 "un_list_data-mem-arguments"=> costs[164],
3049 "un_map_data-cpu-arguments"=> costs[165],
3050 "un_map_data-mem-arguments"=> costs[166],
3051 "verify_ecdsa_secp256k1_signature-cpu-arguments"=> costs[167],
3052 "verify_ecdsa_secp256k1_signature-mem-arguments"=> costs[168],
3053 "verify_ed25519_signature-cpu-arguments-intercept"=> costs[169],
3054 "verify_ed25519_signature-cpu-arguments-slope"=> costs[170],
3055 "verify_ed25519_signature-mem-arguments"=> costs[171],
3056 "verify_schnorr_secp256k1_signature-cpu-arguments-intercept"=> costs[172],
3057 "verify_schnorr_secp256k1_signature-cpu-arguments-slope"=> costs[173],
3058 "verify_schnorr_secp256k1_signature-mem-arguments"=> costs[174]
3059 }
3060 }
3061 Language::PlutusV3 => {
3062 let mut main: HashMap<&str, i64> = hashmap! {
3064 "add_integer-cpu-arguments-intercept" => costs[0],
3065 "add_integer-cpu-arguments-slope" => costs[1],
3066 "add_integer-mem-arguments-intercept" => costs[2],
3067 "add_integer-mem-arguments-slope" => costs[3],
3068 "append_byte_string-cpu-arguments-intercept" => costs[4],
3069 "append_byte_string-cpu-arguments-slope" => costs[5],
3070 "append_byte_string-mem-arguments-intercept" => costs[6],
3071 "append_byte_string-mem-arguments-slope" => costs[7],
3072 "append_string-cpu-arguments-intercept" => costs[8],
3073 "append_string-cpu-arguments-slope" => costs[9],
3074 "append_string-mem-arguments-intercept" => costs[10],
3075 "append_string-mem-arguments-slope" => costs[11],
3076 "b_data-cpu-arguments" => costs[12],
3077 "b_data-mem-arguments" => costs[13],
3078 "blake2b_256-cpu-arguments-intercept" => costs[14],
3079 "blake2b_256-cpu-arguments-slope" => costs[15],
3080 "blake2b_256-mem-arguments" => costs[16],
3081 "cek_apply_cost-exBudgetCPU" => costs[17],
3082 "cek_apply_cost-exBudgetmem" => costs[18],
3083 "cek_builtin_cost-exBudgetCPU" => costs[19],
3084 "cek_builtin_cost-exBudgetmem" => costs[20],
3085 "cek_const_cost-exBudgetCPU" => costs[21],
3086 "cek_const_cost-exBudgetmem" => costs[22],
3087 "cek_delay_cost-exBudgetCPU" => costs[23],
3088 "cek_delay_cost-exBudgetmem" => costs[24],
3089 "cek_force_cost-exBudgetCPU" => costs[25],
3090 "cek_force_cost-exBudgetmem" => costs[26],
3091 "cek_lam_cost-exBudgetCPU" => costs[27],
3092 "cek_lam_cost-exBudgetmem" => costs[28],
3093 "cek_startup_cost-exBudgetCPU" => costs[29],
3094 "cek_startup_cost-exBudgetmem" => costs[30],
3095 "cek_var_cost-exBudgetCPU" => costs[31],
3096 "cek_var_cost-exBudgetmem" => costs[32],
3097 "choose_data-cpu-arguments" => costs[33],
3098 "choose_data-mem-arguments" => costs[34],
3099 "choose_list-cpu-arguments" => costs[35],
3100 "choose_list-mem-arguments" => costs[36],
3101 "choose_unit-cpu-arguments" => costs[37],
3102 "choose_unit-mem-arguments" => costs[38],
3103 "cons_byte_string-cpu-arguments-intercept" => costs[39],
3104 "cons_byte_string-cpu-arguments-slope" => costs[40],
3105 "cons_byte_string-mem-arguments-intercept" => costs[41],
3106 "cons_byte_string-mem-arguments-slope" => costs[42],
3107 "constr_data-cpu-arguments" => costs[43],
3108 "constr_data-mem-arguments" => costs[44],
3109 "decode_utf8-cpu-arguments-intercept" => costs[45],
3110 "decode_utf8-cpu-arguments-slope" => costs[46],
3111 "decode_utf8-mem-arguments-intercept" => costs[47],
3112 "decode_utf8-mem-arguments-slope" => costs[48],
3113 "divide_integer-cpu-arguments-constant" => costs[49],
3114 "divide_integer-cpu-arguments-c00" => costs[50],
3115 "divide_integer-cpu-arguments-c01" => costs[51],
3116 "divide_integer-cpu-arguments-c02" => costs[52],
3117 "divide_integer-cpu-arguments-c10" => costs[53],
3118 "divide_integer-cpu-arguments-c11" => costs[54],
3119 "divide_integer-cpu-arguments-c20" => costs[55],
3120 "divide_integer-cpu-arguments-minimum" => costs[56],
3121 "divide_integer-mem-arguments-intercept" => costs[57],
3122 "divide_integer-mem-arguments-minimum" => costs[58],
3123 "divide_integer-mem-arguments-slope" => costs[59],
3124 "encode_utf8-cpu-arguments-intercept" => costs[60],
3125 "encode_utf8-cpu-arguments-slope" => costs[61],
3126 "encode_utf8-mem-arguments-intercept" => costs[62],
3127 "encode_utf8-mem-arguments-slope" => costs[63],
3128 "equals_byte_string-cpu-arguments-constant" => costs[64],
3129 "equals_byte_string-cpu-arguments-intercept" => costs[65],
3130 "equals_byte_string-cpu-arguments-slope" => costs[66],
3131 "equals_byte_string-mem-arguments" => costs[67],
3132 "equals_data-cpu-arguments-intercept" => costs[68],
3133 "equals_data-cpu-arguments-slope" => costs[69],
3134 "equals_data-mem-arguments" => costs[70],
3135 "equals_integer-cpu-arguments-intercept" => costs[71],
3136 "equals_integer-cpu-arguments-slope" => costs[72],
3137 "equals_integer-mem-arguments" => costs[73],
3138 "equals_string-cpu-arguments-constant" => costs[74],
3139 "equals_string-cpu-arguments-intercept" => costs[75],
3140 "equals_string-cpu-arguments-slope" => costs[76],
3141 "equals_string-mem-arguments" => costs[77],
3142 "fst_pair-cpu-arguments" => costs[78],
3143 "fst_pair-mem-arguments" => costs[79],
3144 "head_list-cpu-arguments" => costs[80],
3145 "head_list-mem-arguments" => costs[81],
3146 "i_data-cpu-arguments" => costs[82],
3147 "i_data-mem-arguments" => costs[83],
3148 "if_then_else-cpu-arguments" => costs[84],
3149 "if_then_else-mem-arguments" => costs[85],
3150 "index_byte_string-cpu-arguments" => costs[86],
3151 "index_byte_string-mem-arguments" => costs[87],
3152 "length_of_byte_string-cpu-arguments" => costs[88],
3153 "length_of_byte_string-mem-arguments" => costs[89],
3154 "less_than_byte_string-cpu-arguments-intercept" => costs[90],
3155 "less_than_byte_string-cpu-arguments-slope" => costs[91],
3156 "less_than_byte_string-mem-arguments" => costs[92],
3157 "less_than_equals_byte_string-cpu-arguments-intercept" => costs[93],
3158 "less_than_equals_byte_string-cpu-arguments-slope" => costs[94],
3159 "less_than_equals_byte_string-mem-arguments" => costs[95],
3160 "less_than_equals_integer-cpu-arguments-intercept" => costs[96],
3161 "less_than_equals_integer-cpu-arguments-slope" => costs[97],
3162 "less_than_equals_integer-mem-arguments" => costs[98],
3163 "less_than_integer-cpu-arguments-intercept" => costs[99],
3164 "less_than_integer-cpu-arguments-slope" => costs[100],
3165 "less_than_integer-mem-arguments" => costs[101],
3166 "list_data-cpu-arguments" => costs[102],
3167 "list_data-mem-arguments" => costs[103],
3168 "map_data-cpu-arguments" => costs[104],
3169 "map_data-mem-arguments" => costs[105],
3170 "mk_cons-cpu-arguments" => costs[106],
3171 "mk_cons-mem-arguments" => costs[107],
3172 "mk_nil_data-cpu-arguments" => costs[108],
3173 "mk_nil_data-mem-arguments" => costs[109],
3174 "mk_nil_pair_data-cpu-arguments" => costs[110],
3175 "mk_nil_pair_data-mem-arguments" => costs[111],
3176 "mk_pair_data-cpu-arguments" => costs[112],
3177 "mk_pair_data-mem-arguments" => costs[113],
3178 "mod_integer-cpu-arguments-constant" => costs[114],
3179 "mod_integer-cpu-arguments-c00" => costs[115],
3180 "mod_integer-cpu-arguments-c01" => costs[116],
3181 "mod_integer-cpu-arguments-c02" => costs[117],
3182 "mod_integer-cpu-arguments-c10" => costs[118],
3183 "mod_integer-cpu-arguments-c11" => costs[119],
3184 "mod_integer-cpu-arguments-c20" => costs[120],
3185 "mod_integer-cpu-arguments-minimum" => costs[121],
3186 "mod_integer-mem-arguments-intercept" => costs[122],
3187 "mod_integer-mem-arguments-slope" => costs[123],
3188 "multiply_integer-cpu-arguments-intercept" => costs[124],
3189 "multiply_integer-cpu-arguments-slope" => costs[125],
3190 "multiply_integer-mem-arguments-intercept" => costs[126],
3191 "multiply_integer-mem-arguments-slope" => costs[127],
3192 "null_list-cpu-arguments" => costs[128],
3193 "null_list-mem-arguments" => costs[129],
3194 "quotient_integer-cpu-arguments-constant" => costs[130],
3195 "quotient_integer-cpu-arguments-c00" => costs[131],
3196 "quotient_integer-cpu-arguments-c01" => costs[132],
3197 "quotient_integer-cpu-arguments-c02" => costs[133],
3198 "quotient_integer-cpu-arguments-c10" => costs[134],
3199 "quotient_integer-cpu-arguments-c11" => costs[135],
3200 "quotient_integer-cpu-arguments-c20" => costs[136],
3201 "quotient_integer-cpu-arguments-minimum" => costs[137],
3202 "quotient_integer-mem-arguments-intercept" => costs[138],
3203 "quotient_integer-mem-arguments-minimum" => costs[139],
3204 "quotient_integer-mem-arguments-slope" => costs[140],
3205 "remainder_integer-cpu-arguments-constant" => costs[141],
3206 "remainder_integer-cpu-arguments-c00" => costs[142],
3207 "remainder_integer-cpu-arguments-c01" => costs[143],
3208 "remainder_integer-cpu-arguments-c02" => costs[144],
3209 "remainder_integer-cpu-arguments-c10" => costs[145],
3210 "remainder_integer-cpu-arguments-c11" => costs[146],
3211 "remainder_integer-cpu-arguments-c20" => costs[147],
3212 "remainder_integer-cpu-arguments-minimum" => costs[148],
3213 "remainder_integer-mem-arguments-intercept" => costs[149],
3214 "remainder_integer-mem-arguments-slope" => costs[150],
3215 "serialise_data-cpu-arguments-intercept" => costs[151],
3216 "serialise_data-cpu-arguments-slope" => costs[152],
3217 "serialise_data-mem-arguments-intercept" => costs[153],
3218 "serialise_data-mem-arguments-slope" => costs[154],
3219 "sha2_256-cpu-arguments-intercept" => costs[155],
3220 "sha2_256-cpu-arguments-slope" => costs[156],
3221 "sha2_256-mem-arguments" => costs[157],
3222 "sha3_256-cpu-arguments-intercept" => costs[158],
3223 "sha3_256-cpu-arguments-slope" => costs[159],
3224 "sha3_256-mem-arguments" => costs[160],
3225 "slice_byte_string-cpu-arguments-intercept" => costs[161],
3226 "slice_byte_string-cpu-arguments-slope" => costs[162],
3227 "slice_byte_string-mem-arguments-intercept" => costs[163],
3228 "slice_byte_string-mem-arguments-slope" => costs[164],
3229 "snd_pair-cpu-arguments" => costs[165],
3230 "snd_pair-mem-arguments" => costs[166],
3231 "subtract_integer-cpu-arguments-intercept" => costs[167],
3232 "subtract_integer-cpu-arguments-slope" => costs[168],
3233 "subtract_integer-mem-arguments-intercept" => costs[169],
3234 "subtract_integer-mem-arguments-slope" => costs[170],
3235 "tail_list-cpu-arguments" => costs[171],
3236 "tail_list-mem-arguments" => costs[172],
3237 "trace-cpu-arguments" => costs[173],
3238 "trace-mem-arguments" => costs[174],
3239 "un_b_data-cpu-arguments" => costs[175],
3240 "un_b_data-mem-arguments" => costs[176],
3241 "un_constr_data-cpu-arguments" => costs[177],
3242 "un_constr_data-mem-arguments" => costs[178],
3243 "un_i_data-cpu-arguments" => costs[179],
3244 "un_i_data-mem-arguments" => costs[180],
3245 "un_list_data-cpu-arguments" => costs[181],
3246 "un_list_data-mem-arguments" => costs[182],
3247 "un_map_data-cpu-arguments" => costs[183],
3248 "un_map_data-mem-arguments" => costs[184],
3249 "verify_ecdsa_secp256k1_signature-cpu-arguments" => costs[185],
3250 "verify_ecdsa_secp256k1_signature-mem-arguments" => costs[186],
3251 "verify_ed25519_signature-cpu-arguments-intercept" => costs[187],
3252 "verify_ed25519_signature-cpu-arguments-slope" => costs[188],
3253 "verify_ed25519_signature-mem-arguments" => costs[189],
3254 "verify_schnorr_secp256k1_signature-cpu-arguments-intercept" => costs[190],
3255 "verify_schnorr_secp256k1_signature-cpu-arguments-slope" => costs[191],
3256 "verify_schnorr_secp256k1_signature-mem-arguments" => costs[192],
3257 "cek_constr_cost-exBudgetCPU" => costs[193],
3258 "cek_constr_cost-exBudgetmem" => costs[194],
3259 "cek_case_cost-exBudgetCPU" => costs[195],
3260 "cek_case_cost-exBudgetmem" => costs[196],
3261 "bls12_381_G1_add-cpu-arguments" => costs[197],
3262 "bls12_381_G1_add-mem-arguments" => costs[198],
3263 "bls12_381_G1_compress-cpu-arguments" => costs[199],
3264 "bls12_381_G1_compress-mem-arguments" => costs[200],
3265 "bls12_381_G1_equal-cpu-arguments" => costs[201],
3266 "bls12_381_G1_equal-mem-arguments" => costs[202],
3267 "bls12_381_G1_hashToGroup-cpu-arguments-intercept" => costs[203],
3268 "bls12_381_G1_hashToGroup-cpu-arguments-slope" => costs[204],
3269 "bls12_381_G1_hashToGroup-mem-arguments" => costs[205],
3270 "bls12_381_G1_neg-cpu-arguments" => costs[206],
3271 "bls12_381_G1_neg-mem-arguments" => costs[207],
3272 "bls12_381_G1_scalarMul-cpu-arguments-intercept" => costs[208],
3273 "bls12_381_G1_scalarMul-cpu-arguments-slope" => costs[209],
3274 "bls12_381_G1_scalarMul-mem-arguments" => costs[210],
3275 "bls12_381_G1_uncompress-cpu-arguments" => costs[211],
3276 "bls12_381_G1_uncompress-mem-arguments" => costs[212],
3277 "bls12_381_G2_add-cpu-arguments" => costs[213],
3278 "bls12_381_G2_add-mem-arguments" => costs[214],
3279 "bls12_381_G2_compress-cpu-arguments" => costs[215],
3280 "bls12_381_G2_compress-mem-arguments" => costs[216],
3281 "bls12_381_G2_equal-cpu-arguments" => costs[217],
3282 "bls12_381_G2_equal-mem-arguments" => costs[218],
3283 "bls12_381_G2_hashToGroup-cpu-arguments-intercept" => costs[219],
3284 "bls12_381_G2_hashToGroup-cpu-arguments-slope" => costs[220],
3285 "bls12_381_G2_hashToGroup-mem-arguments" => costs[221],
3286 "bls12_381_G2_neg-cpu-arguments" => costs[222],
3287 "bls12_381_G2_neg-mem-arguments" => costs[223],
3288 "bls12_381_G2_scalarMul-cpu-arguments-intercept" => costs[224],
3289 "bls12_381_G2_scalarMul-cpu-arguments-slope" => costs[225],
3290 "bls12_381_G2_scalarMul-mem-arguments" => costs[226],
3291 "bls12_381_G2_uncompress-cpu-arguments" => costs[227],
3292 "bls12_381_G2_uncompress-mem-arguments" => costs[228],
3293 "bls12_381_finalVerify-cpu-arguments" => costs[229],
3294 "bls12_381_finalVerify-mem-arguments" => costs[230],
3295 "bls12_381_millerLoop-cpu-arguments" => costs[231],
3296 "bls12_381_millerLoop-mem-arguments" => costs[232],
3297 "bls12_381_mulMlResult-cpu-arguments" => costs[233],
3298 "bls12_381_mulMlResult-mem-arguments" => costs[234],
3299 "keccak_256-cpu-arguments-intercept" => costs[235],
3300 "keccak_256-cpu-arguments-slope" => costs[236],
3301 "keccak_256-mem-arguments" => costs[237],
3302 "blake2b_224-cpu-arguments-intercept" => costs[238],
3303 "blake2b_224-cpu-arguments-slope" => costs[239],
3304 "blake2b_224-mem-arguments-slope" => costs[240],
3305 "integerToByteString-cpu-arguments-c0" => costs[241],
3306 "integerToByteString-cpu-arguments-c1" => costs[242],
3307 "integerToByteString-cpu-arguments-c2" => costs[243],
3308 "integerToByteString-mem-arguments-intercept" => costs[244],
3309 "integerToByteString-mem-arguments-slope" => costs[245],
3310 "byteStringToInteger-cpu-arguments-c0" => costs[246],
3311 "byteStringToInteger-cpu-arguments-c1" => costs[247],
3312 "byteStringToInteger-cpu-arguments-c2" => costs[248],
3313 "byteStringToInteger-mem-arguments-intercept" => costs[249],
3314 "byteStringToInteger-mem-arguments-slope" => costs[250],
3315 };
3316
3317 if costs.len() == 297 {
3318 let test = hashmap! {
3319 "andByteString-cpu-arguments-intercept"=> costs[251],
3320 "andByteString-cpu-arguments-slope1"=> costs[252],
3321 "andByteString-cpu-arguments-slope2"=> costs[253],
3322 "andByteString-memory-arguments-intercept"=> costs[254],
3323 "andByteString-memory-arguments-slope"=> costs[255],
3324 "orByteString-cpu-arguments-intercept"=> costs[256],
3325 "orByteString-cpu-arguments-slope1"=> costs[257],
3326 "orByteString-cpu-arguments-slope2"=> costs[258],
3327 "orByteString-memory-arguments-intercept"=> costs[259],
3328 "orByteString-memory-arguments-slope"=> costs[260],
3329 "xorByteString-cpu-arguments-intercept"=> costs[261],
3330 "xorByteString-cpu-arguments-slope1"=> costs[262],
3331 "xorByteString-cpu-arguments-slope2"=> costs[263],
3332 "xorByteString-memory-arguments-intercept"=> costs[264],
3333 "xorByteString-memory-arguments-slope"=> costs[265],
3334 "complementByteString-cpu-arguments-intercept"=> costs[266],
3335 "complementByteString-cpu-arguments-slope"=> costs[267],
3336 "complementByteString-memory-arguments-intercept"=> costs[268],
3337 "complementByteString-memory-arguments-slope"=> costs[269],
3338 "readBit-cpu-arguments"=> costs[270],
3339 "readBit-memory-arguments"=> costs[271],
3340 "writeBits-cpu-arguments-intercept"=> costs[272],
3341 "writeBits-cpu-arguments-slope"=> costs[273],
3342 "writeBits-memory-arguments-intercept"=> costs[274],
3343 "writeBits-memory-arguments-slope"=> costs[275],
3344 "replicateByte-cpu-arguments-intercept"=> costs[276],
3345 "replicateByte-cpu-arguments-slope"=> costs[277],
3346 "replicateByte-memory-arguments-intercept"=> costs[278],
3347 "replicateByte-memory-arguments-slope"=> costs[279],
3348 "shiftByteString-cpu-arguments-intercept"=> costs[280],
3349 "shiftByteString-cpu-arguments-slope"=> costs[281],
3350 "shiftByteString-memory-arguments-intercept"=> costs[282],
3351 "shiftByteString-memory-arguments-slope"=> costs[283],
3352 "rotateByteString-cpu-arguments-intercept"=> costs[284],
3353 "rotateByteString-cpu-arguments-slope"=> costs[285],
3354 "rotateByteString-memory-arguments-intercept"=> costs[286],
3355 "rotateByteString-memory-arguments-slope"=> costs[287],
3356 "countSetBits-cpu-arguments-intercept"=> costs[288],
3357 "countSetBits-cpu-arguments-slope"=> costs[289],
3358 "countSetBits-memory-arguments"=> costs[290],
3359 "findFirstSetBit-cpu-arguments-intercept"=> costs[291],
3360 "findFirstSetBit-cpu-arguments-slope"=> costs[292],
3361 "findFirstSetBit-memory-arguments"=> costs[293],
3362 "ripemd_160-cpu-arguments-intercept"=> costs[294],
3363 "ripemd_160-cpu-arguments-slope"=> costs[295],
3364 "ripemd_160-memory-arguments"=> costs[296],
3365 };
3366
3367 Extend::extend::<HashMap<&str, i64>>(&mut main, test);
3368 }
3369
3370 main
3371 }
3372 };
3373
3374 CostModel {
3375 machine_costs: MachineCosts {
3376 startup: ExBudget {
3377 mem: *cost_map
3378 .get("cek_startup_cost-exBudgetmem")
3379 .unwrap_or(&30000000000),
3380 cpu: *cost_map
3381 .get("cek_startup_cost-exBudgetCPU")
3382 .unwrap_or(&30000000000),
3383 },
3384 var: ExBudget {
3385 mem: *cost_map
3386 .get("cek_var_cost-exBudgetmem")
3387 .unwrap_or(&30000000000),
3388 cpu: *cost_map
3389 .get("cek_var_cost-exBudgetCPU")
3390 .unwrap_or(&30000000000),
3391 },
3392 constant: ExBudget {
3393 mem: *cost_map
3394 .get("cek_const_cost-exBudgetmem")
3395 .unwrap_or(&30000000000),
3396 cpu: *cost_map
3397 .get("cek_const_cost-exBudgetCPU")
3398 .unwrap_or(&30000000000),
3399 },
3400 lambda: ExBudget {
3401 mem: *cost_map
3402 .get("cek_lam_cost-exBudgetmem")
3403 .unwrap_or(&30000000000),
3404 cpu: *cost_map
3405 .get("cek_lam_cost-exBudgetCPU")
3406 .unwrap_or(&30000000000),
3407 },
3408 delay: ExBudget {
3409 mem: *cost_map
3410 .get("cek_delay_cost-exBudgetmem")
3411 .unwrap_or(&30000000000),
3412 cpu: *cost_map
3413 .get("cek_delay_cost-exBudgetCPU")
3414 .unwrap_or(&30000000000),
3415 },
3416 force: ExBudget {
3417 mem: *cost_map
3418 .get("cek_force_cost-exBudgetmem")
3419 .unwrap_or(&30000000000),
3420 cpu: *cost_map
3421 .get("cek_force_cost-exBudgetCPU")
3422 .unwrap_or(&30000000000),
3423 },
3424 apply: ExBudget {
3425 mem: *cost_map
3426 .get("cek_apply_cost-exBudgetmem")
3427 .unwrap_or(&30000000000),
3428 cpu: *cost_map
3429 .get("cek_apply_cost-exBudgetCPU")
3430 .unwrap_or(&30000000000),
3431 },
3432 builtin: ExBudget {
3433 mem: *cost_map
3434 .get("cek_builtin_cost-exBudgetmem")
3435 .unwrap_or(&30000000000),
3436 cpu: *cost_map
3437 .get("cek_builtin_cost-exBudgetCPU")
3438 .unwrap_or(&30000000000),
3439 },
3440 constr: ExBudget {
3441 mem: *cost_map
3442 .get("cek_constr_cost-exBudgetmem")
3443 .unwrap_or(&30000000000),
3444 cpu: *cost_map
3445 .get("cek_constr_cost-exBudgetCPU")
3446 .unwrap_or(&30000000000),
3447 },
3448 case: ExBudget {
3449 mem: *cost_map
3450 .get("cek_case_cost-exBudgetmem")
3451 .unwrap_or(&30000000000),
3452 cpu: *cost_map
3453 .get("cek_case_cost-exBudgetCPU")
3454 .unwrap_or(&30000000000),
3455 },
3456 },
3457 builtin_costs: BuiltinCosts {
3458 add_integer: CostingFun {
3459 mem: TwoArguments::MaxSize(MaxSize {
3460 intercept: *cost_map
3461 .get("add_integer-mem-arguments-intercept")
3462 .unwrap_or(&30000000000),
3463 slope: *cost_map
3464 .get("add_integer-mem-arguments-slope")
3465 .unwrap_or(&30000000000),
3466 }),
3467 cpu: TwoArguments::MaxSize(MaxSize {
3468 intercept: *cost_map
3469 .get("add_integer-cpu-arguments-intercept")
3470 .unwrap_or(&30000000000),
3471 slope: *cost_map
3472 .get("add_integer-cpu-arguments-slope")
3473 .unwrap_or(&30000000000),
3474 }),
3475 },
3476 subtract_integer: CostingFun {
3477 mem: TwoArguments::MaxSize(MaxSize {
3478 intercept: *cost_map
3479 .get("subtract_integer-mem-arguments-intercept")
3480 .unwrap_or(&30000000000),
3481 slope: *cost_map
3482 .get("subtract_integer-mem-arguments-slope")
3483 .unwrap_or(&30000000000),
3484 }),
3485 cpu: TwoArguments::MaxSize(MaxSize {
3486 intercept: *cost_map
3487 .get("subtract_integer-cpu-arguments-intercept")
3488 .unwrap_or(&30000000000),
3489 slope: *cost_map
3490 .get("subtract_integer-cpu-arguments-slope")
3491 .unwrap_or(&30000000000),
3492 }),
3493 },
3494 multiply_integer: CostingFun {
3495 mem: TwoArguments::AddedSizes(AddedSizes {
3496 intercept: *cost_map
3497 .get("multiply_integer-mem-arguments-intercept")
3498 .unwrap_or(&30000000000),
3499 slope: *cost_map
3500 .get("multiply_integer-mem-arguments-slope")
3501 .unwrap_or(&30000000000),
3502 }),
3503 cpu: TwoArguments::MultipliedSizes(MultipliedSizes {
3504 intercept: *cost_map
3505 .get("multiply_integer-cpu-arguments-intercept")
3506 .unwrap_or(&30000000000),
3507 slope: *cost_map
3508 .get("multiply_integer-cpu-arguments-slope")
3509 .unwrap_or(&30000000000),
3510 }),
3511 },
3512 divide_integer: CostingFun {
3513 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
3514 intercept: *cost_map
3515 .get("divide_integer-mem-arguments-intercept")
3516 .unwrap_or(&30000000000),
3517 slope: *cost_map
3518 .get("divide_integer-mem-arguments-slope")
3519 .unwrap_or(&30000000000),
3520 minimum: *cost_map
3521 .get("divide_integer-mem-arguments-minimum")
3522 .unwrap_or(&30000000000),
3523 }),
3524 cpu: match version {
3525 Language::PlutusV1 | Language::PlutusV2 => {
3526 TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
3527 constant: *cost_map
3528 .get("divide_integer-cpu-arguments-constant")
3529 .unwrap_or(&30000000000),
3530 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
3531 intercept: *cost_map
3532 .get("divide_integer-cpu-arguments-model-arguments-intercept")
3533 .unwrap_or(&30000000000),
3534 slope: *cost_map
3535 .get("divide_integer-cpu-arguments-model-arguments-slope")
3536 .unwrap_or(&30000000000),
3537 })),
3538 })
3539 }
3540 Language::PlutusV3 => TwoArguments::ConstAboveDiagonalIntoQuadraticXAndY(
3541 *cost_map
3542 .get("divide_integer-cpu-arguments-constant")
3543 .unwrap_or(&30000000000),
3544 TwoArgumentsQuadraticFunction {
3545 minimum: *cost_map
3546 .get("divide_integer-cpu-arguments-minimum")
3547 .unwrap_or(&30000000000),
3548 coeff_00: *cost_map
3549 .get("divide_integer-cpu-arguments-c00")
3550 .unwrap_or(&30000000000),
3551 coeff_10: *cost_map
3552 .get("divide_integer-cpu-arguments-c10")
3553 .unwrap_or(&30000000000),
3554 coeff_01: *cost_map
3555 .get("divide_integer-cpu-arguments-c01")
3556 .unwrap_or(&30000000000),
3557 coeff_20: *cost_map
3558 .get("divide_integer-cpu-arguments-c20")
3559 .unwrap_or(&30000000000),
3560 coeff_11: *cost_map
3561 .get("divide_integer-cpu-arguments-c11")
3562 .unwrap_or(&30000000000),
3563 coeff_02: *cost_map
3564 .get("divide_integer-cpu-arguments-c02")
3565 .unwrap_or(&30000000000),
3566 },
3567 ),
3568 },
3569 },
3570 quotient_integer: CostingFun {
3571 mem: TwoArguments::SubtractedSizes(SubtractedSizes {
3572 intercept: *cost_map
3573 .get("quotient_integer-mem-arguments-intercept")
3574 .unwrap_or(&30000000000),
3575 slope: *cost_map
3576 .get("quotient_integer-mem-arguments-slope")
3577 .unwrap_or(&30000000000),
3578 minimum: *cost_map
3579 .get("quotient_integer-mem-arguments-minimum")
3580 .unwrap_or(&30000000000),
3581 }),
3582 cpu: match version {
3583 Language::PlutusV1 | Language::PlutusV2 => {
3584 TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
3585 constant: *cost_map
3586 .get("quotient_integer-cpu-arguments-constant")
3587 .unwrap_or(&30000000000),
3588 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
3589 intercept: *cost_map
3590 .get("quotient_integer-cpu-arguments-model-arguments-intercept")
3591 .unwrap_or(&30000000000),
3592 slope: *cost_map
3593 .get("quotient_integer-cpu-arguments-model-arguments-slope")
3594 .unwrap_or(&30000000000),
3595 })),
3596 })
3597 }
3598 Language::PlutusV3 => TwoArguments::ConstAboveDiagonalIntoQuadraticXAndY(
3599 *cost_map
3600 .get("quotient_integer-cpu-arguments-constant")
3601 .unwrap_or(&30000000000),
3602 TwoArgumentsQuadraticFunction {
3603 minimum: *cost_map
3604 .get("quotient_integer-cpu-arguments-minimum")
3605 .unwrap_or(&30000000000),
3606 coeff_00: *cost_map
3607 .get("quotient_integer-cpu-arguments-c00")
3608 .unwrap_or(&30000000000),
3609 coeff_10: *cost_map
3610 .get("quotient_integer-cpu-arguments-c10")
3611 .unwrap_or(&30000000000),
3612 coeff_01: *cost_map
3613 .get("quotient_integer-cpu-arguments-c01")
3614 .unwrap_or(&30000000000),
3615 coeff_20: *cost_map
3616 .get("quotient_integer-cpu-arguments-c20")
3617 .unwrap_or(&30000000000),
3618 coeff_11: *cost_map
3619 .get("quotient_integer-cpu-arguments-c11")
3620 .unwrap_or(&30000000000),
3621 coeff_02: *cost_map
3622 .get("quotient_integer-cpu-arguments-c02")
3623 .unwrap_or(&30000000000),
3624 },
3625 ),
3626 },
3627 },
3628 remainder_integer: CostingFun {
3629 mem: match version {
3630 Language::PlutusV1 | Language::PlutusV2 => {
3631 TwoArguments::SubtractedSizes(SubtractedSizes {
3632 intercept: *cost_map
3633 .get("remainder_integer-mem-arguments-intercept")
3634 .unwrap_or(&30000000000),
3635 slope: *cost_map
3636 .get("remainder_integer-mem-arguments-slope")
3637 .unwrap_or(&30000000000),
3638 minimum: *cost_map
3639 .get("remainder_integer-mem-arguments-minimum")
3640 .unwrap_or(&30000000000),
3641 })
3642 }
3643 Language::PlutusV3 => TwoArguments::LinearInY(LinearSize {
3644 intercept: *cost_map
3645 .get("remainder_integer-mem-arguments-intercept")
3646 .unwrap_or(&30000000000),
3647 slope: *cost_map
3648 .get("remainder_integer-mem-arguments-slope")
3649 .unwrap_or(&30000000000),
3650 }),
3651 },
3652 cpu: match version {
3653 Language::PlutusV1 | Language::PlutusV2 => {
3654 TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
3655 constant: *cost_map
3656 .get("remainder_integer-cpu-arguments-constant")
3657 .unwrap_or(&30000000000),
3658 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
3659 intercept: *cost_map
3660 .get(
3661 "remainder_integer-cpu-arguments-model-arguments-intercept",
3662 )
3663 .unwrap_or(&30000000000),
3664 slope: *cost_map
3665 .get("remainder_integer-cpu-arguments-model-arguments-slope")
3666 .unwrap_or(&30000000000),
3667 })),
3668 })
3669 }
3670 Language::PlutusV3 => TwoArguments::ConstAboveDiagonalIntoQuadraticXAndY(
3671 *cost_map
3672 .get("remainder_integer-cpu-arguments-constant")
3673 .unwrap_or(&30000000000),
3674 TwoArgumentsQuadraticFunction {
3675 minimum: *cost_map
3676 .get("remainder_integer-cpu-arguments-minimum")
3677 .unwrap_or(&30000000000),
3678 coeff_00: *cost_map
3679 .get("remainder_integer-cpu-arguments-c00")
3680 .unwrap_or(&30000000000),
3681 coeff_10: *cost_map
3682 .get("remainder_integer-cpu-arguments-c10")
3683 .unwrap_or(&30000000000),
3684 coeff_01: *cost_map
3685 .get("remainder_integer-cpu-arguments-c01")
3686 .unwrap_or(&30000000000),
3687 coeff_20: *cost_map
3688 .get("remainder_integer-cpu-arguments-c20")
3689 .unwrap_or(&30000000000),
3690 coeff_11: *cost_map
3691 .get("remainder_integer-cpu-arguments-c11")
3692 .unwrap_or(&30000000000),
3693 coeff_02: *cost_map
3694 .get("remainder_integer-cpu-arguments-c02")
3695 .unwrap_or(&30000000000),
3696 },
3697 ),
3698 },
3699 },
3700 mod_integer: CostingFun {
3701 mem: match version {
3702 Language::PlutusV1 | Language::PlutusV2 => {
3703 TwoArguments::SubtractedSizes(SubtractedSizes {
3704 intercept: *cost_map
3705 .get("mod_integer-mem-arguments-intercept")
3706 .unwrap_or(&30000000000),
3707 slope: *cost_map
3708 .get("mod_integer-mem-arguments-slope")
3709 .unwrap_or(&30000000000),
3710 minimum: *cost_map
3711 .get("mod_integer-mem-arguments-minimum")
3712 .unwrap_or(&30000000000),
3713 })
3714 }
3715 Language::PlutusV3 => TwoArguments::LinearInY(LinearSize {
3716 intercept: *cost_map
3717 .get("mod_integer-mem-arguments-intercept")
3718 .unwrap_or(&30000000000),
3719 slope: *cost_map
3720 .get("mod_integer-mem-arguments-slope")
3721 .unwrap_or(&30000000000),
3722 }),
3723 },
3724 cpu: match version {
3725 Language::PlutusV1 | Language::PlutusV2 => {
3726 TwoArguments::ConstAboveDiagonal(ConstantOrTwoArguments {
3727 constant: *cost_map
3728 .get("mod_integer-cpu-arguments-constant")
3729 .unwrap_or(&30000000000),
3730 model: Box::new(TwoArguments::MultipliedSizes(MultipliedSizes {
3731 intercept: *cost_map
3732 .get("mod_integer-cpu-arguments-model-arguments-intercept")
3733 .unwrap_or(&30000000000),
3734 slope: *cost_map
3735 .get("mod_integer-cpu-arguments-model-arguments-slope")
3736 .unwrap_or(&30000000000),
3737 })),
3738 })
3739 }
3740 Language::PlutusV3 => TwoArguments::ConstAboveDiagonalIntoQuadraticXAndY(
3741 *cost_map
3742 .get("mod_integer-cpu-arguments-constant")
3743 .unwrap_or(&30000000000),
3744 TwoArgumentsQuadraticFunction {
3745 minimum: *cost_map
3746 .get("mod_integer-cpu-arguments-minimum")
3747 .unwrap_or(&30000000000),
3748 coeff_00: *cost_map
3749 .get("mod_integer-cpu-arguments-c00")
3750 .unwrap_or(&30000000000),
3751 coeff_10: *cost_map
3752 .get("mod_integer-cpu-arguments-c10")
3753 .unwrap_or(&30000000000),
3754 coeff_01: *cost_map
3755 .get("mod_integer-cpu-arguments-c01")
3756 .unwrap_or(&30000000000),
3757 coeff_20: *cost_map
3758 .get("mod_integer-cpu-arguments-c20")
3759 .unwrap_or(&30000000000),
3760 coeff_11: *cost_map
3761 .get("mod_integer-cpu-arguments-c11")
3762 .unwrap_or(&30000000000),
3763 coeff_02: *cost_map
3764 .get("mod_integer-cpu-arguments-c02")
3765 .unwrap_or(&30000000000),
3766 },
3767 ),
3768 },
3769 },
3770 equals_integer: CostingFun {
3771 mem: TwoArguments::ConstantCost(
3772 *cost_map
3773 .get("equals_integer-mem-arguments")
3774 .unwrap_or(&30000000000),
3775 ),
3776 cpu: TwoArguments::MinSize(MinSize {
3777 intercept: *cost_map
3778 .get("equals_integer-cpu-arguments-intercept")
3779 .unwrap_or(&30000000000),
3780 slope: *cost_map
3781 .get("equals_integer-cpu-arguments-slope")
3782 .unwrap_or(&30000000000),
3783 }),
3784 },
3785 less_than_integer: CostingFun {
3786 mem: TwoArguments::ConstantCost(
3787 *cost_map
3788 .get("less_than_integer-mem-arguments")
3789 .unwrap_or(&30000000000),
3790 ),
3791 cpu: TwoArguments::MinSize(MinSize {
3792 intercept: *cost_map
3793 .get("less_than_integer-cpu-arguments-intercept")
3794 .unwrap_or(&30000000000),
3795 slope: *cost_map
3796 .get("less_than_integer-cpu-arguments-slope")
3797 .unwrap_or(&30000000000),
3798 }),
3799 },
3800 less_than_equals_integer: CostingFun {
3801 mem: TwoArguments::ConstantCost(
3802 *cost_map
3803 .get("less_than_equals_integer-mem-arguments")
3804 .unwrap_or(&30000000000),
3805 ),
3806 cpu: TwoArguments::MinSize(MinSize {
3807 intercept: *cost_map
3808 .get("less_than_equals_integer-cpu-arguments-intercept")
3809 .unwrap_or(&30000000000),
3810 slope: *cost_map
3811 .get("less_than_equals_integer-cpu-arguments-slope")
3812 .unwrap_or(&30000000000),
3813 }),
3814 },
3815 append_byte_string: CostingFun {
3816 mem: TwoArguments::AddedSizes(AddedSizes {
3817 intercept: *cost_map
3818 .get("append_byte_string-mem-arguments-intercept")
3819 .unwrap_or(&30000000000),
3820 slope: *cost_map
3821 .get("append_byte_string-mem-arguments-slope")
3822 .unwrap_or(&30000000000),
3823 }),
3824 cpu: TwoArguments::AddedSizes(AddedSizes {
3825 intercept: *cost_map
3826 .get("append_byte_string-cpu-arguments-intercept")
3827 .unwrap_or(&30000000000),
3828 slope: *cost_map
3829 .get("append_byte_string-cpu-arguments-slope")
3830 .unwrap_or(&30000000000),
3831 }),
3832 },
3833 cons_byte_string: CostingFun {
3834 mem: TwoArguments::AddedSizes(AddedSizes {
3835 intercept: *cost_map
3836 .get("cons_byte_string-mem-arguments-intercept")
3837 .unwrap_or(&30000000000),
3838 slope: *cost_map
3839 .get("cons_byte_string-mem-arguments-slope")
3840 .unwrap_or(&30000000000),
3841 }),
3842 cpu: TwoArguments::LinearInY(LinearSize {
3843 intercept: *cost_map
3844 .get("cons_byte_string-cpu-arguments-intercept")
3845 .unwrap_or(&30000000000),
3846 slope: *cost_map
3847 .get("cons_byte_string-cpu-arguments-slope")
3848 .unwrap_or(&30000000000),
3849 }),
3850 },
3851 slice_byte_string: CostingFun {
3852 mem: ThreeArguments::LinearInZ(LinearSize {
3853 intercept: *cost_map
3854 .get("slice_byte_string-mem-arguments-intercept")
3855 .unwrap_or(&30000000000),
3856 slope: *cost_map
3857 .get("slice_byte_string-mem-arguments-slope")
3858 .unwrap_or(&30000000000),
3859 }),
3860 cpu: ThreeArguments::LinearInZ(LinearSize {
3861 intercept: *cost_map
3862 .get("slice_byte_string-cpu-arguments-intercept")
3863 .unwrap_or(&30000000000),
3864 slope: *cost_map
3865 .get("slice_byte_string-cpu-arguments-slope")
3866 .unwrap_or(&30000000000),
3867 }),
3868 },
3869 length_of_byte_string: CostingFun {
3870 mem: OneArgument::ConstantCost(
3871 *cost_map
3872 .get("length_of_byte_string-mem-arguments")
3873 .unwrap_or(&30000000000),
3874 ),
3875 cpu: OneArgument::ConstantCost(
3876 *cost_map
3877 .get("length_of_byte_string-cpu-arguments")
3878 .unwrap_or(&30000000000),
3879 ),
3880 },
3881 index_byte_string: CostingFun {
3882 mem: TwoArguments::ConstantCost(
3883 *cost_map
3884 .get("index_byte_string-mem-arguments")
3885 .unwrap_or(&30000000000),
3886 ),
3887 cpu: TwoArguments::ConstantCost(
3888 *cost_map
3889 .get("index_byte_string-cpu-arguments")
3890 .unwrap_or(&30000000000),
3891 ),
3892 },
3893 equals_byte_string: CostingFun {
3894 mem: TwoArguments::ConstantCost(
3895 *cost_map
3896 .get("equals_byte_string-mem-arguments")
3897 .unwrap_or(&30000000000),
3898 ),
3899 cpu: TwoArguments::LinearOnDiagonal(ConstantOrLinear {
3900 constant: *cost_map
3901 .get("equals_byte_string-cpu-arguments-constant")
3902 .unwrap_or(&30000000000),
3903 intercept: *cost_map
3904 .get("equals_byte_string-cpu-arguments-intercept")
3905 .unwrap_or(&30000000000),
3906 slope: *cost_map
3907 .get("equals_byte_string-cpu-arguments-slope")
3908 .unwrap_or(&30000000000),
3909 }),
3910 },
3911 less_than_byte_string: CostingFun {
3912 mem: TwoArguments::ConstantCost(
3913 *cost_map
3914 .get("less_than_byte_string-mem-arguments")
3915 .unwrap_or(&30000000000),
3916 ),
3917 cpu: TwoArguments::MinSize(MinSize {
3918 intercept: *cost_map
3919 .get("less_than_byte_string-cpu-arguments-intercept")
3920 .unwrap_or(&30000000000),
3921 slope: *cost_map
3922 .get("less_than_byte_string-cpu-arguments-slope")
3923 .unwrap_or(&30000000000),
3924 }),
3925 },
3926 less_than_equals_byte_string: CostingFun {
3927 mem: TwoArguments::ConstantCost(
3928 *cost_map
3929 .get("less_than_equals_byte_string-mem-arguments")
3930 .unwrap_or(&30000000000),
3931 ),
3932 cpu: TwoArguments::MinSize(MinSize {
3933 intercept: *cost_map
3934 .get("less_than_equals_byte_string-cpu-arguments-intercept")
3935 .unwrap_or(&30000000000),
3936 slope: *cost_map
3937 .get("less_than_equals_byte_string-cpu-arguments-slope")
3938 .unwrap_or(&30000000000),
3939 }),
3940 },
3941 sha2_256: CostingFun {
3942 mem: OneArgument::ConstantCost(
3943 *cost_map
3944 .get("sha2_256-mem-arguments")
3945 .unwrap_or(&30000000000),
3946 ),
3947 cpu: OneArgument::LinearCost(LinearSize {
3948 intercept: *cost_map
3949 .get("sha2_256-cpu-arguments-intercept")
3950 .unwrap_or(&30000000000),
3951 slope: *cost_map
3952 .get("sha2_256-cpu-arguments-slope")
3953 .unwrap_or(&30000000000),
3954 }),
3955 },
3956 sha3_256: CostingFun {
3957 mem: OneArgument::ConstantCost(
3958 *cost_map
3959 .get("sha3_256-mem-arguments")
3960 .unwrap_or(&30000000000),
3961 ),
3962 cpu: OneArgument::LinearCost(LinearSize {
3963 intercept: *cost_map
3964 .get("sha3_256-cpu-arguments-intercept")
3965 .unwrap_or(&30000000000),
3966 slope: *cost_map
3967 .get("sha3_256-cpu-arguments-slope")
3968 .unwrap_or(&30000000000),
3969 }),
3970 },
3971 blake2b_256: CostingFun {
3972 mem: OneArgument::ConstantCost(
3973 *cost_map
3974 .get("blake2b_256-mem-arguments")
3975 .unwrap_or(&30000000000),
3976 ),
3977 cpu: OneArgument::LinearCost(LinearSize {
3978 intercept: *cost_map
3979 .get("blake2b_256-cpu-arguments-intercept")
3980 .unwrap_or(&30000000000),
3981 slope: *cost_map
3982 .get("blake2b_256-cpu-arguments-slope")
3983 .unwrap_or(&30000000000),
3984 }),
3985 },
3986 verify_ed25519_signature: CostingFun {
3987 mem: ThreeArguments::ConstantCost(
3988 *cost_map
3989 .get("verify_ed25519_signature-mem-arguments")
3990 .unwrap_or(&30000000000),
3991 ),
3992 cpu: {
3993 let sizes = LinearSize {
3994 intercept: *cost_map
3995 .get("verify_ed25519_signature-cpu-arguments-intercept")
3996 .unwrap_or(&30000000000),
3997 slope: *cost_map
3998 .get("verify_ed25519_signature-cpu-arguments-slope")
3999 .unwrap_or(&30000000000),
4000 };
4001
4002 ThreeArguments::LinearInY(sizes)
4003 },
4004 },
4005 verify_ecdsa_secp256k1_signature: CostingFun {
4006 mem: ThreeArguments::ConstantCost(
4007 *cost_map
4008 .get("verify_ecdsa_secp256k1_signature-mem-arguments")
4009 .unwrap_or(&30000000000),
4010 ),
4011 cpu: ThreeArguments::ConstantCost(
4012 *cost_map
4013 .get("verify_ecdsa_secp256k1_signature-cpu-arguments")
4014 .unwrap_or(&30000000000),
4015 ),
4016 },
4017 verify_schnorr_secp256k1_signature: CostingFun {
4018 mem: ThreeArguments::ConstantCost(
4019 *cost_map
4020 .get("verify_schnorr_secp256k1_signature-mem-arguments")
4021 .unwrap_or(&30000000000),
4022 ),
4023 cpu: ThreeArguments::LinearInY(LinearSize {
4024 intercept: *cost_map
4025 .get("verify_schnorr_secp256k1_signature-cpu-arguments-intercept")
4026 .unwrap_or(&30000000000),
4027 slope: *cost_map
4028 .get("verify_schnorr_secp256k1_signature-cpu-arguments-slope")
4029 .unwrap_or(&30000000000),
4030 }),
4031 },
4032 append_string: CostingFun {
4033 mem: TwoArguments::AddedSizes(AddedSizes {
4034 intercept: *cost_map
4035 .get("append_string-mem-arguments-intercept")
4036 .unwrap_or(&30000000000),
4037 slope: *cost_map
4038 .get("append_string-mem-arguments-slope")
4039 .unwrap_or(&30000000000),
4040 }),
4041 cpu: TwoArguments::AddedSizes(AddedSizes {
4042 intercept: *cost_map
4043 .get("append_string-cpu-arguments-intercept")
4044 .unwrap_or(&30000000000),
4045 slope: *cost_map
4046 .get("append_string-cpu-arguments-slope")
4047 .unwrap_or(&30000000000),
4048 }),
4049 },
4050 equals_string: CostingFun {
4051 mem: TwoArguments::ConstantCost(
4052 *cost_map
4053 .get("equals_string-mem-arguments")
4054 .unwrap_or(&30000000000),
4055 ),
4056 cpu: TwoArguments::LinearOnDiagonal(ConstantOrLinear {
4057 constant: *cost_map
4058 .get("equals_string-cpu-arguments-constant")
4059 .unwrap_or(&30000000000),
4060 intercept: *cost_map
4061 .get("equals_string-cpu-arguments-intercept")
4062 .unwrap_or(&30000000000),
4063 slope: *cost_map
4064 .get("equals_string-cpu-arguments-slope")
4065 .unwrap_or(&30000000000),
4066 }),
4067 },
4068 encode_utf8: CostingFun {
4069 mem: OneArgument::LinearCost(LinearSize {
4070 intercept: *cost_map
4071 .get("encode_utf8-mem-arguments-intercept")
4072 .unwrap_or(&30000000000),
4073 slope: *cost_map
4074 .get("encode_utf8-mem-arguments-slope")
4075 .unwrap_or(&30000000000),
4076 }),
4077 cpu: OneArgument::LinearCost(LinearSize {
4078 intercept: *cost_map
4079 .get("encode_utf8-cpu-arguments-intercept")
4080 .unwrap_or(&30000000000),
4081 slope: *cost_map
4082 .get("encode_utf8-cpu-arguments-slope")
4083 .unwrap_or(&30000000000),
4084 }),
4085 },
4086 decode_utf8: CostingFun {
4087 mem: OneArgument::LinearCost(LinearSize {
4088 intercept: *cost_map
4089 .get("decode_utf8-mem-arguments-intercept")
4090 .unwrap_or(&30000000000),
4091 slope: *cost_map
4092 .get("decode_utf8-mem-arguments-slope")
4093 .unwrap_or(&30000000000),
4094 }),
4095 cpu: OneArgument::LinearCost(LinearSize {
4096 intercept: *cost_map
4097 .get("decode_utf8-cpu-arguments-intercept")
4098 .unwrap_or(&30000000000),
4099 slope: *cost_map
4100 .get("decode_utf8-cpu-arguments-slope")
4101 .unwrap_or(&30000000000),
4102 }),
4103 },
4104 if_then_else: CostingFun {
4105 mem: ThreeArguments::ConstantCost(
4106 *cost_map
4107 .get("if_then_else-mem-arguments")
4108 .unwrap_or(&30000000000),
4109 ),
4110 cpu: ThreeArguments::ConstantCost(
4111 *cost_map
4112 .get("if_then_else-cpu-arguments")
4113 .unwrap_or(&30000000000),
4114 ),
4115 },
4116 choose_unit: CostingFun {
4117 mem: TwoArguments::ConstantCost(
4118 *cost_map
4119 .get("choose_unit-mem-arguments")
4120 .unwrap_or(&30000000000),
4121 ),
4122 cpu: TwoArguments::ConstantCost(
4123 *cost_map
4124 .get("choose_unit-cpu-arguments")
4125 .unwrap_or(&30000000000),
4126 ),
4127 },
4128 trace: CostingFun {
4129 mem: TwoArguments::ConstantCost(
4130 *cost_map.get("trace-mem-arguments").unwrap_or(&30000000000),
4131 ),
4132 cpu: TwoArguments::ConstantCost(
4133 *cost_map.get("trace-cpu-arguments").unwrap_or(&30000000000),
4134 ),
4135 },
4136 fst_pair: CostingFun {
4137 mem: OneArgument::ConstantCost(
4138 *cost_map
4139 .get("fst_pair-mem-arguments")
4140 .unwrap_or(&30000000000),
4141 ),
4142 cpu: OneArgument::ConstantCost(
4143 *cost_map
4144 .get("fst_pair-cpu-arguments")
4145 .unwrap_or(&30000000000),
4146 ),
4147 },
4148 snd_pair: CostingFun {
4149 mem: OneArgument::ConstantCost(
4150 *cost_map
4151 .get("snd_pair-mem-arguments")
4152 .unwrap_or(&30000000000),
4153 ),
4154 cpu: OneArgument::ConstantCost(
4155 *cost_map
4156 .get("snd_pair-cpu-arguments")
4157 .unwrap_or(&30000000000),
4158 ),
4159 },
4160 choose_list: CostingFun {
4161 mem: ThreeArguments::ConstantCost(
4162 *cost_map
4163 .get("choose_list-mem-arguments")
4164 .unwrap_or(&30000000000),
4165 ),
4166 cpu: ThreeArguments::ConstantCost(
4167 *cost_map
4168 .get("choose_list-cpu-arguments")
4169 .unwrap_or(&30000000000),
4170 ),
4171 },
4172 mk_cons: CostingFun {
4173 mem: TwoArguments::ConstantCost(
4174 *cost_map
4175 .get("mk_cons-mem-arguments")
4176 .unwrap_or(&30000000000),
4177 ),
4178 cpu: TwoArguments::ConstantCost(
4179 *cost_map
4180 .get("mk_cons-cpu-arguments")
4181 .unwrap_or(&30000000000),
4182 ),
4183 },
4184 head_list: CostingFun {
4185 mem: OneArgument::ConstantCost(
4186 *cost_map
4187 .get("head_list-mem-arguments")
4188 .unwrap_or(&30000000000),
4189 ),
4190 cpu: OneArgument::ConstantCost(
4191 *cost_map
4192 .get("head_list-cpu-arguments")
4193 .unwrap_or(&30000000000),
4194 ),
4195 },
4196 tail_list: CostingFun {
4197 mem: OneArgument::ConstantCost(
4198 *cost_map
4199 .get("tail_list-mem-arguments")
4200 .unwrap_or(&30000000000),
4201 ),
4202 cpu: OneArgument::ConstantCost(
4203 *cost_map
4204 .get("tail_list-cpu-arguments")
4205 .unwrap_or(&30000000000),
4206 ),
4207 },
4208 null_list: CostingFun {
4209 mem: OneArgument::ConstantCost(
4210 *cost_map
4211 .get("null_list-mem-arguments")
4212 .unwrap_or(&30000000000),
4213 ),
4214 cpu: OneArgument::ConstantCost(
4215 *cost_map
4216 .get("null_list-cpu-arguments")
4217 .unwrap_or(&30000000000),
4218 ),
4219 },
4220 choose_data: CostingFun {
4221 mem: SixArguments::ConstantCost(
4222 *cost_map
4223 .get("choose_data-mem-arguments")
4224 .unwrap_or(&30000000000),
4225 ),
4226 cpu: SixArguments::ConstantCost(
4227 *cost_map
4228 .get("choose_data-cpu-arguments")
4229 .unwrap_or(&30000000000),
4230 ),
4231 },
4232 constr_data: CostingFun {
4233 mem: TwoArguments::ConstantCost(
4234 *cost_map
4235 .get("constr_data-mem-arguments")
4236 .unwrap_or(&30000000000),
4237 ),
4238 cpu: TwoArguments::ConstantCost(
4239 *cost_map
4240 .get("constr_data-cpu-arguments")
4241 .unwrap_or(&30000000000),
4242 ),
4243 },
4244 map_data: CostingFun {
4245 mem: OneArgument::ConstantCost(
4246 *cost_map
4247 .get("map_data-mem-arguments")
4248 .unwrap_or(&30000000000),
4249 ),
4250 cpu: OneArgument::ConstantCost(
4251 *cost_map
4252 .get("map_data-cpu-arguments")
4253 .unwrap_or(&30000000000),
4254 ),
4255 },
4256 list_data: CostingFun {
4257 mem: OneArgument::ConstantCost(
4258 *cost_map
4259 .get("list_data-mem-arguments")
4260 .unwrap_or(&30000000000),
4261 ),
4262 cpu: OneArgument::ConstantCost(
4263 *cost_map
4264 .get("list_data-cpu-arguments")
4265 .unwrap_or(&30000000000),
4266 ),
4267 },
4268 i_data: CostingFun {
4269 mem: OneArgument::ConstantCost(
4270 *cost_map.get("i_data-mem-arguments").unwrap_or(&30000000000),
4271 ),
4272 cpu: OneArgument::ConstantCost(
4273 *cost_map.get("i_data-cpu-arguments").unwrap_or(&30000000000),
4274 ),
4275 },
4276 b_data: CostingFun {
4277 mem: OneArgument::ConstantCost(
4278 *cost_map.get("b_data-mem-arguments").unwrap_or(&30000000000),
4279 ),
4280 cpu: OneArgument::ConstantCost(
4281 *cost_map.get("b_data-cpu-arguments").unwrap_or(&30000000000),
4282 ),
4283 },
4284 un_constr_data: CostingFun {
4285 mem: OneArgument::ConstantCost(
4286 *cost_map
4287 .get("un_constr_data-mem-arguments")
4288 .unwrap_or(&30000000000),
4289 ),
4290 cpu: OneArgument::ConstantCost(
4291 *cost_map
4292 .get("un_constr_data-cpu-arguments")
4293 .unwrap_or(&30000000000),
4294 ),
4295 },
4296 un_map_data: CostingFun {
4297 mem: OneArgument::ConstantCost(
4298 *cost_map
4299 .get("un_map_data-mem-arguments")
4300 .unwrap_or(&30000000000),
4301 ),
4302 cpu: OneArgument::ConstantCost(
4303 *cost_map
4304 .get("un_map_data-cpu-arguments")
4305 .unwrap_or(&30000000000),
4306 ),
4307 },
4308 un_list_data: CostingFun {
4309 mem: OneArgument::ConstantCost(
4310 *cost_map
4311 .get("un_list_data-mem-arguments")
4312 .unwrap_or(&30000000000),
4313 ),
4314 cpu: OneArgument::ConstantCost(
4315 *cost_map
4316 .get("un_list_data-cpu-arguments")
4317 .unwrap_or(&30000000000),
4318 ),
4319 },
4320 un_i_data: CostingFun {
4321 mem: OneArgument::ConstantCost(
4322 *cost_map
4323 .get("un_i_data-mem-arguments")
4324 .unwrap_or(&30000000000),
4325 ),
4326 cpu: OneArgument::ConstantCost(
4327 *cost_map
4328 .get("un_i_data-cpu-arguments")
4329 .unwrap_or(&30000000000),
4330 ),
4331 },
4332 un_b_data: CostingFun {
4333 mem: OneArgument::ConstantCost(
4334 *cost_map
4335 .get("un_b_data-mem-arguments")
4336 .unwrap_or(&30000000000),
4337 ),
4338 cpu: OneArgument::ConstantCost(
4339 *cost_map
4340 .get("un_b_data-cpu-arguments")
4341 .unwrap_or(&30000000000),
4342 ),
4343 },
4344 equals_data: CostingFun {
4345 mem: TwoArguments::ConstantCost(
4346 *cost_map
4347 .get("equals_data-mem-arguments")
4348 .unwrap_or(&30000000000),
4349 ),
4350 cpu: TwoArguments::MinSize(MinSize {
4351 intercept: *cost_map
4352 .get("equals_data-cpu-arguments-intercept")
4353 .unwrap_or(&30000000000),
4354 slope: *cost_map
4355 .get("equals_data-cpu-arguments-slope")
4356 .unwrap_or(&30000000000),
4357 }),
4358 },
4359 mk_pair_data: CostingFun {
4360 mem: TwoArguments::ConstantCost(
4361 *cost_map
4362 .get("mk_pair_data-mem-arguments")
4363 .unwrap_or(&30000000000),
4364 ),
4365 cpu: TwoArguments::ConstantCost(
4366 *cost_map
4367 .get("mk_pair_data-cpu-arguments")
4368 .unwrap_or(&30000000000),
4369 ),
4370 },
4371 mk_nil_data: CostingFun {
4372 mem: OneArgument::ConstantCost(
4373 *cost_map
4374 .get("mk_nil_data-mem-arguments")
4375 .unwrap_or(&30000000000),
4376 ),
4377 cpu: OneArgument::ConstantCost(
4378 *cost_map
4379 .get("mk_nil_data-cpu-arguments")
4380 .unwrap_or(&30000000000),
4381 ),
4382 },
4383 mk_nil_pair_data: CostingFun {
4384 mem: OneArgument::ConstantCost(
4385 *cost_map
4386 .get("mk_nil_pair_data-mem-arguments")
4387 .unwrap_or(&30000000000),
4388 ),
4389 cpu: OneArgument::ConstantCost(
4390 *cost_map
4391 .get("mk_nil_pair_data-cpu-arguments")
4392 .unwrap_or(&30000000000),
4393 ),
4394 },
4395 serialise_data: CostingFun {
4396 mem: OneArgument::LinearCost(LinearSize {
4397 intercept: *cost_map
4398 .get("serialise_data-mem-arguments-intercept")
4399 .unwrap_or(&30000000000),
4400 slope: *cost_map
4401 .get("serialise_data-mem-arguments-slope")
4402 .unwrap_or(&30000000000),
4403 }),
4404 cpu: OneArgument::LinearCost(LinearSize {
4405 intercept: *cost_map
4406 .get("serialise_data-cpu-arguments-intercept")
4407 .unwrap_or(&30000000000),
4408 slope: *cost_map
4409 .get("serialise_data-cpu-arguments-slope")
4410 .unwrap_or(&30000000000),
4411 }),
4412 },
4413 blake2b_224: match version {
4414 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4415 cpu: OneArgument::ConstantCost(30000000000),
4416 mem: OneArgument::ConstantCost(30000000000),
4417 },
4418 Language::PlutusV3 => CostingFun {
4419 cpu: OneArgument::LinearCost(LinearSize {
4420 intercept: *cost_map
4421 .get("blake2b_224-cpu-arguments-intercept")
4422 .unwrap_or(&30000000000),
4423 slope: *cost_map
4424 .get("blake2b_224-cpu-arguments-slope")
4425 .unwrap_or(&30000000000),
4426 }),
4427 mem: OneArgument::ConstantCost(
4428 *cost_map
4429 .get("blake2b_224-mem-arguments-slope")
4430 .unwrap_or(&30000000000),
4431 ),
4432 },
4433 },
4434 keccak_256: match version {
4435 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4436 cpu: OneArgument::ConstantCost(30000000000),
4437 mem: OneArgument::ConstantCost(30000000000),
4438 },
4439 Language::PlutusV3 => CostingFun {
4440 cpu: OneArgument::LinearCost(LinearSize {
4441 intercept: *cost_map
4442 .get("keccak_256-cpu-arguments-intercept")
4443 .unwrap_or(&30000000000),
4444 slope: *cost_map
4445 .get("keccak_256-cpu-arguments-slope")
4446 .unwrap_or(&30000000000),
4447 }),
4448 mem: OneArgument::ConstantCost(
4449 *cost_map
4450 .get("keccak_256-mem-arguments")
4451 .unwrap_or(&30000000000),
4452 ),
4453 },
4454 },
4455 bls12_381_g1_add: match version {
4456 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4457 cpu: TwoArguments::ConstantCost(30000000000),
4458 mem: TwoArguments::ConstantCost(30000000000),
4459 },
4460 Language::PlutusV3 => CostingFun {
4461 cpu: TwoArguments::ConstantCost(
4462 *cost_map
4463 .get("bls12_381_G1_add-cpu-arguments")
4464 .unwrap_or(&30000000000),
4465 ),
4466 mem: TwoArguments::ConstantCost(
4467 *cost_map
4468 .get("bls12_381_G1_add-mem-arguments")
4469 .unwrap_or(&30000000000),
4470 ),
4471 },
4472 },
4473 bls12_381_g1_neg: match version {
4474 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4475 cpu: OneArgument::ConstantCost(30000000000),
4476 mem: OneArgument::ConstantCost(30000000000),
4477 },
4478 Language::PlutusV3 => CostingFun {
4479 cpu: OneArgument::ConstantCost(
4480 *cost_map
4481 .get("bls12_381_G1_neg-cpu-arguments")
4482 .unwrap_or(&30000000000),
4483 ),
4484 mem: OneArgument::ConstantCost(
4485 *cost_map
4486 .get("bls12_381_G1_neg-mem-arguments")
4487 .unwrap_or(&30000000000),
4488 ),
4489 },
4490 },
4491 bls12_381_g1_scalar_mul: match version {
4492 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4493 cpu: TwoArguments::ConstantCost(30000000000),
4494 mem: TwoArguments::ConstantCost(30000000000),
4495 },
4496 Language::PlutusV3 => CostingFun {
4497 cpu: TwoArguments::LinearInX(LinearSize {
4498 intercept: *cost_map
4499 .get("bls12_381_G1_scalarMul-cpu-arguments-intercept")
4500 .unwrap_or(&30000000000),
4501 slope: *cost_map
4502 .get("bls12_381_G1_scalarMul-cpu-arguments-slope")
4503 .unwrap_or(&30000000000),
4504 }),
4505 mem: TwoArguments::ConstantCost(
4506 *cost_map
4507 .get("bls12_381_G1_scalarMul-mem-arguments")
4508 .unwrap_or(&30000000000),
4509 ),
4510 },
4511 },
4512 bls12_381_g1_equal: match version {
4513 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4514 cpu: TwoArguments::ConstantCost(30000000000),
4515 mem: TwoArguments::ConstantCost(30000000000),
4516 },
4517 Language::PlutusV3 => CostingFun {
4518 cpu: TwoArguments::ConstantCost(
4519 *cost_map
4520 .get("bls12_381_G1_equal-cpu-arguments")
4521 .unwrap_or(&30000000000),
4522 ),
4523 mem: TwoArguments::ConstantCost(
4524 *cost_map
4525 .get("bls12_381_G1_equal-mem-arguments")
4526 .unwrap_or(&30000000000),
4527 ),
4528 },
4529 },
4530 bls12_381_g1_compress: match version {
4531 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4532 cpu: OneArgument::ConstantCost(30000000000),
4533 mem: OneArgument::ConstantCost(30000000000),
4534 },
4535 Language::PlutusV3 => CostingFun {
4536 cpu: OneArgument::ConstantCost(
4537 *cost_map
4538 .get("bls12_381_G1_compress-cpu-arguments")
4539 .unwrap_or(&30000000000),
4540 ),
4541 mem: OneArgument::ConstantCost(
4542 *cost_map
4543 .get("bls12_381_G1_compress-mem-arguments")
4544 .unwrap_or(&30000000000),
4545 ),
4546 },
4547 },
4548 bls12_381_g1_uncompress: match version {
4549 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4550 cpu: OneArgument::ConstantCost(30000000000),
4551 mem: OneArgument::ConstantCost(30000000000),
4552 },
4553 Language::PlutusV3 => CostingFun {
4554 cpu: OneArgument::ConstantCost(
4555 *cost_map
4556 .get("bls12_381_G1_uncompress-cpu-arguments")
4557 .unwrap_or(&30000000000),
4558 ),
4559 mem: OneArgument::ConstantCost(
4560 *cost_map
4561 .get("bls12_381_G1_uncompress-mem-arguments")
4562 .unwrap_or(&30000000000),
4563 ),
4564 },
4565 },
4566 bls12_381_g1_hash_to_group: match version {
4567 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4568 cpu: TwoArguments::ConstantCost(30000000000),
4569 mem: TwoArguments::ConstantCost(30000000000),
4570 },
4571 Language::PlutusV3 => CostingFun {
4572 cpu: TwoArguments::LinearInX(LinearSize {
4573 intercept: *cost_map
4574 .get("bls12_381_G1_hashToGroup-cpu-arguments-intercept")
4575 .unwrap_or(&30000000000),
4576 slope: *cost_map
4577 .get("bls12_381_G1_hashToGroup-cpu-arguments-slope")
4578 .unwrap_or(&30000000000),
4579 }),
4580 mem: TwoArguments::ConstantCost(
4581 *cost_map
4582 .get("bls12_381_G1_hashToGroup-mem-arguments")
4583 .unwrap_or(&30000000000),
4584 ),
4585 },
4586 },
4587 bls12_381_g2_add: match version {
4588 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4589 cpu: TwoArguments::ConstantCost(30000000000),
4590 mem: TwoArguments::ConstantCost(30000000000),
4591 },
4592 Language::PlutusV3 => CostingFun {
4593 cpu: TwoArguments::ConstantCost(
4594 *cost_map
4595 .get("bls12_381_G2_add-cpu-arguments")
4596 .unwrap_or(&30000000000),
4597 ),
4598 mem: TwoArguments::ConstantCost(
4599 *cost_map
4600 .get("bls12_381_G2_add-mem-arguments")
4601 .unwrap_or(&30000000000),
4602 ),
4603 },
4604 },
4605 bls12_381_g2_neg: match version {
4606 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4607 cpu: OneArgument::ConstantCost(30000000000),
4608 mem: OneArgument::ConstantCost(30000000000),
4609 },
4610 Language::PlutusV3 => CostingFun {
4611 cpu: OneArgument::ConstantCost(
4612 *cost_map
4613 .get("bls12_381_G2_neg-cpu-arguments")
4614 .unwrap_or(&30000000000),
4615 ),
4616 mem: OneArgument::ConstantCost(
4617 *cost_map
4618 .get("bls12_381_G2_neg-mem-arguments")
4619 .unwrap_or(&30000000000),
4620 ),
4621 },
4622 },
4623 bls12_381_g2_scalar_mul: match version {
4624 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4625 cpu: TwoArguments::ConstantCost(30000000000),
4626 mem: TwoArguments::ConstantCost(30000000000),
4627 },
4628 Language::PlutusV3 => CostingFun {
4629 cpu: TwoArguments::LinearInX(LinearSize {
4630 intercept: *cost_map
4631 .get("bls12_381_G2_scalarMul-cpu-arguments-intercept")
4632 .unwrap_or(&30000000000),
4633 slope: *cost_map
4634 .get("bls12_381_G2_scalarMul-cpu-arguments-slope")
4635 .unwrap_or(&30000000000),
4636 }),
4637 mem: TwoArguments::ConstantCost(
4638 *cost_map
4639 .get("bls12_381_G2_scalarMul-mem-arguments")
4640 .unwrap_or(&30000000000),
4641 ),
4642 },
4643 },
4644 bls12_381_g2_equal: match version {
4645 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4646 cpu: TwoArguments::ConstantCost(30000000000),
4647 mem: TwoArguments::ConstantCost(30000000000),
4648 },
4649 Language::PlutusV3 => CostingFun {
4650 cpu: TwoArguments::ConstantCost(
4651 *cost_map
4652 .get("bls12_381_G2_equal-cpu-arguments")
4653 .unwrap_or(&30000000000),
4654 ),
4655 mem: TwoArguments::ConstantCost(
4656 *cost_map
4657 .get("bls12_381_G2_equal-mem-arguments")
4658 .unwrap_or(&30000000000),
4659 ),
4660 },
4661 },
4662 bls12_381_g2_compress: match version {
4663 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4664 cpu: OneArgument::ConstantCost(30000000000),
4665 mem: OneArgument::ConstantCost(30000000000),
4666 },
4667 Language::PlutusV3 => CostingFun {
4668 cpu: OneArgument::ConstantCost(
4669 *cost_map
4670 .get("bls12_381_G2_compress-cpu-arguments")
4671 .unwrap_or(&30000000000),
4672 ),
4673 mem: OneArgument::ConstantCost(
4674 *cost_map
4675 .get("bls12_381_G2_compress-mem-arguments")
4676 .unwrap_or(&30000000000),
4677 ),
4678 },
4679 },
4680 bls12_381_g2_uncompress: match version {
4681 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4682 cpu: OneArgument::ConstantCost(30000000000),
4683 mem: OneArgument::ConstantCost(30000000000),
4684 },
4685 Language::PlutusV3 => CostingFun {
4686 cpu: OneArgument::ConstantCost(
4687 *cost_map
4688 .get("bls12_381_G2_uncompress-cpu-arguments")
4689 .unwrap_or(&30000000000),
4690 ),
4691 mem: OneArgument::ConstantCost(
4692 *cost_map
4693 .get("bls12_381_G2_uncompress-mem-arguments")
4694 .unwrap_or(&30000000000),
4695 ),
4696 },
4697 },
4698 bls12_381_g2_hash_to_group: match version {
4699 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4700 cpu: TwoArguments::ConstantCost(30000000000),
4701 mem: TwoArguments::ConstantCost(30000000000),
4702 },
4703 Language::PlutusV3 => CostingFun {
4704 cpu: TwoArguments::LinearInX(LinearSize {
4705 intercept: *cost_map
4706 .get("bls12_381_G2_hashToGroup-cpu-arguments-intercept")
4707 .unwrap_or(&30000000000),
4708 slope: *cost_map
4709 .get("bls12_381_G2_hashToGroup-cpu-arguments-slope")
4710 .unwrap_or(&30000000000),
4711 }),
4712 mem: TwoArguments::ConstantCost(
4713 *cost_map
4714 .get("bls12_381_G2_hashToGroup-mem-arguments")
4715 .unwrap_or(&30000000000),
4716 ),
4717 },
4718 },
4719
4720 bls12_381_miller_loop: match version {
4721 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4722 cpu: TwoArguments::ConstantCost(30000000000),
4723 mem: TwoArguments::ConstantCost(30000000000),
4724 },
4725 Language::PlutusV3 => CostingFun {
4726 cpu: TwoArguments::ConstantCost(
4727 *cost_map
4728 .get("bls12_381_millerLoop-cpu-arguments")
4729 .unwrap_or(&30000000000),
4730 ),
4731 mem: TwoArguments::ConstantCost(
4732 *cost_map
4733 .get("bls12_381_millerLoop-mem-arguments")
4734 .unwrap_or(&30000000000),
4735 ),
4736 },
4737 },
4738 bls12_381_mul_ml_result: match version {
4739 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4740 cpu: TwoArguments::ConstantCost(30000000000),
4741 mem: TwoArguments::ConstantCost(30000000000),
4742 },
4743 Language::PlutusV3 => CostingFun {
4744 cpu: TwoArguments::ConstantCost(
4745 *cost_map
4746 .get("bls12_381_mulMlResult-cpu-arguments")
4747 .unwrap_or(&30000000000),
4748 ),
4749 mem: TwoArguments::ConstantCost(
4750 *cost_map
4751 .get("bls12_381_mulMlResult-mem-arguments")
4752 .unwrap_or(&30000000000),
4753 ),
4754 },
4755 },
4756 bls12_381_final_verify: match version {
4757 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4758 cpu: TwoArguments::ConstantCost(30000000000),
4759 mem: TwoArguments::ConstantCost(30000000000),
4760 },
4761 Language::PlutusV3 => CostingFun {
4762 cpu: TwoArguments::ConstantCost(
4763 *cost_map
4764 .get("bls12_381_finalVerify-cpu-arguments")
4765 .unwrap_or(&30000000000),
4766 ),
4767 mem: TwoArguments::ConstantCost(
4768 *cost_map
4769 .get("bls12_381_finalVerify-mem-arguments")
4770 .unwrap_or(&30000000000),
4771 ),
4772 },
4773 },
4774 integer_to_byte_string: match version {
4775 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4776 cpu: ThreeArguments::ConstantCost(30000000000),
4777 mem: ThreeArguments::ConstantCost(30000000000),
4778 },
4779 Language::PlutusV3 => CostingFun {
4780 cpu: ThreeArguments::QuadraticInZ(QuadraticFunction {
4781 coeff_0: *cost_map
4782 .get("integerToByteString-cpu-arguments-c0")
4783 .unwrap_or(&30000000000),
4784 coeff_1: *cost_map
4785 .get("integerToByteString-cpu-arguments-c1")
4786 .unwrap_or(&30000000000),
4787 coeff_2: *cost_map
4788 .get("integerToByteString-cpu-arguments-c2")
4789 .unwrap_or(&30000000000),
4790 }),
4791 mem: ThreeArguments::LiteralInYorLinearInZ(LinearSize {
4792 intercept: *cost_map
4793 .get("integerToByteString-mem-arguments-intercept")
4794 .unwrap_or(&30000000000),
4795 slope: *cost_map
4796 .get("integerToByteString-mem-arguments-slope")
4797 .unwrap_or(&30000000000),
4798 }),
4799 },
4800 },
4801 byte_string_to_integer: match version {
4802 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4803 cpu: TwoArguments::ConstantCost(30000000000),
4804 mem: TwoArguments::ConstantCost(30000000000),
4805 },
4806 Language::PlutusV3 => CostingFun {
4807 cpu: TwoArguments::QuadraticInY(QuadraticFunction {
4808 coeff_0: *cost_map
4809 .get("byteStringToInteger-cpu-arguments-c0")
4810 .unwrap_or(&30000000000),
4811 coeff_1: *cost_map
4812 .get("byteStringToInteger-cpu-arguments-c1")
4813 .unwrap_or(&30000000000),
4814 coeff_2: *cost_map
4815 .get("byteStringToInteger-cpu-arguments-c2")
4816 .unwrap_or(&30000000000),
4817 }),
4818 mem: TwoArguments::LinearInY(LinearSize {
4819 intercept: *cost_map
4820 .get("byteStringToInteger-mem-arguments-intercept")
4821 .unwrap_or(&30000000000),
4822 slope: *cost_map
4823 .get("byteStringToInteger-mem-arguments-slope")
4824 .unwrap_or(&30000000000),
4825 }),
4826 },
4827 },
4828 and_byte_string: match version {
4829 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4830 cpu: ThreeArguments::ConstantCost(30000000000),
4831 mem: ThreeArguments::ConstantCost(30000000000),
4832 },
4833 Language::PlutusV3 => CostingFun {
4834 cpu: ThreeArguments::LinearInYandZ(TwoVariableLinearSize {
4835 intercept: *cost_map
4836 .get("andByteString-cpu-arguments-intercept")
4837 .unwrap_or(&30000000000),
4838 slope1: *cost_map
4839 .get("andByteString-cpu-arguments-slope1")
4840 .unwrap_or(&30000000000),
4841 slope2: *cost_map
4842 .get("andByteString-cpu-arguments-slope2")
4843 .unwrap_or(&30000000000),
4844 }),
4845 mem: ThreeArguments::LinearInMaxYZ(LinearSize {
4846 intercept: *cost_map
4847 .get("andByteString-memory-arguments-intercept")
4848 .unwrap_or(&30000000000),
4849 slope: *cost_map
4850 .get("andByteString-memory-arguments-slope")
4851 .unwrap_or(&30000000000),
4852 }),
4853 },
4854 },
4855 or_byte_string: match version {
4856 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4857 cpu: ThreeArguments::ConstantCost(30000000000),
4858 mem: ThreeArguments::ConstantCost(30000000000),
4859 },
4860 Language::PlutusV3 => CostingFun {
4861 cpu: ThreeArguments::LinearInYandZ(TwoVariableLinearSize {
4862 intercept: *cost_map
4863 .get("orByteString-cpu-arguments-intercept")
4864 .unwrap_or(&30000000000),
4865 slope1: *cost_map
4866 .get("orByteString-cpu-arguments-slope1")
4867 .unwrap_or(&30000000000),
4868 slope2: *cost_map
4869 .get("orByteString-cpu-arguments-slope2")
4870 .unwrap_or(&30000000000),
4871 }),
4872 mem: ThreeArguments::LinearInMaxYZ(LinearSize {
4873 intercept: *cost_map
4874 .get("orByteString-memory-arguments-intercept")
4875 .unwrap_or(&30000000000),
4876 slope: *cost_map
4877 .get("orByteString-memory-arguments-slope")
4878 .unwrap_or(&30000000000),
4879 }),
4880 },
4881 },
4882 xor_byte_string: match version {
4883 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4884 cpu: ThreeArguments::ConstantCost(30000000000),
4885 mem: ThreeArguments::ConstantCost(30000000000),
4886 },
4887 Language::PlutusV3 => CostingFun {
4888 cpu: ThreeArguments::LinearInYandZ(TwoVariableLinearSize {
4889 intercept: *cost_map
4890 .get("xorByteString-cpu-arguments-intercept")
4891 .unwrap_or(&30000000000),
4892 slope1: *cost_map
4893 .get("xorByteString-cpu-arguments-slope1")
4894 .unwrap_or(&30000000000),
4895 slope2: *cost_map
4896 .get("xorByteString-cpu-arguments-slope2")
4897 .unwrap_or(&30000000000),
4898 }),
4899 mem: ThreeArguments::LinearInMaxYZ(LinearSize {
4900 intercept: *cost_map
4901 .get("xorByteString-memory-arguments-intercept")
4902 .unwrap_or(&30000000000),
4903 slope: *cost_map
4904 .get("xorByteString-memory-arguments-slope")
4905 .unwrap_or(&30000000000),
4906 }),
4907 },
4908 },
4909 complement_byte_string: match version {
4910 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4911 cpu: OneArgument::ConstantCost(30000000000),
4912 mem: OneArgument::ConstantCost(30000000000),
4913 },
4914 Language::PlutusV3 => CostingFun {
4915 cpu: OneArgument::LinearCost(LinearSize {
4916 intercept: *cost_map
4917 .get("complementByteString-cpu-arguments-intercept")
4918 .unwrap_or(&30000000000),
4919 slope: *cost_map
4920 .get("complementByteString-cpu-arguments-slope")
4921 .unwrap_or(&30000000000),
4922 }),
4923 mem: OneArgument::LinearCost(LinearSize {
4924 intercept: *cost_map
4925 .get("complementByteString-memory-arguments-intercept")
4926 .unwrap_or(&30000000000),
4927 slope: *cost_map
4928 .get("complementByteString-memory-arguments-slope")
4929 .unwrap_or(&30000000000),
4930 }),
4931 },
4932 },
4933 read_bit: match version {
4934 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4935 cpu: TwoArguments::ConstantCost(30000000000),
4936 mem: TwoArguments::ConstantCost(30000000000),
4937 },
4938 Language::PlutusV3 => CostingFun {
4939 cpu: TwoArguments::ConstantCost(
4940 *cost_map
4941 .get("readBit-cpu-arguments")
4942 .unwrap_or(&30000000000),
4943 ),
4944 mem: TwoArguments::ConstantCost(
4945 *cost_map
4946 .get("readBit-memory-arguments")
4947 .unwrap_or(&30000000000),
4948 ),
4949 },
4950 },
4951 write_bits: match version {
4952 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4953 cpu: ThreeArguments::ConstantCost(30000000000),
4954 mem: ThreeArguments::ConstantCost(30000000000),
4955 },
4956 Language::PlutusV3 => CostingFun {
4957 cpu: ThreeArguments::LinearInY(LinearSize {
4958 intercept: *cost_map
4959 .get("writeBits-cpu-arguments-intercept")
4960 .unwrap_or(&30000000000),
4961 slope: *cost_map
4962 .get("writeBits-cpu-arguments-slope")
4963 .unwrap_or(&30000000000),
4964 }),
4965 mem: ThreeArguments::LinearInX(LinearSize {
4966 intercept: *cost_map
4967 .get("writeBits-memory-arguments-intercept")
4968 .unwrap_or(&30000000000),
4969 slope: *cost_map
4970 .get("writeBits-memory-arguments-slope")
4971 .unwrap_or(&30000000000),
4972 }),
4973 },
4974 },
4975 replicate_byte: match version {
4976 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
4977 cpu: TwoArguments::ConstantCost(30000000000),
4978 mem: TwoArguments::ConstantCost(30000000000),
4979 },
4980 Language::PlutusV3 => CostingFun {
4981 cpu: TwoArguments::LinearInX(LinearSize {
4982 intercept: *cost_map
4983 .get("replicateByte-cpu-arguments-intercept")
4984 .unwrap_or(&30000000000),
4985 slope: *cost_map
4986 .get("replicateByte-cpu-arguments-slope")
4987 .unwrap_or(&30000000000),
4988 }),
4989 mem: TwoArguments::LinearInX(LinearSize {
4990 intercept: *cost_map
4991 .get("replicateByte-memory-arguments-intercept")
4992 .unwrap_or(&30000000000),
4993 slope: *cost_map
4994 .get("replicateByte-memory-arguments-slope")
4995 .unwrap_or(&30000000000),
4996 }),
4997 },
4998 },
4999 shift_byte_string: match version {
5000 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
5001 cpu: TwoArguments::ConstantCost(30000000000),
5002 mem: TwoArguments::ConstantCost(30000000000),
5003 },
5004 Language::PlutusV3 => CostingFun {
5005 cpu: TwoArguments::LinearInX(LinearSize {
5006 intercept: *cost_map
5007 .get("shiftByteString-cpu-arguments-intercept")
5008 .unwrap_or(&30000000000),
5009 slope: *cost_map
5010 .get("shiftByteString-cpu-arguments-slope")
5011 .unwrap_or(&30000000000),
5012 }),
5013 mem: TwoArguments::LinearInX(LinearSize {
5014 intercept: *cost_map
5015 .get("shiftByteString-memory-arguments-intercept")
5016 .unwrap_or(&30000000000),
5017 slope: *cost_map
5018 .get("shiftByteString-memory-arguments-slope")
5019 .unwrap_or(&30000000000),
5020 }),
5021 },
5022 },
5023 rotate_byte_string: match version {
5024 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
5025 cpu: TwoArguments::ConstantCost(30000000000),
5026 mem: TwoArguments::ConstantCost(30000000000),
5027 },
5028 Language::PlutusV3 => CostingFun {
5029 cpu: TwoArguments::LinearInX(LinearSize {
5030 intercept: *cost_map
5031 .get("rotateByteString-cpu-arguments-intercept")
5032 .unwrap_or(&30000000000),
5033 slope: *cost_map
5034 .get("rotateByteString-cpu-arguments-slope")
5035 .unwrap_or(&30000000000),
5036 }),
5037 mem: TwoArguments::LinearInX(LinearSize {
5038 intercept: *cost_map
5039 .get("rotateByteString-memory-arguments-intercept")
5040 .unwrap_or(&30000000000),
5041 slope: *cost_map
5042 .get("rotateByteString-memory-arguments-slope")
5043 .unwrap_or(&30000000000),
5044 }),
5045 },
5046 },
5047 count_set_bits: match version {
5048 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
5049 cpu: OneArgument::ConstantCost(30000000000),
5050 mem: OneArgument::ConstantCost(30000000000),
5051 },
5052 Language::PlutusV3 => CostingFun {
5053 cpu: OneArgument::LinearCost(LinearSize {
5054 intercept: *cost_map
5055 .get("countSetBits-cpu-arguments-intercept")
5056 .unwrap_or(&30000000000),
5057 slope: *cost_map
5058 .get("countSetBits-cpu-arguments-slope")
5059 .unwrap_or(&30000000000),
5060 }),
5061 mem: OneArgument::ConstantCost(
5062 *cost_map
5063 .get("countSetBits-memory-arguments")
5064 .unwrap_or(&30000000000),
5065 ),
5066 },
5067 },
5068 find_first_set_bit: match version {
5069 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
5070 cpu: OneArgument::ConstantCost(30000000000),
5071 mem: OneArgument::ConstantCost(30000000000),
5072 },
5073 Language::PlutusV3 => CostingFun {
5074 cpu: OneArgument::LinearCost(LinearSize {
5075 intercept: *cost_map
5076 .get("findFirstSetBit-cpu-arguments-intercept")
5077 .unwrap_or(&30000000000),
5078 slope: *cost_map
5079 .get("findFirstSetBit-cpu-arguments-slope")
5080 .unwrap_or(&30000000000),
5081 }),
5082 mem: OneArgument::ConstantCost(
5083 *cost_map
5084 .get("findFirstSetBit-memory-arguments")
5085 .unwrap_or(&30000000000),
5086 ),
5087 },
5088 },
5089 ripemd_160: match version {
5090 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
5091 cpu: OneArgument::ConstantCost(30000000000),
5092 mem: OneArgument::ConstantCost(30000000000),
5093 },
5094 Language::PlutusV3 => CostingFun {
5095 cpu: OneArgument::LinearCost(LinearSize {
5096 intercept: *cost_map
5097 .get("ripemd_160-cpu-arguments-intercept")
5098 .unwrap_or(&30000000000),
5099 slope: *cost_map
5100 .get("ripemd_160-cpu-arguments-slope")
5101 .unwrap_or(&30000000000),
5102 }),
5103 mem: OneArgument::ConstantCost(
5104 *cost_map
5105 .get("ripemd_160-memory-arguments")
5106 .unwrap_or(&30000000000),
5107 ),
5108 },
5109 },
5110 exp_mod_int: match version {
5111 Language::PlutusV1 | Language::PlutusV2 => CostingFun {
5112 cpu: ThreeArguments::ConstantCost(30000000000),
5113 mem: ThreeArguments::ConstantCost(30000000000),
5114 },
5115 Language::PlutusV3 => CostingFun {
5116 cpu: ThreeArguments::ConstantCost(
5117 *cost_map
5118 .get("expModInteger-cpu-arguments")
5119 .unwrap_or(&30000000000),
5120 ),
5121 mem: ThreeArguments::ConstantCost(
5122 *cost_map
5123 .get("expModInteger-memory-arguments")
5124 .unwrap_or(&30000000000),
5125 ),
5126 },
5127 },
5128 },
5129 }
5130}
5131
5132#[derive(Debug, PartialEq)]
5133pub struct CostingFun<T> {
5134 pub mem: T,
5135 pub cpu: T,
5136}
5137
5138#[derive(Debug, PartialEq)]
5139pub enum OneArgument {
5140 ConstantCost(i64),
5141 LinearCost(LinearSize),
5142}
5143
5144impl OneArgument {
5145 pub fn cost(&self, x: i64) -> i64 {
5146 match self {
5147 OneArgument::ConstantCost(c) => *c,
5148 OneArgument::LinearCost(m) => m.slope * x + m.intercept,
5149 }
5150 }
5151}
5152
5153#[derive(Debug, PartialEq, Clone)]
5154pub enum TwoArguments {
5155 ConstantCost(i64),
5156 LinearInX(LinearSize),
5157 LinearInY(LinearSize),
5158 LinearInXAndY(TwoVariableLinearSize),
5159 AddedSizes(AddedSizes),
5160 SubtractedSizes(SubtractedSizes),
5161 MultipliedSizes(MultipliedSizes),
5162 MinSize(MinSize),
5163 MaxSize(MaxSize),
5164 LinearOnDiagonal(ConstantOrLinear),
5165 ConstAboveDiagonal(ConstantOrTwoArguments),
5166 ConstBelowDiagonal(ConstantOrTwoArguments),
5167 QuadraticInY(QuadraticFunction),
5168 ConstAboveDiagonalIntoQuadraticXAndY(i64, TwoArgumentsQuadraticFunction),
5169}
5170
5171impl TwoArguments {
5172 pub fn cost(&self, x: i64, y: i64) -> i64 {
5173 match self {
5174 TwoArguments::ConstantCost(c) => *c,
5175 TwoArguments::LinearInX(l) => l.slope * x + l.intercept,
5176 TwoArguments::LinearInY(l) => l.slope * y + l.intercept,
5177 TwoArguments::LinearInXAndY(l) => l.slope1 * x + l.slope2 * y + l.intercept,
5178 TwoArguments::AddedSizes(s) => s.slope * (x + y) + s.intercept,
5179 TwoArguments::SubtractedSizes(s) => s.slope * s.minimum.max(x - y) + s.intercept,
5180 TwoArguments::MultipliedSizes(s) => s.slope * (x * y) + s.intercept,
5181 TwoArguments::MinSize(s) => s.slope * x.min(y) + s.intercept,
5182 TwoArguments::MaxSize(s) => s.slope * x.max(y) + s.intercept,
5183 TwoArguments::LinearOnDiagonal(l) => {
5184 if x == y {
5185 x * l.slope + l.intercept
5186 } else {
5187 l.constant
5188 }
5189 }
5190 TwoArguments::ConstAboveDiagonal(l) => {
5191 if x < y {
5192 l.constant
5193 } else {
5194 let p = *l.model.clone();
5195 p.cost(x, y)
5196 }
5197 }
5198 TwoArguments::ConstBelowDiagonal(l) => {
5199 if x > y {
5200 l.constant
5201 } else {
5202 let p = *l.model.clone();
5203 p.cost(x, y)
5204 }
5205 }
5206 TwoArguments::QuadraticInY(q) => q.coeff_0 + (q.coeff_1 * y) + (q.coeff_2 * y * y),
5207 TwoArguments::ConstAboveDiagonalIntoQuadraticXAndY(constant, q) => {
5208 if x < y {
5209 *constant
5210 } else {
5211 std::cmp::max(
5212 q.minimum,
5213 q.coeff_00
5214 + q.coeff_10 * x
5215 + q.coeff_01 * y
5216 + q.coeff_20 * x * x
5217 + q.coeff_11 * x * y
5218 + q.coeff_02 * y * y,
5219 )
5220 }
5221 }
5222 }
5223 }
5224}
5225
5226#[derive(Debug, PartialEq)]
5227pub enum ThreeArguments {
5228 ConstantCost(i64),
5229 AddedSizes(AddedSizes),
5230 LinearInX(LinearSize),
5231 LinearInY(LinearSize),
5232 LinearInZ(LinearSize),
5233 QuadraticInZ(QuadraticFunction),
5234 LiteralInYorLinearInZ(LinearSize),
5235 LinearInMaxYZ(LinearSize),
5236 LinearInYandZ(TwoVariableLinearSize),
5237}
5238
5239impl ThreeArguments {
5240 pub fn cost(&self, x: i64, y: i64, z: i64) -> i64 {
5241 match self {
5242 ThreeArguments::ConstantCost(c) => *c,
5243 ThreeArguments::AddedSizes(s) => (x + y + z) * s.slope + s.intercept,
5244 ThreeArguments::LinearInX(l) => x * l.slope + l.intercept,
5245 ThreeArguments::LinearInY(l) => y * l.slope + l.intercept,
5246 ThreeArguments::LinearInZ(l) => z * l.slope + l.intercept,
5247 ThreeArguments::QuadraticInZ(q) => q.coeff_0 + (q.coeff_1 * z) + (q.coeff_2 * z * z),
5248 ThreeArguments::LiteralInYorLinearInZ(l) => {
5249 if y == 0 {
5250 l.slope * z + l.intercept
5251 } else {
5252 y
5253 }
5254 }
5255 ThreeArguments::LinearInMaxYZ(l) => y.max(z) * l.slope + l.intercept,
5256 ThreeArguments::LinearInYandZ(l) => y * l.slope1 + z * l.slope2 + l.intercept,
5257 }
5258 }
5259}
5260
5261#[derive(Debug, PartialEq)]
5262pub enum SixArguments {
5263 ConstantCost(i64),
5264}
5265
5266impl SixArguments {
5267 pub fn cost(&self, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64) -> i64 {
5268 match self {
5269 SixArguments::ConstantCost(c) => *c,
5270 }
5271 }
5272}
5273
5274#[derive(Debug, PartialEq, Clone)]
5275pub struct LinearSize {
5276 pub intercept: i64,
5277 pub slope: i64,
5278}
5279
5280#[derive(Debug, PartialEq, Clone)]
5281pub struct TwoVariableLinearSize {
5282 pub intercept: i64,
5283 pub slope1: i64,
5284 pub slope2: i64,
5285}
5286
5287#[derive(Debug, PartialEq, Clone)]
5288pub struct AddedSizes {
5289 pub intercept: i64,
5290 pub slope: i64,
5291}
5292
5293#[derive(Debug, PartialEq, Clone)]
5294pub struct SubtractedSizes {
5295 pub intercept: i64,
5296 pub slope: i64,
5297 pub minimum: i64,
5298}
5299
5300#[derive(Debug, PartialEq, Clone)]
5301pub struct MultipliedSizes {
5302 pub intercept: i64,
5303 pub slope: i64,
5304}
5305
5306#[derive(Debug, PartialEq, Clone)]
5307pub struct MinSize {
5308 pub intercept: i64,
5309 pub slope: i64,
5310}
5311
5312#[derive(Debug, PartialEq, Clone)]
5313pub struct MaxSize {
5314 pub intercept: i64,
5315 pub slope: i64,
5316}
5317
5318#[derive(Debug, PartialEq, Clone)]
5319pub struct ConstantOrLinear {
5320 pub constant: i64,
5321 pub intercept: i64,
5322 pub slope: i64,
5323}
5324
5325#[derive(Debug, PartialEq, Clone)]
5326pub struct ConstantOrTwoArguments {
5327 pub constant: i64,
5328 pub model: Box<TwoArguments>,
5329}
5330
5331#[derive(Debug, PartialEq, Clone)]
5332pub struct QuadraticFunction {
5333 coeff_0: i64,
5334 coeff_1: i64,
5335 coeff_2: i64,
5336}
5337
5338#[derive(Debug, PartialEq, Clone)]
5339pub struct TwoArgumentsQuadraticFunction {
5340 minimum: i64,
5341 coeff_00: i64,
5342 coeff_10: i64,
5343 coeff_01: i64,
5344 coeff_20: i64,
5345 coeff_11: i64,
5346 coeff_02: i64,
5347}
5348
5349#[repr(u8)]
5350#[derive(Debug, EnumIter, Display, Clone, Copy)]
5351pub enum StepKind {
5352 Constant = 0,
5353 Var = 1,
5354 Lambda = 2,
5355 Apply = 3,
5356 Delay = 4,
5357 Force = 5,
5358 Builtin = 6,
5359 Constr = 7,
5360 Case = 8,
5361 StartUp = 9,
5363}
5364
5365impl TryFrom<u8> for StepKind {
5366 type Error = super::error::Error;
5367
5368 fn try_from(value: u8) -> Result<Self, Self::Error> {
5369 match value {
5370 0 => Ok(StepKind::Constant),
5371 1 => Ok(StepKind::Var),
5372 2 => Ok(StepKind::Lambda),
5373 3 => Ok(StepKind::Apply),
5374 4 => Ok(StepKind::Delay),
5375 5 => Ok(StepKind::Force),
5376 6 => Ok(StepKind::Builtin),
5377 7 => Ok(StepKind::Constr),
5378 8 => Ok(StepKind::Case),
5379 v => Err(super::error::Error::InvalidStepKind(v)),
5380 }
5381 }
5382}
5383
5384#[cfg(test)]
5385mod tests {
5386 use super::*;
5387 use pretty_assertions::assert_eq;
5388
5389 #[test]
5390 fn assert_default_cost_model_v1_mainnet_2024_09_29() {
5391 let costs = vec![
5392 100788, 420, 1, 1, 1000, 173, 0, 1, 1000, 59957, 4, 1, 11183, 32, 201305, 8356, 4,
5393 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 100, 100,
5394 16000, 100, 94375, 32, 132994, 32, 61462, 4, 72010, 178, 0, 1, 22151, 32, 91189, 769,
5395 4, 2, 85848, 228465, 122, 0, 1, 1, 1000, 42921, 4, 2, 24548, 29498, 38, 1, 898148,
5396 27279, 1, 51775, 558, 1, 39184, 1000, 60594, 1, 141895, 32, 83150, 32, 15299, 32,
5397 76049, 1, 13169, 4, 22100, 10, 28999, 74, 1, 28999, 74, 1, 43285, 552, 1, 44749, 541,
5398 1, 33852, 32, 68246, 32, 72362, 32, 7243, 32, 7391, 32, 11546, 32, 85848, 228465, 122,
5399 0, 1, 1, 90434, 519, 0, 1, 74433, 32, 85848, 228465, 122, 0, 1, 1, 85848, 228465, 122,
5400 0, 1, 1, 270652, 22588, 4, 1457325, 64566, 4, 20467, 1, 4, 0, 141992, 32, 100788, 420,
5401 1, 1, 81663, 32, 59498, 32, 20142, 32, 24588, 32, 20744, 32, 25933, 32, 24623, 32,
5402 53384111, 14333, 10,
5403 ];
5404
5405 let cost_model = initialize_cost_model(&Language::PlutusV1, &costs);
5406
5407 assert_eq!(CostModel::v1(), cost_model);
5408 }
5409
5410 #[test]
5411 fn assert_default_cost_model_v2_mainnet_2024_09_29() {
5412 let costs = vec![
5413 100788, 420, 1, 1, 1000, 173, 0, 1, 1000, 59957, 4, 1, 11183, 32, 201305, 8356, 4,
5414 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 100, 100,
5415 16000, 100, 94375, 32, 132994, 32, 61462, 4, 72010, 178, 0, 1, 22151, 32, 91189, 769,
5416 4, 2, 85848, 228465, 122, 0, 1, 1, 1000, 42921, 4, 2, 24548, 29498, 38, 1, 898148,
5417 27279, 1, 51775, 558, 1, 39184, 1000, 60594, 1, 141895, 32, 83150, 32, 15299, 32,
5418 76049, 1, 13169, 4, 22100, 10, 28999, 74, 1, 28999, 74, 1, 43285, 552, 1, 44749, 541,
5419 1, 33852, 32, 68246, 32, 72362, 32, 7243, 32, 7391, 32, 11546, 32, 85848, 228465, 122,
5420 0, 1, 1, 90434, 519, 0, 1, 74433, 32, 85848, 228465, 122, 0, 1, 1, 85848, 228465, 122,
5421 0, 1, 1, 955506, 213312, 0, 2, 270652, 22588, 4, 1457325, 64566, 4, 20467, 1, 4, 0,
5422 141992, 32, 100788, 420, 1, 1, 81663, 32, 59498, 32, 20142, 32, 24588, 32, 20744, 32,
5423 25933, 32, 24623, 32, 43053543, 10, 53384111, 14333, 10, 43574283, 26308, 10,
5424 ];
5425
5426 let cost_model = initialize_cost_model(&Language::PlutusV2, &costs);
5427
5428 assert_eq!(CostModel::v2(), cost_model);
5429 }
5430
5431 #[test]
5459 fn assert_default_cost_model_v3_preprod_2024_11_22() {
5460 let costs: Vec<i64> = vec![
5461 100788, 420, 1, 1, 1000, 173, 0, 1, 1000, 59957, 4, 1, 11183, 32, 201305, 8356, 4,
5462 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 16000, 100, 100, 100,
5463 16000, 100, 94375, 32, 132994, 32, 61462, 4, 72010, 178, 0, 1, 22151, 32, 91189, 769,
5464 4, 2, 85848, 123203, 7305, -900, 1716, 549, 57, 85848, 0, 1, 1, 1000, 42921, 4, 2,
5465 24548, 29498, 38, 1, 898148, 27279, 1, 51775, 558, 1, 39184, 1000, 60594, 1, 141895,
5466 32, 83150, 32, 15299, 32, 76049, 1, 13169, 4, 22100, 10, 28999, 74, 1, 28999, 74, 1,
5467 43285, 552, 1, 44749, 541, 1, 33852, 32, 68246, 32, 72362, 32, 7243, 32, 7391, 32,
5468 11546, 32, 85848, 123203, 7305, -900, 1716, 549, 57, 85848, 0, 1, 90434, 519, 0, 1,
5469 74433, 32, 85848, 123203, 7305, -900, 1716, 549, 57, 85848, 0, 1, 1, 85848, 123203,
5470 7305, -900, 1716, 549, 57, 85848, 0, 1, 955506, 213312, 0, 2, 270652, 22588, 4,
5471 1457325, 64566, 4, 20467, 1, 4, 0, 141992, 32, 100788, 420, 1, 1, 81663, 32, 59498, 32,
5472 20142, 32, 24588, 32, 20744, 32, 25933, 32, 24623, 32, 43053543, 10, 53384111, 14333,
5473 10, 43574283, 26308, 10, 16000, 100, 16000, 100, 962335, 18, 2780678, 6, 442008, 1,
5474 52538055, 3756, 18, 267929, 18, 76433006, 8868, 18, 52948122, 18, 1995836, 36, 3227919,
5475 12, 901022, 1, 166917843, 4307, 36, 284546, 36, 158221314, 26549, 36, 74698472, 36,
5476 333849714, 1, 254006273, 72, 2174038, 72, 2261318, 64571, 4, 207616, 8310, 4, 1293828,
5477 28716, 63, 0, 1, 1006041, 43623, 251, 0, 1, 100181, 726, 719, 0, 1, 100181, 726, 719,
5478 0, 1, 100181, 726, 719, 0, 1, 107878, 680, 0, 1, 95336, 1, 281145, 18848, 0, 1, 180194,
5479 159, 1, 1, 158519, 8942, 0, 1, 159378, 8813, 0, 1, 107490, 3298, 1, 106057, 655, 1,
5480 1964219, 24520, 3,
5481 ];
5482
5483 let cost_model = initialize_cost_model(&Language::PlutusV3, &costs);
5484
5485 assert_eq!(CostModel::v3(), cost_model);
5486 }
5487}