Module Tezos_dal_node_lib.Profile_manager

This module provides different handlers related to DAL profiles.

type t

A profile manager context stores profile-specific data used by the daemon.

type unresolved_profile =
  1. | Profile of t
  2. | Random_observer
  3. | Empty

Type for a "profile" produced from CLI parsing and/or reading the configuration file, which may be refined (for instance by determining the slot to be observed for "random observers").

val is_bootstrap_profile : t -> bool

is_bootstrap_profile t returns true if the node has a bootstrap profile.

val is_prover_profile : t -> bool

is_prover_profile profile returns true if producing proofs is part of the activity of the provided profile. This is the case for observer and slot producers but bootstrap and attester profiles never need to produce proofs.

val is_empty : t -> bool

is_empty profile returns true if it is a Controller profile which is empty.

val is_attester_only_profile : t -> bool

is_attester_only_profile profile returns true if the node is in controller mode, with at least one attester role and no producer nor observer roles.

val can_publish_on_slot_index : Tezos_dal_node_services.Types.slot_index -> t -> bool

can_publish_on_slot_index slot_index profile returns true if the node has either the producer or the observer profile of the given slot index.

val empty : t

The empty profile manager context.

val bootstrap : unresolved_profile
val random_observer : unresolved_profile

controller profiles returns an unresolved profile matching profiles

val merge_profiles : lower_prio:unresolved_profile -> higher_prio:unresolved_profile -> unresolved_profile

Merge the two sets of profiles. In case of incompatibility (that is, case Bootstrap vs the other kinds), the profiles from higher_prio take priority.

val add_and_register_controller_profiles : t -> number_of_slots:int -> Tezos_dal_node_lib_gossipsub.Gossipsub.Worker.t -> Tezos_dal_node_services.Controller_profiles.t -> t option

add_and_register_controller_profiles t ~number_of_slots gs_worker controller_profile adds the new controller_profiles to t. It registers any new attester profile within controller_profiles with gossipsub, that is, it instructs the gs_worker to join the corresponding topics.

If the current profile t is a bootstrap profile, it will return None as bootstrap profiles are incompatible with controller profiles.

It assumes the current profile is not a random observer.

val register_profile : t -> number_of_slots:int -> Tezos_dal_node_lib_gossipsub.Gossipsub.Worker.t -> t

register_profile t ~number_of_slots gs_worker does the following:

  • It registers the attester profiles within t with gossipsub, that is, it instructs the gs_worker to join the corresponding topics.
  • If t is the random observer profile, then it randomly selects a slot index, and transforms the profile into an observer profile for the selected slot index.

The function returns the updated profile.

val validate_slot_indexes : t -> number_of_slots:int -> unit Tezos_base.TzPervasives.tzresult

Checks that each producer (operator or observer) profile only refers to slot indexes strictly smaller than number_of_slots. This may not be the case when the profile context is first built because there is no information about the number of slots. Returns an Invalid_slot_index error if the check fails.

val on_new_head : t -> number_of_slots:int -> Tezos_dal_node_lib_gossipsub.Gossipsub.Worker.t -> Committee_cache.committee -> unit

on_new_head t ~number_of_slots gs_worker committee performs profile-related actions that depend on the current head, more precisely on the current committee.

get_profiles node_store returns the list of profiles that the node tracks

val get_attested_data_default_store_period : t -> Tezos_dal_node_services.Types.proto_parameters -> int

Returns the number of previous blocks for which the node should keep the shards in the storage, depending on the profile of the node (3 months for operators, twice attestation lag for observers and attesters.)

val resolve_profile : unresolved_profile -> number_of_slots:int -> t

Resolves a profile by either returning it unchanged (for bootstrap and controller profiles) or generating a new observer profile for random observer profile. The random slot is selected within the DAL slots range defined by the protocol parameters.

This function is called when generating an observer profile from a random profile before launching a DAL node, as implemented in the daemon.

val supports_refutations : t -> bool

Returns true iff the node should support refutation games.

val load_profile_ctxt : base_dir:string -> t Tezos_base.TzPervasives.tzresult Lwt.t

Load the profile context from disk. The file where the context is loaded from is relative to the given base_dir. An error is returned in case of an IO failure or an ill formatted file.

val save_profile_ctxt : t -> base_dir:string -> unit Tezos_base.TzPervasives.tzresult Lwt.t

Save the profile context to disk. The file where the context is saved is relative to the given base_dir. An error is returned in case of an IO failure.

val get_storage_period : t -> Tezos_dal_node_services.Types.proto_parameters -> head_level:int32 -> first_seen_level:int32 option -> int

get_storage_period profile_ctxt proto_parameters ~head_level ~first_seen_level computes the number of levels of DAL data the node should retain, based on its profile and L1 activity.

For nodes that support refutations, the returned storage period is the minimum between:

  • the default retention period defined by the profile context, and
  • the number of levels the node has been online (i.e. since first_seen_level), capped to ensure at least two attestation lags worth of levels are always retained.

For nodes that do not support refutations, the returned value is always the default period.

This function is used to decide how far back attested data should be kept in the store.