Source file validate_errors.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
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
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
open Alpha_context
type operation_conflict =
| Operation_conflict of {
existing : Operation_hash.t;
new_operation : Operation_hash.t;
}
let operation_conflict_encoding =
let open Data_encoding in
def
"operation_conflict"
~title:"Conflict error"
~description:"Conflict between two operations"
@@ conv
(function
| Operation_conflict {existing; new_operation} ->
(existing, new_operation))
(fun (existing, new_operation) ->
Operation_conflict {existing; new_operation})
(obj2
(req "existing" Operation_hash.encoding)
(req "new_operation" Operation_hash.encoding))
module Consensus = struct
type error += Forbidden_delegate of Signature.Public_key_hash.t
let () =
register_error_kind
`Permanent
~id:"validate.temporarily_forbidden_delegate"
~title:"Temporarily forbidden delegate"
~description:"The delegate has committed too many misbehaviours."
~pp:(fun ppf delegate ->
Format.fprintf
ppf
"Delegate %a has committed too many misbehaviours; it is temporarily \
not allowed to bake/preattest/attest."
Signature.Public_key_hash.pp
delegate)
Data_encoding.(obj1 (req "delegate" Signature.Public_key_hash.encoding))
(function Forbidden_delegate delegate -> Some delegate | _ -> None)
(fun delegate -> Forbidden_delegate delegate)
(** This type is only used in consensus operation errors to make
them more informative. *)
type consensus_operation_kind = Preattestation | Attestation
let consensus_operation_kind_encoding =
Data_encoding.string_enum
[("Preattestation", Preattestation); ("Attestation", Attestation)]
let consensus_operation_kind_pp fmt = function
| Preattestation -> Format.fprintf fmt "Preattestation"
| Attestation -> Format.fprintf fmt "Attestation"
(** Errors for preattestation and attestation. *)
type error +=
| Consensus_operation_for_old_level of {
kind : consensus_operation_kind;
expected : Raw_level.t;
provided : Raw_level.t;
}
| Consensus_operation_for_future_level of {
kind : consensus_operation_kind;
expected : Raw_level.t;
provided : Raw_level.t;
}
| Consensus_operation_for_old_round of {
kind : consensus_operation_kind;
expected : Round.t;
provided : Round.t;
}
| Consensus_operation_for_future_round of {
kind : consensus_operation_kind;
expected : Round.t;
provided : Round.t;
}
| Wrong_payload_hash_for_consensus_operation of {
kind : consensus_operation_kind;
expected : Block_payload_hash.t;
provided : Block_payload_hash.t;
}
| Unexpected_preattestation_in_block
| Unexpected_attestation_in_block
| Preattestation_round_too_high of {
block_round : Round.t;
provided : Round.t;
}
| Wrong_slot_used_for_consensus_operation of {
kind : consensus_operation_kind;
}
| Conflicting_consensus_operation of {
kind : consensus_operation_kind;
conflict : operation_conflict;
}
| Consensus_operation_not_allowed
let () =
register_error_kind
`Outdated
~id:"validate.consensus_operation_for_old_level"
~title:"Consensus operation for old level"
~description:"Consensus operation for old level."
~pp:(fun ppf (kind, expected, provided) ->
Format.fprintf
ppf
"%a for old level (expected: %a, provided: %a)."
consensus_operation_kind_pp
kind
Raw_level.pp
expected
Raw_level.pp
provided)
Data_encoding.(
obj3
(req "kind" consensus_operation_kind_encoding)
(req "expected" Raw_level.encoding)
(req "provided" Raw_level.encoding))
(function
| Consensus_operation_for_old_level {kind; expected; provided} ->
Some (kind, expected, provided)
| _ -> None)
(fun (kind, expected, provided) ->
Consensus_operation_for_old_level {kind; expected; provided}) ;
register_error_kind
`Temporary
~id:"validate.consensus_operation_for_future_level"
~title:"Consensus operation for future level"
~description:"Consensus operation for future level."
~pp:(fun ppf (kind, expected, provided) ->
Format.fprintf
ppf
"%a for future level (expected: %a, provided: %a)."
consensus_operation_kind_pp
kind
Raw_level.pp
expected
Raw_level.pp
provided)
Data_encoding.(
obj3
(req "kind" consensus_operation_kind_encoding)
(req "expected" Raw_level.encoding)
(req "provided" Raw_level.encoding))
(function
| Consensus_operation_for_future_level {kind; expected; provided} ->
Some (kind, expected, provided)
| _ -> None)
(fun (kind, expected, provided) ->
Consensus_operation_for_future_level {kind; expected; provided}) ;
register_error_kind
`Branch
~id:"validate.consensus_operation_for_old_round"
~title:"Consensus operation for old round"
~description:"Consensus operation for old round."
~pp:(fun ppf (kind, expected, provided) ->
Format.fprintf
ppf
"%a for old round (expected_min: %a, provided: %a)."
consensus_operation_kind_pp
kind
Round.pp
expected
Round.pp
provided)
Data_encoding.(
obj3
(req "kind" consensus_operation_kind_encoding)
(req "expected_min" Round.encoding)
(req "provided" Round.encoding))
(function
| Consensus_operation_for_old_round {kind; expected; provided} ->
Some (kind, expected, provided)
| _ -> None)
(fun (kind, expected, provided) ->
Consensus_operation_for_old_round {kind; expected; provided}) ;
register_error_kind
`Temporary
~id:"validate.consensus_operation_for_future_round"
~title:"Consensus operation for future round"
~description:"Consensus operation for future round."
~pp:(fun ppf (kind, expected, provided) ->
Format.fprintf
ppf
"%a for future round (expected: %a, provided: %a)."
consensus_operation_kind_pp
kind
Round.pp
expected
Round.pp
provided)
Data_encoding.(
obj3
(req "kind" consensus_operation_kind_encoding)
(req "expected_max" Round.encoding)
(req "provided" Round.encoding))
(function
| Consensus_operation_for_future_round {kind; expected; provided} ->
Some (kind, expected, provided)
| _ -> None)
(fun (kind, expected, provided) ->
Consensus_operation_for_future_round {kind; expected; provided}) ;
register_error_kind
`Branch
~id:"validate.wrong_payload_hash_for_consensus_operation"
~title:"Wrong payload hash for consensus operation"
~description:"Wrong payload hash for consensus operation."
~pp:(fun ppf (kind, expected, provided) ->
Format.fprintf
ppf
"%a with wrong payload hash (expected: %a, provided: %a)."
consensus_operation_kind_pp
kind
Block_payload_hash.pp_short
expected
Block_payload_hash.pp_short
provided)
Data_encoding.(
obj3
(req "kind" consensus_operation_kind_encoding)
(req "expected" Block_payload_hash.encoding)
(req "provided" Block_payload_hash.encoding))
(function
| Wrong_payload_hash_for_consensus_operation {kind; expected; provided}
->
Some (kind, expected, provided)
| _ -> None)
(fun (kind, expected, provided) ->
Wrong_payload_hash_for_consensus_operation {kind; expected; provided}) ;
register_error_kind
`Permanent
~id:"validate.unexpected_preattestation_in_block"
~title:"Unexpected preattestation in block"
~description:"Unexpected preattestation in block."
~pp:(fun ppf () ->
Format.fprintf ppf "Unexpected preattestation in block.")
Data_encoding.empty
(function Unexpected_preattestation_in_block -> Some () | _ -> None)
(fun () -> Unexpected_preattestation_in_block) ;
register_error_kind
`Permanent
~id:"validate.unexpected_attestation_in_block"
~title:"Unexpected attestation in block"
~description:"Unexpected attestation in block."
~pp:(fun ppf () -> Format.fprintf ppf "Unexpected attestation in block.")
Data_encoding.empty
(function Unexpected_attestation_in_block -> Some () | _ -> None)
(fun () -> Unexpected_attestation_in_block) ;
register_error_kind
`Permanent
~id:"validate.preattestation_round_too_high"
~title:"Preattestation round too high"
~description:"Preattestation round too high."
~pp:(fun ppf (block_round, provided) ->
Format.fprintf
ppf
"Preattestation round too high (block_round: %a, provided: %a)."
Round.pp
block_round
Round.pp
provided)
Data_encoding.(
obj2 (req "block_round" Round.encoding) (req "provided" Round.encoding))
(function
| Preattestation_round_too_high {block_round; provided} ->
Some (block_round, provided)
| _ -> None)
(fun (block_round, provided) ->
Preattestation_round_too_high {block_round; provided}) ;
register_error_kind
`Permanent
~id:"validate.wrong_slot_for_consensus_operation"
~title:"Wrong slot for consensus operation"
~description:"Wrong slot used for a preattestation or attestation."
~pp:(fun ppf kind ->
Format.fprintf
ppf
"Wrong slot used for a %a."
consensus_operation_kind_pp
kind)
Data_encoding.(obj1 (req "kind" consensus_operation_kind_encoding))
(function
| Wrong_slot_used_for_consensus_operation {kind} -> Some kind
| _ -> None)
(fun kind -> Wrong_slot_used_for_consensus_operation {kind}) ;
register_error_kind
`Branch
~id:"validate.double_inclusion_of_consensus_operation"
~title:"Double inclusion of consensus operation"
~description:"Double inclusion of consensus operation."
~pp:(fun ppf (kind, Operation_conflict {existing; new_operation}) ->
Format.fprintf
ppf
"%a operation %a conflicts with existing %a"
consensus_operation_kind_pp
kind
Operation_hash.pp
new_operation
Operation_hash.pp
existing)
Data_encoding.(
obj2
(req "kind" consensus_operation_kind_encoding)
(req "conflict" operation_conflict_encoding))
(function
| Conflicting_consensus_operation {kind; conflict} ->
Some (kind, conflict)
| _ -> None)
(fun (kind, conflict) -> Conflicting_consensus_operation {kind; conflict}) ;
register_error_kind
`Branch
~id:"validate.consensus_operation_not_allowed"
~title:"Consensus operation not allowed"
~description:"Consensus operation not allowed."
~pp:(fun ppf () ->
Format.fprintf ppf "Validation of consensus operation if forbidden ")
Data_encoding.empty
(function Consensus_operation_not_allowed -> Some () | _ -> None)
(fun () -> Consensus_operation_not_allowed)
end
module Voting = struct
type error +=
|
Wrong_voting_period_index of {
expected : int32;
provided : int32;
}
| Wrong_voting_period_kind of {
current : Voting_period.kind;
expected : Voting_period.kind list;
}
| Source_not_in_vote_listings
|
Empty_proposals
| Proposals_contain_duplicate of {proposal : Protocol_hash.t}
| Already_proposed of {proposal : Protocol_hash.t}
| Too_many_proposals of {previous_count : int; operation_count : int}
| Conflicting_proposals of operation_conflict
| Testnet_dictator_multiple_proposals
| Proposals_from_unregistered_delegate of Signature.Public_key_hash.t
|
Ballot_for_wrong_proposal of {
current : Protocol_hash.t;
submitted : Protocol_hash.t;
}
| Already_submitted_a_ballot
| Ballot_from_unregistered_delegate of Signature.Public_key_hash.t
| Conflicting_ballot of operation_conflict
let () =
register_error_kind
`Temporary
~id:"validate.operation.wrong_voting_period_index"
~title:"Wrong voting period index"
~description:
"The voting operation contains a voting period index different from \
the current one."
~pp:(fun ppf (expected, provided) ->
Format.fprintf
ppf
"The voting operation is meant for voting period %ld, whereas the \
current period is %ld."
provided
expected)
Data_encoding.(
obj2 (req "current_index" int32) (req "provided_index" int32))
(function
| Wrong_voting_period_index {expected; provided} ->
Some (expected, provided)
| _ -> None)
(fun (expected, provided) ->
Wrong_voting_period_index {expected; provided}) ;
register_error_kind
`Temporary
~id:"validate.operation.wrong_voting_period_kind"
~title:"Wrong voting period kind"
~description:
"The voting operation is incompatible the current voting period kind."
~pp:(fun ppf (current, expected) ->
Format.fprintf
ppf
"The voting operation is only valid during a %a voting period, but \
we are currently in a %a period."
(Format.pp_print_list
~pp_sep:(fun fmt () -> Format.fprintf fmt " or ")
Voting_period.pp_kind)
expected
Voting_period.pp_kind
current)
Data_encoding.(
obj2
(req "current" Voting_period.kind_encoding)
(req "expected" (list Voting_period.kind_encoding)))
(function
| Wrong_voting_period_kind {current; expected} ->
Some (current, expected)
| _ -> None)
(fun (current, expected) -> Wrong_voting_period_kind {current; expected}) ;
let description = "The delegate is not in the vote listings." in
register_error_kind
`Temporary
~id:"validate.operation.source_not_in_vote_listings"
~title:"Source not in vote listings"
~description
~pp:(fun ppf () -> Format.fprintf ppf "%s" description)
Data_encoding.empty
(function Source_not_in_vote_listings -> Some () | _ -> None)
(fun () -> Source_not_in_vote_listings) ;
let description = "Proposal list cannot be empty." in
register_error_kind
`Permanent
~id:"validate.operation.empty_proposals"
~title:"Empty proposals"
~description
~pp:(fun ppf () -> Format.fprintf ppf "%s" description)
Data_encoding.empty
(function Empty_proposals -> Some () | _ -> None)
(fun () -> Empty_proposals) ;
register_error_kind
`Permanent
~id:"validate.operation.proposals_contain_duplicate"
~title:"Proposals contain duplicate"
~description:"The list of proposals contains a duplicate element."
~pp:(fun ppf proposal ->
Format.fprintf
ppf
"The list of proposals contains multiple occurrences of the proposal \
%a."
Protocol_hash.pp
proposal)
Data_encoding.(obj1 (req "proposal" Protocol_hash.encoding))
(function
| Proposals_contain_duplicate {proposal} -> Some proposal | _ -> None)
(fun proposal -> Proposals_contain_duplicate {proposal}) ;
register_error_kind
`Branch
~id:"validate.operation.already_proposed"
~title:"Already proposed"
~description:
"The delegate has already submitted one of the operation's proposals."
~pp:(fun ppf proposal ->
Format.fprintf
ppf
"The delegate has already submitted the proposal %a."
Protocol_hash.pp
proposal)
Data_encoding.(obj1 (req "proposal" Protocol_hash.encoding))
(function Already_proposed {proposal} -> Some proposal | _ -> None)
(fun proposal -> Already_proposed {proposal}) ;
register_error_kind
`Temporary
~id:"validate.operation.conflict_too_many_proposals"
~title:"Conflict too many proposals"
~description:
"The delegate exceeded the maximum number of allowed proposals due to, \
among others, previous Proposals operations in the current \
block/mempool."
~pp:(fun ppf (previous_count, operation_count) ->
Format.fprintf
ppf
"The delegate cannot submit too many protocol proposals: it \
currently voted for %d and is trying to vote for %d more."
previous_count
operation_count)
Data_encoding.(
obj2 (req "previous_count" int8) (req "operation_count" int31))
(function
| Too_many_proposals {previous_count; operation_count} ->
Some (previous_count, operation_count)
| _ -> None)
(fun (previous_count, operation_count) ->
Too_many_proposals {previous_count; operation_count}) ;
register_error_kind
`Temporary
~id:"validate.operation.conflicting_proposals"
~title:"Conflicting proposals"
~description:
"The current block/mempool already contains a testnest dictator \
proposals operation, so it cannot have any other voting operation."
~pp:(fun ppf (Operation_conflict {existing; _}) ->
Format.fprintf
ppf
"The current block/mempool already contains a conflicting operation \
%a."
Operation_hash.pp
existing)
Data_encoding.(obj1 (req "conflict" operation_conflict_encoding))
(function Conflicting_proposals conflict -> Some conflict | _ -> None)
(fun conflict -> Conflicting_proposals conflict) ;
let description =
"A testnet dictator cannot submit more than one proposal at a time."
in
register_error_kind
`Permanent
~id:"validate.operation.testnet_dictator_multiple_proposals"
~title:"Testnet dictator multiple proposals"
~description
~pp:(fun ppf () -> Format.fprintf ppf "%s" description)
Data_encoding.empty
(function Testnet_dictator_multiple_proposals -> Some () | _ -> None)
(fun () -> Testnet_dictator_multiple_proposals) ;
register_error_kind
`Permanent
~id:"operation.proposals_from_unregistered_delegate"
~title:"Proposals from an unregistered delegate"
~description:"Cannot submit proposals with an unregistered delegate."
~pp:(fun ppf c ->
Format.fprintf
ppf
"Cannot submit proposals with public key hash %a (unregistered \
delegate)."
Signature.Public_key_hash.pp
c)
Data_encoding.(obj1 (req "delegate" Signature.Public_key_hash.encoding))
(function Proposals_from_unregistered_delegate c -> Some c | _ -> None)
(fun c -> Proposals_from_unregistered_delegate c) ;
register_error_kind
`Branch
~id:"validate.operation.ballot_for_wrong_proposal"
~title:"Ballot for wrong proposal"
~description:"Ballot provided for a proposal that is not the current one."
~pp:(fun ppf (current, submitted) ->
Format.fprintf
ppf
"Ballot provided for proposal %a whereas the current proposal is %a."
Protocol_hash.pp
submitted
Protocol_hash.pp
current)
Data_encoding.(
obj2
(req "current_proposal" Protocol_hash.encoding)
(req "ballot_proposal" Protocol_hash.encoding))
(function
| Ballot_for_wrong_proposal {current; submitted} ->
Some (current, submitted)
| _ -> None)
(fun (current, submitted) ->
Ballot_for_wrong_proposal {current; submitted}) ;
let description =
"The delegate has already submitted a ballot for the current voting \
period."
in
register_error_kind
`Branch
~id:"validate.operation.already_submitted_a_ballot"
~title:"Already submitted a ballot"
~description
~pp:(fun ppf () -> Format.fprintf ppf "%s" description)
Data_encoding.empty
(function Already_submitted_a_ballot -> Some () | _ -> None)
(fun () -> Already_submitted_a_ballot) ;
register_error_kind
`Permanent
~id:"operation.ballot_from_unregistered_delegate"
~title:"Ballot from an unregistered delegate"
~description:"Cannot cast a ballot for an unregistered delegate."
~pp:(fun ppf c ->
Format.fprintf
ppf
"Cannot cast a ballot for public key hash %a (unregistered delegate)."
Signature.Public_key_hash.pp
c)
Data_encoding.(obj1 (req "delegate" Signature.Public_key_hash.encoding))
(function Ballot_from_unregistered_delegate c -> Some c | _ -> None)
(fun c -> Ballot_from_unregistered_delegate c) ;
register_error_kind
`Temporary
~id:"validate.operation.conflicting_ballot"
~title:"Conflicting ballot"
~description:
"The delegate has already submitted a ballot in a previously validated \
operation of the current block or mempool."
~pp:(fun ppf (Operation_conflict {existing; _}) ->
Format.fprintf
ppf
"The delegate has already submitted a ballot in the previously \
validated operation %a of the current block or mempool."
Operation_hash.pp
existing)
Data_encoding.(obj1 (req "conflict" operation_conflict_encoding))
(function Conflicting_ballot conflict -> Some conflict | _ -> None)
(fun conflict -> Conflicting_ballot conflict)
end
module Anonymous = struct
type error +=
| Invalid_activation of {pkh : Ed25519.Public_key_hash.t}
| Conflicting_activation of {
edpkh : Ed25519.Public_key_hash.t;
conflict : operation_conflict;
}
let () =
register_error_kind
`Permanent
~id:"validate.operation.invalid_activation"
~title:"Invalid activation"
~description:
"The given key and secret do not correspond to any existing \
preallocated contract."
~pp:(fun ppf pkh ->
Format.fprintf
ppf
"Invalid activation. The public key %a and accompanying secret do \
not match any commitment."
Ed25519.Public_key_hash.pp
pkh)
Data_encoding.(obj1 (req "pkh" Ed25519.Public_key_hash.encoding))
(function Invalid_activation {pkh} -> Some pkh | _ -> None)
(fun pkh -> Invalid_activation {pkh}) ;
register_error_kind
`Branch
~id:"validate.operation.conflicting_activation"
~title:"Account already activated in current validation_state"
~description:
"The account has already been activated by a previous operation in the \
current validation state."
~pp:(fun ppf (edpkh, Operation_conflict {existing; _}) ->
Format.fprintf
ppf
"Invalid activation: the account %a has already been activated in \
the current validation state by operation %a."
Ed25519.Public_key_hash.pp
edpkh
Operation_hash.pp
existing)
Data_encoding.(
obj2
(req "edpkh" Ed25519.Public_key_hash.encoding)
(req "conflict" operation_conflict_encoding))
(function
| Conflicting_activation {edpkh; conflict} -> Some (edpkh, conflict)
| _ -> None)
(fun (edpkh, conflict) -> Conflicting_activation {edpkh; conflict})
type denunciation_kind = Misbehaviour.kind
let pp_denunciation_kind fmt : denunciation_kind -> unit = function
| Double_preattesting -> Format.fprintf fmt "preattestation"
| Double_attesting -> Format.fprintf fmt "attestation"
| Double_baking -> Format.fprintf fmt "block"
type error +=
| Invalid_double_baking_evidence of {
hash1 : Block_hash.t;
level1 : Raw_level.t;
round1 : Round.t;
hash2 : Block_hash.t;
level2 : Raw_level.t;
round2 : Round.t;
}
| Invalid_denunciation of denunciation_kind
| Inconsistent_denunciation of {
kind : denunciation_kind;
delegate1 : Signature.Public_key_hash.t;
delegate2 : Signature.Public_key_hash.t;
}
| Already_denounced of {
kind : denunciation_kind;
delegate : Signature.Public_key_hash.t;
level : Level.t;
}
| Conflicting_denunciation of {
kind : denunciation_kind;
conflict : operation_conflict;
}
| Too_early_denunciation of {
kind : denunciation_kind;
level : Raw_level.t;
current : Raw_level.t;
}
| Outdated_denunciation of {
kind : denunciation_kind;
level : Raw_level.t;
last_cycle : Cycle.t;
}
let () =
register_error_kind
`Permanent
~id:"validate.block.invalid_double_baking_evidence"
~title:"Invalid double baking evidence"
~description:
"A double-baking evidence is inconsistent (two distinct levels)"
~pp:(fun ppf (hash1, level1, round1, hash2, level2, round2) ->
Format.fprintf
ppf
"Invalid double-baking evidence (hash: %a and %a, levels/rounds: \
(%ld,%ld) and (%ld,%ld))"
Block_hash.pp
hash1
Block_hash.pp
hash2
(Raw_level.to_int32 level1)
(Round.to_int32 round1)
(Raw_level.to_int32 level2)
(Round.to_int32 round2))
Data_encoding.(
obj6
(req "hash1" Block_hash.encoding)
(req "level1" Raw_level.encoding)
(req "round1" Round.encoding)
(req "hash2" Block_hash.encoding)
(req "level2" Raw_level.encoding)
(req "round2" Round.encoding))
(function
| Invalid_double_baking_evidence
{hash1; level1; round1; hash2; level2; round2} ->
Some (hash1, level1, round1, hash2, level2, round2)
| _ -> None)
(fun (hash1, level1, round1, hash2, level2, round2) ->
Invalid_double_baking_evidence
{hash1; level1; round1; hash2; level2; round2}) ;
register_error_kind
`Permanent
~id:"validate.operation.block.invalid_denunciation"
~title:"Invalid denunciation"
~description:"A denunciation is malformed"
~pp:(fun ppf kind ->
Format.fprintf
ppf
"Malformed double-%a evidence"
pp_denunciation_kind
kind)
Data_encoding.(obj1 (req "kind" Misbehaviour.kind_encoding))
(function Invalid_denunciation kind -> Some kind | _ -> None)
(fun kind -> Invalid_denunciation kind) ;
register_error_kind
`Permanent
~id:"validate.operation.block.inconsistent_denunciation"
~title:"Inconsistent denunciation"
~description:
"A denunciation operation is inconsistent (two distinct delegates)"
~pp:(fun ppf (kind, delegate1, delegate2) ->
Format.fprintf
ppf
"Inconsistent double-%a evidence (distinct delegate: %a and %a)"
pp_denunciation_kind
kind
Signature.Public_key_hash.pp_short
delegate1
Signature.Public_key_hash.pp_short
delegate2)
Data_encoding.(
obj3
(req "kind" Misbehaviour.kind_encoding)
(req "delegate1" Signature.Public_key_hash.encoding)
(req "delegate2" Signature.Public_key_hash.encoding))
(function
| Inconsistent_denunciation {kind; delegate1; delegate2} ->
Some (kind, delegate1, delegate2)
| _ -> None)
(fun (kind, delegate1, delegate2) ->
Inconsistent_denunciation {kind; delegate1; delegate2}) ;
register_error_kind
`Branch
~id:"validate.operation.already_denounced"
~title:"Already denounced"
~description:"The same denunciation has already been validated."
~pp:(fun ppf (kind, delegate, level) ->
Format.fprintf
ppf
"Delegate %a at level %a has already been denounced for a double %a."
Signature.Public_key_hash.pp
delegate
Level.pp
level
pp_denunciation_kind
kind)
Data_encoding.(
obj3
(req "denunciation_kind" Misbehaviour.kind_encoding)
(req "delegate" Signature.Public_key_hash.encoding)
(req "level" Level.encoding))
(function
| Already_denounced {kind; delegate; level} ->
Some (kind, delegate, level)
| _ -> None)
(fun (kind, delegate, level) -> Already_denounced {kind; delegate; level}) ;
register_error_kind
`Branch
~id:"validate.operation.conflicting_denunciation"
~title:"Conflicting denunciation in current validation state"
~description:
"The same denunciation has already been validated in the current \
validation state."
~pp:(fun ppf (kind, Operation_conflict {existing; _}) ->
Format.fprintf
ppf
"Double %a evidence already exists in the current validation state \
as operation %a."
pp_denunciation_kind
kind
Operation_hash.pp
existing)
Data_encoding.(
obj2
(req "denunciation_kind" Misbehaviour.kind_encoding)
(req "conflict" operation_conflict_encoding))
(function
| Conflicting_denunciation {kind; conflict} -> Some (kind, conflict)
| _ -> None)
(fun (kind, conflict) -> Conflicting_denunciation {kind; conflict}) ;
register_error_kind
`Temporary
~id:"validate.operation.block.too_early_denunciation"
~title:"Too early denunciation"
~description:"A denunciation is too far in the future"
~pp:(fun ppf (kind, level, current) ->
Format.fprintf
ppf
"A double-%a denunciation is too far in the future (current level: \
%a, given level: %a)"
pp_denunciation_kind
kind
Raw_level.pp
current
Raw_level.pp
level)
Data_encoding.(
obj3
(req "kind" Misbehaviour.kind_encoding)
(req "level" Raw_level.encoding)
(req "current" Raw_level.encoding))
(function
| Too_early_denunciation {kind; level; current} ->
Some (kind, level, current)
| _ -> None)
(fun (kind, level, current) ->
Too_early_denunciation {kind; level; current}) ;
register_error_kind
`Permanent
~id:"validate.operation.block.outdated_denunciation"
~title:"Outdated denunciation"
~description:"A denunciation is outdated."
~pp:(fun ppf (kind, level, last_cycle) ->
Format.fprintf
ppf
"A double-%a denunciation is outdated (last acceptable cycle: %a, \
given level: %a)."
pp_denunciation_kind
kind
Cycle.pp
last_cycle
Raw_level.pp
level)
Data_encoding.(
obj3
(req "kind" Misbehaviour.kind_encoding)
(req "level" Raw_level.encoding)
(req "last" Cycle.encoding))
(function
| Outdated_denunciation {kind; level; last_cycle} ->
Some (kind, level, last_cycle)
| _ -> None)
(fun (kind, level, last_cycle) ->
Outdated_denunciation {kind; level; last_cycle})
type error += Conflicting_nonce_revelation of operation_conflict
let () =
register_error_kind
`Branch
~id:"validate.operation.conflicting_nonce_revelation"
~title:"Conflicting nonce revelation in the current validation state)."
~description:
"A revelation for the same nonce has already been validated for the \
current validation state."
~pp:(fun ppf (Operation_conflict {existing; _}) ->
Format.fprintf
ppf
"This nonce revelation is conflicting with an existing revelation %a"
Operation_hash.pp
existing)
Data_encoding.(obj1 (req "conflict" operation_conflict_encoding))
(function
| Conflicting_nonce_revelation conflict -> Some conflict | _ -> None)
(fun conflict -> Conflicting_nonce_revelation conflict)
type error += Conflicting_vdf_revelation of operation_conflict
let () =
register_error_kind
`Branch
~id:"validate.operation.conflicting_vdf_revelation"
~title:"Conflicting vdf revelation in the current validation state)."
~description:
"A revelation for the same vdf has already been validated for the \
current validation state."
~pp:(fun ppf (Operation_conflict {existing; _}) ->
Format.fprintf
ppf
"This vdf revelation is conflicting with an existing revelation %a"
Operation_hash.pp
existing)
Data_encoding.(obj1 (req "conflict" operation_conflict_encoding))
(function
| Conflicting_vdf_revelation conflict -> Some conflict | _ -> None)
(fun conflict -> Conflicting_vdf_revelation conflict)
type error +=
| Drain_delegate_on_unregistered_delegate of Signature.Public_key_hash.t
| Invalid_drain_delegate_inactive_key of {
delegate : Signature.Public_key_hash.t;
consensus_key : Signature.Public_key_hash.t;
active_consensus_key : Signature.Public_key_hash.t;
}
| Invalid_drain_delegate_no_consensus_key of Signature.Public_key_hash.t
| Invalid_drain_delegate_noop of Signature.Public_key_hash.t
| Invalid_drain_delegate_insufficient_funds_for_burn_or_fees of {
delegate : Signature.Public_key_hash.t;
destination : Signature.Public_key_hash.t;
min_amount : Tez.t;
}
| Conflicting_drain_delegate of {
delegate : Signature.Public_key_hash.t;
conflict : operation_conflict;
}
let () =
register_error_kind
`Temporary
~id:"operation.drain_delegate_key_on_unregistered_delegate"
~title:"Drain delegate key on an unregistered delegate"
~description:"Cannot drain an unregistered delegate."
~pp:(fun ppf c ->
Format.fprintf
ppf
"Cannot drain an unregistered delegate %a."
Signature.Public_key_hash.pp
c)
Data_encoding.(obj1 (req "delegate" Signature.Public_key_hash.encoding))
(function
| Drain_delegate_on_unregistered_delegate c -> Some c | _ -> None)
(fun c -> Drain_delegate_on_unregistered_delegate c) ;
register_error_kind
`Temporary
~id:"operation.invalid_drain.inactive_key"
~title:"Drain delegate with an inactive consensus key"
~description:"Cannot drain with an inactive consensus key."
~pp:(fun ppf (delegate, consensus_key, active_consensus_key) ->
Format.fprintf
ppf
"Consensus key %a is not the active consensus key for delegate %a. \
The active consensus key is %a."
Signature.Public_key_hash.pp
consensus_key
Signature.Public_key_hash.pp
delegate
Signature.Public_key_hash.pp
active_consensus_key)
Data_encoding.(
obj3
(req "delegate" Signature.Public_key_hash.encoding)
(req "consensus_key" Signature.Public_key_hash.encoding)
(req "active_consensus_key" Signature.Public_key_hash.encoding))
(function
| Invalid_drain_delegate_inactive_key
{delegate; consensus_key; active_consensus_key} ->
Some (delegate, consensus_key, active_consensus_key)
| _ -> None)
(fun (delegate, consensus_key, active_consensus_key) ->
Invalid_drain_delegate_inactive_key
{delegate; consensus_key; active_consensus_key}) ;
register_error_kind
`Temporary
~id:"operation.invalid_drain.no_consensus_key"
~title:"Drain a delegate without consensus key"
~description:"Cannot drain a delegate without consensus key."
~pp:(fun ppf delegate ->
Format.fprintf
ppf
"There is no active consensus key for delegate %a."
Signature.Public_key_hash.pp
delegate)
Data_encoding.(obj1 (req "delegate" Signature.Public_key_hash.encoding))
(function
| Invalid_drain_delegate_no_consensus_key c -> Some c | _ -> None)
(fun c -> Invalid_drain_delegate_no_consensus_key c) ;
register_error_kind
`Temporary
~id:"operation.invalid_drain.noop"
~title:"Invalid drain delegate: noop"
~description:"Cannot drain a delegate to itself."
~pp:(fun ppf delegate ->
Format.fprintf
ppf
"The destination of a drain operation cannot be the delegate itself \
(%a)."
Signature.Public_key_hash.pp
delegate)
Data_encoding.(obj1 (req "delegate" Signature.Public_key_hash.encoding))
(function Invalid_drain_delegate_noop c -> Some c | _ -> None)
(fun c -> Invalid_drain_delegate_noop c) ;
register_error_kind
`Temporary
~id:"operation.invalid_drain.insufficient_funds_for_burn_or_fees"
~title:
"Drain delegate without enough balance for allocation burn or drain \
fees"
~description:"Cannot drain without enough allocation burn and drain fees."
~pp:(fun ppf (delegate, destination, min_amount) ->
Format.fprintf
ppf
"Cannot drain delegate from %a to %a: not enough funds for the drain \
fees in the delegate account (minimum balance required: %a)."
Signature.Public_key_hash.pp
delegate
Signature.Public_key_hash.pp
destination
Tez.pp
min_amount)
Data_encoding.(
obj3
(req "delegate" Signature.Public_key_hash.encoding)
(req "destination" Signature.Public_key_hash.encoding)
(req "min_amount" Tez.encoding))
(function
| Invalid_drain_delegate_insufficient_funds_for_burn_or_fees
{delegate; destination; min_amount} ->
Some (delegate, destination, min_amount)
| _ -> None)
(fun (delegate, destination, min_amount) ->
Invalid_drain_delegate_insufficient_funds_for_burn_or_fees
{delegate; destination; min_amount}) ;
register_error_kind
`Branch
~id:"validate.operation.conflicting_drain"
~title:"Conflicting drain in the current validation state)."
~description:
"A manager operation or another drain operation is in conflict."
~pp:(fun ppf (delegate, Operation_conflict {existing; _}) ->
Format.fprintf
ppf
"This drain operation conflicts with operation %a for the delegate %a"
Operation_hash.pp
existing
Signature.Public_key_hash.pp
delegate)
Data_encoding.(
obj2
(req "delegate" Signature.Public_key_hash.encoding)
(req "conflict" operation_conflict_encoding))
(function
| Conflicting_drain_delegate {delegate; conflict} ->
Some (delegate, conflict)
| _ -> None)
(fun (delegate, conflict) ->
Conflicting_drain_delegate {delegate; conflict})
end
module Manager = struct
type error +=
| Manager_restriction of {
source : Signature.Public_key_hash.t;
conflict : operation_conflict;
}
| Inconsistent_sources
| Inconsistent_counters
| Incorrect_reveal_position
| Insufficient_gas_for_manager
| Gas_quota_exceeded_init_deserialize
| Sc_rollup_arith_pvm_disabled
| Sc_rollup_riscv_pvm_disabled
| Zk_rollup_feature_disabled
let () =
register_error_kind
`Temporary
~id:"validate.operation.manager_restriction"
~title:"Manager restriction"
~description:
"An operation with the same manager has already been validated in the \
current block."
~pp:(fun ppf (source, Operation_conflict {existing; _}) ->
Format.fprintf
ppf
"Manager %a already has the operation %a in the current block."
Signature.Public_key_hash.pp
source
Operation_hash.pp
existing)
Data_encoding.(
obj2
(req "source" Signature.Public_key_hash.encoding)
(req "conflict" operation_conflict_encoding))
(function
| Manager_restriction {source; conflict} -> Some (source, conflict)
| _ -> None)
(fun (source, conflict) -> Manager_restriction {source; conflict}) ;
let inconsistent_sources_description =
"The operation batch includes operations from different sources."
in
register_error_kind
`Permanent
~id:"validate.operation.inconsistent_sources"
~title:"Inconsistent sources in operation batch"
~description:inconsistent_sources_description
~pp:(fun ppf () ->
Format.fprintf ppf "%s" inconsistent_sources_description)
Data_encoding.empty
(function Inconsistent_sources -> Some () | _ -> None)
(fun () -> Inconsistent_sources) ;
let inconsistent_counters_description =
"Inconsistent counters in operation. Counters of an operation must be \
successive."
in
register_error_kind
`Permanent
~id:"validate.operation.inconsistent_counters"
~title:"Inconsistent counters in operation"
~description:inconsistent_counters_description
~pp:(fun ppf () ->
Format.fprintf ppf "%s" inconsistent_counters_description)
Data_encoding.empty
(function Inconsistent_counters -> Some () | _ -> None)
(fun () -> Inconsistent_counters) ;
let incorrect_reveal_description =
"Incorrect reveal operation position in batch: only allowed in first \
position."
in
register_error_kind
`Permanent
~id:"validate.operation.incorrect_reveal_position"
~title:"Incorrect reveal position"
~description:incorrect_reveal_description
~pp:(fun ppf () -> Format.fprintf ppf "%s" incorrect_reveal_description)
Data_encoding.empty
(function Incorrect_reveal_position -> Some () | _ -> None)
(fun () -> Incorrect_reveal_position) ;
register_error_kind
`Permanent
~id:"validate.operation.insufficient_gas_for_manager"
~title:"Not enough gas for initial manager cost"
~description:
(Format.asprintf
"Gas limit is too low to cover the initial cost of manager \
operations: a minimum of %a gas units is required."
Gas.pp_cost_as_gas
Michelson_v1_gas.Cost_of.manager_operation)
Data_encoding.empty
(function Insufficient_gas_for_manager -> Some () | _ -> None)
(fun () -> Insufficient_gas_for_manager) ;
let gas_deserialize_description =
"Gas limit was not high enough to deserialize the transaction parameters \
or origination script code or initial storage etc., making the \
operation impossible to parse within the provided gas bounds."
in
register_error_kind
`Permanent
~id:"validate.operation.gas_quota_exceeded_init_deserialize"
~title:"Not enough gas for initial deserialization of script expressions"
~description:gas_deserialize_description
~pp:(fun ppf () -> Format.fprintf ppf "%s" gas_deserialize_description)
Data_encoding.empty
(function Gas_quota_exceeded_init_deserialize -> Some () | _ -> None)
(fun () -> Gas_quota_exceeded_init_deserialize) ;
let scoru_arith_pvm_disabled_description =
"Arith PVM is disabled in this network."
in
register_error_kind
`Permanent
~id:"operation.arith_pvm_disabled"
~title:"The Arith PVM is disabled"
~description:scoru_arith_pvm_disabled_description
~pp:(fun ppf () ->
Format.fprintf ppf "%s" scoru_arith_pvm_disabled_description)
Data_encoding.unit
(function Sc_rollup_arith_pvm_disabled -> Some () | _ -> None)
(fun () -> Sc_rollup_arith_pvm_disabled) ;
let scoru_riscv_pvm_disabled_description =
"RISCV PVM is disabled in this network."
in
register_error_kind
`Permanent
~id:"operation.riscv_pvm_disabled"
~title:"The RISCV PVM is disabled"
~description:scoru_riscv_pvm_disabled_description
~pp:(fun ppf () ->
Format.fprintf ppf "%s" scoru_riscv_pvm_disabled_description)
Data_encoding.unit
(function Sc_rollup_riscv_pvm_disabled -> Some () | _ -> None)
(fun () -> Sc_rollup_riscv_pvm_disabled) ;
let zkru_disabled_description =
"ZK rollups will be enabled in a future proposal."
in
register_error_kind
`Permanent
~id:"validate.operation.zk_rollup_disabled"
~title:"ZK rollups are disabled"
~description:zkru_disabled_description
~pp:(fun ppf () -> Format.fprintf ppf "%s" zkru_disabled_description)
Data_encoding.unit
(function Zk_rollup_feature_disabled -> Some () | _ -> None)
(fun () -> Zk_rollup_feature_disabled)
end
type error += Failing_noop_error
let () =
let description = "A failing_noop operation can never be validated." in
register_error_kind
`Permanent
~id:"validate.operation.failing_noop_error"
~title:"Failing_noop error"
~description
~pp:(fun ppf () -> Format.fprintf ppf "%s" description)
Data_encoding.empty
(function Failing_noop_error -> Some () | _ -> None)
(fun () -> Failing_noop_error)
module Block = struct
type error +=
| Not_enough_attestations of {required : int; provided : int}
| Inconsistent_validation_passes_in_block of {
expected : int;
provided : int;
}
| Invalid_payload_hash of {
expected : Block_payload_hash.t;
provided : Block_payload_hash.t;
}
| Locked_round_after_block_round of {
locked_round : Round.t;
round : Round.t;
}
| Insufficient_locked_round_evidence of {
voting_power : int;
consensus_threshold : int;
}
let () =
register_error_kind
`Permanent
~id:"validate.block.not_enough_attestations"
~title:"Not enough attestations"
~description:
"The block being validated does not include the required minimum \
number of attestations."
~pp:(fun ppf (required, provided) ->
Format.fprintf
ppf
"Wrong number of attestations (%i), at least %i are expected"
provided
required)
Data_encoding.(obj2 (req "required" int31) (req "provided" int31))
(function
| Not_enough_attestations {required; provided} ->
Some (required, provided)
| _ -> None)
(fun (required, provided) -> Not_enough_attestations {required; provided}) ;
register_error_kind
`Permanent
~id:"validate.block.inconsistent_validation_passes_in_block"
~title:"Inconsistent validation passes in block"
~description:
"Validation of operation should be ordered by their validation passes \
in a block."
~pp:(fun ppf (expected, provided) ->
Format.fprintf
ppf
"Validation of operation should be ordered by their validation \
passes in a block. Got an operation with validation pass: %d while \
the last validated operation had the validation pass %d."
provided
expected)
Data_encoding.(obj2 (req "expected" int31) (req "provided" int31))
(function
| Inconsistent_validation_passes_in_block {expected; provided} ->
Some (expected, provided)
| _ -> None)
(fun (expected, provided) ->
Inconsistent_validation_passes_in_block {expected; provided}) ;
register_error_kind
`Permanent
~id:"validate.block.invalid_payload_hash"
~title:"Invalid payload hash"
~description:"Invalid payload hash."
~pp:(fun ppf (expected, provided) ->
Format.fprintf
ppf
"Invalid payload hash (expected: %a, provided: %a)."
Block_payload_hash.pp_short
expected
Block_payload_hash.pp_short
provided)
Data_encoding.(
obj2
(req "expected" Block_payload_hash.encoding)
(req "provided" Block_payload_hash.encoding))
(function
| Invalid_payload_hash {expected; provided} -> Some (expected, provided)
| _ -> None)
(fun (expected, provided) -> Invalid_payload_hash {expected; provided}) ;
() ;
register_error_kind
`Permanent
~id:"validate.block.locked_round_after_block_round"
~title:"Locked round after block round"
~description:"Locked round after block round."
~pp:(fun ppf (locked_round, round) ->
Format.fprintf
ppf
"Locked round (%a) is after the block round (%a)."
Round.pp
locked_round
Round.pp
round)
Data_encoding.(
obj2 (req "locked_round" Round.encoding) (req "round" Round.encoding))
(function
| Locked_round_after_block_round {locked_round; round} ->
Some (locked_round, round)
| _ -> None)
(fun (locked_round, round) ->
Locked_round_after_block_round {locked_round; round}) ;
() ;
register_error_kind
`Permanent
~id:"validate.block.insufficient_locked_round_evidence"
~title:"Insufficient locked round evidence"
~description:"Insufficient locked round evidence."
~pp:(fun ppf (voting_power, consensus_threshold) ->
Format.fprintf
ppf
"The provided locked round evidence is not sufficient: provided %d \
voting power but was expecting at least %d."
voting_power
consensus_threshold)
Data_encoding.(
obj2 (req "voting_power" int31) (req "consensus_threshold" int31))
(function
| Insufficient_locked_round_evidence {voting_power; consensus_threshold}
->
Some (voting_power, consensus_threshold)
| _ -> None)
(fun (voting_power, consensus_threshold) ->
Insufficient_locked_round_evidence {voting_power; consensus_threshold})
end