gear_core/gas_metering/
schedule.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
// This file is part of Gear.
//
// Copyright (C) 2021-2024 Gear Technologies Inc.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

#![allow(rustdoc::broken_intra_doc_links, missing_docs)]
#![doc = r" This is auto-generated module that contains cost schedule from"]
#![doc = r" `pallets/gear/src/schedule.rs`."]
#![doc = r""]
#![doc = r" See `./scripts/weight-dump.sh` if you want to update it."]

use crate::costs::*;

#[derive(Debug, Clone)]
#[doc = " Definition of the cost schedule and other parameterization for the wasm vm."]
pub struct Schedule {
    #[doc = " Describes the upper limits on various metrics."]
    pub limits: Limits,
    #[doc = " The weights for individual wasm instructions."]
    pub instruction_weights: InstructionWeights,
    #[doc = " The weights for each imported function a program is allowed to call."]
    pub syscall_weights: SyscallWeights,
    #[doc = " The weights for memory interaction."]
    pub memory_weights: MemoryWeights,
    #[doc = " The weights for renting."]
    pub rent_weights: RentWeights,
    #[doc = " The weights for database access."]
    pub db_weights: DbWeights,
    #[doc = " The weights for executing tasks."]
    pub task_weights: TaskWeights,
    #[doc = " The weights for instantiation of the module."]
    pub instantiation_weights: InstantiationWeights,
    #[doc = " WASM code instrumentation base cost."]
    pub code_instrumentation_cost: Weight,
    #[doc = " WASM code instrumentation per-byte cost."]
    pub code_instrumentation_byte_cost: Weight,
    #[doc = " Load allocations weight."]
    pub load_allocations_weight: Weight,
}

impl Default for Schedule {
    fn default() -> Self {
        Self {
            limits: Limits::default(),
            instruction_weights: InstructionWeights::default(),
            syscall_weights: SyscallWeights::default(),
            memory_weights: MemoryWeights::default(),
            rent_weights: RentWeights::default(),
            db_weights: DbWeights::default(),
            task_weights: TaskWeights::default(),
            instantiation_weights: InstantiationWeights::default(),
            code_instrumentation_cost: Weight {
                ref_time: 325729000,
                proof_size: 3793,
            },
            code_instrumentation_byte_cost: Weight {
                ref_time: 715243,
                proof_size: 0,
            },
            load_allocations_weight: Weight {
                ref_time: 25197,
                proof_size: 0,
            },
        }
    }
}

#[derive(Debug, Clone)]
#[doc = " Describes the upper limits on various metrics."]
#[doc = ""]
#[doc = " # Note"]
#[doc = ""]
#[doc = " The values in this struct should never be decreased. The reason is that decreasing those"]
#[doc = " values will break existing programs which are above the new limits when a"]
#[doc = " re-instrumentation is triggered."]
pub struct Limits {
    #[doc = " Maximum allowed stack height in number of elements."]
    #[doc = ""]
    #[doc = " See <https://wiki.parity.io/WebAssembly-StackHeight> to find out"]
    #[doc = " how the stack frame cost is calculated. Each element can be of one of the"]
    #[doc = " wasm value types. This means the maximum size per element is 64bit."]
    #[doc = ""]
    #[doc = " # Note"]
    #[doc = ""]
    #[doc = " It is safe to disable (pass `None`) the `stack_height` when the execution engine"]
    #[doc = " is part of the runtime and hence there can be no indeterminism between different"]
    #[doc = " client resident execution engines."]
    pub stack_height: Option<u32>,
    #[doc = " Maximum number of globals a module is allowed to declare."]
    #[doc = ""]
    #[doc = " Globals are not limited through the linear memory limit `memory_pages`."]
    pub globals: u32,
    #[doc = " Maximum number of locals a function can have."]
    #[doc = ""]
    #[doc = " As wasm engine initializes each of the local, we need to limit their number to confine"]
    #[doc = " execution costs."]
    pub locals: u32,
    #[doc = " Maximum numbers of parameters a function can have."]
    #[doc = ""]
    #[doc = " Those need to be limited to prevent a potentially exploitable interaction with"]
    #[doc = " the stack height instrumentation: The costs of executing the stack height"]
    #[doc = " instrumentation for an indirectly called function scales linearly with the amount"]
    #[doc = " of parameters of this function. Because the stack height instrumentation itself is"]
    #[doc = " is not weight metered its costs must be static (via this limit) and included in"]
    #[doc = " the costs of the instructions that cause them (call, call_indirect)."]
    pub parameters: u32,
    #[doc = " Maximum number of memory pages allowed for a program."]
    pub memory_pages: u16,
    #[doc = " Maximum number of elements allowed in a table."]
    #[doc = ""]
    #[doc = " Currently, the only type of element that is allowed in a table is funcref."]
    pub table_size: u32,
    #[doc = " Maximum number of tables allowed for a program."]
    #[doc = " The same limit also imposed by `wasmparser`,"]
    #[doc = " see <https://github.com/bytecodealliance/wasm-tools/blob/main/crates/wasmparser/src/limits.rs>"]
    pub table_number: u32,
    #[doc = " Maximum number of elements that can appear as immediate value to the br_table instruction."]
    pub br_table_size: u32,
    #[doc = " The maximum length of a subject in bytes used for PRNG generation."]
    pub subject_len: u32,
    #[doc = " The maximum nesting level of the call stack."]
    pub call_depth: u32,
    #[doc = " The maximum size of a message payload in bytes."]
    pub payload_len: u32,
    #[doc = " The maximum length of a program code in bytes. This limit applies to the instrumented"]
    #[doc = " version of the code. Therefore `instantiate_with_code` can fail even when supplying"]
    #[doc = " a wasm binary below this maximum size."]
    pub code_len: u32,
    #[doc = " The maximum number of wasm data segments allowed for a program."]
    pub data_segments_amount: u32,
}

