package octez-protocol-019-PtParisB-libs
Octez protocol 019-PtParisB libraries
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/src/octez-protocol-019-PtParisB-libs.test-helpers/op.ml.html
Source file op.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
(*****************************************************************************) (* *) (* 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. *) (* *) (*****************************************************************************) open Protocol open Alpha_context let pack_operation ctxt signature contents = let branch = Context.branch ctxt in Operation.pack ({shell = {branch}; protocol_data = {contents; signature}} : _ Operation.t) let sign ?(watermark = Signature.Generic_operation) sk branch contents = let unsigned = Data_encoding.Binary.to_bytes_exn Operation.unsigned_encoding ({branch}, Contents_list contents) in let signature = Some (Signature.sign ~watermark sk unsigned) in ({shell = {branch}; protocol_data = {contents; signature}} : _ Operation.t) (** Generates the block payload hash based on the hash [pred_hash] of the predecessor block and the hash of non-consensus operations of the current block [b]. *) let mk_block_payload_hash payload_round (b : Block.t) = let ops = Block.Forge.classify_operations b.operations in let non_consensus_operations = List.concat (match List.tl ops with None -> [] | Some l -> l) in let hashes = List.map Operation.hash_packed non_consensus_operations in Block_payload.hash ~predecessor_hash:b.header.shell.predecessor ~payload_round hashes let mk_consensus_content_signer_and_branch ?delegate ?slot ?level ?round ?block_payload_hash ?branch attested_block = let open Lwt_result_wrap_syntax in let branch = match branch with | None -> attested_block.Block.header.shell.predecessor | Some branch -> branch in let* delegate_pkh, slots = match delegate with | None -> Context.get_attester (B attested_block) | Some del -> ( let* slots = Context.get_attester_slot (B attested_block) del in match slots with | None -> return (del, []) | Some slots -> return (del, slots)) in let slot = match slot with None -> Stdlib.List.hd slots | Some slot -> slot in let* level = match level with | None -> let*? level = Context.get_level (B attested_block) in return level | Some level -> return level in let* round = match round with | None -> let*?@ round = Block.get_round attested_block in return round | Some round -> return round in let block_payload_hash = match block_payload_hash with | None -> mk_block_payload_hash round attested_block | Some block_payload_hash -> block_payload_hash in let consensus_content = {slot; level; round; block_payload_hash} in let* signer = Account.find delegate_pkh in return (consensus_content, signer.sk, branch) let raw_attestation ?delegate ?slot ?level ?round ?block_payload_hash ?dal_content ?branch attested_block = let open Lwt_result_syntax in let* consensus_content, signer, branch = mk_consensus_content_signer_and_branch ?delegate ?slot ?level ?round ?block_payload_hash ?branch attested_block in let op = Single (Attestation {consensus_content; dal_content}) in return (sign ~watermark:Operation.(to_watermark (Attestation Chain_id.zero)) signer branch op) let attestation ?delegate ?slot ?level ?round ?block_payload_hash ?dal_content ?branch attested_block = let open Lwt_result_syntax in let* op = raw_attestation ?delegate ?slot ?level ?round ?block_payload_hash ?dal_content ?branch attested_block in return (Operation.pack op) let raw_preattestation ?delegate ?slot ?level ?round ?block_payload_hash ?branch attested_block = let open Lwt_result_syntax in let* consensus_content, signer, branch = mk_consensus_content_signer_and_branch ?delegate ?slot ?level ?round ?block_payload_hash ?branch attested_block in let op = Single (Preattestation consensus_content) in return (sign ~watermark:Operation.(to_watermark (Preattestation Chain_id.zero)) signer branch op) let preattestation ?delegate ?slot ?level ?round ?block_payload_hash ?branch attested_block = let open Lwt_result_syntax in let* op = raw_preattestation ?delegate ?slot ?level ?round ?block_payload_hash ?branch attested_block in return (Operation.pack op) let sign ?watermark sk ctxt (Contents_list contents) = Operation.pack (sign ?watermark sk ctxt contents) let batch_operations ?(recompute_counters = false) ~source ctxt (operations : packed_operation list) = let open Lwt_result_wrap_syntax in let operations = List.map (function | {Alpha_context.protocol_data = Operation_data {contents; _}; _} -> Operation.to_list (Contents_list contents)) operations |> List.flatten in let* operations = if recompute_counters then let* counter = Context.Contract.counter ctxt source in (* Update counters and transform into a contents_list *) let _, rev_operations = List.fold_left (fun (counter, acc) -> function | Contents (Manager_operation m) -> ( Manager_counter.succ counter, Contents (Manager_operation {m with counter}) :: acc ) | x -> (counter, x :: acc)) (Manager_counter.succ counter, []) operations in return (List.rev rev_operations) else return operations in let* account = Context.Contract.manager ctxt source in let*?@ operations = Operation.of_list operations in return @@ sign account.sk (Context.branch ctxt) operations type gas_limit = Max | High | Low | Zero | Custom_gas of Gas.Arith.integral let default_low_gas_limit op pkh = let {shell; protocol_data = Operation_data protocol_data} = op in let op : _ operation = {shell; protocol_data} in let check_sig_gas = Operation_costs.check_signature_cost (Michelson_v1_gas.Cost_of.Interpreter.algo_of_public_key_hash pkh) op in let total_cost = Gas.(Michelson_v1_gas.Cost_of.manager_operation +@ check_sig_gas) in (* Some tests need milligas precision to distinguish failures in validation from failures in application but limits in the protocol are statically guaranteed to be integral values so we use Obj.magic to bypass them. *) (Obj.magic total_cost : Gas.Arith.integral) let default_high_gas_limit = Gas.Arith.integral_of_int_exn (49_000 + Michelson_v1_gas.Internal_for_tests.int_cost_of_manager_operation) let resolve_gas_limit ?(force_reveal = false) ctxt op source gas_limit = let open Lwt_result_syntax in let pkh = Context.Contract.pkh source in let* revealed = Context.Contract.is_manager_key_revealed ctxt source in match gas_limit with | Max -> let* c = Context.get_constants ctxt in return (c.parametric.hard_gas_limit_per_operation, None) | High -> return (default_high_gas_limit, None) | Low when force_reveal && not revealed -> (* If force reveal is set, the operation is a batch where the reveal is the first operation. This operation should have a gas_limit corresponding to the manager_operation constant (Low) + the cost of the signature checking. The second op should only have Low as gas_limit *) let op_gas : Gas.Arith.integral = Obj.magic Michelson_v1_gas.Cost_of.manager_operation in return (op_gas, Some (default_low_gas_limit op pkh)) | Low -> return (default_low_gas_limit op pkh, None) | Zero -> return (Gas.Arith.zero, None) | Custom_gas x -> return (x, None) let pp_gas_limit fmt = function | Max -> Format.fprintf fmt "Max" | High -> Format.fprintf fmt "High: %a" Gas.Arith.pp_integral default_high_gas_limit | Low -> Format.fprintf fmt "Low" | Zero -> Format.fprintf fmt "Zero: %a" Gas.Arith.pp_integral Gas.Arith.zero | Custom_gas x -> Format.fprintf fmt "Custom: %a" Gas.Arith.pp_integral x let combine_operations ?public_key ?counter ?spurious_operation ~source ctxt (packed_operations : packed_operation list) = let open Lwt_result_wrap_syntax in assert (match packed_operations with [] -> false | _ :: _ -> true) ; (* Hypothesis : each operation must have the same branch (is this really true?) *) let {Tezos_base.Operation.branch} = (WithExceptions.Option.get ~loc:__LOC__ @@ List.hd packed_operations).shell in assert ( List.for_all (fun {shell = {Tezos_base.Operation.branch = b; _}; _} -> Block_hash.(branch = b)) packed_operations) ; (* TODO? : check signatures consistency *) let unpacked_operations = List.map (function | {Alpha_context.protocol_data = Operation_data {contents; _}; _} -> ( match Contents_list contents with | Contents_list (Single o) -> Contents o | Contents_list (Cons (Manager_operation {operation = Reveal _; _}, Single o)) -> Contents o | _ -> (* TODO : decent error *) assert false)) packed_operations in let* counter = match counter with | Some counter -> return counter | None -> Context.Contract.counter ctxt source in (* We increment the counter *) let counter = Manager_counter.succ counter in let* account = Context.Contract.manager ctxt source in let public_key = Option.value ~default:account.pk public_key in let* manager_op, counter = let+ is_revealed = Context.Contract.is_manager_key_revealed ctxt source in match is_revealed with | false -> let reveal_op = Manager_operation { source = Signature.Public_key.hash public_key; fee = Tez.zero; counter; operation = Reveal public_key; gas_limit = default_high_gas_limit; storage_limit = Z.zero; } in (Some (Contents reveal_op), Manager_counter.succ counter) | true -> (None, counter) in (* Update counters and transform into a contents_list *) let counter, rev_operations = List.fold_left (fun (counter, acc) -> function | Contents (Manager_operation m) -> ( Manager_counter.succ counter, Contents (Manager_operation {m with counter}) :: acc ) | x -> (counter, x :: acc)) (counter, match manager_op with None -> [] | Some op -> [op]) unpacked_operations in let operations = List.rev rev_operations in (* patch a random operation with a corrupted pkh *) let operations = match spurious_operation with | None -> operations | Some op -> let op = match op with | {protocol_data; shell = _} -> ( match protocol_data with | Operation_data {contents; _} -> ( match contents with | Cons _ -> assert false | Single (Manager_operation m) -> Alpha_context.Contents (Manager_operation {m with counter}) | Single op -> Contents op)) in (* Insert at the end *) operations @ [op] in let*?@ operations = Operation.of_list operations in return @@ sign account.sk (Context.branch ctxt) operations let manager_operation_with_fixed_gas_limit ?(force_reveal = false) ?counter ~gas_limit ?(reveal_gas_limit = default_high_gas_limit) ?(fee = Tez.zero) ?storage_limit ?public_key ~source ctxt operation = let open Lwt_result_syntax in let* counter = match counter with | Some counter -> return counter | None -> Context.Contract.counter ctxt source in let* c = Context.get_constants ctxt in let storage_limit = Option.value ~default:c.parametric.hard_storage_limit_per_operation storage_limit in let* account = Context.Contract.manager ctxt source in let public_key = Option.value ~default:account.pk public_key in let counter = Manager_counter.succ counter in let+ revealed = Context.Contract.is_manager_key_revealed ctxt source in (* If the manager is revealed or we are not forcing reveals, we generate a singleton manager operation. *) if revealed || not force_reveal then let op = Manager_operation { source = Signature.Public_key.hash public_key; fee; counter; operation; gas_limit; storage_limit; } in Contents_list (Single op) (* Otherwise if the manager is unrevealed and we are force_revaling managers by default, we pre-attach a revelation for it. *) else let op_reveal = Manager_operation { source = Signature.Public_key.hash public_key; fee = Tez.zero; counter; operation = Reveal public_key; gas_limit = reveal_gas_limit; storage_limit = Z.zero; } in let op = Manager_operation { source = Signature.Public_key.hash public_key; fee; counter = Manager_counter.succ counter; operation; gas_limit; storage_limit; } in Contents_list (Cons (op_reveal, Single op)) let manager_operation ?force_reveal ?counter ?fee ?(gas_limit = High) ?storage_limit ?public_key ~source ctxt operation = let open Lwt_result_syntax in let default_gas_limit = default_high_gas_limit in let* (Contents_list dummy_operation) = manager_operation_with_fixed_gas_limit ?force_reveal ?counter ~gas_limit:default_gas_limit ?fee ?storage_limit ?public_key ~source ctxt operation in let* gas_limit, reveal_gas_limit = resolve_gas_limit ?force_reveal ctxt { shell = {branch = Context.branch ctxt}; protocol_data = Operation_data {contents = dummy_operation; signature = None}; } source gas_limit in manager_operation_with_fixed_gas_limit ?force_reveal ?counter ~gas_limit ?reveal_gas_limit ?fee ?storage_limit ?public_key ~source ctxt operation let revelation_with_fixed_gas_limit ?(fee = Tez.zero) ~gas_limit ?(storage_limit = Z.zero) ?counter ?(forge_pkh = None) ctxt public_key = let open Lwt_result_syntax in (* If Some pkh is provided to ?forge_pkh we take that hash at face value, otherwise we honestly compute the hash from [public_key]. This is useful to test forging Reveal operations (cf. tezos!5182). *) let pkh = match forge_pkh with | Some pkh -> pkh | None -> Signature.Public_key.hash public_key in let source = Contract.Implicit pkh in let+ counter = match counter with | None -> Context.Contract.counter ctxt source | Some ctr -> return ctr in let counter = Manager_counter.succ counter in Manager_operation { source = pkh; fee; counter; operation = Reveal public_key; gas_limit; storage_limit; } let revelation ?fee ?(gas_limit = High) ?storage_limit ?counter ?forge_pkh ctxt public_key = let open Lwt_result_syntax in let* (Manager_operation {source; _} as dummy_operation) = revelation_with_fixed_gas_limit ?fee ~gas_limit:default_high_gas_limit ?storage_limit ?counter ?forge_pkh ctxt public_key in let* gas_limit, _ = resolve_gas_limit ctxt { shell = {branch = Context.branch ctxt}; protocol_data = Operation_data {contents = Single dummy_operation; signature = None}; } (Contract.Implicit source) gas_limit in let* op = revelation_with_fixed_gas_limit ?fee ~gas_limit ?storage_limit ?counter ?forge_pkh ctxt public_key in let sop = Contents_list (Single op) in let+ account = Context.Contract.manager ctxt (Implicit source) in sign account.sk (Context.branch ctxt) sop let failing_noop ctxt source arbitrary = let open Lwt_result_syntax in let op = Contents_list (Single (Failing_noop arbitrary)) in let* account = Account.find source in return @@ sign account.sk (Context.branch ctxt) op let originated_contract_hash op = let nonce = Protocol.Origination_nonce.initial (Operation.hash_packed op) in Contract_hash.of_nonce nonce let originated_contract op = Contract.Originated (originated_contract_hash op) exception Impossible let contract_origination_gen k ?force_reveal ?counter ?delegate ~script ?public_key ?credit ?fee ?gas_limit ?storage_limit ctxt source = let open Lwt_result_syntax in let* account = Context.Contract.manager ctxt source in let default_credit = Tez.of_mutez @@ Int64.of_int 1000001 in let default_credit = WithExceptions.Option.to_exn ~none:Impossible default_credit in let credit = Option.value ~default:default_credit credit in let operation = Origination {delegate; script; credit} in let+ sop = manager_operation ?force_reveal ?counter ?public_key ?fee ?gas_limit ?storage_limit ~source ctxt operation in k (sign account.sk (Context.branch ctxt) sop) let contract_origination = contract_origination_gen (fun op -> (op, originated_contract op)) let contract_origination_hash = contract_origination_gen (fun op -> (op, originated_contract_hash op)) let register_global_constant ?force_reveal ?counter ?public_key ?fee ?gas_limit ?storage_limit ctxt ~source ~value = let open Lwt_result_syntax in let* account = Context.Contract.manager ctxt source in let operation = Register_global_constant {value} in let+ sop = manager_operation ?force_reveal ?counter ?public_key ?fee ?gas_limit ?storage_limit ~source ctxt operation in sign account.sk (Context.branch ctxt) sop let unsafe_transaction ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ?(parameters = Script.unit_parameter) ?(entrypoint = Entrypoint.default) ctxt (src : Contract.t) (destination : Contract.t) (amount : Tez.t) = let open Lwt_result_syntax in let top = Transaction {amount; parameters; destination; entrypoint} in let* sop = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt top in let+ account = Context.Contract.manager ctxt src in sign account.sk (Context.branch ctxt) sop let transaction ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ?parameters ?entrypoint ctxt (src : Contract.t) (dst : Contract.t) (amount : Tez.t) = unsafe_transaction ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ?parameters ?entrypoint ctxt src dst amount let delegation ?force_reveal ?fee ?gas_limit ?counter ?storage_limit ctxt source dst = let open Lwt_result_syntax in let top = Delegation dst in let* sop = manager_operation ?force_reveal ?fee ?counter ?gas_limit ?storage_limit ~source ctxt top in let+ account = Context.Contract.manager ctxt source in sign account.sk (Context.branch ctxt) sop let set_deposits_limit ?force_reveal ?fee ?gas_limit ?storage_limit ?counter ctxt source limit = let open Lwt_result_syntax in let top = Set_deposits_limit limit in let* sop = manager_operation ?force_reveal ?fee ?counter ?storage_limit ?gas_limit ~source ctxt top in let+ account = Context.Contract.manager ctxt source in sign account.sk (Context.branch ctxt) sop let increase_paid_storage ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt ~source ~destination (amount : Z.t) = let open Lwt_result_syntax in let top = Increase_paid_storage {amount_in_bytes = amount; destination} in let* sop = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source ctxt top in let+ account = Context.Contract.manager ctxt source in sign account.sk (Context.branch ctxt) sop let activation ctxt (pkh : Signature.Public_key_hash.t) activation_code = let open Lwt_result_syntax in let+ id = match pkh with | Ed25519 edpkh -> return edpkh | _ -> failwith "Wrong public key hash : %a - Commitments must be activated with an \ Signature.Ed25519 encrypted public key hash" Signature.Public_key_hash.pp pkh in let contents = Single (Activate_account {id; activation_code}) in let branch = Context.branch ctxt in { shell = {branch}; protocol_data = Operation_data {contents; signature = None}; } let double_attestation ctxt op1 op2 = let contents = Single (Double_attestation_evidence {op1; op2}) in let branch = Context.branch ctxt in { shell = {branch}; protocol_data = Operation_data {contents; signature = None}; } let double_preattestation ctxt op1 op2 = let contents = Single (Double_preattestation_evidence {op1; op2}) in let branch = Context.branch ctxt in { shell = {branch}; protocol_data = Operation_data {contents; signature = None}; } let double_baking ctxt bh1 bh2 = let contents = Single (Double_baking_evidence {bh1; bh2}) in let branch = Context.branch ctxt in { shell = {branch}; protocol_data = Operation_data {contents; signature = None}; } let seed_nonce_revelation ctxt level nonce = { shell = {branch = Context.branch ctxt}; protocol_data = Operation_data { contents = Single (Seed_nonce_revelation {level; nonce}); signature = None; }; } let vdf_revelation ctxt solution = { shell = {branch = Context.branch ctxt}; protocol_data = Operation_data {contents = Single (Vdf_revelation {solution}); signature = None}; } let get_period ?period ctxt = let open Lwt_result_syntax in match period with | Some period -> return period | None -> let* current_period = Context.Vote.get_current_period ctxt in return current_period.voting_period.index let proposals_contents ctxt proposer ?period proposals = let open Lwt_result_syntax in let source = Context.Contract.pkh proposer in let* period = get_period ?period ctxt in return (Single (Proposals {source; period; proposals})) let proposals ctxt proposer ?period proposals = let open Lwt_result_syntax in let* contents = proposals_contents ctxt proposer ?period proposals in let* account = Account.find (Context.Contract.pkh proposer) in return (sign account.sk (Context.branch ctxt) (Contents_list contents)) let ballot_contents ctxt voter ?period proposal ballot = let open Lwt_result_syntax in let source = Context.Contract.pkh voter in let* period = get_period ?period ctxt in return (Single (Ballot {source; period; proposal; ballot})) let ballot ctxt voter ?period proposal ballot = let open Lwt_result_syntax in let* contents = ballot_contents ctxt voter ?period proposal ballot in let* account = Account.find (Context.Contract.pkh voter) in return (sign account.sk (Context.branch ctxt) (Contents_list contents)) let dummy_script = let open Micheline in Script. { code = lazy_expr (strip_locations (Seq ( (), [ Prim ((), K_parameter, [Prim ((), T_unit, [], [])], []); Prim ((), K_storage, [Prim ((), T_unit, [], [])], []); Prim ( (), K_code, [ Seq ( (), [ Prim ((), I_CDR, [], []); Prim ( (), I_NIL, [Prim ((), T_operation, [], [])], [] ); Prim ((), I_PAIR, [], []); ] ); ], [] ); ] ))); storage = lazy_expr (strip_locations (Prim ((), D_Unit, [], []))); } let dummy_script_cost = Test_tez.of_mutez_exn 9_500L let transfer_ticket ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt ~(source : Contract.t) ~contents ~ty ~ticketer ~amount ~destination ~entrypoint = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source ctxt (Transfer_ticket {contents; ty; ticketer; amount; destination; entrypoint}) in let+ account = Context.Contract.manager ctxt source in sign account.sk (Context.branch ctxt) to_sign_op let originated_sc_rollup op = let packed = Operation.hash_packed op in let nonce = Origination_nonce.Internal_for_tests.initial packed in Sc_rollup.Internal_for_tests.originated_sc_rollup nonce let sc_rollup_origination ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ?whitelist ctxt (src : Contract.t) kind ~boot_sector ~parameters_ty = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Sc_rollup_originate {kind; boot_sector; parameters_ty; whitelist}) in let* account = Context.Contract.manager ctxt src in let op = sign account.sk (Context.branch ctxt) to_sign_op in let t = originated_sc_rollup op |> fun addr -> (op, addr) in return t let sc_rollup_publish ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt (src : Contract.t) rollup commitment = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Sc_rollup_publish {rollup; commitment}) in let+ account = Context.Contract.manager ctxt src in sign account.sk (Context.branch ctxt) to_sign_op let sc_rollup_cement ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt (src : Contract.t) rollup = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Sc_rollup_cement {rollup}) in let+ account = Context.Contract.manager ctxt src in sign account.sk (Context.branch ctxt) to_sign_op let sc_rollup_execute_outbox_message ?counter ?fee ?gas_limit ?storage_limit ?force_reveal ctxt (src : Contract.t) rollup cemented_commitment ~output_proof = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Sc_rollup_execute_outbox_message {rollup; cemented_commitment; output_proof}) in let+ account = Context.Contract.manager ctxt src in sign account.sk (Context.branch ctxt) to_sign_op let sc_rollup_recover_bond ?counter ?fee ?gas_limit ?storage_limit ?force_reveal ctxt (source : Contract.t) (sc_rollup : Sc_rollup.t) (staker : public_key_hash) = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source ctxt (Sc_rollup_recover_bond {sc_rollup; staker}) in let+ account = Context.Contract.manager ctxt source in sign account.sk (Context.branch ctxt) to_sign_op let sc_rollup_add_messages ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt (src : Contract.t) messages = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Sc_rollup_add_messages {messages}) in let+ account = Context.Contract.manager ctxt src in sign account.sk (Context.branch ctxt) to_sign_op let sc_rollup_refute ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt (src : Contract.t) rollup opponent refutation = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Sc_rollup_refute {rollup; opponent; refutation}) in let+ account = Context.Contract.manager ctxt src in sign account.sk (Context.branch ctxt) to_sign_op let sc_rollup_timeout ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt (src : Contract.t) rollup stakers = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Sc_rollup_timeout {rollup; stakers}) in let+ account = Context.Contract.manager ctxt src in sign account.sk (Context.branch ctxt) to_sign_op let dal_publish_commitment ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt (src : Contract.t) slot_header = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Dal_publish_commitment slot_header) in let+ account = Context.Contract.manager ctxt src in sign account.sk (Context.branch ctxt) to_sign_op let originated_zk_rollup op = let packed = Operation.hash_packed op in let nonce = Origination_nonce.Internal_for_tests.initial packed in Zk_rollup.Internal_for_tests.originated_zk_rollup nonce let zk_rollup_origination ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt (src : Contract.t) ~public_parameters ~circuits_info ~init_state ~nb_ops = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Zk_rollup_origination {public_parameters; circuits_info; init_state; nb_ops}) in let+ account = Context.Contract.manager ctxt src in let op = sign account.sk (Context.branch ctxt) to_sign_op in originated_zk_rollup op |> fun addr -> (op, addr) let update_consensus_key ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt (src : Contract.t) pkh = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Update_consensus_key pkh) in let+ account = Context.Contract.manager ctxt src in sign account.sk (Context.branch ctxt) to_sign_op let drain_delegate ctxt ~consensus_key ~delegate ~destination = let open Lwt_result_syntax in let contents = Single (Drain_delegate {consensus_key; delegate; destination}) in let+ account = Context.Contract.manager ctxt (Contract.Implicit consensus_key) in sign account.sk (Context.branch ctxt) (Contents_list contents) let zk_rollup_publish ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt (src : Contract.t) ~zk_rollup ~ops = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Zk_rollup_publish {zk_rollup; ops}) in let+ account = Context.Contract.manager ctxt src in sign account.sk (Context.branch ctxt) to_sign_op let zk_rollup_update ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ctxt (src : Contract.t) ~zk_rollup ~update = let open Lwt_result_syntax in let* to_sign_op = manager_operation ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ~source:src ctxt (Zk_rollup_update {zk_rollup; update}) in let+ account = Context.Contract.manager ctxt src in sign account.sk (Context.branch ctxt) to_sign_op
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>