Module Tezos_dal_node_lib.Slot_manager

This module provides different handlers related to DAL slots.

Functions to manage slots storage.

FIXME: https://gitlab.com/tezos/tezos/-/issues/4099 DAL/Node: make slot_header/commitment definition consistent with alpha_context.mli

type slot = bytes
val get_slot_pages : reconstruct_if_missing:bool -> Node_context.t -> Tezos_dal_node_services.Types.slot_id -> (bytes list, [> Errors.not_found | Errors.other ]) Stdlib.result Lwt.t

get_slot_pages ~reconstruct_if_missing cryptobox node_ctxt store slot_id fetches from the store the slot corresponding to the given slot id and split it into pages. If the slot is not found in the store and reconstruct_if_missing is true, the slot is reconstructed from the stored shards.

Returns an Error _ if:

  • the slot is not found in the store and reconstruct_if_missing is false,
  • the slot is not found in the store, reconstruct_if_missing is true, and too few shards are stored to reconstruct the slot,
  • the length of the slot associated to the Cryptobox.commitment is ill-formed. Specifically, when its length is not a multiple of the page-size specified in the Cryptobox.parameters argument.
type Tezos_base.TzPervasives.error +=
  1. | Invalid_slot_size of {
    1. provided : int;
    2. expected : int;
    }
  2. | No_prover_SRS

Cryptobox.polynomial_from_slot but using the Errors module.

The function returns an error Invalid_slot_size if the slot's size doesn't match the expected slots' size given in cryptobox, or the slot's polynomial otherwise.

commit cryptobox polynomial computes the commitment of the given polynomial.

val get_slot_content : reconstruct_if_missing:bool -> Node_context.t -> Tezos_dal_node_services.Types.slot_id -> (slot, [> Errors.other | Errors.not_found ]) Stdlib.result Lwt.t

get_slot_content ~reconstruct_if_missing node_ctxt slot_id returns the slot content associated with the given slot_id in the node's store.

If the slot is not found in the store and reconstruct_if_missing is true, the slot is reconstructed from the stored shards.

In addition to decoding errors, the function returns `Not_found if there is no slot content for slot_id in the node's store or if reconstruct_if_missing is true and not enough shards are stored to reconstruct the slot.

add_commitment_shards ~shards_proofs_precomputation node_store cryptobox commitment slot polynomial registers the shards of the slot whose commitment is given.

Proofs are generated for the computed shards using shards_proofs_precomputation and stored in a bounded structure in memory.

In addition to storage errors, this function may return the following errors:

  • Invalid_slot_size if the given slot does not have the expected size,
  • No_prover_SRS if the given shards_proofs_precomputation is None.

This function publishes the given shards and their proofs.

This function publishes the shards of a commitment that is waiting for attestion on L1 if this node has those shards on disk and their proofs in memory.

val store_slot_headers : number_of_slots:int -> block_level:int32 -> Dal_plugin.slot_header list -> Store.t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

store_slot_headers ~number_of_slots ~block_level ~block_hash slot_headers node_store stores slot_headers onto the node_store associated to the given block_hash baked at level block_level.

val update_selected_slot_headers_statuses : block_level:int32 -> attestation_lag:int -> number_of_slots:int -> (Dal_plugin.slot_index -> bool) -> Store.t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

update_selected_slot_headers_statuses ~block_level ~attestation_lag ~number_of_slots attested_slots store updates the statuses of the previously selected slots at level block_level - attestation_lag and that were waiting for attestation.

Slot headers whose indexes are in attested_slots are now set as `Attested in store. Those which are not are marked as `Unattested in the store if they previously had a "waiting for attestation" status.

get_slot_status ~slot_id store returns the status associated to the accepted slot of id slot_id or None if no status is currently stored for that slot id.

get_slot_shard store slot_id shard_index returns the shard at index shard_index of the slot given by slot_id.

val maybe_register_trap : Store.Traps.t -> traps_fraction:Q.t -> Tezos_dal_node_services.Types.Message_id.t -> Tezos_dal_node_services.Types.Message.t -> unit

maybe_register_trap traps_store ~traps_fraction message_id message checks if the given message is a trap according to Trap.share_is_trap. If the share is identified as a trap, it is stored in the traps cache of the DAL node store. Otherwise does nothing.