impl Default for Limits {
    fn default() -> Self {
        Self {
            stack_height: Some(36743),
            globals: 256,
            locals: 1024,
            parameters: 128,
            memory_pages: 32768,
            table_size: 4096,
            table_number: 100,
            br_table_size: 256,
            subject_len: 32,
            call_depth: 32,
            payload_len: 8388608,
            code_len: 524288,
            data_segments_amount: 1024,
        }
    }
}

#[derive(Debug, Clone)]
#[doc = " Describes the weight for all categories of supported wasm instructions."]
#[doc = ""]
#[doc = " There there is one field for each wasm instruction that describes the weight to"]
#[doc = " execute one instruction of that name. There are a few exceptions:"]
#[doc = ""]
#[doc = " 1. If there is a i64 and a i32 variant of an instruction we use the weight"]
#[doc = "    of the former for both."]
#[doc = " 2. The following instructions are free of charge because they merely structure the"]
#[doc = "    wasm module and cannot be spammed without making the module invalid (and rejected):"]
#[doc = "    End, Unreachable, Return, Else"]
#[doc = " 3. The following instructions cannot be benchmarked because they are removed by any"]
#[doc = "    real world execution engine as a preprocessing step and therefore don't yield a"]
#[doc = "    meaningful benchmark result. However, in contrast to the instructions mentioned"]
#[doc = "    in 2. they can be spammed. We price them with the same weight as the \"default\""]
#[doc = "    instruction (i64.const): Block, Loop, Nop"]
#[doc = " 4. We price both i64.const and drop as InstructionWeights.i64const / 2. The reason"]
#[doc = "    for that is that we cannot benchmark either of them on its own but we need their"]
#[doc = "    individual values to derive (by subtraction) the weight of all other instructions"]
#[doc = "    that use them as supporting instructions. Supporting means mainly pushing arguments"]
#[doc = "    and dropping return values in order to maintain a valid module."]
pub struct InstructionWeights {
    #[doc = " Version of the instruction weights."]
    #[doc = ""]
    #[doc = " # Note"]
    #[doc = ""]
    #[doc = " Should be incremented whenever any instruction weight is changed. The"]
    #[doc = " reason is that changes to instruction weights require a re-instrumentation"]
    #[doc = " in order to apply the changes to an already deployed code. The re-instrumentation"]
    #[doc = " is triggered by comparing the version of the current schedule with the version the code was"]
    #[doc = " instrumented with. Changes usually happen when pallet_gear is re-benchmarked."]
    #[doc = ""]
    #[doc = " Changes to other parts of the schedule should not increment the version in"]
    #[doc = " order to avoid unnecessary re-instrumentations."]
    pub version: u32,
    pub i64const: u32,
    pub i64load: u32,
    pub i32load: u32,
    pub i64store: u32,
    pub i32store: u32,
    pub select: u32,
    pub r#if: u32,
    pub br: u32,
    pub br_if: u32,
    pub br_table: u32,
    pub br_table_per_entry: u32,
    pub call: u32,
    pub call_indirect: u32,
    pub call_indirect_per_param: u32,
    pub call_per_local: u32,
    pub local_get: u32,
    pub local_set: u32,
    pub local_tee: u32,
    pub global_get: u32,
    pub global_set: u32,
    pub memory_current: u32,
    pub i64clz: u32,
    pub i32clz: u32,
    pub i64ctz: u32,
    pub i32ctz: u32,
    pub i64popcnt: u32,
    pub i32popcnt: u32,
    pub i64eqz: u32,
    pub i32eqz: u32,
    pub i32extend8s: u32,
    pub i32extend16s: u32,
    pub i64extend8s: u32,
    pub i64extend16s: u32,
    pub i64extend32s: u32,
    pub i64extendsi32: u32,
    pub i64extendui32: u32,
    pub i32wrapi64: u32,
    pub i64eq: u32,
    pub i32eq: u32,
    pub i64ne: u32,
    pub i32ne: u32,
    pub i64lts: u32,
    pub i32lts: u32,
    pub i64ltu: u32,
    pub i32ltu: u32,
    pub i64gts: u32,
    pub i32gts: u32,
    pub i64gtu: u32,
    pub i32gtu: u32,
    pub i64les: u32,
    pub i32les: u32,
    pub i64leu: u32,
    pub i32leu: u32,
    pub i64ges: u32,
    pub i32ges: u32,
    pub i64geu: u32,
    pub i32geu: u32,
    pub i64add: u32,
    pub i32add: u32,
    pub i64sub: u32,
    pub i32sub: u32,
    pub i64mul: u32,
    pub i32mul: u32,
    pub i64divs: u32,
    pub i32divs: u32,
    pub i64divu: u32,
    pub i32divu: u32,
    pub i64rems: u32,
    pub i32rems: u32,
    pub i64remu: u32,
    pub i32remu: u32,
    pub i64and: u32,
    pub i32and: u32,
    pub i64or: u32,
    pub i32or: u32,
    pub i64xor: u32,
    pub i32xor: u32,
    pub i64shl: u32,
    pub i32shl: u32,
    pub i64shrs: u32,
    pub i32shrs: u32,
    pub i64shru: u32,
    pub i32shru: u32,
    pub i64rotl: u32,
    pub i32rotl: u32,
    pub i64rotr: u32,
    pub i32rotr: u32,
}

