123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *)(* Copyright (c) 2022 Trili Tech, <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. *)(* *)(*****************************************************************************)openSc_rollup_reprmoduleHash=structincludeSmart_rollup.Commitment_hashincludePath_encoding.Make_hex(Smart_rollup.Commitment_hash)endmoduleV1=structtypet={compressed_state:State_hash.t;inbox_level:Raw_level_repr.t;predecessor:Hash.t;number_of_ticks:Number_of_ticks.t;}letppfmt{compressed_state;inbox_level;predecessor;number_of_ticks}=Format.fprintffmt"compressed_state: %a@,\
inbox_level: %a@,\
predecessor: %a@,\
number_of_ticks: %Ld"State_hash.ppcompressed_stateRaw_level_repr.ppinbox_levelHash.pppredecessor(Number_of_ticks.to_valuenumber_of_ticks)letencoding=letopenData_encodinginconv(fun{compressed_state;inbox_level;predecessor;number_of_ticks}->(compressed_state,inbox_level,predecessor,number_of_ticks))(fun(compressed_state,inbox_level,predecessor,number_of_ticks)->{compressed_state;inbox_level;predecessor;number_of_ticks})(obj4(req"compressed_state"State_hash.encoding)(req"inbox_level"Raw_level_repr.encoding)(req"predecessor"Hash.encoding)(req"number_of_ticks"Number_of_ticks.encoding))lethash_uncarbonatedcommitment=letcommitment_bytes=Data_encoding.Binary.to_bytes_exnencodingcommitmentinHash.hash_bytes[commitment_bytes](* For [number_of_messages] and [number_of_ticks] min_value is equal to zero. *)letgenesis_commitment~origination_level~genesis_state_hash=letopenSc_rollup_reprinletnumber_of_ticks=Number_of_ticks.zeroin{compressed_state=genesis_state_hash;inbox_level=origination_level;predecessor=Hash.zero;number_of_ticks;}typegenesis_info={level:Raw_level_repr.t;commitment_hash:Hash.t}letgenesis_info_encoding=letopenData_encodinginconv(fun{level;commitment_hash}->(level,commitment_hash))(fun(level,commitment_hash)->{level;commitment_hash})(obj2(req"level"Raw_level_repr.encoding)(req"commitment_hash"Hash.encoding))endtypeversioned=V1ofV1.tletversioned_encoding=letopenData_encodinginunion[case~title:"V1"(Tag0)V1.encoding(functionV1commitment->Somecommitment)(funcommitment->V1commitment);]includeV1letof_versioned=functionV1commitment->commitment[@@inline]letto_versionedcommitment=V1commitment[@@inline]