Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file sc_rollup_services.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 Nomadic Labs, <contact@nomadic-labs.com> *)(* Copyright (c) 2023 TriliTech <contact@trili.tech> *)(* Copyright (c) 2023 Functori, <contact@functori.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. *)(* *)(*****************************************************************************)openProtocol.Alpha_contexttypeeval_result={state_hash:Sc_rollup.State_hash.t;status:string;output:Sc_rollup.outputlist;inbox_level:int32;num_ticks:Z.t;insights:bytesoptionlist;(** The simulation can ask to look at values on the state after
the simulation. *)}typeinsight_request=|Pvm_state_keyofstringlist|Durable_storage_keyofstringlisttypesimulate_input={messages:stringlist;reveal_pages:stringlistoption;insight_requests:insight_requestlist;log_kernel_debug_file:stringoption;}typecommitment_info={commitment:Sc_rollup.Commitment.t;commitment_hash:Sc_rollup.Commitment.Hash.t;first_published_at_level:Raw_level.t;published_at_level:Raw_level.t;}moduleEncodings=structopenData_encodinglethex_string=string'Hexleteval_result=conv(fun{state_hash;status;output;inbox_level;num_ticks;insights}->(state_hash,status,output,inbox_level,num_ticks,insights))(fun(state_hash,status,output,inbox_level,num_ticks,insights)->{state_hash;status;output;inbox_level;num_ticks;insights})@@obj6(req"state_hash"Sc_rollup.State_hash.encoding~description:"Hash of the state after execution of the PVM on the input \
messages")(req"status"string~description:"Status of the PVM after evaluation")(req"output"(listSc_rollup.output_encoding)~description:"Output produced by evaluation of the messages")(req"inbox_level"int32~description:"Level of the inbox that would contain these messages")(req"num_ticks"z~description:"Ticks taken by the PVM for evaluating the messages")(dft"insights"(list(optionbytes))[]~description:"PVM state values requested after the simulation")letinsight_request=union[case(Tag0)~title:"pvm_state"~description:"Path in the PVM state"(obj2(req"kind"(constant"pvm_state"))(req"key"(liststring)))(functionPvm_state_keykey->Some((),key)|_->None)(fun((),key)->Pvm_state_keykey);case(Tag1)~title:"durable_storage"~description:"Path in the PVM durable storage"(obj2(req"kind"(constant"durable_storage"))(req"key"(liststring)))(functionDurable_storage_keykey->Some((),key)|_->None)(fun((),key)->Durable_storage_keykey);]letsimulate_input=conv(fun{messages;reveal_pages;insight_requests;log_kernel_debug_file}->(messages,reveal_pages,insight_requests,log_kernel_debug_file))(fun(messages,reveal_pages,insight_requests,log_kernel_debug_file)->{messages;reveal_pages;insight_requests;log_kernel_debug_file})@@obj4(req"messages"(listhex_string)~description:"Serialized messages for simulation.")(opt"reveal_pages"(listhex_string)~description:"Pages (at most 4kB) to be used for revelation ticks")(dft"insight_requests"(listinsight_request)[]~description:"Paths in the PVM to inspect after the simulation")(opt"log_kernel_debug_file"string~description:"File in which to emit kernel logs. This file will be created in \
<data-dir>/simulation_kernel_logs/, where <data-dir> is the \
data directory of the rollup node.")letcommitment_info=conv(fun{commitment;commitment_hash;first_published_at_level;published_at_level;}->(commitment,commitment_hash,first_published_at_level,published_at_level))(fun(commitment,commitment_hash,first_published_at_level,published_at_level)->{commitment;commitment_hash;first_published_at_level;published_at_level;})@@obj4(req"commitment"Sc_rollup.Commitment.encoding)(req"hash"Sc_rollup.Commitment.Hash.encoding)(req"first_published_at_level"Raw_level.encoding)(req"published_at_level"Raw_level.encoding)endmoduleQuery=structletoutbox_proof_query=letopenTezos_rpc.QueryinletopenSc_rollupinletinvalid_messagee=raise(Invalid(Format.asprintf"Invalid message (%a)"Environment.Error_monad.pp_tracee))inquery(funoutbox_levelmessage_indexserialized_outbox_message->letreqnamef=function|None->raise(Invalid(Format.sprintf"Query parameter %s is required"name))|Somearg->farginletoutbox_level=req"outbox_level"Raw_level.of_int32_exnoutbox_levelinletmessage_index=req"message_index"Z.of_int64message_indexinletmessage=req"serialized_outbox_message"(funs->Outbox.Message.(unsafe_of_strings|>deserialize))serialized_outbox_messageinmatchmessagewith|Errore->invalid_messagee|Okmessage->{outbox_level;message_index;message})|+opt_field"outbox_level"Tezos_rpc.Arg.int32(funo->Some(Raw_level.to_int32o.outbox_level))|+opt_field"message_index"Tezos_rpc.Arg.int64(funo->Some(Z.to_int64o.message_index))|+opt_field"serialized_outbox_message"Tezos_rpc.Arg.string(funo->matchOutbox.Message.serializeo.messagewith|Okmessage->Some(Outbox.Message.unsafe_to_stringmessage)|Errore->invalid_messagee)|>sealtypekey_query={key:string}letkey_query:key_queryTezos_rpc.Query.t=letopenTezos_rpc.Queryinquery(funkey->{key})|+field"key"Tezos_rpc.Arg.string""(funt->t.key)|>sealletoutbox_level_query=letopenTezos_rpc.Queryinquery(funoutbox_level->letreqnamef=function|None->raise(Invalid(Format.sprintf"Query parameter %s is required"name))|Somearg->farginreq"outbox_level"Raw_level.of_int32_exnoutbox_level)|+opt_field"outbox_level"Tezos_rpc.Arg.int32(funo->Some(Raw_level.to_int32o))|>sealletmessage_index_query=letopenTezos_rpc.Queryinquery(funmessage_index->letreqnamef=function|None->raise(Invalid(Format.sprintf"Query parameter %s is required"name))|Somearg->farginreq"index"(funo->o)message_index)|+opt_field"index"Tezos_rpc.Arg.uint(funo->Someo)|>sealendtypesimulate_query={fuel:int64option}letsimulate_query:simulate_queryTezos_rpc.Query.t=letopenTezos_rpc.Queryinquery(funfuel->{fuel})|+opt_field"fuel"Tezos_rpc.Arg.int64(funt->t.fuel)|>sealmoduleBlock=structopenTezos_rpc.Pathtypeprefix=unit*Rollup_node_services.Arg.block_idletpath:prefixTezos_rpc.Path.context=open_rootletprefix=root/"global"/"block"/:Rollup_node_services.Arg.block_idletblock=Tezos_rpc.Service.get_service~description:"Layer-2 block of the layer-2 chain with respect to a Layer 1 block \
identifier"~query:Tezos_rpc.Query.empty~output:Sc_rollup_block.full_encodingpathlethash=Tezos_rpc.Service.get_service~description:"Tezos block hash of block known to the smart rollup node"~query:Tezos_rpc.Query.empty~output:Block_hash.encoding(path/"hash")letlevel=Tezos_rpc.Service.get_service~description:"Level of Tezos block known to the smart rollup node"~query:Tezos_rpc.Query.empty~output:Data_encoding.int32(path/"level")letinbox=Tezos_rpc.Service.get_service~description:"Rollup inbox for block"~query:Tezos_rpc.Query.empty~output:Octez_smart_rollup.Inbox.encoding(path/"inbox")letticks=Tezos_rpc.Service.get_service~description:"Number of ticks for specified level"~query:Tezos_rpc.Query.empty~output:Data_encoding.z(path/"ticks")lettotal_ticks=Tezos_rpc.Service.get_service~description:"Total number of ticks at specified block"~query:Tezos_rpc.Query.empty~output:Sc_rollup.Tick.encoding(path/"total_ticks")letnum_messages=Tezos_rpc.Service.get_service~description:"Number of messages for specified block"~query:Tezos_rpc.Query.empty~output:Data_encoding.z(path/"num_messages")letstate_hash=Tezos_rpc.Service.get_service~description:"State hash for this block"~query:Tezos_rpc.Query.empty~output:Sc_rollup.State_hash.encoding(path/"state_hash")letstate_current_level=Tezos_rpc.Service.get_service~description:"Retrieve the current level of a PVM"~query:Tezos_rpc.Query.empty~output:(Data_encoding.optionRaw_level.encoding)(path/"state_current_level")letstate_value=Tezos_rpc.Service.get_service~description:"Retrieve value from key is PVM state of specified block"~query:Query.key_query~output:Data_encoding.bytes(path/"state")letdurable_state_value(pvm_kind:Sc_rollup.Kind.t)=Tezos_rpc.Service.get_service~description:"Retrieve value by key from PVM durable storage. PVM state is taken \
with respect to the specified block level. Value returned in hex \
format."~query:Query.key_query~output:Data_encoding.(optionbytes)(path/"durable"/Sc_rollup.Kind.to_stringpvm_kind/"value")letdurable_state_length(pvm_kind:Protocol.Alpha_context.Sc_rollup.Kind.t)=Tezos_rpc.Service.get_service~description:"Retrieve number of bytes in raw representation of value by key from \
PVM durable storage. PVM state is taken with respect to the specified \
block level."~query:Query.key_query~output:Data_encoding.(optionint64)(path/"durable"/Sc_rollup.Kind.to_stringpvm_kind/"length")letdurable_state_subkeys(pvm_kind:Sc_rollup.Kind.t)=Tezos_rpc.Service.get_service~description:"Retrieve subkeys of the specified key from PVM durable storage. PVM \
state is taken with respect to the specified block level."~query:Query.key_query~output:Data_encoding.(liststring)(path/"durable"/Sc_rollup.Kind.to_stringpvm_kind/"subkeys")letstatus=Tezos_rpc.Service.get_service~description:"PVM status at block"~query:Tezos_rpc.Query.empty~output:Data_encoding.string(path/"status")letoutbox=Tezos_rpc.Service.get_service~description:"Outbox at block for a given outbox level"~query:Query.outbox_level_query~output:Data_encoding.(listSc_rollup.output_encoding)(path/"outbox")letsimulate=Tezos_rpc.Service.post_service~description:"Simulate messages evaluation by the PVM"~query:Tezos_rpc.Query.empty~input:Encodings.simulate_input~output:Encodings.eval_result(path/"simulate")letdal_slots=Tezos_rpc.Service.get_service~description:"Availability slots for a given block"~query:Tezos_rpc.Query.empty~output:(Data_encoding.listDal.Slot.Header.encoding)(path/"dal"/"slot_headers")letdal_slot_status_encoding:[`Confirmed|`Unconfirmed]Data_encoding.t=Data_encoding.string_enum[("confirmed",`Confirmed);("unconfirmed",`Unconfirmed)]letdal_processed_slots=Tezos_rpc.Service.get_service~description:"Data availability processed slots and their statuses"~query:Tezos_rpc.Query.empty~output:Data_encoding.(list@@obj2(req"index"int31)(req"status"dal_slot_status_encoding))(path/"dal"/"processed_slots")letlevel_param=letdestructs=matchInt32.of_string_optswith|None->Error"Invalid level"|Somel->(matchRaw_level.of_int32lwith|Error_->Error"Invalid level"|Okl->Okl)inletconstruct=Format.asprintf"%a"Raw_level.ppinTezos_rpc.Arg.make~name:"level"~construct~destruct()letoutbox_messages=Tezos_rpc.Service.get_service~description:"Outbox at block for a given outbox level"~query:Tezos_rpc.Query.empty~output:Data_encoding.(listSc_rollup.output_encoding)(path/"outbox"/:level_param/"messages")moduleHelpers=structtypenonrecprefix=prefixletpath=path/"helpers"letoutbox_proof=Tezos_rpc.Service.get_service~description:"Generate serialized output proof for some outbox message"~query:Query.outbox_proof_query~output:Data_encoding.(obj2(req"commitment"Sc_rollup.Commitment.Hash.encoding)(req"proof"Encodings.hex_string))(path/"proofs"/"outbox")letoutbox_proof_simple=Tezos_rpc.Service.get_service~description:"Generate serialized output proof for some outbox message at level \
and index"~query:Query.message_index_query~output:Data_encoding.(obj2(req"commitment"Sc_rollup.Commitment.Hash.encoding)(req"proof"Encodings.hex_string))(path/"proofs"/"outbox"/:level_param/"messages")endend