Module Tezos_dal_node_lib.Message_validation

val gossipsub_app_messages_validation : Node_context.t -> Tezos_crypto_dal.Cryptobox.t -> int32 -> Tezos_dal_node_services.Types.proto_parameters -> ?message:Tezos_dal_node_services.Types.Message.t -> message_id:Tezos_dal_node_services.Types.Message_id.t -> unit -> [> `Invalid | `Outdated | `Unknown | `Valid ]

gossipsub_app_messages_validation ctxt cryptobox head_level proto_parameters ?message ~message_id () validates a Gossipsub message and its associated message ID in the context of the given DAL node.

The validation follows a layered approach:

  • If the node is a bootstrap node, any received message is rejected as invalid. In fact, bootstrap nodes are not expected to receive application data.
  • If the message is considered too old (i.e., its level is too far in the past compared to head_level and proto_parameters.attestation_lag plus some slack), it is marked as `Outdated.
  • If the message ID is invalid (bad commitment, shard index, or unrelated topic) the function returns `Invalid.
  • If the message ID cannot be checked (because the associated commitment or committee could not be found), the function returns `Unknown. accordingly.
  • If a message payload is provided and the message ID is valid, the shard is cryptographically verified against the commitment.
  • Valid messages may also trigger trap detection and registration.

This function is intended to be registered as the Gossipsub validation hook.