123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300(*****************************************************************************)(* *)(* 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. *)(* *)(*****************************************************************************)(** Protocol specific RPC directory, used as a dynamic directory in the protocol
agnostic rollup node. *)moduletypeRPC_DIRECTORY=sig(** The RPC directory, specific to blocks of the protocol, for this rollup
node. *)valblock_directory:Node_context.rw->(unit*Rollup_node_services.Arg.block_id)Tezos_rpc.Directory.tend(** Protocol specific functions to track endorsed DAL slots of L1 blocks. *)moduletypeDAL_SLOTS_TRACKER=sig(** [process_head node_ctxt head] performs the following operations for a
given protocol:
{ul
{li it reads the endorsements for headers published attestation_lag
levels preceding [head] from the block metadata, determines which
ones the rollup node will download, and stores the results in
[Store.Dal_confirmed_slots].}
} *)valprocess_head:Node_context.rw->Layer1.head->unittzresultLwt.tend(** Protocol specific functions to reconstruct inboxes from L1 blocks. *)moduletypeINBOX=sig(** [process_head node_ctxt ~predecessor head] changes the state of
the inbox on disk to react to the operations contained in the block [head]
(where [predecessor] is the predecessor of [head] in the L1 chain). It
returns a tuple [(inbox_hash, inbox, payload_hash, messages)] where
[inbox] is the new inbox and [inbox_hash] its hash, [payload_hash] is the
hash of the merkelized payload for this inbox and [messages] are the
serialized messages present in the block (with the internal messages added
by the protocol). *)valprocess_head:Node_context.rw->predecessor:Layer1.header->Layer1.header->(Octez_smart_rollup.Inbox.Hash.t*Octez_smart_rollup.Inbox.t*Merkelized_payload_hashes_hash.t*stringlist)tzresultLwt.t(** [same_as_layer_1 node_ctxt block node_inbox] ensures that the rollup node
agrees with the L1 node that inbox for [block] is [node_inbox]. *)valsame_as_layer_1:_Node_context.t->Block_hash.t->Octez_smart_rollup.Inbox.t->unittzresultLwt.t(** Serialize an external messages to the protocol representation. NOTE: so
far, in all available protocols, this adds a tag ['\001'] at the
beginning. *)valserialize_external_message:string->stringtzresult(** Returns the initial global inbox where [level] is the first level of the
protocol with smart rollups. *)valinit:predecessor_timestamp:Time.Protocol.t->predecessor:Block_hash.t->level:int32->Octez_smart_rollup.Inbox.t(**/**)moduleInternal_for_tests:sig(** Only for tests. [process_messages node_ctxt ~is_first_block ~predecessor
head messages] reconstructs the inbox on disk for the [messages] as if
they appeared in [head]. See {!val:process_head} for the return
values. *)valprocess_messages:Node_context.rw->is_first_block:bool->predecessor:Layer1.header->Layer1.header->stringlist->(Octez_smart_rollup.Inbox.Hash.t*Octez_smart_rollup.Inbox.t*Merkelized_payload_hashes_hash.t*stringlist)tzresultLwt.tendend(** Protocol specific constants for the batcher. *)moduletypeBATCHER_CONSTANTS=sig(** Maximum size of an L2 message allowed by the prototcol, which is
{!val:Protocol.Constants_repr.sc_rollup_message_size_limit}. *)valmessage_size_limit:int(** Maximum size in bytes of an batch of L2 messages that can fit in an
operation on L1. It is protocol dependent. *)valprotocol_max_batch_size:intend(** Protocol specific batcher. NOTE: The batcher has to be stopped and the new
one restarted on protocol change. *)moduletypeBATCHER=sig(** The type for the status of messages in the batcher. *)typestatus=|Pending_batch(** The message is in the queue of the batcher. *)|BatchedofInjector.Inj_operation.hash(** The message has already been batched and sent to the injector in an
L1 operation whose hash is given. *)(** [init config ~signer node_ctxt] initializes and starts the batcher for
[signer]. If [config.simulation] is [true] (the default), messages added
to the batcher are simulated in an incremental simulation context. *)valinit:Configuration.batcher->signer:Signature.public_key_hash->_Node_context.t->unittzresultLwt.t(** [new_head head] create batches of L2 messages from the queue and pack each
batch in an L1 operation. The L1 operations (i.e. L2 batches) are queued
in the injector for injection on the Tezos node. *)valnew_head:Layer1.head->unittzresultLwt.t(** [shutdown ()] stops the batcher, waiting for the ongoing request to be
processed. *)valshutdown:unit->unitLwt.t(** List all queued messages in the order they appear in the queue, i.e. the
message that were added first to the queue are at the end of list. *)valget_queue:unit->(L2_message.hash*L2_message.t)listtzresult(** [register_messages messages] registers new L2 [messages] in the queue of
the batcher for future injection on L1. If the batcher was initialized
with [simualte = true], the messages are evaluated the batcher's
incremental simulation context. In this case, when the application fails,
the messages are not queued. *)valregister_messages:stringlist->L2_message.hashlisttzresultLwt.t(** The status of a message in the batcher. Returns [None] if the message is
not known by the batcher (the batcher only keeps the batched status of the
last 500000 messages). *)valmessage_status:L2_message.hash->(status*string)optiontzresultend(** Protocol specific functions to interact with the L1 node. *)moduletypeLAYER1_HELPERS=sig(** [prefetch_tezos_blocks l1_ctxt blocks] prefetches the blocks
asynchronously. NOTE: the number of blocks to prefetch must not be greater
than the size of the blocks cache otherwise they will be lost. *)valprefetch_tezos_blocks:Layer1.t->Layer1.headlist->unitvalget_last_cemented_commitment:#Client_context.full->Address.t->Node_context.lcctzresultLwt.tvalget_last_published_commitment:#Client_context.full->Address.t->Signature.public_key_hash->Commitment.toptiontzresultLwt.tvalget_kind:#Client_context.full->Address.t->Kind.ttzresultLwt.tvalgenesis_inbox:#Client_context.full->genesis_level:int32->Octez_smart_rollup.Inbox.ttzresultLwt.t(** Retrieve protocol agnotic constants for the head of the chain. *)valretrieve_constants:?block:Tezos_shell_services.Block_services.block->#Client_context.full->Rollup_constants.protocol_constantstzresultLwt.tvalretrieve_genesis_info:#Client_context.full->Address.t->Node_context.genesis_infotzresultLwt.tvalget_boot_sector:Block_hash.t->_Node_context.t->stringtzresultLwt.tvalfind_whitelist:#Client_context.full->Address.t->Signature.public_key_hashlistoptiontzresultLwt.tend(** Protocol specific functions for processing L1 blocks. *)moduletypeL1_PROCESSING=sig(** Ensure that the initial state hash of the PVM as defined by the rollup
node matches the one of the PVM on the L1 node. *)valcheck_pvm_initial_state_hash:_Node_context.t->unittzresultLwt.t(** React to L1 operations included in a block of the chain. *)valprocess_l1_block_operations:Node_context.rw->Layer1.header->unittzresultLwt.tend(** Partial protocol plugin with just the PVM and the function to access the
Layer1. This signature exists in order to build plugins for the interpreter
and the refutation games while avoiding circular dependencies. *)moduletypePARTIAL=sig(** The protocol for which this plugin is. *)valprotocol:Protocol_hash.tmoduleLayer1_helpers:LAYER1_HELPERSmodulePvm:Pvm_plugin_sig.Send(** Protocol specific refutation helper functions. *)moduletypeREFUTATION_GAME_HELPERS=sig(** [generate_proof node_ctxt (game) start_state] generates a serialized proof
for the current [game] for the execution step starting with
[start_state]. *)valgenerate_proof:Node_context.rw->Game.t->Context.tree->stringtzresultLwt.t(** [make_dissection plugin node_ctxt ~start_state ~start_chunk ~our_stop_chunk
~default_number_of_sections ~last_level] computes a dissection from between
[start_chunk] and [our_stop_chunk] at level [last_level]. This dissection
has [default_number_of_sections] if there are enough ticks. *)valmake_dissection:(modulePARTIAL)->_Node_context.t->start_state:Fuel.Accounted.tPvm_plugin_sig.eval_stateoption->start_chunk:Game.dissection_chunk->our_stop_chunk:Game.dissection_chunk->default_number_of_sections:int->last_level:int32->Game.dissection_chunktracetzresultLwt.t(** [timeout_reached node_ctxt ~self ~opponent] returns [true] if the
timeout is reached against opponent in head of the L1 chain. *)valtimeout_reached:_Node_context.t->self:Signature.public_key_hash->opponent:Signature.public_key_hash->booltzresultLwt.t(** [get_conflicts cctxt rollup signer] returns the conflicts for commitments
staked on by [signer]. *)valget_conflicts:Client_context.full->Address.t->Signature.public_key_hash->Game.conflictlisttzresultLwt.t(** [get_ongoing_games cctxt rollup signer] returns the games that [signer] is
currently playing. *)valget_ongoing_games:Client_context.full->Address.t->Signature.public_key_hash->(Game.t*Signature.public_key_hash*Signature.public_key_hash)listtzresultLwt.tend(** Signature of protocol plugins for the rollup node. NOTE: the plugins have to
be registered to be made available to the rollup node. *)moduletypeS=sigincludePARTIALmoduleRPC_directory:RPC_DIRECTORYmoduleDal_slots_tracker:DAL_SLOTS_TRACKERmoduleInbox:INBOXmoduleBatcher_constants:BATCHER_CONSTANTSmoduleL1_processing:L1_PROCESSINGmoduleRefutation_game_helpers:REFUTATION_GAME_HELPERSend