impl Default for InstructionWeights {
    fn default() -> Self {
        Self {
            version: 1700,
            i64const: 200,
            i64load: 7823,
            i32load: 7716,
            i64store: 10343,
            i32store: 9920,
            select: 6672,
            r#if: 5345,
            br: 3851,
            br_if: 6165,
            br_table: 11700,
            br_table_per_entry: 184,
            call: 5506,
            call_indirect: 24900,
            call_indirect_per_param: 1308,
            call_per_local: 0,
            local_get: 714,
            local_set: 1386,
            local_tee: 1423,
            global_get: 725,
            global_set: 1260,
            memory_current: 14725,
            i64clz: 492,
            i32clz: 244,
            i64ctz: 536,
            i32ctz: 255,
            i64popcnt: 534,
            i32popcnt: 265,
            i64eqz: 1768,
            i32eqz: 1054,
            i32extend8s: 281,
            i32extend16s: 285,
            i64extend8s: 443,
            i64extend16s: 400,
            i64extend32s: 318,
            i64extendsi32: 248,
            i64extendui32: 241,
            i32wrapi64: 219,
            i64eq: 1769,
            i32eq: 1041,
            i64ne: 1771,
            i32ne: 1162,
            i64lts: 1658,
            i32lts: 1007,
            i64ltu: 1647,
            i32ltu: 1067,
            i64gts: 1820,
            i32gts: 1009,
            i64gtu: 1687,
            i32gtu: 1079,
            i64les: 1699,
            i32les: 1084,
            i64leu: 1640,
            i32leu: 1021,
            i64ges: 1677,
            i32ges: 1074,
            i64geu: 1804,
            i32geu: 1139,
            i64add: 984,
            i32add: 492,
            i64sub: 1037,
            i32sub: 550,
            i64mul: 1818,
            i32mul: 841,
            i64divs: 3642,
            i32divs: 2612,
            i64divu: 3825,
            i32divu: 2672,
            i64rems: 19964,
            i32rems: 14516,
            i64remu: 3854,
            i32remu: 2541,
            i64and: 1133,
            i32and: 457,
            i64or: 833,
            i32or: 447,
            i64xor: 954,
            i32xor: 592,
            i64shl: 713,
            i32shl: 198,
            i64shrs: 719,
            i32shrs: 206,
            i64shru: 841,
            i32shru: 201,
            i64rotl: 711,
            i32rotl: 224,
            i64rotr: 763,
            i32rotr: 288,
        }
    }
}

