package tezos-protocol-015-PtLimaPt
Tezos protocol 015-PtLimaPt package
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/src/tezos_raw_protocol_015_PtLimaPt/zk_rollup_storage.ml.html
Source file zk_rollup_storage.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
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.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. *) (* *) (*****************************************************************************) type error += | Zk_rollup_does_not_exist of Zk_rollup_repr.t | Zk_rollup_invalid_op_code of int let () = register_error_kind `Temporary ~id:"Zk_rollup_does_not_exist" ~title:"ZK Rollup does not exist" ~description:"Attempted to use a ZK rollup that has not been originated." ~pp:(fun ppf x -> Format.fprintf ppf "Rollup %a does not exist" Zk_rollup_repr.Address.pp x) Data_encoding.(obj1 (req "rollup" Zk_rollup_repr.Address.encoding)) (function Zk_rollup_does_not_exist x -> Some x | _ -> None) (fun x -> Zk_rollup_does_not_exist x) ; register_error_kind `Permanent ~id:"Zk_rollup_invalid_op code" ~title:"Invalid op code in append" ~description:"Invalid op code in append" ~pp:(fun ppf oc -> Format.fprintf ppf "Op code %d is not valid for this ZK Rollup" oc) Data_encoding.(obj1 (req "op_code" int31)) (function Zk_rollup_invalid_op_code oc -> Some oc | _ -> None) (fun oc -> Zk_rollup_invalid_op_code oc) let originate ctxt static ~init_state = let open Lwt_result_syntax in let*? ctxt, nonce = Raw_context.increment_origination_nonce ctxt in let*? address = Zk_rollup_repr.Address.from_nonce nonce in let origination_size = Constants_storage.zk_rollup_origination_size ctxt in let initial_account = Zk_rollup_account_repr. { static; dynamic = { state = init_state; paid_l2_operations_storage_space = Z.of_int origination_size; used_l2_operations_storage_space = Z.zero; }; } in let* ctxt, account_size = Storage.Zk_rollup.Account.init ctxt address initial_account in let init_pl = Zk_rollup_repr.(Empty {next_index = 0L}) in let* ctxt, pl_size = Storage.Zk_rollup.Pending_list.init ctxt address init_pl in let address_size = Zk_rollup_repr.Address.size in let size = Z.of_int (origination_size + address_size + account_size + pl_size) in return (ctxt, address, size) let add_to_pending ctxt rollup ops = let open Lwt_result_syntax in let open Zk_rollup_repr in let open Zk_rollup_operation_repr in let* ctxt, acc = Storage.Zk_rollup.Account.get ctxt rollup in let*? () = List.iter_e (fun (op, _ticket_hash_opt) -> if Compare.Int.(op.op_code >= acc.static.nb_ops || op.op_code < 0) then error @@ Zk_rollup_invalid_op_code op.op_code else ok ()) ops in let* ctxt, pl = Storage.Zk_rollup.Pending_list.get ctxt rollup in let next_index, length = match pl with | Empty {next_index} -> (next_index, 0) | Pending {next_index; length} -> (next_index, length) in let* ctxt, next_index, length, storage_diff = List.fold_left_es (fun (ctxt, next_index, length, storage_diff) op -> let* ctxt, new_storage_diff, _was_bound = Storage.Zk_rollup.Pending_operation.add (ctxt, rollup) next_index op in return ( ctxt, Int64.succ next_index, length + 1, new_storage_diff + storage_diff )) (ctxt, next_index, length, 0) ops in let used_l2_operations_storage_space = Z.(add acc.dynamic.used_l2_operations_storage_space (Z.of_int storage_diff)) in let l2_operations_storage_space_to_pay = Z.( max zero (sub used_l2_operations_storage_space acc.dynamic.paid_l2_operations_storage_space)) in let paid_l2_operations_storage_space = Z.( add acc.dynamic.paid_l2_operations_storage_space l2_operations_storage_space_to_pay) in let acc = { acc with dynamic = { acc.dynamic with paid_l2_operations_storage_space; used_l2_operations_storage_space; }; } in let pl = if Compare.Int.(length = 0) then Empty {next_index} else Pending {next_index; length} in (* Users aren't charged for storage diff in the account or pending list description of a ZKRU. When updating a ZKRU account, the storage diff can only come from the dynamically sized [Z.t] used for the watermark. These changes in storage size will not be accounted for. As for the pending list description, the storage size is fixed for each of the two cases (empty / non-empty). Then, there will be a storage diff when switching between these two, which won't be accounted for either. *) let* ctxt, _diff_acc = Storage.Zk_rollup.Account.update ctxt rollup acc in let* ctxt, _diff_pl = Storage.Zk_rollup.Pending_list.update ctxt rollup pl in return (ctxt, l2_operations_storage_space_to_pay) let assert_exist ctxt rollup = let open Lwt_result_syntax in let* ctxt, exists = Storage.Zk_rollup.Account.mem ctxt rollup in let*? () = error_unless exists (Zk_rollup_does_not_exist rollup) in return ctxt let exists ctxt rollup = Storage.Zk_rollup.Account.mem ctxt rollup
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>