Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file services.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454(*****************************************************************************)(* *)(* 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. *)(* *)(*****************************************************************************)includeServices_legacyopenTezos_crypto_daltype'rpcservice=('meth,'prefix,'params,'query,'input,'output)Tezos_rpc.Service.serviceconstraint'rpc=<meth:'meth;prefix:'prefix;params:'params;query:'query;input:'input;output:'output>moduleTypes=structtypelevel=int32typeslot_index=int(* Declaration of types used as inputs and/or outputs. *)typeslot_id={slot_level:level;slot_index:slot_index}(** A set of slots, represented by a list of booleans (false for not in the
set). It is used for instance to record which slots are deemed available
by an attestor. *)typeslot_set=boollisttypeattestable_slots=Attestable_slotsofslot_set|Not_in_committeetypeheader_status=[`Waiting_attestation|`Attested|`Unattested|`Not_selected|`Unseen_or_not_finalized]typeshard_index=inttypeslot_header={slot_id:slot_id;commitment:Cryptobox.Commitment.t;status:header_status;}typeoperator_profile=|AttestorofTezos_crypto.Signature.public_key_hash|Producerof{slot_index:int}typeoperator_profiles=operator_profilelisttypeprofiles=Bootstrap|Operatorofoperator_profilestypewith_proof={with_proof:bool}(* Auxiliary functions. *)(* Encodings associated to the types. *)letslot_id_encoding=(* TODO: https://gitlab.com/tezos/tezos/-/issues/4396
Reuse protocol encodings. *)letopenData_encodinginconv(fun{slot_level;slot_index}->(slot_level,slot_index))(fun(slot_level,slot_index)->{slot_level;slot_index})(obj2(req"slot_level"int32)(req"slot_index"uint8))letslot_encoding=Data_encoding.bytesletattestable_slots_encoding:attestable_slotsData_encoding.t=letopenData_encodinginunion[case~title:"attestable_slots_set"(Tag0)(obj2(req"kind"(constant"attestable_slots_set"))(req"attestable_slots_set"Data_encoding.(listbool)))(functionAttestable_slotsslots->Some((),slots)|_->None)(function(),slots->Attestable_slotsslots);case~title:"not_in_committee"(Tag1)(obj1(req"kind"(constant"not_in_committee")))(functionNot_in_committee->Some()|_->None)(function()->Not_in_committee);]letheader_status_encoding:header_statusData_encoding.t=letopenData_encodinginunion[case~title:"waiting_attestation"(Tag0)(obj1(req"status"(constant"waiting_attestation")))(function`Waiting_attestation->Some()|_->None)(function()->`Waiting_attestation);case~title:"attested"(Tag1)(obj1(req"status"(constant"attested")))(function`Attested->Some()|_->None)(function()->`Attested);case~title:"unattested"(Tag2)(obj1(req"status"(constant"unattested")))(function`Unattested->Some()|_->None)(function()->`Unattested);case~title:"not_selected"(Tag3)(obj1(req"status"(constant"not_selected")))(function`Not_selected->Some()|_->None)(function()->`Not_selected);case~title:"unseen_or_not_finalized"(Tag4)(obj1(req"status"(constant"unseen")))(function`Unseen_or_not_finalized->Some()|_->None)(function()->`Unseen_or_not_finalized);]letslot_header_encoding=letopenData_encodinginconv(fun{slot_id;commitment;status}->(slot_id,(commitment,status)))(fun(slot_id,(commitment,status))->{slot_id;commitment;status})(merge_objsslot_id_encoding(merge_objs(obj1(req"commitment"Cryptobox.Commitment.encoding))header_status_encoding))letoperator_profile_encoding=letopenData_encodinginunion[case~title:"Attestor with pkh"(Tag0)(obj2(req"kind"(constant"attestor"))(req"public_key_hash"Tezos_crypto.Signature.Public_key_hash.encoding))(functionAttestorattest->Some((),attest)|_->None)(function(),attest->Attestorattest);case~title:"Slot producer"(Tag1)(obj2(req"kind"(constant"producer"))(req"slot_index"int31))(function|Producer{slot_index}->Some((),slot_index)|_->None)(function(),slot_index->Producer{slot_index});]letprofiles_encoding=letopenData_encodinginunion[case~title:"Boostrap node"(Tag1)(obj1(req"kind"(constant"bootstrap")))(functionBootstrap->Some()|_->None)(function()->Bootstrap);case~title:"Operator"(Tag2)(obj2(req"kind"(constant"operator"))(req"operator_profiles"(listoperator_profile_encoding)))(function|Operatoroperator_profiles->Some((),operator_profiles)|_->None)(function(),operator_profiles->Operatoroperator_profiles);]letwith_proof_encoding=letopenData_encodinginconv(fun{with_proof}->with_proof)(funwith_proof->{with_proof})(obj1(req"with_proof"bool))(* String parameters queries. *)letheader_status_arg=letdestructs=lets=`O[("status",`Strings)]intryOk(Data_encoding.Json.destructheader_status_encodings)with_->Error"Cannot parse header status value"inletconstruct=Data_encoding.Binary.to_string_exnheader_status_encodinginTezos_rpc.Arg.make~name:"header_status"~destruct~construct()letslot_id_query=letopenTezos_rpcinletopenQueryinquery(funslot_levelslot_index->(slot_level,slot_index))|+opt_field"slot_level"Arg.int32fst|+opt_field"slot_index"Arg.intsnd|>sealletopt_header_status_query=letopenTezos_rpcinletopenQueryinquery(funheader_status->header_status)|+opt_field"status"header_status_arg(funhs->hs)|>sealendletpost_commitment:<meth:[`POST];input:Cryptobox.slot;output:Cryptobox.commitment;prefix:unit;params:unit;query:unit>service=Tezos_rpc.Service.post_service~description:"Add a slot in the node's context if not already present. The \
corresponding commitment is returned."~query:Tezos_rpc.Query.empty~input:Types.slot_encoding~output:Cryptobox.Commitment.encodingTezos_rpc.Path.(open_root/"commitments")letpatch_commitment:<meth:[`PATCH];input:Types.slot_id;output:unit;prefix:unit;params:unit*Cryptobox.commitment;query:unit>service=Tezos_rpc.Service.patch_service~description:"Associate a commitment to a level and a slot index."~query:Tezos_rpc.Query.empty~input:Types.slot_id_encoding~output:Data_encoding.unitTezos_rpc.Path.(open_root/"commitments"/:Cryptobox.Commitment.rpc_arg)letget_commitment_slot:<meth:[`GET];input:unit;output:Cryptobox.slot;prefix:unit;params:unit*Cryptobox.commitment;query:unit>service=Tezos_rpc.Service.get_service~description:"Retrieve the content of the slot associated with the given commitment."~query:Tezos_rpc.Query.empty~output:Types.slot_encodingTezos_rpc.Path.(open_root/"commitments"/:Cryptobox.Commitment.rpc_arg/"slot")letget_commitment_proof:<meth:[`GET];input:unit;output:Cryptobox.commitment_proof;prefix:unit;params:unit*Cryptobox.commitment;query:unit>service=Tezos_rpc.Service.get_service~description:"Compute the proof associated with a commitment"~query:Tezos_rpc.Query.empty~output:Cryptobox.Commitment_proof.encodingTezos_rpc.Path.(open_root/"commitments"/:Cryptobox.Commitment.rpc_arg/"proof")letput_commitment_shards:<meth:[`PUT];input:Types.with_proof;output:unit;prefix:unit;params:unit*Cryptobox.commitment;query:unit>service=Tezos_rpc.Service.put_service~description:"Compute and save the shards of the slot associated to the given \
commitment. If the input's flag is true, the proofs associated with \
each given shards are also computed."~query:Tezos_rpc.Query.empty~input:Types.with_proof_encoding~output:Data_encoding.unitTezos_rpc.Path.(open_root/"commitments"/:Cryptobox.Commitment.rpc_arg/"shards")letget_commitment_by_published_level_and_index:<meth:[`GET];input:unit;output:Cryptobox.commitment;prefix:unit;params:(unit*Types.level)*Types.slot_index;query:unit>service=Tezos_rpc.Service.get_service~description:"Return the accepted commitment associated to the given slot index and \
published at the given level."~query:Tezos_rpc.Query.empty~output:Cryptobox.Commitment.encodingTezos_rpc.Path.(open_root/"levels"/:Tezos_rpc.Arg.int32/"slot_indices"/:Tezos_rpc.Arg.int/"commitment")letget_commitment_headers:<meth:[`GET];input:unit;output:Types.slot_headerlist;prefix:unit;params:unit*Cryptobox.commitment;query:Types.leveloption*Types.slot_indexoption>service=Tezos_rpc.Service.get_service~description:"Return the known headers for the slot whose commitment is given."~query:Types.slot_id_query~output:(Data_encoding.listTypes.slot_header_encoding)Tezos_rpc.Path.(open_root/"commitments"/:Cryptobox.Commitment.rpc_arg/"headers")letget_published_level_headers:<meth:[`GET];input:unit;output:Types.slot_headerlist;prefix:unit;params:unit*Types.level;query:Types.header_statusoption>service=Tezos_rpc.Service.get_service~description:"Return the known headers for the given published level."~query:Types.opt_header_status_query~output:(Data_encoding.listTypes.slot_header_encoding)Tezos_rpc.Path.(open_root/"levels"/:Tezos_rpc.Arg.int32/"headers")letpatch_profiles:<meth:[`PATCH];input:Types.operator_profiles;output:unit;prefix:unit;params:unit;query:unit>service=Tezos_rpc.Service.patch_service~description:"Update the list of profiles tracked by the DAL node. Note that it does \
not take the bootstrap profile as it is incompatible with other \
profiles."~query:Tezos_rpc.Query.empty~input:(Data_encoding.listTypes.operator_profile_encoding)~output:Data_encoding.unitTezos_rpc.Path.(open_root/"profiles")letget_profiles:<meth:[`GET];input:unit;output:Types.profiles;prefix:unit;params:unit;query:unit>service=Tezos_rpc.Service.get_service~description:"Return the list of current profiles tracked by the DAL node"~query:Tezos_rpc.Query.empty~output:Types.profiles_encodingTezos_rpc.Path.(open_root/"profiles")letget_assigned_shard_indices:<meth:[`GET];input:unit;output:Types.shard_indexlist;prefix:unit;params:(unit*Tezos_crypto.Signature.public_key_hash)*Types.level;query:unit>service=Tezos_rpc.Service.get_service~description:"Return the shard indexes assigned to the given public key hash at the \
given level."~query:Tezos_rpc.Query.empty~output:Data_encoding.(listint16)Tezos_rpc.Path.(open_root/"profiles"/:Tezos_crypto.Signature.Public_key_hash.rpc_arg/"attested_levels"/:Tezos_rpc.Arg.int32/"assigned_shard_indices")letget_attestable_slots:<meth:[`GET];input:unit;output:Types.attestable_slots;prefix:unit;params:(unit*Tezos_crypto.Signature.public_key_hash)*Types.level;query:unit>service=Tezos_rpc.Service.get_service~description:"Return the currently attestable slots at the given attested level by \
the given public key hash. A slot is attestable at level [l] if it is \
published at level [l - attestation_lag] and *all* the shards assigned \
at level [l] to the given public key hash are available in the DAL \
node's store."~query:Tezos_rpc.Query.empty~output:Types.attestable_slots_encodingTezos_rpc.Path.(open_root/"profiles"/:Tezos_crypto.Signature.Public_key_hash.rpc_arg/"attested_levels"/:Tezos_rpc.Arg.int32/"attestable_slots")letmonitor_shards:<meth:[`GET];input:unit;output:Cryptobox.Commitment.t;prefix:unit;params:unit;query:unit>service=Tezos_rpc.Service.get_service~description:"Monitor put shards"~query:Tezos_rpc.Query.empty~output:Cryptobox.Commitment.encodingTezos_rpc.Path.(open_root/"monitor_shards")