#[derive(Debug, Clone)]
#[doc = " Describes the weight for each imported function that a program is allowed to call."]
pub struct SyscallWeights {
    #[doc = " Weight of calling `alloc`."]
    pub alloc: Weight,
    #[doc = " Weight of calling `free`."]
    pub free: Weight,
    #[doc = " Weight of calling `free_range`."]
    pub free_range: Weight,
    #[doc = " Weight of calling `free_range` per page."]
    pub free_range_per_page: Weight,
    #[doc = " Weight of calling `gr_reserve_gas`."]
    pub gr_reserve_gas: Weight,
    #[doc = " Weight of calling `gr_unreserve_gas`"]
    pub gr_unreserve_gas: Weight,
    #[doc = " Weight of calling `gr_system_reserve_gas`"]
    pub gr_system_reserve_gas: Weight,
    #[doc = " Weight of calling `gr_gas_available`."]
    pub gr_gas_available: Weight,
    #[doc = " Weight of calling `gr_message_id`."]
    pub gr_message_id: Weight,
    #[doc = " Weight of calling `gr_program_id`."]
    pub gr_program_id: Weight,
    #[doc = " Weight of calling `gr_source`."]
    pub gr_source: Weight,
    #[doc = " Weight of calling `gr_value`."]
    pub gr_value: Weight,
    #[doc = " Weight of calling `gr_value_available`."]
    pub gr_value_available: Weight,
    #[doc = " Weight of calling `gr_size`."]
    pub gr_size: Weight,
    #[doc = " Weight of calling `gr_read`."]
    pub gr_read: Weight,
    #[doc = " Weight per payload byte by `gr_read`."]
    pub gr_read_per_byte: Weight,
    #[doc = " Weight of calling `gr_env_vars`."]
    pub gr_env_vars: Weight,
    #[doc = " Weight of calling `gr_block_height`."]
    pub gr_block_height: Weight,
    #[doc = " Weight of calling `gr_block_timestamp`."]
    pub gr_block_timestamp: Weight,
    #[doc = " Weight of calling `gr_random`."]
    pub gr_random: Weight,
    #[doc = " Weight of calling `gr_reply_deposit`."]
    pub gr_reply_deposit: Weight,
    #[doc = " Weight of calling `gr_send`."]
    pub gr_send: Weight,
    #[doc = " Weight per payload byte in `gr_send`."]
    pub gr_send_per_byte: Weight,
    #[doc = " Weight of calling `gr_send_wgas`."]
    pub gr_send_wgas: Weight,
    #[doc = " Weight per payload byte in `gr_send_wgas`."]
    pub gr_send_wgas_per_byte: Weight,
    #[doc = " Weight of calling `gr_value_available`."]
    pub gr_send_init: Weight,
    #[doc = " Weight of calling `gr_send_push`."]
    pub gr_send_push: Weight,
    #[doc = " Weight per payload byte by `gr_send_push`."]
    pub gr_send_push_per_byte: Weight,
    #[doc = " Weight of calling `gr_send_commit`."]
    pub gr_send_commit: Weight,
    #[doc = " Weight of calling `gr_send_commit_wgas`."]
    pub gr_send_commit_wgas: Weight,
    #[doc = " Weight of calling `gr_reservation_send`."]
    pub gr_reservation_send: Weight,
    #[doc = " Weight per payload byte in `gr_reservation_send`."]
    pub gr_reservation_send_per_byte: Weight,
    #[doc = " Weight of calling `gr_reservation_send_commit`."]
    pub gr_reservation_send_commit: Weight,
    #[doc = " Weight of calling `gr_reply_commit`."]
    pub gr_reply_commit: Weight,
    #[doc = " Weight of calling `gr_reply_commit_wgas`."]
    pub gr_reply_commit_wgas: Weight,
    #[doc = " Weight of calling `gr_reservation_reply`."]
    pub gr_reservation_reply: Weight,
    #[doc = " Weight of calling `gr_reservation_reply` per one payload byte."]
    pub gr_reservation_reply_per_byte: Weight,
    #[doc = " Weight of calling `gr_reservation_reply_commit`."]
    pub gr_reservation_reply_commit: Weight,
    #[doc = " Weight of calling `gr_reply_push`."]
    pub gr_reply_push: Weight,
    #[doc = " Weight of calling `gr_reply`."]
    pub gr_reply: Weight,
    #[doc = " Weight of calling `gr_reply` per one payload byte."]
    pub gr_reply_per_byte: Weight,
    #[doc = " Weight of calling `gr_reply_wgas`."]
    pub gr_reply_wgas: Weight,
    #[doc = " Weight of calling `gr_reply_wgas` per one payload byte."]
    pub gr_reply_wgas_per_byte: Weight,
    #[doc = " Weight per payload byte by `gr_reply_push`."]
    pub gr_reply_push_per_byte: Weight,
    #[doc = " Weight of calling `gr_reply_to`."]
    pub gr_reply_to: Weight,
    #[doc = " Weight of calling `gr_signal_code`."]
    pub gr_signal_code: Weight,
    #[doc = " Weight of calling `gr_signal_from`."]
    pub gr_signal_from: Weight,
    #[doc = " Weight of calling `gr_reply_input`."]
    pub gr_reply_input: Weight,
    #[doc = " Weight of calling `gr_reply_input_wgas`."]
    pub gr_reply_input_wgas: Weight,
    #[doc = " Weight of calling `gr_reply_push_input`."]
    pub gr_reply_push_input: Weight,
    #[doc = " Weight per payload byte by `gr_reply_push_input`."]
    pub gr_reply_push_input_per_byte: Weight,
    #[doc = " Weight of calling `gr_send_input`."]
    pub gr_send_input: Weight,
    #[doc = " Weight of calling `gr_send_input_wgas`."]
    pub gr_send_input_wgas: Weight,
    #[doc = " Weight of calling `gr_send_push_input`."]
    pub gr_send_push_input: Weight,
    #[doc = " Weight per payload byte by `gr_send_push_input`."]
    pub gr_send_push_input_per_byte: Weight,
    #[doc = " Weight of calling `gr_debug`."]
    pub gr_debug: Weight,
    #[doc = " Weight per payload byte by `gr_debug_per_byte`."]
    pub gr_debug_per_byte: Weight,
    #[doc = " Weight of calling `gr_reply_code`."]
    pub gr_reply_code: Weight,
    #[doc = " Weight of calling `gr_exit`."]
    pub gr_exit: Weight,
    #[doc = " Weight of calling `gr_leave`."]
    pub gr_leave: Weight,
    #[doc = " Weight of calling `gr_wait`."]
    pub gr_wait: Weight,
    #[doc = " Weight of calling `gr_wait_for`."]
    pub gr_wait_for: Weight,
    #[doc = " Weight of calling `gr_wait_up_to`."]
    pub gr_wait_up_to: Weight,
    #[doc = " Weight of calling `gr_wake`."]
    pub gr_wake: Weight,
    #[doc = " Weight of calling `gr_create_program`."]
    pub gr_create_program: Weight,
    #[doc = " Weight per payload byte in `gr_create_program`."]
    pub gr_create_program_payload_per_byte: Weight,
    #[doc = " Weight per salt byte in `gr_create_program`"]
    pub gr_create_program_salt_per_byte: Weight,
    #[doc = " Weight of calling `create_program_wgas`."]
    pub gr_create_program_wgas: Weight,
    #[doc = " Weight per payload byte by `create_program_wgas`."]
    pub gr_create_program_wgas_payload_per_byte: Weight,
    #[doc = " Weight per salt byte by `create_program_wgas`."]
    pub gr_create_program_wgas_salt_per_byte: Weight,
}

