123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154(*****************************************************************************)(* *)(* Open Source License *)(* 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. *)(* *)(*****************************************************************************)(** Evaluation state for the PVM. *)type'fueleval_state={state:Context.tree;(** The actual PVM state. *)state_hash:State_hash.t;(** Hash of [state]. *)tick:Z.t;(** Tick of [state]. *)inbox_level:int32;(** Inbox level in which messages are evaluated. *)message_counter_offset:int;(** Offset for message index, which corresponds to the number of
messages of the inbox already evaluated. *)remaining_fuel:'fuel;(** Fuel remaining for the evaluation of the inbox. *)remaining_messages:stringlist;(** Messages of the inbox that remain to be evaluated. *)}type'fueleval_result={state:'fueleval_state;num_ticks:Z.t;num_messages:int;}moduletypeFUELED_PVM=sigtypefuel(** Evaluation result for the PVM which contains the evaluation state and
additional information. *)(** [eval_block_inbox ~fuel node_ctxt (inbox, messages) state] evaluates the
[messages] for the [inbox] in the given [state] of the PVM and returns the
evaluation result containing the new state, the number of messages, the
inbox level and the remaining fuel. *)valeval_block_inbox:fuel:fuel->_Node_context.t->Inbox.t*stringlist->Context.tree->fueleval_resultNode_context.delayed_writetzresultLwt.t(** [eval_messages ?reveal_map ~fuel node_ctxt ~message_counter_offset state
inbox_level messages] evaluates the [messages] for inbox level
[inbox_level] in the given [state] of the PVM and returns the evaluation
results containing the new state, the remaining fuel, and the number of
ticks for the evaluation of these messages. If [messages] is empty, the
PVM progresses until the next input request (within the allocated
[fuel]). [message_counter_offset] is used when we evaluate partial
inboxes, such as during simulation. When [reveal_map] is provided, it is
used as an additional source of data for revelation ticks. *)valeval_messages:?reveal_map:stringUtils.Reveal_hash_map.t->_Node_context.t->fueleval_state->fueleval_resultNode_context.delayed_writetzresultLwt.tendmoduletypeS=sigvalget_tick:Kind.t->Context.tree->Z.tLwt.tvalstate_hash:Kind.t->Context.tree->State_hash.tLwt.tvalinitial_state:Kind.t->Context.treeLwt.tvalparse_boot_sector:Kind.t->string->stringoptionvalinstall_boot_sector:Kind.t->Context.tree->string->Context.treeLwt.tvalget_status:_Node_context.t->Context.tree->stringtzresultLwt.tvalfind_whitelist_update_output_index:_Node_context.t->Context.tree->outbox_level:int32->intoptionLwt.tvalproduce_serialized_output_proof:Node_context.rw->Context.tree->outbox_level:int32->message_index:int->stringtzresultLwt.tvalget_current_level:Kind.t->Context.tree->int32optionLwt.tvalstart_of_level_serialized:stringvalend_of_level_serialized:stringvalprotocol_migration_serialized:stringoptionvalinfo_per_level_serialized:predecessor:Block_hash.t->predecessor_timestamp:Time.Protocol.t->stringmoduleWasm_2_0_0:sig(** [decode_durable_state enc tree] decodes a value using the encoder
[enc] from the provided [tree] *)valdecode_durable_state:'aTezos_tree_encoding.t->Context.tree->'aLwt.t(** [proof_mem_tree t k] is false iff [find_tree k = None].*)valproof_mem_tree:Context.tree->stringlist->boolLwt.t(** [fold ?depth t root ~order ~init ~f] recursively folds over the trees and
values of t. The f callbacks are called with a key relative to root. f is
never called with an empty key for values; i.e., folding over a value is a no-op.
The depth is 0-indexed. If depth is set (by default it is not), then f is only
called when the conditions described by the parameter is true:
- [Eq d] folds over nodes and values of depth exactly d.
- [Lt d] folds over nodes and values of depth strictly less than d.
- [Le d] folds over nodes and values of depth less than or equal to d.
- [Gt d] folds over nodes and values of depth strictly more than d.
- [Ge d] folds over nodes and values of depth more than or equal to d.
If order is [`Sorted] (the default), the elements are traversed in lexicographic
order of their keys. *)valproof_fold_tree:?depth:Tezos_context_sigs.Context.depth->Context.tree->stringlist->order:[`Sorted|`Undefined]->init:'a->f:(stringlist->Context.tree->'a->'aLwt.t)->'aLwt.tendmoduleFueled:sigmoduleFree:FUELED_PVMwithtypefuel:=Fuel.Free.tmoduleAccounted:FUELED_PVMwithtypefuel:=Fuel.Accounted.tendend