123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 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. *)(* *)(*****************************************************************************)modulePVM=structtypeboot_sector=stringmoduletypeS=sigvalparse_boot_sector:string->boot_sectoroptionvalpp_boot_sector:Format.formatter->boot_sector->unitincludeSc_rollup_PVM_sig.Sendtype('state,'proof,'output)implementation=(moduleSwithtypestate='stateandtypeproof='proofandtypeoutput_proof='output)typet=Packed:('state,'proof,'output)implementation->t[@@unboxed]endmoduleKind=struct(*
Each time we add a data constructor to [t], we also need:
- to extend [Sc_rollups.all] with this new constructor ;
- to update [Sc_rollups.of_string] and [encoding] ;
- to update [Sc_rollups.wrapped_proof] and [wrapped_proof_encoding].
*)typet=Example_arith|Wasm_2_0_0|Riscvletall=[Example_arith;Wasm_2_0_0;Riscv]letto_string=function|Example_arith->"arith"|Wasm_2_0_0->"wasm_2_0_0"|Riscv->"riscv"letof_string=function|"arith"->SomeExample_arith|"wasm_2_0_0"->SomeWasm_2_0_0|"riscv"->SomeRiscv|_->Noneletencoding=Data_encoding.string_enum@@List.map(funk->(to_stringk,k))allletppfmt=function|Example_arith->Format.pp_print_stringfmt"arith"|Wasm_2_0_0->Format.pp_print_stringfmt"wasm_2_0_0"|Riscv->Format.pp_print_stringfmt"riscv"letequalxy=match(x,y)with|Example_arith,Example_arith->true|Wasm_2_0_0,Wasm_2_0_0->true|Riscv,Riscv->true|_->falseletexample_arith_pvm=PVM.Packed(moduleSc_rollup_arith.Protocol_implementation)letwasm_2_0_0_pvm=PVM.Packed(moduleSc_rollup_wasm.V2_0_0.Protocol_implementation)letriscv_pvm=PVM.Packed(moduleSc_rollup_riscv.Protocol_implementation)letreference_initial_state_hash_of=function|Example_arith->Sc_rollup_arith.reference_initial_state_hash|Wasm_2_0_0->Sc_rollup_wasm.V2_0_0.reference_initial_state_hash|Riscv->Sc_rollup_riscv.reference_initial_state_hashletpvm_of=function|Example_arith->example_arith_pvm|Wasm_2_0_0->wasm_2_0_0_pvm|Riscv->riscv_pvmletno_proof_machine_of:t->(moduleSc_rollup_machine_no_proofs.S)=function|Example_arith->(moduleSc_rollup_machine_no_proofs.Arith)|Wasm_2_0_0->(moduleSc_rollup_machine_no_proofs.Wasm)|Riscv->(moduleSc_rollup_machine_no_proofs.Riscv)endletgenesis_state_hash_of~boot_sectorkind=letopenLwt_syntaxinlet(moduleMachine)=Kind.no_proof_machine_ofkindinletempty=Sc_rollup_machine_no_proofs.empty_tree()inlet*tree=Machine.initial_state~emptyinlet*initial_hash=Machine.state_hashtreeinassert(Sc_rollup_repr.State_hash.(initial_hash=Kind.reference_initial_state_hash_ofkind));let*tree=Machine.install_boot_sectortreeboot_sectorinMachine.state_hashtree