Source file constants_repr.ml
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
let fitness_version_number = "\002"
let proof_of_work_nonce_size = 8
let nonce_length = 32
let max_anon_ops_per_block = 132
let max_proposals_per_delegate = 20
let max_operation_data_length = 32 * 1024
let max_micheline_node_count = 50_000
let max_micheline_bytes_limit = 50_000
let max_allowed_global_constant_depth = 10_000
let michelson_maximum_type_size = 2001
let cache_layout_size = 3
type fixed = unit
type ratio = {numerator : int; denominator : int}
let ratio_encoding =
let open Data_encoding in
conv_with_guard
(fun r -> (r.numerator, r.denominator))
(fun (numerator, denominator) ->
if Compare.Int.(denominator > 0) then ok {numerator; denominator}
else Error "The denominator must be greater than 0.")
(obj2 (req "numerator" uint16) (req "denominator" uint16))
let pp_ratio fmt {numerator; denominator} =
Format.fprintf fmt "%d/%d" numerator denominator
let fixed_encoding =
let open Data_encoding in
conv
(fun () ->
( proof_of_work_nonce_size,
nonce_length,
max_anon_ops_per_block,
max_operation_data_length,
max_proposals_per_delegate,
max_micheline_node_count,
max_micheline_bytes_limit,
max_allowed_global_constant_depth,
cache_layout_size,
michelson_maximum_type_size ))
(fun ( _proof_of_work_nonce_size,
_nonce_length,
_max_anon_ops_per_block,
_max_operation_data_length,
_max_proposals_per_delegate,
_max_micheline_node_count,
_max_micheline_bytes_limit,
_max_allowed_global_constant_depth,
_cache_layout_size,
_michelson_maximum_type_size ) -> ())
(obj10
(req "proof_of_work_nonce_size" uint8)
(req "nonce_length" uint8)
(req "max_anon_ops_per_block" uint8)
(req "max_operation_data_length" int31)
(req "max_proposals_per_delegate" uint8)
(req "max_micheline_node_count" int31)
(req "max_micheline_bytes_limit" int31)
(req "max_allowed_global_constants_depth" int31)
(req "cache_layout_size" uint8)
(req "michelson_maximum_type_size" uint16))
let fixed = ()
type parametric = {
preserved_cycles : int;
blocks_per_cycle : int32;
blocks_per_commitment : int32;
blocks_per_stake_snapshot : int32;
cycles_per_voting_period : int32;
hard_gas_limit_per_operation : Gas_limit_repr.Arith.integral;
hard_gas_limit_per_block : Gas_limit_repr.Arith.integral;
proof_of_work_threshold : int64;
tokens_per_roll : Tez_repr.t;
seed_nonce_revelation_tip : Tez_repr.t;
origination_size : int;
baking_reward_fixed_portion : Tez_repr.t;
baking_reward_bonus_per_slot : Tez_repr.t;
endorsing_reward_per_slot : Tez_repr.t;
cost_per_byte : Tez_repr.t;
hard_storage_limit_per_operation : Z.t;
quorum_min : int32;
quorum_max : int32;
min_proposal_quorum : int32;
liquidity_baking_subsidy : Tez_repr.t;
liquidity_baking_sunset_level : int32;
liquidity_baking_toggle_ema_threshold : int32;
max_operations_time_to_live : int;
minimal_block_delay : Period_repr.t;
delay_increment_per_round : Period_repr.t;
minimal_participation_ratio : ratio;
consensus_committee_size : int;
consensus_threshold : int;
max_slashing_period : int;
frozen_deposits_percentage : int;
double_baking_punishment : Tez_repr.t;
ratio_of_frozen_deposits_slashed_per_double_endorsement : ratio;
initial_seed : State_hash.t option;
cache_script_size : int;
cache_stake_distribution_cycles : int;
cache_sampler_state_cycles : int;
tx_rollup_enable : bool;
tx_rollup_origination_size : int;
tx_rollup_hard_size_limit_per_inbox : int;
tx_rollup_hard_size_limit_per_message : int;
tx_rollup_commitment_bond : Tez_repr.t;
tx_rollup_finality_period : int;
tx_rollup_withdraw_period : int;
tx_rollup_max_inboxes_count : int;
tx_rollup_max_messages_per_inbox : int;
tx_rollup_max_commitments_count : int;
tx_rollup_cost_per_byte_ema_factor : int;
tx_rollup_max_ticket_payload_size : int;
tx_rollup_max_withdrawals_per_batch : int;
tx_rollup_rejection_max_proof_size : int;
tx_rollup_sunset_level : int32;
sc_rollup_enable : bool;
sc_rollup_origination_size : int;
sc_rollup_challenge_window_in_blocks : int;
sc_rollup_max_available_messages : int;
}
let parametric_encoding =
let open Data_encoding in
conv
(fun c ->
( ( c.preserved_cycles,
c.blocks_per_cycle,
c.blocks_per_commitment,
c.blocks_per_stake_snapshot,
c.cycles_per_voting_period,
c.hard_gas_limit_per_operation,
c.hard_gas_limit_per_block,
c.proof_of_work_threshold,
c.tokens_per_roll ),
( ( c.seed_nonce_revelation_tip,
c.origination_size,
c.baking_reward_fixed_portion,
c.baking_reward_bonus_per_slot,
c.endorsing_reward_per_slot,
c.cost_per_byte,
c.hard_storage_limit_per_operation,
c.quorum_min ),
( ( c.quorum_max,
c.min_proposal_quorum,
c.liquidity_baking_subsidy,
c.liquidity_baking_sunset_level,
c.liquidity_baking_toggle_ema_threshold,
c.max_operations_time_to_live,
c.minimal_block_delay,
c.delay_increment_per_round,
c.consensus_committee_size,
c.consensus_threshold ),
( ( c.minimal_participation_ratio,
c.max_slashing_period,
c.frozen_deposits_percentage,
c.double_baking_punishment,
c.ratio_of_frozen_deposits_slashed_per_double_endorsement,
c.initial_seed ),
( ( c.cache_script_size,
c.cache_stake_distribution_cycles,
c.cache_sampler_state_cycles ),
( ( ( c.tx_rollup_enable,
c.tx_rollup_origination_size,
c.tx_rollup_hard_size_limit_per_inbox,
c.tx_rollup_hard_size_limit_per_message,
c.tx_rollup_max_withdrawals_per_batch,
c.tx_rollup_commitment_bond,
c.tx_rollup_finality_period,
c.tx_rollup_withdraw_period,
c.tx_rollup_max_inboxes_count,
c.tx_rollup_max_messages_per_inbox ),
( c.tx_rollup_max_commitments_count,
c.tx_rollup_cost_per_byte_ema_factor,
c.tx_rollup_max_ticket_payload_size,
c.tx_rollup_rejection_max_proof_size,
c.tx_rollup_sunset_level ) ),
( c.sc_rollup_enable,
c.sc_rollup_origination_size,
c.sc_rollup_challenge_window_in_blocks,
c.sc_rollup_max_available_messages ) ) ) ) ) ) ))
(fun ( ( preserved_cycles,
blocks_per_cycle,
blocks_per_commitment,
blocks_per_stake_snapshot,
cycles_per_voting_period,
hard_gas_limit_per_operation,
hard_gas_limit_per_block,
proof_of_work_threshold,
tokens_per_roll ),
( ( seed_nonce_revelation_tip,
origination_size,
baking_reward_fixed_portion,
baking_reward_bonus_per_slot,
endorsing_reward_per_slot,
cost_per_byte,
hard_storage_limit_per_operation,
quorum_min ),
( ( quorum_max,
min_proposal_quorum,
liquidity_baking_subsidy,
liquidity_baking_sunset_level,
liquidity_baking_toggle_ema_threshold,
max_operations_time_to_live,
minimal_block_delay,
delay_increment_per_round,
consensus_committee_size,
consensus_threshold ),
( ( minimal_participation_ratio,
max_slashing_period,
frozen_deposits_percentage,
double_baking_punishment,
ratio_of_frozen_deposits_slashed_per_double_endorsement,
initial_seed ),
( ( cache_script_size,
cache_stake_distribution_cycles,
cache_sampler_state_cycles ),
( ( ( tx_rollup_enable,
tx_rollup_origination_size,
tx_rollup_hard_size_limit_per_inbox,
tx_rollup_hard_size_limit_per_message,
tx_rollup_max_withdrawals_per_batch,
tx_rollup_commitment_bond,
tx_rollup_finality_period,
tx_rollup_withdraw_period,
tx_rollup_max_inboxes_count,
tx_rollup_max_messages_per_inbox ),
( tx_rollup_max_commitments_count,
tx_rollup_cost_per_byte_ema_factor,
tx_rollup_max_ticket_payload_size,
tx_rollup_rejection_max_proof_size,
tx_rollup_sunset_level ) ),
( sc_rollup_enable,
sc_rollup_origination_size,
sc_rollup_challenge_window_in_blocks,
sc_rollup_max_available_messages ) ) ) ) ) ) ) ->
{
preserved_cycles;
blocks_per_cycle;
blocks_per_commitment;
blocks_per_stake_snapshot;
cycles_per_voting_period;
hard_gas_limit_per_operation;
hard_gas_limit_per_block;
proof_of_work_threshold;
tokens_per_roll;
seed_nonce_revelation_tip;
origination_size;
baking_reward_fixed_portion;
baking_reward_bonus_per_slot;
endorsing_reward_per_slot;
cost_per_byte;
hard_storage_limit_per_operation;
quorum_min;
quorum_max;
min_proposal_quorum;
liquidity_baking_subsidy;
liquidity_baking_sunset_level;
liquidity_baking_toggle_ema_threshold;
max_operations_time_to_live;
minimal_block_delay;
delay_increment_per_round;
minimal_participation_ratio;
max_slashing_period;
consensus_committee_size;
consensus_threshold;
frozen_deposits_percentage;
double_baking_punishment;
ratio_of_frozen_deposits_slashed_per_double_endorsement;
initial_seed;
cache_script_size;
cache_stake_distribution_cycles;
cache_sampler_state_cycles;
tx_rollup_enable;
tx_rollup_origination_size;
tx_rollup_hard_size_limit_per_inbox;
tx_rollup_hard_size_limit_per_message;
tx_rollup_max_withdrawals_per_batch;
tx_rollup_commitment_bond;
tx_rollup_finality_period;
tx_rollup_withdraw_period;
tx_rollup_max_inboxes_count;
tx_rollup_max_messages_per_inbox;
tx_rollup_max_commitments_count;
tx_rollup_cost_per_byte_ema_factor;
tx_rollup_max_ticket_payload_size;
tx_rollup_rejection_max_proof_size;
tx_rollup_sunset_level;
sc_rollup_enable;
sc_rollup_origination_size;
sc_rollup_challenge_window_in_blocks;
sc_rollup_max_available_messages;
})
(merge_objs
(obj9
(req "preserved_cycles" uint8)
(req "blocks_per_cycle" int32)
(req "blocks_per_commitment" int32)
(req "blocks_per_stake_snapshot" int32)
(req "cycles_per_voting_period" int32)
(req
"hard_gas_limit_per_operation"
Gas_limit_repr.Arith.z_integral_encoding)
(req
"hard_gas_limit_per_block"
Gas_limit_repr.Arith.z_integral_encoding)
(req "proof_of_work_threshold" int64)
(req "tokens_per_roll" Tez_repr.encoding))
(merge_objs
(obj8
(req "seed_nonce_revelation_tip" Tez_repr.encoding)
(req "origination_size" int31)
(req "baking_reward_fixed_portion" Tez_repr.encoding)
(req "baking_reward_bonus_per_slot" Tez_repr.encoding)
(req "endorsing_reward_per_slot" Tez_repr.encoding)
(req "cost_per_byte" Tez_repr.encoding)
(req "hard_storage_limit_per_operation" z)
(req "quorum_min" int32))
(merge_objs
(obj10
(req "quorum_max" int32)
(req "min_proposal_quorum" int32)
(req "liquidity_baking_subsidy" Tez_repr.encoding)
(req "liquidity_baking_sunset_level" int32)
(req "liquidity_baking_toggle_ema_threshold" int32)
(req "max_operations_time_to_live" int16)
(req "minimal_block_delay" Period_repr.encoding)
(req "delay_increment_per_round" Period_repr.encoding)
(req "consensus_committee_size" int31)
(req "consensus_threshold" int31))
(merge_objs
(obj6
(req "minimal_participation_ratio" ratio_encoding)
(req "max_slashing_period" int31)
(req "frozen_deposits_percentage" int31)
(req "double_baking_punishment" Tez_repr.encoding)
(req
"ratio_of_frozen_deposits_slashed_per_double_endorsement"
ratio_encoding)
(opt "initial_seed" State_hash.encoding))
(merge_objs
(obj3
(req "cache_script_size" int31)
(req "cache_stake_distribution_cycles" int8)
(req "cache_sampler_state_cycles" int8))
(merge_objs
(merge_objs
(obj10
(req "tx_rollup_enable" bool)
(req "tx_rollup_origination_size" int31)
(req "tx_rollup_hard_size_limit_per_inbox" int31)
(req "tx_rollup_hard_size_limit_per_message" int31)
(req "tx_rollup_max_withdrawals_per_batch" int31)
(req "tx_rollup_commitment_bond" Tez_repr.encoding)
(req "tx_rollup_finality_period" int31)
(req "tx_rollup_withdraw_period" int31)
(req "tx_rollup_max_inboxes_count" int31)
(req "tx_rollup_max_messages_per_inbox" int31))
(obj5
(req "tx_rollup_max_commitments_count" int31)
(req "tx_rollup_cost_per_byte_ema_factor" int31)
(req "tx_rollup_max_ticket_payload_size" int31)
(req "tx_rollup_rejection_max_proof_size" int31)
(req "tx_rollup_sunset_level" int32)))
(obj4
(req "sc_rollup_enable" bool)
(req "sc_rollup_origination_size" int31)
(req "sc_rollup_challenge_window_in_blocks" int31)
(req "sc_rollup_max_available_messages" int31))))))))
type t = {fixed : fixed; parametric : parametric}
let all_of_parametric parametric = {fixed; parametric}
let encoding =
let open Data_encoding in
conv
(fun {fixed; parametric} -> (fixed, parametric))
(fun (fixed, parametric) -> {fixed; parametric})
(merge_objs fixed_encoding parametric_encoding)
type error += Invalid_protocol_constants of string
let () =
register_error_kind
`Permanent
~id:"constants.invalid_protocol_constants"
~title:"Invalid protocol constants"
~description:"The provided protocol constants are not coherent."
~pp:(fun ppf reason ->
Format.fprintf ppf "Invalid protocol constants: %s" reason)
Data_encoding.(obj1 (req "reason" string))
(function Invalid_protocol_constants reason -> Some reason | _ -> None)
(fun reason -> Invalid_protocol_constants reason)
let check_constants constants =
error_unless
Period_repr.(constants.minimal_block_delay > zero)
(Invalid_protocol_constants
"The minimal block delay must be greater than zero")
>>? fun () ->
error_unless
Period_repr.(constants.delay_increment_per_round > zero)
(Invalid_protocol_constants
"The delay increment per round must be greater than zero")
>>? fun () ->
error_unless
Compare.Int.(constants.consensus_committee_size > 0)
(Invalid_protocol_constants
"The consensus committee size must be strictly greater than 0.")
>>? fun () ->
error_unless
Compare.Int.(
constants.consensus_threshold >= 0
&& constants.consensus_threshold <= constants.consensus_committee_size)
(Invalid_protocol_constants
"The consensus threshold must be greater than or equal to 0 and less \
than or equal to the consensus commitee size.")
>>? fun () ->
error_unless
(let {numerator; denominator} = constants.minimal_participation_ratio in
Compare.Int.(numerator >= 0 && denominator > 0))
(Invalid_protocol_constants
"The minimal participation ratio must be a non-negative valid ratio.")
>>? fun () ->
error_unless
Compare.Int.(
constants.minimal_participation_ratio.numerator
<= constants.minimal_participation_ratio.denominator)
(Invalid_protocol_constants
"The minimal participation ratio must be less than or equal to 100%.")
>>? fun () ->
error_unless
Compare.Int.(constants.max_slashing_period > 0)
(Invalid_protocol_constants
"The unfreeze delay must be strictly greater than 0.")
>>? fun () ->
error_unless
Compare.Int.(
constants.frozen_deposits_percentage > 0
&& constants.frozen_deposits_percentage <= 100)
(Invalid_protocol_constants
"The frozen percentage ratio must be strictly greater than 0 and less \
or equal than 100.")
>>? fun () ->
error_unless
Tez_repr.(constants.double_baking_punishment >= zero)
(Invalid_protocol_constants
"The double baking punishment must be non-negative.")
>>? fun () ->
error_unless
(let {numerator; denominator} =
constants.ratio_of_frozen_deposits_slashed_per_double_endorsement
in
Compare.Int.(numerator >= 0 && denominator > 0))
(Invalid_protocol_constants
"The ratio of frozen deposits ratio slashed per double endorsement must \
be a non-negative valid ratio.")
>>? fun () ->
error_unless
(let snapshot_frequence =
Int32.div constants.blocks_per_cycle constants.blocks_per_stake_snapshot
in
Compare.Int32.(
snapshot_frequence > Int32.zero
&& snapshot_frequence < Int32.of_int (1 lsl 16)))
(Invalid_protocol_constants
"The ratio blocks_per_cycle per blocks_per_stake_snapshot should be \
between 1 and 65535")
>>? fun () -> Result.return_unit
module Generated = struct
type t = {
consensus_threshold : int;
baking_reward_fixed_portion : Tez_repr.t;
baking_reward_bonus_per_slot : Tez_repr.t;
endorsing_reward_per_slot : Tez_repr.t;
}
let generate ~consensus_committee_size ~blocks_per_minute =
let consensus_threshold = (consensus_committee_size * 2 / 3) + 1 in
let rewards_per_minute = Tez_repr.(mul_exn one 80) in
let rewards_per_block =
Tez_repr.(
div_exn
(mul_exn rewards_per_minute blocks_per_minute.denominator)
blocks_per_minute.numerator)
in
let rewards_half = Tez_repr.(div_exn rewards_per_block 2) in
let rewards_quarter = Tez_repr.(div_exn rewards_per_block 4) in
let bonus_committee_size = consensus_committee_size - consensus_threshold in
{
consensus_threshold;
baking_reward_fixed_portion =
(if Compare.Int.(bonus_committee_size <= 0) then
rewards_half
else rewards_quarter);
baking_reward_bonus_per_slot =
(if Compare.Int.(bonus_committee_size <= 0) then Tez_repr.zero
else Tez_repr.div_exn rewards_quarter bonus_committee_size);
endorsing_reward_per_slot =
Tez_repr.div_exn rewards_half consensus_committee_size;
}
end
module Proto_previous = struct
type delegate_selection =
| Random
| Round_robin_over of Signature.Public_key.t list list
let delegate_selection_encoding =
let open Data_encoding in
union
[
case
(Tag 0)
~title:"Random_delegate_selection"
(constant "random")
(function Random -> Some () | _ -> None)
(fun () -> Random);
case
(Tag 1)
~title:"Round_robin_over_delegates"
(list (list Signature.Public_key.encoding))
(function Round_robin_over l -> Some l | _ -> None)
(fun l -> Round_robin_over l);
]
type parametric = {
preserved_cycles : int;
blocks_per_cycle : int32;
blocks_per_commitment : int32;
blocks_per_stake_snapshot : int32;
blocks_per_voting_period : int32;
hard_gas_limit_per_operation : Gas_limit_repr.Arith.integral;
hard_gas_limit_per_block : Gas_limit_repr.Arith.integral;
proof_of_work_threshold : int64;
tokens_per_roll : Tez_repr.t;
seed_nonce_revelation_tip : Tez_repr.t;
origination_size : int;
baking_reward_fixed_portion : Tez_repr.t;
baking_reward_bonus_per_slot : Tez_repr.t;
endorsing_reward_per_slot : Tez_repr.t;
cost_per_byte : Tez_repr.t;
hard_storage_limit_per_operation : Z.t;
quorum_min : int32;
quorum_max : int32;
min_proposal_quorum : int32;
liquidity_baking_subsidy : Tez_repr.t;
liquidity_baking_sunset_level : int32;
liquidity_baking_toggle_ema_threshold : int32;
max_operations_time_to_live : int;
minimal_block_delay : Period_repr.t;
delay_increment_per_round : Period_repr.t;
minimal_participation_ratio : ratio;
consensus_committee_size : int;
consensus_threshold : int;
max_slashing_period : int;
frozen_deposits_percentage : int;
double_baking_punishment : Tez_repr.t;
ratio_of_frozen_deposits_slashed_per_double_endorsement : ratio;
delegate_selection : delegate_selection;
}
let parametric_encoding =
let open Data_encoding in
conv
(fun c ->
( ( c.preserved_cycles,
c.blocks_per_cycle,
c.blocks_per_commitment,
c.blocks_per_stake_snapshot,
c.blocks_per_voting_period,
c.hard_gas_limit_per_operation,
c.hard_gas_limit_per_block,
c.proof_of_work_threshold,
c.tokens_per_roll ),
( ( c.seed_nonce_revelation_tip,
c.origination_size,
c.baking_reward_fixed_portion,
c.baking_reward_bonus_per_slot,
c.endorsing_reward_per_slot,
c.cost_per_byte,
c.hard_storage_limit_per_operation,
c.quorum_min ),
( ( c.quorum_max,
c.min_proposal_quorum,
c.liquidity_baking_subsidy,
c.liquidity_baking_sunset_level,
c.liquidity_baking_toggle_ema_threshold,
c.max_operations_time_to_live,
c.minimal_block_delay,
c.delay_increment_per_round,
c.consensus_committee_size,
c.consensus_threshold ),
( c.minimal_participation_ratio,
c.max_slashing_period,
c.frozen_deposits_percentage,
c.double_baking_punishment,
c.ratio_of_frozen_deposits_slashed_per_double_endorsement,
c.delegate_selection ) ) ) ))
(fun ( ( preserved_cycles,
blocks_per_cycle,
blocks_per_commitment,
blocks_per_stake_snapshot,
blocks_per_voting_period,
hard_gas_limit_per_operation,
hard_gas_limit_per_block,
proof_of_work_threshold,
tokens_per_roll ),
( ( seed_nonce_revelation_tip,
origination_size,
baking_reward_fixed_portion,
baking_reward_bonus_per_slot,
endorsing_reward_per_slot,
cost_per_byte,
hard_storage_limit_per_operation,
quorum_min ),
( ( quorum_max,
min_proposal_quorum,
liquidity_baking_subsidy,
liquidity_baking_sunset_level,
liquidity_baking_toggle_ema_threshold,
max_operations_time_to_live,
minimal_block_delay,
delay_increment_per_round,
consensus_committee_size,
consensus_threshold ),
( minimal_participation_ratio,
max_slashing_period,
frozen_deposits_percentage,
double_baking_punishment,
ratio_of_frozen_deposits_slashed_per_double_endorsement,
delegate_selection ) ) ) ) ->
{
preserved_cycles;
blocks_per_cycle;
blocks_per_commitment;
blocks_per_stake_snapshot;
blocks_per_voting_period;
hard_gas_limit_per_operation;
hard_gas_limit_per_block;
proof_of_work_threshold;
tokens_per_roll;
seed_nonce_revelation_tip;
origination_size;
baking_reward_fixed_portion;
baking_reward_bonus_per_slot;
endorsing_reward_per_slot;
cost_per_byte;
hard_storage_limit_per_operation;
quorum_min;
quorum_max;
min_proposal_quorum;
liquidity_baking_subsidy;
liquidity_baking_sunset_level;
liquidity_baking_toggle_ema_threshold;
max_operations_time_to_live;
minimal_block_delay;
delay_increment_per_round;
minimal_participation_ratio;
max_slashing_period;
consensus_committee_size;
consensus_threshold;
frozen_deposits_percentage;
double_baking_punishment;
ratio_of_frozen_deposits_slashed_per_double_endorsement;
delegate_selection;
})
(merge_objs
(obj9
(req "preserved_cycles" uint8)
(req "blocks_per_cycle" int32)
(req "blocks_per_commitment" int32)
(req "blocks_per_stake_snapshot" int32)
(req "blocks_per_voting_period" int32)
(req
"hard_gas_limit_per_operation"
Gas_limit_repr.Arith.z_integral_encoding)
(req
"hard_gas_limit_per_block"
Gas_limit_repr.Arith.z_integral_encoding)
(req "proof_of_work_threshold" int64)
(req "tokens_per_roll" Tez_repr.encoding))
(merge_objs
(obj8
(req "seed_nonce_revelation_tip" Tez_repr.encoding)
(req "origination_size" int31)
(req "baking_reward_fixed_portion" Tez_repr.encoding)
(req "baking_reward_bonus_per_slot" Tez_repr.encoding)
(req "endorsing_reward_per_slot" Tez_repr.encoding)
(req "cost_per_byte" Tez_repr.encoding)
(req "hard_storage_limit_per_operation" z)
(req "quorum_min" int32))
(merge_objs
(obj10
(req "quorum_max" int32)
(req "min_proposal_quorum" int32)
(req "liquidity_baking_subsidy" Tez_repr.encoding)
(req "liquidity_baking_sunset_level" int32)
(req "liquidity_baking_toggle_ema_threshold" int32)
(req "max_operations_time_to_live" int16)
(req "minimal_block_delay" Period_repr.encoding)
(req "delay_increment_per_round" Period_repr.encoding)
(req "consensus_committee_size" int31)
(req "consensus_threshold" int31))
(obj6
(req "minimal_participation_ratio" ratio_encoding)
(req "max_slashing_period" int31)
(req "frozen_deposits_percentage" int31)
(req "double_baking_punishment" Tez_repr.encoding)
(req
"ratio_of_frozen_deposits_slashed_per_double_endorsement"
ratio_encoding)
(dft "delegate_selection" delegate_selection_encoding Random)))))
end
let cache_layout p =
[
p.cache_script_size;
p.cache_stake_distribution_cycles;
p.cache_sampler_state_cycles;
]