impl Default for SyscallWeights {
    fn default() -> Self {
        Self {
            alloc: Weight {
                ref_time: 1920272,
                proof_size: 0,
            },
            free: Weight {
                ref_time: 1092586,
                proof_size: 0,
            },
            free_range: Weight {
                ref_time: 1110471,
                proof_size: 0,
            },
            free_range_per_page: Weight {
                ref_time: 47342,
                proof_size: 0,
            },
            gr_reserve_gas: Weight {
                ref_time: 2670085,
                proof_size: 0,
            },
            gr_unreserve_gas: Weight {
                ref_time: 2734271,
                proof_size: 0,
            },
            gr_system_reserve_gas: Weight {
                ref_time: 1319754,
                proof_size: 0,
            },
            gr_gas_available: Weight {
                ref_time: 1145028,
                proof_size: 0,
            },
            gr_message_id: Weight {
                ref_time: 1162103,
                proof_size: 0,
            },
            gr_program_id: Weight {
                ref_time: 1135148,
                proof_size: 0,
            },
            gr_source: Weight {
                ref_time: 1146591,
                proof_size: 0,
            },
            gr_value: Weight {
                ref_time: 1155786,
                proof_size: 0,
            },
            gr_value_available: Weight {
                ref_time: 1280202,
                proof_size: 0,
            },
            gr_size: Weight {
                ref_time: 1136229,
                proof_size: 0,
            },
            gr_read: Weight {
                ref_time: 2182474,
                proof_size: 0,
            },
            gr_read_per_byte: Weight {
                ref_time: 205,
                proof_size: 0,
            },
            gr_env_vars: Weight {
                ref_time: 1423916,
                proof_size: 0,
            },
            gr_block_height: Weight {
                ref_time: 1269836,
                proof_size: 0,
            },
            gr_block_timestamp: Weight {
                ref_time: 1160379,
                proof_size: 0,
            },
            gr_random: Weight {
                ref_time: 2357705,
                proof_size: 0,
            },
            gr_reply_deposit: Weight {
                ref_time: 6140059,
                proof_size: 0,
            },
            gr_send: Weight {
                ref_time: 3466148,
                proof_size: 0,
            },
            gr_send_per_byte: Weight {
                ref_time: 554,
                proof_size: 0,
            },
            gr_send_wgas: Weight {
                ref_time: 3513164,
                proof_size: 0,
            },
            gr_send_wgas_per_byte: Weight {
                ref_time: 556,
                proof_size: 0,
            },
            gr_send_init: Weight {
                ref_time: 1288058,
                proof_size: 0,
            },
            gr_send_push: Weight {
                ref_time: 2388429,
                proof_size: 0,
            },
            gr_send_push_per_byte: Weight {
                ref_time: 556,
                proof_size: 0,
            },
            gr_send_commit: Weight {
                ref_time: 2883535,
                proof_size: 0,
            },
            gr_send_commit_wgas: Weight {
                ref_time: 2979813,
                proof_size: 0,
            },
            gr_reservation_send: Weight {
                ref_time: 4058338,
                proof_size: 0,
            },
            gr_reservation_send_per_byte: Weight {
                ref_time: 539,
                proof_size: 0,
            },
            gr_reservation_send_commit: Weight {
                ref_time: 3524780,
                proof_size: 0,
            },
            gr_reply_commit: Weight {
                ref_time: 13221664,
                proof_size: 0,
            },
            gr_reply_commit_wgas: Weight {
                ref_time: 13147416,
                proof_size: 0,
            },
            gr_reservation_reply: Weight {
                ref_time: 9823620,
                proof_size: 0,
            },
            gr_reservation_reply_per_byte: Weight {
                ref_time: 803373,
                proof_size: 0,
            },
            gr_reservation_reply_commit: Weight {
                ref_time: 9709446,
                proof_size: 0,
            },
            gr_reply_push: Weight {
                ref_time: 2048771,
                proof_size: 0,
            },
            gr_reply: Weight {
                ref_time: 14931672,
                proof_size: 0,
            },
            gr_reply_per_byte: Weight {
                ref_time: 799,
                proof_size: 0,
            },
            gr_reply_wgas: Weight {
                ref_time: 19273312,
                proof_size: 0,
            },
            gr_reply_wgas_per_byte: Weight {
                ref_time: 795,
                proof_size: 0,
            },
            gr_reply_push_per_byte: Weight {
                ref_time: 731,
                proof_size: 0,
            },
            gr_reply_to: Weight {
                ref_time: 1206031,
                proof_size: 0,
            },
            gr_signal_code: Weight {
                ref_time: 1163371,
                proof_size: 0,
            },
            gr_signal_from: Weight {
                ref_time: 1211220,
                proof_size: 0,
            },
            gr_reply_input: Weight {
                ref_time: 17861142,
                proof_size: 0,
            },
            gr_reply_input_wgas: Weight {
                ref_time: 8281780,
                proof_size: 0,
            },
            gr_reply_push_input: Weight {
                ref_time: 1420010,
                proof_size: 0,
            },
            gr_reply_push_input_per_byte: Weight {
                ref_time: 171,
                proof_size: 0,
            },
            gr_send_input: Weight {
                ref_time: 3389148,
                proof_size: 0,
            },
            gr_send_input_wgas: Weight {
                ref_time: 3433164,
                proof_size: 0,
            },
            gr_send_push_input: Weight {
                ref_time: 1853427,
                proof_size: 0,
            },
            gr_send_push_input_per_byte: Weight {
                ref_time: 184,
                proof_size: 0,
            },
            gr_debug: Weight {
                ref_time: 1514473,
                proof_size: 0,
            },
            gr_debug_per_byte: Weight {
                ref_time: 488,
                proof_size: 0,
            },
            gr_reply_code: Weight {
                ref_time: 1159603,
                proof_size: 0,
            },
            gr_exit: Weight {
                ref_time: 21601724,
                proof_size: 0,
            },
            gr_leave: Weight {
                ref_time: 17362098,
                proof_size: 0,
            },
            gr_wait: Weight {
                ref_time: 16620354,
                proof_size: 0,
            },
            gr_wait_for: Weight {
                ref_time: 17483266,
                proof_size: 0,
            },
            gr_wait_up_to: Weight {
                ref_time: 17329450,
                proof_size: 0,
            },
            gr_wake: Weight {
                ref_time: 3799288,
                proof_size: 0,
            },
            gr_create_program: Weight {
                ref_time: 4256142,
                proof_size: 0,
            },
            gr_create_program_payload_per_byte: Weight {
                ref_time: 118,
                proof_size: 0,
            },
            gr_create_program_salt_per_byte: Weight {
                ref_time: 1611,
                proof_size: 0,
            },
            gr_create_program_wgas: Weight {
                ref_time: 4339280,
                proof_size: 0,
            },
            gr_create_program_wgas_payload_per_byte: Weight {
                ref_time: 133,
                proof_size: 0,
            },
            gr_create_program_wgas_salt_per_byte: Weight {
                ref_time: 1591,
                proof_size: 0,
            },
        }
    }
}

