package tezos-protocol-alpha
Tezos/Protocol: economic-protocol definition
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-17.3.tar.gz
sha256=7062cd57addd452852598a2214ade393130efa087b99068d53713bdf912b3680
sha512=08e4091144a03ce3c107fb91a66501bd8b65ca3278917c455a2eaac6df3e108ade63f6ab8340a4bb152d60f404326e464d0ec95d26cafe8e82f870465d24a5fc
doc/src/tezos-protocol-alpha.raw/sc_rollup_storage.ml.html
Source file sc_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 169 170 171 172
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2021 Nomadic Labs <contact@nomadic-labs.com> *) (* Copyright (c) 2022 TriliTech <contact@trili.tech> *) (* *) (* 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 Sc_rollup_errors module Store = Storage.Sc_rollup module Commitment = Sc_rollup_commitment_repr module Commitment_hash = Commitment.Hash (** [new_address ctxt] produces an address completely determined by an operation hash and an origination counter, and accounts for gas spent. *) let new_address ctxt = let open Result_syntax in let* ctxt, nonce = Raw_context.increment_origination_nonce ctxt in let* ctxt = Raw_context.consume_gas ctxt Sc_rollup_costs.Constants.cost_serialize_nonce in match Data_encoding.Binary.to_bytes_opt Origination_nonce.encoding nonce with | None -> error Sc_rollup_address_generation | Some nonce_bytes -> let bytes_len = Bytes.length nonce_bytes in let+ ctxt = Raw_context.consume_gas ctxt (Sc_rollup_costs.cost_hash_bytes ~bytes_len) in (ctxt, Sc_rollup_repr.Address.hash_bytes [nonce_bytes]) let init_genesis_info ctxt address genesis_commitment = let open Lwt_result_syntax in let level = (Raw_context.current_level ctxt).level in let*? ctxt, commitment_hash = Sc_rollup_commitment_storage.hash ctxt genesis_commitment in let genesis_info = Commitment.{commitment_hash; level} in let* ctxt, size = Store.Genesis_info.init ctxt address genesis_info in return (ctxt, genesis_info, size) let init_commitment_storage ctxt address ({commitment_hash = genesis_commitment_hash; level = origination_level} : Commitment.genesis_info) genesis_commitment = let open Lwt_result_syntax in let* ctxt, lcc_size = Store.Last_cemented_commitment.init ctxt address genesis_commitment_hash in let* ctxt, commitment_size_diff = Store.Commitments.init (ctxt, address) genesis_commitment_hash genesis_commitment in (* Those stores [Store.Commitment_added] and [Store.Commitment_stake_count] are going to be used to look this bootstrap commitment. This commitment is added here so the [sc_rollup_state_storage.deallocate] function does not have to handle a edge case. *) let* ctxt, commitment_added_size_diff = Store.Commitment_added.init (ctxt, address) genesis_commitment_hash origination_level in (* Those stores [Store.Commitment_first_publication_level] and [Store.Commitment_count_per_inbox_level] are populated with dummy values, in order the [sc_rollup_state_storage.deallocate_commitment_metadata] function does not have to handle an edge case of genesis commitment hash. *) let* ctxt, commitment_first_publication_level_diff = Store.Commitment_first_publication_level.init (ctxt, address) origination_level origination_level in let* ctxt, commitments_per_inbox_level_diff = Store.Commitments_per_inbox_level.init (ctxt, address) origination_level [genesis_commitment_hash] in return ( ctxt, lcc_size + commitment_size_diff + commitment_added_size_diff + commitment_first_publication_level_diff + commitments_per_inbox_level_diff ) let originate ctxt ~kind ~parameters_ty ~genesis_commitment = let open Lwt_result_syntax in let*? ctxt, address = new_address ctxt in let* ctxt, pvm_kind_size = Store.PVM_kind.init ctxt address kind in let* ctxt, param_ty_size = Store.Parameters_type.init ctxt address parameters_ty in let* ctxt = Sc_rollup_staker_index_storage.init ctxt address in let* ctxt, genesis_info, genesis_info_size_diff = init_genesis_info ctxt address genesis_commitment in let* ctxt, commitment_size_diff = init_commitment_storage ctxt address genesis_info genesis_commitment in (* TODO: https://gitlab.com/tezos/tezos/-/issues/4551 There is no need to have both `origination_size` and the size of storage. We should remove one of them. *) let addresses_size = 2 * Sc_rollup_repr.Address.size in let stored_kind_size = 2 (* because tag_size of kind encoding is 16bits. *) in let origination_size = Constants_storage.sc_rollup_origination_size ctxt in let size = Z.of_int (origination_size + stored_kind_size + addresses_size + param_ty_size + pvm_kind_size + genesis_info_size_diff + commitment_size_diff) in return (address, size, genesis_info.commitment_hash, ctxt) let kind ctxt address = let open Lwt_result_syntax in let* ctxt, kind_opt = Store.PVM_kind.find ctxt address in match kind_opt with | Some k -> return (ctxt, k) | None -> tzfail (Sc_rollup_errors.Sc_rollup_does_not_exist address) let list_unaccounted ctxt = let open Lwt_syntax in let+ res = Store.PVM_kind.keys_unaccounted ctxt in Result.return res let genesis_info ctxt rollup = let open Lwt_result_syntax in let* ctxt, genesis_info = Store.Genesis_info.find ctxt rollup in match genesis_info with | None -> tzfail (Sc_rollup_does_not_exist rollup) | Some genesis_info -> return (ctxt, genesis_info) let get_metadata ctxt rollup = let open Lwt_result_syntax in let* ctxt, genesis_info = genesis_info ctxt rollup in let metadata : Sc_rollup_metadata_repr.t = {address = rollup; origination_level = genesis_info.level} in return (ctxt, metadata) let parameters_type ctxt rollup = let open Lwt_result_syntax in let+ ctxt, res = Store.Parameters_type.find ctxt rollup in (res, ctxt) let must_exist ctxt rollup = let open Lwt_result_syntax in let+ ctxt, _info = genesis_info ctxt rollup in ctxt
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>