package tezos-protocol-013-PtJakart
Tezos/Protocol: economic-protocol definition
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-17.3.tar.gz
sha256=7062cd57addd452852598a2214ade393130efa087b99068d53713bdf912b3680
sha512=08e4091144a03ce3c107fb91a66501bd8b65ca3278917c455a2eaac6df3e108ade63f6ab8340a4bb152d60f404326e464d0ec95d26cafe8e82f870465d24a5fc
doc/src/tezos-protocol-013-PtJakart.raw/operation_repr.ml.html
Source file operation_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 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 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) (* Tezos Protocol Implementation - Low level Repr. of Operations *) module Kind = struct type preendorsement_consensus_kind = Preendorsement_consensus_kind type endorsement_consensus_kind = Endorsement_consensus_kind type 'a consensus = | Preendorsement_kind : preendorsement_consensus_kind consensus | Endorsement_kind : endorsement_consensus_kind consensus type preendorsement = preendorsement_consensus_kind consensus type endorsement = endorsement_consensus_kind consensus type seed_nonce_revelation = Seed_nonce_revelation_kind type 'a double_consensus_operation_evidence = | Double_consensus_operation_evidence type double_endorsement_evidence = endorsement_consensus_kind double_consensus_operation_evidence type double_preendorsement_evidence = preendorsement_consensus_kind double_consensus_operation_evidence type double_baking_evidence = Double_baking_evidence_kind type activate_account = Activate_account_kind type proposals = Proposals_kind type ballot = Ballot_kind type reveal = Reveal_kind type transaction = Transaction_kind type origination = Origination_kind type delegation = Delegation_kind type set_deposits_limit = Set_deposits_limit_kind type failing_noop = Failing_noop_kind type register_global_constant = Register_global_constant_kind type tx_rollup_origination = Tx_rollup_origination_kind type tx_rollup_submit_batch = Tx_rollup_submit_batch_kind type tx_rollup_commit = Tx_rollup_commit_kind type tx_rollup_return_bond = Tx_rollup_return_bond_kind type tx_rollup_finalize_commitment = Tx_rollup_finalize_commitment_kind type tx_rollup_remove_commitment = Tx_rollup_remove_commitment_kind type tx_rollup_rejection = Tx_rollup_rejection_kind type tx_rollup_dispatch_tickets = Tx_rollup_dispatch_tickets_kind type transfer_ticket = Transfer_ticket_kind type sc_rollup_originate = Sc_rollup_originate_kind type sc_rollup_add_messages = Sc_rollup_add_messages_kind type sc_rollup_cement = Sc_rollup_cement_kind type sc_rollup_publish = Sc_rollup_publish_kind type 'a manager = | Reveal_manager_kind : reveal manager | Transaction_manager_kind : transaction manager | Origination_manager_kind : origination manager | Delegation_manager_kind : delegation manager | Register_global_constant_manager_kind : register_global_constant manager | Set_deposits_limit_manager_kind : set_deposits_limit manager | Tx_rollup_origination_manager_kind : tx_rollup_origination manager | Tx_rollup_submit_batch_manager_kind : tx_rollup_submit_batch manager | Tx_rollup_commit_manager_kind : tx_rollup_commit manager | Tx_rollup_return_bond_manager_kind : tx_rollup_return_bond manager | Tx_rollup_finalize_commitment_manager_kind : tx_rollup_finalize_commitment manager | Tx_rollup_remove_commitment_manager_kind : tx_rollup_remove_commitment manager | Tx_rollup_rejection_manager_kind : tx_rollup_rejection manager | Tx_rollup_dispatch_tickets_manager_kind : tx_rollup_dispatch_tickets manager | Transfer_ticket_manager_kind : transfer_ticket manager | Sc_rollup_originate_manager_kind : sc_rollup_originate manager | Sc_rollup_add_messages_manager_kind : sc_rollup_add_messages manager | Sc_rollup_cement_manager_kind : sc_rollup_cement manager | Sc_rollup_publish_manager_kind : sc_rollup_publish manager end type 'a consensus_operation_type = | Endorsement : Kind.endorsement consensus_operation_type | Preendorsement : Kind.preendorsement consensus_operation_type let pp_operation_kind (type kind) ppf (operation_kind : kind consensus_operation_type) = match operation_kind with | Endorsement -> Format.fprintf ppf "Endorsement" | Preendorsement -> Format.fprintf ppf "Preendorsement" type consensus_content = { slot : Slot_repr.t; level : Raw_level_repr.t; (* The level is not required to validate an endorsement when it corresponds to the current payload, but if we want to filter endorsements, we need the level. *) round : Round_repr.t; block_payload_hash : Block_payload_hash.t; (* NOTE: This could be just the hash of the set of operations (the actual payload). The grandfather block hash should already be fixed by the operation.shell.branch field. This is not really important but could make things easier for debugging *) } let consensus_content_encoding = let open Data_encoding in conv (fun {slot; level; round; block_payload_hash} -> (slot, level, round, block_payload_hash)) (fun (slot, level, round, block_payload_hash) -> {slot; level; round; block_payload_hash}) (obj4 (req "slot" Slot_repr.encoding) (req "level" Raw_level_repr.encoding) (req "round" Round_repr.encoding) (req "block_payload_hash" Block_payload_hash.encoding)) let pp_consensus_content ppf content = Format.fprintf ppf "(%ld, %a, %a, %a)" (Raw_level_repr.to_int32 content.level) Round_repr.pp content.round Slot_repr.pp content.slot Block_payload_hash.pp_short content.block_payload_hash type consensus_watermark = | Endorsement of Chain_id.t | Preendorsement of Chain_id.t let bytes_of_consensus_watermark = function | Preendorsement chain_id -> Bytes.cat (Bytes.of_string "\x12") (Chain_id.to_bytes chain_id) | Endorsement chain_id -> Bytes.cat (Bytes.of_string "\x13") (Chain_id.to_bytes chain_id) let to_watermark w = Signature.Custom (bytes_of_consensus_watermark w) let of_watermark = function | Signature.Custom b -> if Compare.Int.(Bytes.length b > 0) then match Bytes.get b 0 with | '\x12' -> Option.map (fun chain_id -> Endorsement chain_id) (Chain_id.of_bytes_opt (Bytes.sub b 1 (Bytes.length b - 1))) | '\x13' -> Option.map (fun chain_id -> Preendorsement chain_id) (Chain_id.of_bytes_opt (Bytes.sub b 1 (Bytes.length b - 1))) | _ -> None else None | _ -> None type raw = Operation.t = {shell : Operation.shell_header; proto : bytes} let raw_encoding = Operation.encoding type transaction = { amount : Tez_repr.tez; parameters : Script_repr.lazy_expr; entrypoint : Entrypoint_repr.t; destination : Destination_repr.t; } type origination = { delegate : Signature.Public_key_hash.t option; script : Script_repr.t; credit : Tez_repr.tez; } type 'kind operation = { shell : Operation.shell_header; protocol_data : 'kind protocol_data; } and 'kind protocol_data = { contents : 'kind contents_list; signature : Signature.t option; } and _ contents_list = | Single : 'kind contents -> 'kind contents_list | Cons : 'kind Kind.manager contents * 'rest Kind.manager contents_list -> ('kind * 'rest) Kind.manager contents_list and _ contents = | Preendorsement : consensus_content -> Kind.preendorsement contents | Endorsement : consensus_content -> Kind.endorsement contents | Seed_nonce_revelation : { level : Raw_level_repr.t; nonce : Seed_repr.nonce; } -> Kind.seed_nonce_revelation contents | Double_preendorsement_evidence : { op1 : Kind.preendorsement operation; op2 : Kind.preendorsement operation; } -> Kind.double_preendorsement_evidence contents | Double_endorsement_evidence : { op1 : Kind.endorsement operation; op2 : Kind.endorsement operation; } -> Kind.double_endorsement_evidence contents | Double_baking_evidence : { bh1 : Block_header_repr.t; bh2 : Block_header_repr.t; } -> Kind.double_baking_evidence contents | Activate_account : { id : Ed25519.Public_key_hash.t; activation_code : Blinded_public_key_hash.activation_code; } -> Kind.activate_account contents | Proposals : { source : Signature.Public_key_hash.t; period : int32; proposals : Protocol_hash.t list; } -> Kind.proposals contents | Ballot : { source : Signature.Public_key_hash.t; period : int32; proposal : Protocol_hash.t; ballot : Vote_repr.ballot; } -> Kind.ballot contents | Failing_noop : string -> Kind.failing_noop contents | Manager_operation : { source : Signature.public_key_hash; fee : Tez_repr.tez; counter : counter; operation : 'kind manager_operation; gas_limit : Gas_limit_repr.Arith.integral; storage_limit : Z.t; } -> 'kind Kind.manager contents and _ manager_operation = | Reveal : Signature.Public_key.t -> Kind.reveal manager_operation | Transaction : transaction -> Kind.transaction manager_operation | Origination : origination -> Kind.origination manager_operation | Delegation : Signature.Public_key_hash.t option -> Kind.delegation manager_operation | Register_global_constant : { value : Script_repr.lazy_expr; } -> Kind.register_global_constant manager_operation | Set_deposits_limit : Tez_repr.t option -> Kind.set_deposits_limit manager_operation | Tx_rollup_origination : Kind.tx_rollup_origination manager_operation | Tx_rollup_submit_batch : { tx_rollup : Tx_rollup_repr.t; content : string; burn_limit : Tez_repr.t option; } -> Kind.tx_rollup_submit_batch manager_operation | Tx_rollup_commit : { tx_rollup : Tx_rollup_repr.t; commitment : Tx_rollup_commitment_repr.Full.t; } -> Kind.tx_rollup_commit manager_operation | Tx_rollup_return_bond : { tx_rollup : Tx_rollup_repr.t; } -> Kind.tx_rollup_return_bond manager_operation | Tx_rollup_finalize_commitment : { tx_rollup : Tx_rollup_repr.t; } -> Kind.tx_rollup_finalize_commitment manager_operation | Tx_rollup_remove_commitment : { tx_rollup : Tx_rollup_repr.t; } -> Kind.tx_rollup_remove_commitment manager_operation | Tx_rollup_rejection : { tx_rollup : Tx_rollup_repr.t; level : Tx_rollup_level_repr.t; message : Tx_rollup_message_repr.t; message_position : int; message_path : Tx_rollup_inbox_repr.Merkle.path; message_result_hash : Tx_rollup_message_result_hash_repr.t; message_result_path : Tx_rollup_commitment_repr.Merkle.path; previous_message_result : Tx_rollup_message_result_repr.t; previous_message_result_path : Tx_rollup_commitment_repr.Merkle.path; proof : Tx_rollup_l2_proof.t; } -> Kind.tx_rollup_rejection manager_operation | Tx_rollup_dispatch_tickets : { tx_rollup : Tx_rollup_repr.t; level : Tx_rollup_level_repr.t; context_hash : Context_hash.t; message_index : int; message_result_path : Tx_rollup_commitment_repr.Merkle.path; tickets_info : Tx_rollup_reveal_repr.t list; } -> Kind.tx_rollup_dispatch_tickets manager_operation | Transfer_ticket : { contents : Script_repr.lazy_expr; ty : Script_repr.lazy_expr; ticketer : Contract_repr.t; amount : Z.t; destination : Contract_repr.t; entrypoint : Entrypoint_repr.t; } -> Kind.transfer_ticket manager_operation | Sc_rollup_originate : { kind : Sc_rollup_repr.Kind.t; boot_sector : string; } -> Kind.sc_rollup_originate manager_operation | Sc_rollup_add_messages : { rollup : Sc_rollup_repr.t; messages : string list; } -> Kind.sc_rollup_add_messages manager_operation | Sc_rollup_cement : { rollup : Sc_rollup_repr.t; commitment : Sc_rollup_repr.Commitment_hash.t; } -> Kind.sc_rollup_cement manager_operation | Sc_rollup_publish : { rollup : Sc_rollup_repr.t; commitment : Sc_rollup_repr.Commitment.t; } -> Kind.sc_rollup_publish manager_operation and counter = Z.t let manager_kind : type kind. kind manager_operation -> kind Kind.manager = function | Reveal _ -> Kind.Reveal_manager_kind | Transaction _ -> Kind.Transaction_manager_kind | Origination _ -> Kind.Origination_manager_kind | Delegation _ -> Kind.Delegation_manager_kind | Register_global_constant _ -> Kind.Register_global_constant_manager_kind | Set_deposits_limit _ -> Kind.Set_deposits_limit_manager_kind | Tx_rollup_origination -> Kind.Tx_rollup_origination_manager_kind | Tx_rollup_submit_batch _ -> Kind.Tx_rollup_submit_batch_manager_kind | Tx_rollup_commit _ -> Kind.Tx_rollup_commit_manager_kind | Tx_rollup_return_bond _ -> Kind.Tx_rollup_return_bond_manager_kind | Tx_rollup_finalize_commitment _ -> Kind.Tx_rollup_finalize_commitment_manager_kind | Tx_rollup_remove_commitment _ -> Kind.Tx_rollup_remove_commitment_manager_kind | Tx_rollup_rejection _ -> Kind.Tx_rollup_rejection_manager_kind | Tx_rollup_dispatch_tickets _ -> Kind.Tx_rollup_dispatch_tickets_manager_kind | Transfer_ticket _ -> Kind.Transfer_ticket_manager_kind | Sc_rollup_originate _ -> Kind.Sc_rollup_originate_manager_kind | Sc_rollup_add_messages _ -> Kind.Sc_rollup_add_messages_manager_kind | Sc_rollup_cement _ -> Kind.Sc_rollup_cement_manager_kind | Sc_rollup_publish _ -> Kind.Sc_rollup_publish_manager_kind type packed_manager_operation = | Manager : 'kind manager_operation -> packed_manager_operation type packed_contents = Contents : 'kind contents -> packed_contents type packed_contents_list = | Contents_list : 'kind contents_list -> packed_contents_list type packed_protocol_data = | Operation_data : 'kind protocol_data -> packed_protocol_data type packed_operation = { shell : Operation.shell_header; protocol_data : packed_protocol_data; } let pack ({shell; protocol_data} : _ operation) : packed_operation = {shell; protocol_data = Operation_data protocol_data} let rec contents_list_to_list : type a. a contents_list -> _ = function | Single o -> [Contents o] | Cons (o, os) -> Contents o :: contents_list_to_list os let to_list = function Contents_list l -> contents_list_to_list l (* This first version of of_list has the type (_, string) result expected by the conv_with_guard combinator of Data_encoding. For a more conventional return type see [of_list] below. *) let rec of_list_internal = function | [] -> Error "Operation lists should not be empty." | [Contents o] -> Ok (Contents_list (Single o)) | Contents o :: os -> ( of_list_internal os >>? fun (Contents_list os) -> match (o, os) with | (Manager_operation _, Single (Manager_operation _)) -> Ok (Contents_list (Cons (o, os))) | (Manager_operation _, Cons _) -> Ok (Contents_list (Cons (o, os))) | _ -> Error "Operation list of length > 1 should only contains manager \ operations.") type error += Contents_list_error of string (* `Permanent *) let of_list l = match of_list_internal l with | Ok contents -> Ok contents | Error s -> error @@ Contents_list_error s let tx_rollup_operation_tag_offset = 150 let tx_rollup_operation_origination_tag = tx_rollup_operation_tag_offset + 0 let tx_rollup_operation_submit_batch_tag = tx_rollup_operation_tag_offset + 1 let tx_rollup_operation_commit_tag = tx_rollup_operation_tag_offset + 2 let tx_rollup_operation_return_bond_tag = tx_rollup_operation_tag_offset + 3 let tx_rollup_operation_finalize_commitment_tag = tx_rollup_operation_tag_offset + 4 let tx_rollup_operation_remove_commitment_tag = tx_rollup_operation_tag_offset + 5 let tx_rollup_operation_rejection_tag = tx_rollup_operation_tag_offset + 6 let tx_rollup_operation_dispatch_tickets_tag = tx_rollup_operation_tag_offset + 7 let transfer_ticket_tag = tx_rollup_operation_tag_offset + 8 let sc_rollup_operation_tag_offset = 200 let sc_rollup_operation_origination_tag = sc_rollup_operation_tag_offset + 0 let sc_rollup_operation_add_message_tag = sc_rollup_operation_tag_offset + 1 let sc_rollup_operation_cement_tag = sc_rollup_operation_tag_offset + 2 let sc_rollup_operation_publish_tag = sc_rollup_operation_tag_offset + 3 module Encoding = struct open Data_encoding let case tag name args proj inj = case tag ~title:(String.capitalize_ascii name) (merge_objs (obj1 (req "kind" (constant name))) args) (fun x -> match proj x with None -> None | Some x -> Some ((), x)) (fun ((), x) -> inj x) module Manager_operations = struct type 'kind case = | MCase : { tag : int; name : string; encoding : 'a Data_encoding.t; select : packed_manager_operation -> 'kind manager_operation option; proj : 'kind manager_operation -> 'a; inj : 'a -> 'kind manager_operation; } -> 'kind case [@@coq_force_gadt] let[@coq_axiom_with_reason "gadt"] reveal_case = MCase { tag = 0; name = "reveal"; encoding = obj1 (req "public_key" Signature.Public_key.encoding); select = (function Manager (Reveal _ as op) -> Some op | _ -> None); proj = (function Reveal pkh -> pkh); inj = (fun pkh -> Reveal pkh); } let transaction_tag = 1 let[@coq_axiom_with_reason "gadt"] transaction_case = MCase { tag = transaction_tag; name = "transaction"; encoding = obj3 (req "amount" Tez_repr.encoding) (req "destination" Destination_repr.encoding) (opt "parameters" (obj2 (req "entrypoint" Entrypoint_repr.smart_encoding) (req "value" Script_repr.lazy_expr_encoding))); select = (function Manager (Transaction _ as op) -> Some op | _ -> None); proj = (function | Transaction {amount; destination; parameters; entrypoint} -> let parameters = if Script_repr.is_unit_parameter parameters && Entrypoint_repr.is_default entrypoint then None else Some (entrypoint, parameters) in (amount, destination, parameters)); inj = (fun (amount, destination, parameters) -> let (entrypoint, parameters) = match parameters with | None -> (Entrypoint_repr.default, Script_repr.unit_parameter) | Some (entrypoint, value) -> (entrypoint, value) in Transaction {amount; destination; parameters; entrypoint}); } let origination_tag = 2 let[@coq_axiom_with_reason "gadt"] origination_case = MCase { tag = origination_tag; name = "origination"; encoding = obj3 (req "balance" Tez_repr.encoding) (opt "delegate" Signature.Public_key_hash.encoding) (req "script" Script_repr.encoding); select = (function Manager (Origination _ as op) -> Some op | _ -> None); proj = (function | Origination {credit; delegate; script} -> (credit, delegate, script)); inj = (fun (credit, delegate, script) -> Origination {credit; delegate; script}); } let delegation_tag = 3 let[@coq_axiom_with_reason "gadt"] delegation_case = MCase { tag = delegation_tag; name = "delegation"; encoding = obj1 (opt "delegate" Signature.Public_key_hash.encoding); select = (function Manager (Delegation _ as op) -> Some op | _ -> None); proj = (function Delegation key -> key); inj = (fun key -> Delegation key); } let[@coq_axiom_with_reason "gadt"] register_global_constant_case = MCase { tag = 4; name = "register_global_constant"; encoding = obj1 (req "value" Script_repr.lazy_expr_encoding); select = (function | Manager (Register_global_constant _ as op) -> Some op | _ -> None); proj = (function Register_global_constant {value} -> value); inj = (fun value -> Register_global_constant {value}); } let[@coq_axiom_with_reason "gadt"] set_deposits_limit_case = MCase { tag = 5; name = "set_deposits_limit"; encoding = obj1 (opt "limit" Tez_repr.encoding); select = (function | Manager (Set_deposits_limit _ as op) -> Some op | _ -> None); proj = (function Set_deposits_limit key -> key); inj = (fun key -> Set_deposits_limit key); } let[@coq_axiom_with_reason "gadt"] tx_rollup_origination_case = MCase { tag = tx_rollup_operation_origination_tag; name = "tx_rollup_origination"; encoding = obj1 (req "tx_rollup_origination" Data_encoding.unit); select = (function | Manager (Tx_rollup_origination as op) -> Some op | _ -> None); proj = (function Tx_rollup_origination -> ()); inj = (fun () -> Tx_rollup_origination); } let tx_rollup_batch_content = (* The content of batches is a string, but stands for an immutable byte sequence. JSON only allows unicode strings so we use the [bytes] encoding which is in hexadecimal for JSON. *) conv Bytes.of_string Bytes.to_string bytes let[@coq_axiom_with_reason "gadt"] tx_rollup_submit_batch_case = MCase { tag = tx_rollup_operation_submit_batch_tag; name = "tx_rollup_submit_batch"; encoding = obj3 (req "rollup" Tx_rollup_repr.encoding) (req "content" tx_rollup_batch_content) (opt "burn_limit" Tez_repr.encoding); select = (function | Manager (Tx_rollup_submit_batch _ as op) -> Some op | _ -> None); proj = (function | Tx_rollup_submit_batch {tx_rollup; content; burn_limit} -> (tx_rollup, content, burn_limit)); inj = (fun (tx_rollup, content, burn_limit) -> Tx_rollup_submit_batch {tx_rollup; content; burn_limit}); } let[@coq_axiom_with_reason "gadt"] tx_rollup_commit_case = MCase { tag = tx_rollup_operation_commit_tag; name = "tx_rollup_commit"; encoding = obj2 (req "rollup" Tx_rollup_repr.encoding) (req "commitment" Tx_rollup_commitment_repr.Full.encoding); select = (function | Manager (Tx_rollup_commit _ as op) -> Some op | _ -> None); proj = (function | Tx_rollup_commit {tx_rollup; commitment} -> (tx_rollup, commitment)); inj = (fun (tx_rollup, commitment) -> Tx_rollup_commit {tx_rollup; commitment}); } let[@coq_axiom_with_reason "gadt"] tx_rollup_return_bond_case = MCase { tag = tx_rollup_operation_return_bond_tag; name = "tx_rollup_return_bond"; encoding = obj1 (req "rollup" Tx_rollup_repr.encoding); select = (function | Manager (Tx_rollup_return_bond _ as op) -> Some op | _ -> None); proj = (function Tx_rollup_return_bond {tx_rollup} -> tx_rollup); inj = (fun tx_rollup -> Tx_rollup_return_bond {tx_rollup}); } let[@coq_axiom_with_reason "gadt"] tx_rollup_finalize_commitment_case = MCase { tag = tx_rollup_operation_finalize_commitment_tag; name = "tx_rollup_finalize_commitment"; encoding = obj1 (req "rollup" Tx_rollup_repr.encoding); select = (function | Manager (Tx_rollup_finalize_commitment _ as op) -> Some op | _ -> None); proj = (function Tx_rollup_finalize_commitment {tx_rollup} -> tx_rollup); inj = (fun tx_rollup -> Tx_rollup_finalize_commitment {tx_rollup}); } let[@coq_axiom_with_reason "gadt"] tx_rollup_remove_commitment_case = MCase { tag = tx_rollup_operation_remove_commitment_tag; name = "tx_rollup_remove_commitment"; encoding = obj1 (req "rollup" Tx_rollup_repr.encoding); select = (function | Manager (Tx_rollup_remove_commitment _ as op) -> Some op | _ -> None); proj = (function Tx_rollup_remove_commitment {tx_rollup} -> tx_rollup); inj = (fun tx_rollup -> Tx_rollup_remove_commitment {tx_rollup}); } let[@coq_axiom_with_reason "gadt"] tx_rollup_rejection_case = MCase { tag = tx_rollup_operation_rejection_tag; name = "tx_rollup_rejection"; encoding = obj10 (req "rollup" Tx_rollup_repr.encoding) (req "level" Tx_rollup_level_repr.encoding) (req "message" Tx_rollup_message_repr.encoding) (req "message_position" n) (req "message_path" Tx_rollup_inbox_repr.Merkle.path_encoding) (req "message_result_hash" Tx_rollup_message_result_hash_repr.encoding) (req "message_result_path" Tx_rollup_commitment_repr.Merkle.path_encoding) (req "previous_message_result" Tx_rollup_message_result_repr.encoding) (req "previous_message_result_path" Tx_rollup_commitment_repr.Merkle.path_encoding) (req "proof" Tx_rollup_l2_proof.encoding); select = (function | Manager (Tx_rollup_rejection _ as op) -> Some op | _ -> None); proj = (function | Tx_rollup_rejection { tx_rollup; level; message; message_position; message_path; message_result_hash; message_result_path; previous_message_result; previous_message_result_path; proof; } -> ( tx_rollup, level, message, Z.of_int message_position, message_path, message_result_hash, message_result_path, previous_message_result, previous_message_result_path, proof )); inj = (fun ( tx_rollup, level, message, message_position, message_path, message_result_hash, message_result_path, previous_message_result, previous_message_result_path, proof ) -> Tx_rollup_rejection { tx_rollup; level; message; message_position = Z.to_int message_position; message_path; message_result_hash; message_result_path; previous_message_result; previous_message_result_path; proof; }); } let[@coq_axiom_with_reason "gadt"] tx_rollup_dispatch_tickets_case = MCase { tag = tx_rollup_operation_dispatch_tickets_tag; name = "tx_rollup_dispatch_tickets"; encoding = obj6 (req "tx_rollup" Tx_rollup_repr.encoding) (req "level" Tx_rollup_level_repr.encoding) (req "context_hash" Context_hash.encoding) (req "message_index" int31) (req "message_result_path" Tx_rollup_commitment_repr.Merkle.path_encoding) (req "tickets_info" (Data_encoding.list Tx_rollup_reveal_repr.encoding)); select = (function | Manager (Tx_rollup_dispatch_tickets _ as op) -> Some op | _ -> None); proj = (function | Tx_rollup_dispatch_tickets { tx_rollup; level; context_hash; message_index; message_result_path; tickets_info; } -> ( tx_rollup, level, context_hash, message_index, message_result_path, tickets_info )); inj = (fun ( tx_rollup, level, context_hash, message_index, message_result_path, tickets_info ) -> Tx_rollup_dispatch_tickets { tx_rollup; level; context_hash; message_index; message_result_path; tickets_info; }); } let[@coq_axiom_with_reason "gadt"] transfer_ticket_case = MCase { tag = transfer_ticket_tag; name = "transfer_ticket"; encoding = obj6 (req "ticket_contents" Script_repr.lazy_expr_encoding) (req "ticket_ty" Script_repr.lazy_expr_encoding) (req "ticket_ticketer" Contract_repr.encoding) (req "ticket_amount" n) (req "destination" Contract_repr.encoding) (req "entrypoint" Entrypoint_repr.simple_encoding); select = (function | Manager (Transfer_ticket _ as op) -> Some op | _ -> None); proj = (function | Transfer_ticket {contents; ty; ticketer; amount; destination; entrypoint} -> (contents, ty, ticketer, amount, destination, entrypoint)); inj = (fun (contents, ty, ticketer, amount, destination, entrypoint) -> Transfer_ticket {contents; ty; ticketer; amount; destination; entrypoint}); } let[@coq_axiom_with_reason "gadt"] sc_rollup_originate_case = MCase { tag = sc_rollup_operation_origination_tag; name = "sc_rollup_originate"; encoding = obj2 (req "kind" Sc_rollup_repr.Kind.encoding) (req "boot_sector" Data_encoding.string); select = (function | Manager (Sc_rollup_originate _ as op) -> Some op | _ -> None); proj = (function | Sc_rollup_originate {kind; boot_sector} -> (kind, boot_sector)); inj = (fun (kind, boot_sector) -> Sc_rollup_originate {kind; boot_sector}); } let[@coq_axiom_with_reason "gadt"] sc_rollup_add_messages_case = MCase { tag = sc_rollup_operation_add_message_tag; name = "sc_rollup_add_messages"; encoding = obj2 (req "rollup" Sc_rollup_repr.encoding) (req "message" (list string)); select = (function | Manager (Sc_rollup_add_messages _ as op) -> Some op | _ -> None); proj = (function | Sc_rollup_add_messages {rollup; messages} -> (rollup, messages)); inj = (fun (rollup, messages) -> Sc_rollup_add_messages {rollup; messages}); } let[@coq_axiom_with_reason "gadt"] sc_rollup_cement_case = MCase { tag = sc_rollup_operation_cement_tag; name = "sc_rollup_cement"; encoding = obj2 (req "rollup" Sc_rollup_repr.encoding) (req "commitment" Sc_rollup_repr.Commitment_hash.encoding); select = (function | Manager (Sc_rollup_cement _ as op) -> Some op | _ -> None); proj = (function | Sc_rollup_cement {rollup; commitment} -> (rollup, commitment)); inj = (fun (rollup, commitment) -> Sc_rollup_cement {rollup; commitment}); } let[@coq_axiom_with_reason "gadt"] sc_rollup_publish_case = MCase { tag = sc_rollup_operation_publish_tag; name = "sc_rollup_publish"; encoding = obj2 (req "rollup" Sc_rollup_repr.encoding) (req "commitment" Sc_rollup_repr.Commitment.encoding); select = (function | Manager (Sc_rollup_publish _ as op) -> Some op | _ -> None); proj = (function | Sc_rollup_publish {rollup; commitment} -> (rollup, commitment)); inj = (fun (rollup, commitment) -> Sc_rollup_publish {rollup; commitment}); } end type 'b case = | Case : { tag : int; name : string; encoding : 'a Data_encoding.t; select : packed_contents -> 'b contents option; proj : 'b contents -> 'a; inj : 'a -> 'b contents; } -> 'b case let preendorsement_case = Case { tag = 20; name = "preendorsement"; encoding = consensus_content_encoding; select = (function Contents (Preendorsement _ as op) -> Some op | _ -> None); proj = (fun (Preendorsement preendorsement) -> preendorsement); inj = (fun preendorsement -> Preendorsement preendorsement); } let preendorsement_encoding = let make (Case {tag; name; encoding; select = _; proj; inj}) = case (Tag tag) name encoding (fun o -> Some (proj o)) (fun x -> inj x) in let to_list : Kind.preendorsement contents_list -> _ = function | Single o -> o in let of_list : Kind.preendorsement contents -> _ = function | o -> Single o in def "inlined.preendorsement" @@ conv (fun ({shell; protocol_data = {contents; signature}} : _ operation) -> (shell, (contents, signature))) (fun (shell, (contents, signature)) : _ operation -> {shell; protocol_data = {contents; signature}}) (merge_objs Operation.shell_header_encoding (obj2 (req "operations" (conv to_list of_list @@ def "inlined.preendorsement.contents" @@ union [make preendorsement_case])) (varopt "signature" Signature.encoding))) let endorsement_encoding = obj4 (req "slot" Slot_repr.encoding) (req "level" Raw_level_repr.encoding) (req "round" Round_repr.encoding) (req "block_payload_hash" Block_payload_hash.encoding) let endorsement_case = Case { tag = 21; name = "endorsement"; encoding = endorsement_encoding; select = (function Contents (Endorsement _ as op) -> Some op | _ -> None); proj = (fun [@coq_match_with_default] (Endorsement consensus_content) -> ( consensus_content.slot, consensus_content.level, consensus_content.round, consensus_content.block_payload_hash )); inj = (fun (slot, level, round, block_payload_hash) -> Endorsement {slot; level; round; block_payload_hash}); } let[@coq_axiom_with_reason "gadt"] endorsement_encoding = let make (Case {tag; name; encoding; select = _; proj; inj}) = case (Tag tag) name encoding (fun o -> Some (proj o)) (fun x -> inj x) in let to_list : Kind.endorsement contents_list -> _ = fun (Single o) -> o in let of_list : Kind.endorsement contents -> _ = fun o -> Single o in def "inlined.endorsement" @@ conv (fun ({shell; protocol_data = {contents; signature}} : _ operation) -> (shell, (contents, signature))) (fun (shell, (contents, signature)) : _ operation -> {shell; protocol_data = {contents; signature}}) (merge_objs Operation.shell_header_encoding (obj2 (req "operations" (conv to_list of_list @@ def "inlined.endorsement_mempool.contents" @@ union [make endorsement_case])) (varopt "signature" Signature.encoding))) let[@coq_axiom_with_reason "gadt"] seed_nonce_revelation_case = Case { tag = 1; name = "seed_nonce_revelation"; encoding = obj2 (req "level" Raw_level_repr.encoding) (req "nonce" Seed_repr.nonce_encoding); select = (function | Contents (Seed_nonce_revelation _ as op) -> Some op | _ -> None); proj = (fun (Seed_nonce_revelation {level; nonce}) -> (level, nonce)); inj = (fun (level, nonce) -> Seed_nonce_revelation {level; nonce}); } let[@coq_axiom_with_reason "gadt"] double_preendorsement_evidence_case : Kind.double_preendorsement_evidence case = Case { tag = 7; name = "double_preendorsement_evidence"; encoding = obj2 (req "op1" (dynamic_size preendorsement_encoding)) (req "op2" (dynamic_size preendorsement_encoding)); select = (function | Contents (Double_preendorsement_evidence _ as op) -> Some op | _ -> None); proj = (fun (Double_preendorsement_evidence {op1; op2}) -> (op1, op2)); inj = (fun (op1, op2) -> Double_preendorsement_evidence {op1; op2}); } let[@coq_axiom_with_reason "gadt"] double_endorsement_evidence_case : Kind.double_endorsement_evidence case = Case { tag = 2; name = "double_endorsement_evidence"; encoding = obj2 (req "op1" (dynamic_size endorsement_encoding)) (req "op2" (dynamic_size endorsement_encoding)); select = (function | Contents (Double_endorsement_evidence _ as op) -> Some op | _ -> None); proj = (fun (Double_endorsement_evidence {op1; op2}) -> (op1, op2)); inj = (fun (op1, op2) -> Double_endorsement_evidence {op1; op2}); } let[@coq_axiom_with_reason "gadt"] double_baking_evidence_case = Case { tag = 3; name = "double_baking_evidence"; encoding = obj2 (req "bh1" (dynamic_size Block_header_repr.encoding)) (req "bh2" (dynamic_size Block_header_repr.encoding)); select = (function | Contents (Double_baking_evidence _ as op) -> Some op | _ -> None); proj = (fun (Double_baking_evidence {bh1; bh2}) -> (bh1, bh2)); inj = (fun (bh1, bh2) -> Double_baking_evidence {bh1; bh2}); } let[@coq_axiom_with_reason "gadt"] activate_account_case = Case { tag = 4; name = "activate_account"; encoding = obj2 (req "pkh" Ed25519.Public_key_hash.encoding) (req "secret" Blinded_public_key_hash.activation_code_encoding); select = (function | Contents (Activate_account _ as op) -> Some op | _ -> None); proj = (fun (Activate_account {id; activation_code}) -> (id, activation_code)); inj = (fun (id, activation_code) -> Activate_account {id; activation_code}); } let[@coq_axiom_with_reason "gadt"] proposals_case = Case { tag = 5; name = "proposals"; encoding = obj3 (req "source" Signature.Public_key_hash.encoding) (req "period" int32) (req "proposals" (list Protocol_hash.encoding)); select = (function Contents (Proposals _ as op) -> Some op | _ -> None); proj = (fun (Proposals {source; period; proposals}) -> (source, period, proposals)); inj = (fun (source, period, proposals) -> Proposals {source; period; proposals}); } let[@coq_axiom_with_reason "gadt"] ballot_case = Case { tag = 6; name = "ballot"; encoding = obj4 (req "source" Signature.Public_key_hash.encoding) (req "period" int32) (req "proposal" Protocol_hash.encoding) (req "ballot" Vote_repr.ballot_encoding); select = (function Contents (Ballot _ as op) -> Some op | _ -> None); proj = (function | Ballot {source; period; proposal; ballot} -> (source, period, proposal, ballot)); inj = (fun (source, period, proposal, ballot) -> Ballot {source; period; proposal; ballot}); } let failing_noop_case = Case { tag = 17; name = "failing_noop"; encoding = obj1 (req "arbitrary" Data_encoding.string); select = (function Contents (Failing_noop _ as op) -> Some op | _ -> None); proj = (function[@coq_match_with_default] Failing_noop message -> message); inj = (function message -> Failing_noop message); } let manager_encoding = obj5 (req "source" Signature.Public_key_hash.encoding) (req "fee" Tez_repr.encoding) (req "counter" (check_size 10 n)) (req "gas_limit" (check_size 10 Gas_limit_repr.Arith.n_integral_encoding)) (req "storage_limit" (check_size 10 n)) let extract : type kind. kind Kind.manager contents -> _ = function[@coq_match_with_default] | Manager_operation {source; fee; counter; gas_limit; storage_limit; operation = _} -> (source, fee, counter, gas_limit, storage_limit) let rebuild (source, fee, counter, gas_limit, storage_limit) operation = Manager_operation {source; fee; counter; gas_limit; storage_limit; operation} let[@coq_axiom_with_reason "gadt"] make_manager_case tag (type kind) (Manager_operations.MCase mcase : kind Manager_operations.case) = Case { tag; name = mcase.name; encoding = merge_objs manager_encoding mcase.encoding; select = (function | Contents (Manager_operation ({operation; _} as op)) -> ( match mcase.select (Manager operation) with | None -> None | Some operation -> Some (Manager_operation {op with operation})) | _ -> None); proj = (function | Manager_operation {operation; _} as op -> (extract op, mcase.proj operation)); inj = (fun (op, contents) -> rebuild op (mcase.inj contents)); } let reveal_case = make_manager_case 107 Manager_operations.reveal_case let transaction_case = make_manager_case 108 Manager_operations.transaction_case let origination_case = make_manager_case 109 Manager_operations.origination_case let delegation_case = make_manager_case 110 Manager_operations.delegation_case let register_global_constant_case = make_manager_case 111 Manager_operations.register_global_constant_case let set_deposits_limit_case = make_manager_case 112 Manager_operations.set_deposits_limit_case let tx_rollup_origination_case = make_manager_case tx_rollup_operation_tag_offset Manager_operations.tx_rollup_origination_case let tx_rollup_submit_batch_case = make_manager_case tx_rollup_operation_submit_batch_tag Manager_operations.tx_rollup_submit_batch_case let tx_rollup_commit_case = make_manager_case tx_rollup_operation_commit_tag Manager_operations.tx_rollup_commit_case let tx_rollup_return_bond_case = make_manager_case tx_rollup_operation_return_bond_tag Manager_operations.tx_rollup_return_bond_case let tx_rollup_finalize_commitment_case = make_manager_case tx_rollup_operation_finalize_commitment_tag Manager_operations.tx_rollup_finalize_commitment_case let tx_rollup_remove_commitment_case = make_manager_case tx_rollup_operation_remove_commitment_tag Manager_operations.tx_rollup_remove_commitment_case let tx_rollup_rejection_case = make_manager_case tx_rollup_operation_rejection_tag Manager_operations.tx_rollup_rejection_case let tx_rollup_dispatch_tickets_case = make_manager_case tx_rollup_operation_dispatch_tickets_tag Manager_operations.tx_rollup_dispatch_tickets_case let transfer_ticket_case = make_manager_case transfer_ticket_tag Manager_operations.transfer_ticket_case let sc_rollup_originate_case = make_manager_case sc_rollup_operation_origination_tag Manager_operations.sc_rollup_originate_case let sc_rollup_add_messages_case = make_manager_case sc_rollup_operation_add_message_tag Manager_operations.sc_rollup_add_messages_case let sc_rollup_cement_case = make_manager_case sc_rollup_operation_cement_tag Manager_operations.sc_rollup_cement_case let sc_rollup_publish_case = make_manager_case sc_rollup_operation_publish_tag Manager_operations.sc_rollup_publish_case let contents_encoding = let make (Case {tag; name; encoding; select; proj; inj}) = case (Tag tag) name encoding (fun o -> match select o with None -> None | Some o -> Some (proj o)) (fun x -> Contents (inj x)) in def "operation.alpha.contents" @@ union [ make endorsement_case; make preendorsement_case; make seed_nonce_revelation_case; make double_endorsement_evidence_case; make double_preendorsement_evidence_case; make double_baking_evidence_case; make activate_account_case; make proposals_case; make ballot_case; make reveal_case; make transaction_case; make origination_case; make delegation_case; make set_deposits_limit_case; make failing_noop_case; make register_global_constant_case; make tx_rollup_origination_case; make tx_rollup_submit_batch_case; make tx_rollup_commit_case; make tx_rollup_return_bond_case; make tx_rollup_finalize_commitment_case; make tx_rollup_remove_commitment_case; make tx_rollup_rejection_case; make tx_rollup_dispatch_tickets_case; make transfer_ticket_case; make sc_rollup_originate_case; make sc_rollup_add_messages_case; make sc_rollup_cement_case; make sc_rollup_publish_case; ] let contents_list_encoding = conv_with_guard to_list of_list_internal (Variable.list contents_encoding) let optional_signature_encoding = conv (function Some s -> s | None -> Signature.zero) (fun s -> if Signature.equal s Signature.zero then None else Some s) Signature.encoding let protocol_data_encoding = def "operation.alpha.contents_and_signature" @@ conv (fun (Operation_data {contents; signature}) -> (Contents_list contents, signature)) (fun (Contents_list contents, signature) -> Operation_data {contents; signature}) (obj2 (req "contents" contents_list_encoding) (req "signature" optional_signature_encoding)) let operation_encoding = conv (fun {shell; protocol_data} -> (shell, protocol_data)) (fun (shell, protocol_data) -> {shell; protocol_data}) (merge_objs Operation.shell_header_encoding protocol_data_encoding) let unsigned_operation_encoding = def "operation.alpha.unsigned_operation" @@ merge_objs Operation.shell_header_encoding (obj1 (req "contents" contents_list_encoding)) end let encoding = Encoding.operation_encoding let contents_encoding = Encoding.contents_encoding let contents_list_encoding = Encoding.contents_list_encoding let protocol_data_encoding = Encoding.protocol_data_encoding let unsigned_operation_encoding = Encoding.unsigned_operation_encoding let raw ({shell; protocol_data} : _ operation) = let proto = Data_encoding.Binary.to_bytes_exn protocol_data_encoding (Operation_data protocol_data) in {Operation.shell; proto} let acceptable_passes (op : packed_operation) = let (Operation_data protocol_data) = op.protocol_data in match protocol_data.contents with | Single (Failing_noop _) -> [] | Single (Preendorsement _) -> [0] | Single (Endorsement _) -> [0] | Single (Proposals _) -> [1] | Single (Ballot _) -> [1] | Single (Seed_nonce_revelation _) -> [2] | Single (Double_endorsement_evidence _) -> [2] | Single (Double_preendorsement_evidence _) -> [2] | Single (Double_baking_evidence _) -> [2] | Single (Activate_account _) -> [2] | Single (Manager_operation _) -> [3] | Cons (Manager_operation _, _ops) -> [3] type error += Invalid_signature (* `Permanent *) type error += Missing_signature (* `Permanent *) let () = register_error_kind `Permanent ~id:"operation.invalid_signature" ~title:"Invalid operation signature" ~description: "The operation signature is ill-formed or has been made with the wrong \ public key" ~pp:(fun ppf () -> Format.fprintf ppf "The operation signature is invalid") Data_encoding.unit (function Invalid_signature -> Some () | _ -> None) (fun () -> Invalid_signature) ; register_error_kind `Permanent ~id:"operation.missing_signature" ~title:"Missing operation signature" ~description: "The operation is of a kind that must be signed, but the signature is \ missing" ~pp:(fun ppf () -> Format.fprintf ppf "The operation requires a signature") Data_encoding.unit (function Missing_signature -> Some () | _ -> None) (fun () -> Missing_signature) ; register_error_kind `Permanent ~id:"operation.contents_list_error" ~title:"Invalid list of operation contents." ~description: "An operation contents list has an unexpected shape; it should be either \ a single operation or a non-empty list of manager operations" ~pp:(fun ppf s -> Format.fprintf ppf "An operation contents list has an unexpected shape: %s" s) Data_encoding.(obj1 (req "message" string)) (function Contents_list_error s -> Some s | _ -> None) (fun s -> Contents_list_error s) let check_signature (type kind) key chain_id ({shell; protocol_data} : kind operation) = let check ~watermark contents signature = let unsigned_operation = Data_encoding.Binary.to_bytes_exn unsigned_operation_encoding (shell, contents) in if Signature.check ~watermark key signature unsigned_operation then Ok () else error Invalid_signature in match protocol_data.signature with | None -> error Missing_signature | Some signature -> ( match protocol_data.contents with | Single (Preendorsement _) as contents -> check ~watermark:(to_watermark (Preendorsement chain_id)) (Contents_list contents) signature | Single (Endorsement _) as contents -> check ~watermark:(to_watermark (Endorsement chain_id)) (Contents_list contents) signature | Single ( Failing_noop _ | Proposals _ | Ballot _ | Seed_nonce_revelation _ | Double_endorsement_evidence _ | Double_preendorsement_evidence _ | Double_baking_evidence _ | Activate_account _ | Manager_operation _ ) -> check ~watermark:Generic_operation (Contents_list protocol_data.contents) signature | Cons (Manager_operation _, _ops) -> check ~watermark:Generic_operation (Contents_list protocol_data.contents) signature) let hash_raw = Operation.hash let hash (o : _ operation) = let proto = Data_encoding.Binary.to_bytes_exn protocol_data_encoding (Operation_data o.protocol_data) in Operation.hash {shell = o.shell; proto} let hash_packed (o : packed_operation) = let proto = Data_encoding.Binary.to_bytes_exn protocol_data_encoding o.protocol_data in Operation.hash {shell = o.shell; proto} type ('a, 'b) eq = Eq : ('a, 'a) eq [@@coq_force_gadt] let equal_manager_operation_kind : type a b. a manager_operation -> b manager_operation -> (a, b) eq option = fun op1 op2 -> match (op1, op2) with | (Reveal _, Reveal _) -> Some Eq | (Reveal _, _) -> None | (Transaction _, Transaction _) -> Some Eq | (Transaction _, _) -> None | (Origination _, Origination _) -> Some Eq | (Origination _, _) -> None | (Delegation _, Delegation _) -> Some Eq | (Delegation _, _) -> None | (Register_global_constant _, Register_global_constant _) -> Some Eq | (Register_global_constant _, _) -> None | (Set_deposits_limit _, Set_deposits_limit _) -> Some Eq | (Set_deposits_limit _, _) -> None | (Tx_rollup_origination, Tx_rollup_origination) -> Some Eq | (Tx_rollup_origination, _) -> None | (Tx_rollup_submit_batch _, Tx_rollup_submit_batch _) -> Some Eq | (Tx_rollup_submit_batch _, _) -> None | (Tx_rollup_commit _, Tx_rollup_commit _) -> Some Eq | (Tx_rollup_commit _, _) -> None | (Tx_rollup_return_bond _, Tx_rollup_return_bond _) -> Some Eq | (Tx_rollup_return_bond _, _) -> None | (Tx_rollup_finalize_commitment _, Tx_rollup_finalize_commitment _) -> Some Eq | (Tx_rollup_finalize_commitment _, _) -> None | (Tx_rollup_remove_commitment _, Tx_rollup_remove_commitment _) -> Some Eq | (Tx_rollup_remove_commitment _, _) -> None | (Tx_rollup_rejection _, Tx_rollup_rejection _) -> Some Eq | (Tx_rollup_rejection _, _) -> None | (Tx_rollup_dispatch_tickets _, Tx_rollup_dispatch_tickets _) -> Some Eq | (Tx_rollup_dispatch_tickets _, _) -> None | (Transfer_ticket _, Transfer_ticket _) -> Some Eq | (Transfer_ticket _, _) -> None | (Sc_rollup_originate _, Sc_rollup_originate _) -> Some Eq | (Sc_rollup_originate _, _) -> None | (Sc_rollup_add_messages _, Sc_rollup_add_messages _) -> Some Eq | (Sc_rollup_add_messages _, _) -> None | (Sc_rollup_cement _, Sc_rollup_cement _) -> Some Eq | (Sc_rollup_cement _, _) -> None | (Sc_rollup_publish _, Sc_rollup_publish _) -> Some Eq | (Sc_rollup_publish _, _) -> None let equal_contents_kind : type a b. a contents -> b contents -> (a, b) eq option = fun op1 op2 -> match (op1, op2) with | (Preendorsement _, Preendorsement _) -> Some Eq | (Preendorsement _, _) -> None | (Endorsement _, Endorsement _) -> Some Eq | (Endorsement _, _) -> None | (Seed_nonce_revelation _, Seed_nonce_revelation _) -> Some Eq | (Seed_nonce_revelation _, _) -> None | (Double_endorsement_evidence _, Double_endorsement_evidence _) -> Some Eq | (Double_endorsement_evidence _, _) -> None | (Double_preendorsement_evidence _, Double_preendorsement_evidence _) -> Some Eq | (Double_preendorsement_evidence _, _) -> None | (Double_baking_evidence _, Double_baking_evidence _) -> Some Eq | (Double_baking_evidence _, _) -> None | (Activate_account _, Activate_account _) -> Some Eq | (Activate_account _, _) -> None | (Proposals _, Proposals _) -> Some Eq | (Proposals _, _) -> None | (Ballot _, Ballot _) -> Some Eq | (Ballot _, _) -> None | (Failing_noop _, Failing_noop _) -> Some Eq | (Failing_noop _, _) -> None | (Manager_operation op1, Manager_operation op2) -> ( match equal_manager_operation_kind op1.operation op2.operation with | None -> None | Some Eq -> Some Eq) | (Manager_operation _, _) -> None let rec equal_contents_kind_list : type a b. a contents_list -> b contents_list -> (a, b) eq option = fun op1 op2 -> match (op1, op2) with | (Single op1, Single op2) -> equal_contents_kind op1 op2 | (Single _, Cons _) -> None | (Cons _, Single _) -> None | (Cons (op1, ops1), Cons (op2, ops2)) -> ( match equal_contents_kind op1 op2 with | None -> None | Some Eq -> ( match equal_contents_kind_list ops1 ops2 with | None -> None | Some Eq -> Some Eq)) let equal : type a b. a operation -> b operation -> (a, b) eq option = fun op1 op2 -> if not (Operation_hash.equal (hash op1) (hash op2)) then None else equal_contents_kind_list op1.protocol_data.contents op2.protocol_data.contents
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>