#[derive(Debug, Clone)]
#[doc = " Describes the weight for memory interaction."]
#[doc = ""]
#[doc = " Each weight with `lazy_pages_` prefix includes weight for storage read,"]
#[doc = " because for each first page access we need to at least check whether page exists in storage."]
#[doc = " But they do not include cost for loading page data from storage into program memory."]
#[doc = " This weight is taken in account separately, when loading occurs."]
#[doc = ""]
#[doc = " Lazy-pages write accesses does not include cost for uploading page data to storage,"]
#[doc = " because uploading happens after execution, so benchmarks do not include this cost."]
#[doc = " But they include cost for processing changed page data in runtime."]
pub struct MemoryWeights {
    #[doc = " Cost per one [GearPage] signal `read` processing in lazy-pages,"]
    pub lazy_pages_signal_read: Weight,
    #[doc = " Cost per one [GearPage] signal `write` processing in lazy-pages,"]
    pub lazy_pages_signal_write: Weight,
    #[doc = " Cost per one [GearPage] signal `write after read` processing in lazy-pages,"]
    pub lazy_pages_signal_write_after_read: Weight,
    #[doc = " Cost per one [GearPage] host func `read` access processing in lazy-pages,"]
    pub lazy_pages_host_func_read: Weight,
    #[doc = " Cost per one [GearPage] host func `write` access processing in lazy-pages,"]
    pub lazy_pages_host_func_write: Weight,
    #[doc = " Cost per one [GearPage] host func `write after read` access processing in lazy-pages,"]
    pub lazy_pages_host_func_write_after_read: Weight,
    #[doc = " Cost per one [GearPage] data loading from storage and moving it in program memory."]
    #[doc = " Does not include cost for storage read, because it is taken in account separately."]
    pub load_page_data: Weight,
    #[doc = " Cost per one [GearPage] uploading data to storage."]
    #[doc = " Does not include cost for processing changed page data in runtime,"]
    #[doc = " cause it is taken in account separately."]
    pub upload_page_data: Weight,
    #[doc = " Cost per one [WasmPage] for memory growing."]
    pub mem_grow: Weight,
    #[doc = " Cost per one [WasmPage] for memory growing."]
    pub mem_grow_per_page: Weight,
    #[doc = " Cost per one [GearPage]."]
    #[doc = " When we read page data from storage in para-chain, then it should be sent to relay-chain,"]
    #[doc = " in order to use it for process queue execution. So, reading from storage cause"]
    #[doc = " additional resources consumption after block(s) production on para-chain."]
    pub parachain_read_heuristic: Weight,
}

impl Default for MemoryWeights {
    fn default() -> Self {
        Self {
            lazy_pages_signal_read: Weight {
                ref_time: 29095435,
                proof_size: 0,
            },
            lazy_pages_signal_write: Weight {
                ref_time: 35715357,
                proof_size: 0,
            },
            lazy_pages_signal_write_after_read: Weight {
                ref_time: 10357154,
                proof_size: 0,
            },
            lazy_pages_host_func_read: Weight {
                ref_time: 30654828,
                proof_size: 0,
            },
            lazy_pages_host_func_write: Weight {
                ref_time: 38272235,
                proof_size: 0,
            },
            lazy_pages_host_func_write_after_read: Weight {
                ref_time: 12852610,
                proof_size: 0,
            },
            load_page_data: Weight {
                ref_time: 10702585,
                proof_size: 0,
            },
            upload_page_data: Weight {
                ref_time: 104433184,
                proof_size: 0,
            },
            mem_grow: Weight {
                ref_time: 712693,
                proof_size: 0,
            },
            mem_grow_per_page: Weight {
                ref_time: 4,
                proof_size: 0,
            },
            parachain_read_heuristic: Weight {
                ref_time: 0,
                proof_size: 0,
            },
        }
    }
}

#[derive(Debug, Clone)]
#[doc = " Describes the weight for instantiation of the module."]
pub struct InstantiationWeights {
    #[doc = " WASM module code section instantiation per byte cost."]
    pub code_section_per_byte: Weight,
    #[doc = " WASM module data section instantiation per byte cost."]
    pub data_section_per_byte: Weight,
    #[doc = " WASM module global section instantiation per byte cost."]
    pub global_section_per_byte: Weight,
    #[doc = " WASM module table section instantiation per byte cost."]
    pub table_section_per_byte: Weight,
    #[doc = " WASM module element section instantiation per byte cost."]
    pub element_section_per_byte: Weight,
    #[doc = " WASM module type section instantiation per byte cost."]
    pub type_section_per_byte: Weight,
}

impl Default for InstantiationWeights {
    fn default() -> Self {
        Self {
            code_section_per_byte: Weight {
                ref_time: 2582,
                proof_size: 0,
            },
            data_section_per_byte: Weight {
                ref_time: 595,
                proof_size: 0,
            },
            global_section_per_byte: Weight {
                ref_time: 2400,
                proof_size: 0,
            },
            table_section_per_byte: Weight {
                ref_time: 651,
                proof_size: 0,
            },
            element_section_per_byte: Weight {
                ref_time: 2523,
                proof_size: 0,
            },
            type_section_per_byte: Weight {
                ref_time: 18285,
                proof_size: 0,
            },
        }
    }
}

#[derive(Debug, Clone)]
#[doc = " Describes the weight for renting."]
pub struct RentWeights {
    #[doc = " Holding message in waitlist weight."]
    pub waitlist: Weight,
    #[doc = " Holding message in dispatch stash weight."]
    pub dispatch_stash: Weight,
    #[doc = " Holding reservation weight."]
    pub reservation: Weight,
    #[doc = " Holding message in mailbox weight."]
    pub mailbox: Weight,
    #[doc = " The minimal gas amount for message to be inserted in mailbox."]
    pub mailbox_threshold: Weight,
}

impl Default for RentWeights {
    fn default() -> Self {
        Self {
            waitlist: Weight {
                ref_time: 100,
                proof_size: 0,
            },
            dispatch_stash: Weight {
                ref_time: 100,
                proof_size: 0,
            },
            reservation: Weight {
                ref_time: 100,
                proof_size: 0,
            },
            mailbox: Weight {
                ref_time: 100,
                proof_size: 0,
            },
            mailbox_threshold: Weight {
                ref_time: 3000,
                proof_size: 0,
            },
        }
    }
}

