Module Tezos_raw_protocol_alpha.Dal_attestations_repr

Multiple attestations representation for the data-availability layer.

Overview

This module extends Dal_attestation_repr to handle multiple DAL attestations at different lags. A lag represents the difference between the attested level of a slot and its published level.

The structure stores a fixed number of attestations, determined by number_of_lags. Each attestation is indexed by lag_index (0-based) and is a bitset encoding which slots are attested at a particular level. The slots' (published) level is implicit (it is obtained as "attested level" minus the lag corresponding to the given lag index), and is not relevant for this module.

Encoding

The encoding uses a compact bitset representation that minimizes space when small slot indices are attested:

Bitset structure

The bitset is stored as an integer, with bit positions starting at 0 (LSB). The structure is:

Example

For number_of_lags = 4 and number_of_slots = 160:

The prefix has bits 1 and 3 set. The data section contains:

00100001 00000010 01000101    1010
<- lag 3 data --> <-lag 1>    <-->
  (16 bits)       (8 bits)    prefix
  slots 0, 11     slots 1, 5  lags 1, 3

The order of the bits is:

[slot13]...[slot7][is_last] [slot6]...[slot0][is_last] [slot6]...[slot0][is_last] [lag3]...[lag0]
<-------------- lag 3 data (2 chunks) ---------------> <---- lag 1 (1 chunk) ---> <-- prefix --->

The size of the encoding is not bounded. However, the size of a DAL attestations bitset is checked during validation of an attestation; and there is a bound on the size of a generic operation.

RPC path argument for parsing a DAL attestation bitset from a decimal integer string in URL paths.

val empty : t

empty returns an empty attestation structure where all slots at all lags are marked as unavailable.

val is_empty : t -> bool

is_empty t returns true if all attestations at all lags are empty.

val is_empty_at_lag_index : t -> lag_index:int -> bool

is_empty_at_lag_index t returns true if the attestation at lag_index is empty.

val is_attested : t -> number_of_slots:int -> number_of_lags:int -> lag_index:int -> Dal_slot_index_repr.t -> bool

is_attested t ~number_of_slots ~number_of_lags ~lag_index slot_index returns true if the attestation at lag_index commits that the slot at slot_index is available. lag_index must satisfy 0 <= lag_index < number_of_lags, and slot_index must satisfy 0 <= slot_index < number_of_slots.

type unfolded_lag_attestation = {
  1. lag_index : int;
  2. slot_indices : int list;
}

The decoded representation of the slots attested for a given lag_index.

val decode : t -> number_of_slots:int -> number_of_lags:int -> unfolded_lag_attestation list Tezos_protocol_environment_alpha.Error_monad.tzresult

decode t ~number_of_slots ~number_of_lags decodes the attestation bitset t into an explicit representation. Returns a list of unfolded_lag_attestation, one entry per non-empty lag, in increasing lag order. slot_indices contains the attested slot indices for that lag, in increasing order. Empty lags are omitted from the result. Fails with Dal_invalid_attestation_bitset if t is malformed.

val commit : t -> number_of_slots:int -> number_of_lags:int -> lag_index:int -> Dal_slot_index_repr.t -> t

commit t ~number_of_slots ~number_of_lags ~lag_index slot_index commits into the attestation at lag_index that the slot slot_index is available. lag_index must satisfy 0 <= lag_index < number_of_lags, and slot_index must satisfy 0 <= slot_index < number_of_slots.

val occupied_size_in_bits : t -> int

occupied_size_in_bits v returns the size in bits of v.

val expected_max_size_in_bits : number_of_slots:int -> number_of_lags:int -> int

expected_max_size_in_bits ~number_of_slots ~number_of_lags returns the maximum size (in bits) of a t value.

val weight : t -> int
type attestation = t

Type alias for use in submodules.

module Slot_availability : sig ... end

Slot availability represents the protocol's attestation result for a block.

module Accountability : sig ... end

This module is used to record the shard attestations.

module Dal_dependent_signing : sig ... end

t-dependent combination of public keys or signatures.

module Internal_for_tests : sig ... end