#[derive(Debug, Clone)]
#[doc = " Describes DB access weights."]
pub struct DbWeights {
    pub read: Weight,
    pub read_per_byte: Weight,
    pub write: Weight,
    pub write_per_byte: Weight,
}

impl Default for DbWeights {
    fn default() -> Self {
        Self {
            read: Weight {
                ref_time: 25000000,
                proof_size: 0,
            },
            read_per_byte: Weight {
                ref_time: 687,
                proof_size: 0,
            },
            write: Weight {
                ref_time: 100000000,
                proof_size: 0,
            },
            write_per_byte: Weight {
                ref_time: 270,
                proof_size: 0,
            },
        }
    }
}

#[derive(Debug, Clone)]
#[doc = " Describes weights for running tasks."]
pub struct TaskWeights {
    pub remove_gas_reservation: Weight,
    pub send_user_message_to_mailbox: Weight,
    pub send_user_message: Weight,
    pub send_dispatch: Weight,
    pub wake_message: Weight,
    pub wake_message_no_wake: Weight,
    pub remove_from_waitlist: Weight,
    pub remove_from_mailbox: Weight,
}

impl Default for TaskWeights {
    fn default() -> Self {
        Self {
            remove_gas_reservation: Weight {
                ref_time: 935038000,
                proof_size: 6196,
            },
            send_user_message_to_mailbox: Weight {
                ref_time: 712947000,
                proof_size: 4323,
            },
            send_user_message: Weight {
                ref_time: 1450225000,
                proof_size: 6196,
            },
            send_dispatch: Weight {
                ref_time: 817079000,
                proof_size: 4159,
            },
            wake_message: Weight {
                ref_time: 859250000,
                proof_size: 4404,
            },
            wake_message_no_wake: Weight {
                ref_time: 31951000,
                proof_size: 3545,
            },
            remove_from_waitlist: Weight {
                ref_time: 1886527000,
                proof_size: 7611,
            },
            remove_from_mailbox: Weight {
                ref_time: 1844454000,
                proof_size: 7338,
            },
        }
    }
}

#[doc = r" Represents the computational time and storage space required for an operation."]
#[derive(Debug, Clone, Copy)]
pub struct Weight {
    #[doc = r" The weight of computational time used based on some reference hardware."]
    pub ref_time: u64,
    #[doc = r" The weight of storage space used by proof of validity."]
    pub proof_size: u64,
}

impl Weight {
    #[doc = r" Return the reference time part of the weight."]
    #[doc(hidden)]
    pub const fn ref_time(&self) -> u64 {
        self.ref_time
    }
    #[doc = r" Saturating [`Weight`] addition. Computes `self + rhs`, saturating at the numeric bounds of"]
    #[doc = r" all fields instead of overflowing."]
    #[doc(hidden)]
    pub const fn saturating_add(&self, other: Self) -> Self {
        Self {
            ref_time: self.ref_time.saturating_add(other.ref_time),
            proof_size: self.proof_size.saturating_add(other.proof_size),
        }
    }
}

impl From<SyscallWeights> for SyscallCosts {
    fn from(val: SyscallWeights) -> Self {
        Self {
            alloc: val.alloc.ref_time().into(),
            free: val.free.ref_time().into(),
            free_range: val.free_range.ref_time().into(),
            free_range_per_page: val.free_range_per_page.ref_time().into(),
            gr_reserve_gas: val.gr_reserve_gas.ref_time().into(),
            gr_unreserve_gas: val.gr_unreserve_gas.ref_time().into(),
            gr_system_reserve_gas: val.gr_system_reserve_gas.ref_time().into(),
            gr_gas_available: val.gr_gas_available.ref_time().into(),
            gr_message_id: val.gr_message_id.ref_time().into(),
            gr_program_id: val.gr_program_id.ref_time().into(),
            gr_source: val.gr_source.ref_time().into(),
            gr_value: val.gr_value.ref_time().into(),
            gr_value_available: val.gr_value_available.ref_time().into(),
            gr_size: val.gr_size.ref_time().into(),
            gr_read: val.gr_read.ref_time().into(),
            gr_read_per_byte: val.gr_read_per_byte.ref_time().into(),
            gr_env_vars: val.gr_env_vars.ref_time().into(),
            gr_block_height: val.gr_block_height.ref_time().into(),
            gr_block_timestamp: val.gr_block_timestamp.ref_time().into(),
            gr_random: val.gr_random.ref_time().into(),
            gr_reply_deposit: val.gr_reply_deposit.ref_time().into(),
            gr_send: val.gr_send.ref_time().into(),
            gr_send_per_byte: val.gr_send_per_byte.ref_time().into(),
            gr_send_wgas: val.gr_send_wgas.ref_time().into(),
            gr_send_wgas_per_byte: val.gr_send_wgas_per_byte.ref_time().into(),
            gr_send_init: val.gr_send_init.ref_time().into(),
            gr_send_push: val.gr_send_push.ref_time().into(),
            gr_send_push_per_byte: val.gr_send_push_per_byte.ref_time().into(),
            gr_send_commit: val.gr_send_commit.ref_time().into(),
            gr_send_commit_wgas: val.gr_send_commit_wgas.ref_time().into(),
            gr_reservation_send: val.gr_reservation_send.ref_time().into(),
            gr_reservation_send_per_byte: val.gr_reservation_send_per_byte.ref_time().into(),
            gr_reservation_send_commit: val.gr_reservation_send_commit.ref_time().into(),
            gr_send_input: val.gr_send_input.ref_time().into(),
            gr_send_input_wgas: val.gr_send_input_wgas.ref_time().into(),
            gr_send_push_input: val.gr_send_push_input.ref_time().into(),
            gr_send_push_input_per_byte: val.gr_send_push_input_per_byte.ref_time().into(),
            gr_reply: val.gr_reply.ref_time().into(),
            gr_reply_per_byte: val.gr_reply_per_byte.ref_time().into(),
            gr_reply_wgas: val.gr_reply_wgas.ref_time().into(),
            gr_reply_wgas_per_byte: val.gr_reply_wgas_per_byte.ref_time().into(),
            gr_reply_push: val.gr_reply_push.ref_time().into(),
            gr_reply_push_per_byte: val.gr_reply_push_per_byte.ref_time().into(),
            gr_reply_commit: val.gr_reply_commit.ref_time().into(),
            gr_reply_commit_wgas: val.gr_reply_commit_wgas.ref_time().into(),
            gr_reservation_reply: val.gr_reservation_reply.ref_time().into(),
            gr_reservation_reply_per_byte: val.gr_reservation_reply_per_byte.ref_time().into(),
            gr_reservation_reply_commit: val.gr_reservation_reply_commit.ref_time().into(),
            gr_reply_input: val.gr_reply_input.ref_time().into(),
            gr_reply_input_wgas: val.gr_reply_input_wgas.ref_time().into(),
            gr_reply_push_input: val.gr_reply_push_input.ref_time().into(),
            gr_reply_push_input_per_byte: val.gr_reply_push_input_per_byte.ref_time().into(),
            gr_debug: val.gr_debug.ref_time().into(),
            gr_debug_per_byte: val.gr_debug_per_byte.ref_time().into(),
            gr_reply_to: val.gr_reply_to.ref_time().into(),
            gr_signal_code: val.gr_signal_code.ref_time().into(),
            gr_signal_from: val.gr_signal_from.ref_time().into(),
            gr_reply_code: val.gr_reply_code.ref_time().into(),
            gr_exit: val.gr_exit.ref_time().into(),
            gr_leave: val.gr_leave.ref_time().into(),
            gr_wait: val.gr_wait.ref_time().into(),
            gr_wait_for: val.gr_wait_for.ref_time().into(),
            gr_wait_up_to: val.gr_wait_up_to.ref_time().into(),
            gr_wake: val.gr_wake.ref_time().into(),
            gr_create_program: val.gr_create_program.ref_time().into(),
            gr_create_program_payload_per_byte: val
                .gr_create_program_payload_per_byte
                .ref_time()
                .into(),
            gr_create_program_salt_per_byte: val.gr_create_program_salt_per_byte.ref_time().into(),
            gr_create_program_wgas: val.gr_create_program_wgas.ref_time().into(),
            gr_create_program_wgas_payload_per_byte: val
                .gr_create_program_wgas_payload_per_byte
                .ref_time()
                .into(),
            gr_create_program_wgas_salt_per_byte: val
                .gr_create_program_wgas_salt_per_byte
                .ref_time()
                .into(),
        }
    }
}

impl From<MemoryWeights> for LazyPagesCosts {
    fn from(val: MemoryWeights) -> Self {
        Self {
            signal_read: val.lazy_pages_signal_read.ref_time().into(),
            signal_write: val
                .lazy_pages_signal_write
                .saturating_add(val.upload_page_data)
                .ref_time()
                .into(),
            signal_write_after_read: val
                .lazy_pages_signal_write_after_read
                .saturating_add(val.upload_page_data)
                .ref_time()
                .into(),
            host_func_read: val.lazy_pages_host_func_read.ref_time().into(),
            host_func_write: val
                .lazy_pages_host_func_write
                .saturating_add(val.upload_page_data)
                .ref_time()
                .into(),
            host_func_write_after_read: val
                .lazy_pages_host_func_write_after_read
                .saturating_add(val.upload_page_data)
                .ref_time()
                .into(),
            load_page_storage_data: val
                .load_page_data
                .saturating_add(val.parachain_read_heuristic)
                .ref_time()
                .into(),
        }
    }
}

impl From<RentWeights> for RentCosts {
    fn from(val: RentWeights) -> Self {
        Self {
            waitlist: val.waitlist.ref_time().into(),
            dispatch_stash: val.dispatch_stash.ref_time().into(),
            reservation: val.reservation.ref_time().into(),
        }
    }
}

impl From<InstantiationWeights> for InstantiationCosts {
    fn from(val: InstantiationWeights) -> Self {
        Self {
            code_section_per_byte: val.code_section_per_byte.ref_time().into(),
            data_section_per_byte: val.data_section_per_byte.ref_time().into(),
            global_section_per_byte: val.global_section_per_byte.ref_time().into(),
            table_section_per_byte: val.table_section_per_byte.ref_time().into(),
            element_section_per_byte: val.element_section_per_byte.ref_time().into(),
            type_section_per_byte: val.type_section_per_byte.ref_time().into(),
        }
    }
}

impl Schedule {
    pub fn process_costs(&self) -> ProcessCosts {
        ProcessCosts {
            ext: ExtCosts {
                syscalls: self.syscall_weights.clone().into(),
                rent: self.rent_weights.clone().into(),
                mem_grow: self.memory_weights.mem_grow.ref_time().into(),
                mem_grow_per_page: self.memory_weights.mem_grow_per_page.ref_time().into(),
            },
            lazy_pages: self.memory_weights.clone().into(),
            read: self.db_weights.read.ref_time().into(),
            read_per_byte: self.db_weights.read_per_byte.ref_time().into(),
            write: self.db_weights.write.ref_time().into(),
            instrumentation: self.code_instrumentation_cost.ref_time().into(),
            instrumentation_per_byte: self.code_instrumentation_byte_cost.ref_time().into(),
            instantiation_costs: self.instantiation_weights.clone().into(),
            load_allocations_per_interval: self.load_allocations_weight.ref_time().into(),
        }
    }
}