From 4788b13ece50b71f881d8041bcf6cf04d51ec9d4 Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Thu, 4 Dec 2025 14:15:37 +0000 Subject: [PATCH 1/5] Teztale: Add DAL attested slots in archiver interface --- teztale/bin_teztale_archiver/archiver.ml | 3 +++ teztale/bin_teztale_archiver/archiver.mli | 3 +++ teztale/bin_teztale_archiver/json_archiver.ml | 3 +++ teztale/bin_teztale_archiver/server_archiver.ml | 17 +++++++++++++++++ .../bin_teztale_archiver/server_archiver.mli | 1 + .../teztale_archiver_main.ml | 3 +++ 6 files changed, 30 insertions(+) diff --git a/teztale/bin_teztale_archiver/archiver.ml b/teztale/bin_teztale_archiver/archiver.ml index df097473dd1a..620d77a45047 100644 --- a/teztale/bin_teztale_archiver/archiver.ml +++ b/teztale/bin_teztale_archiver/archiver.ml @@ -37,4 +37,7 @@ module type S = sig val add_rights : level:Int32.t -> Consensus_ops.rights -> unit val add_dal_shards : level:Int32.t -> Data.Dal.shard_assignment list -> unit + + val add_dal_attested_slots : + level:int32 -> Data.Dal.attested_slots list -> unit end diff --git a/teztale/bin_teztale_archiver/archiver.mli b/teztale/bin_teztale_archiver/archiver.mli index df097473dd1a..620d77a45047 100644 --- a/teztale/bin_teztale_archiver/archiver.mli +++ b/teztale/bin_teztale_archiver/archiver.mli @@ -37,4 +37,7 @@ module type S = sig val add_rights : level:Int32.t -> Consensus_ops.rights -> unit val add_dal_shards : level:Int32.t -> Data.Dal.shard_assignment list -> unit + + val add_dal_attested_slots : + level:int32 -> Data.Dal.attested_slots list -> unit end diff --git a/teztale/bin_teztale_archiver/json_archiver.ml b/teztale/bin_teztale_archiver/json_archiver.ml index b249522ec782..9bdf2d67784e 100644 --- a/teztale/bin_teztale_archiver/json_archiver.ml +++ b/teztale/bin_teztale_archiver/json_archiver.ml @@ -545,3 +545,6 @@ let add_rights ~level:_ _rights = () (* not used *) let add_dal_shards ~level:_ _shard_assignments = () + +(* not used *) +let add_dal_attested_slots ~level:_ _attested_slots = () diff --git a/teztale/bin_teztale_archiver/server_archiver.ml b/teztale/bin_teztale_archiver/server_archiver.ml index 9a950cd2af43..fb3b86b2f92c 100644 --- a/teztale/bin_teztale_archiver/server_archiver.ml +++ b/teztale/bin_teztale_archiver/server_archiver.ml @@ -20,6 +20,7 @@ type chunk = | Mempool of Int32.t (* level *) * Consensus_ops.delegate_ops | Rights of (Int32.t (* level *) * Consensus_ops.rights) | Dal_shards of Int32.t (* level *) * Data.Dal.shard_assignment list + | Dal_attested_slots of Int32.t (* level *) * Data.Dal.attested_slots list type ctx = { cohttp_ctx : Cohttp_lwt_unix.Net.ctx; @@ -111,6 +112,17 @@ let send_dal_shards ctx level shard_assignments = let path = Int32.to_string level ^ "/dal_shards" in send_something ctx path body +let send_dal_attested_slots ctx level attested_slots = + let body = + `String + (Ezjsonm.value_to_string + (Data_encoding.Json.construct + Data.Dal.attested_slots_list_encoding + attested_slots)) + in + let path = Int32.to_string level ^ "/dal_attested_slots" in + send_something ctx path body + let chunk_stream, chunk_feeder = Lwt_stream.create () let send actx = function @@ -119,6 +131,8 @@ let send actx = function | Rights (level, rights) -> send_rights actx level rights | Dal_shards (level, shard_assignments) -> send_dal_shards actx level shard_assignments + | Dal_attested_slots (level, attested_slots) -> + send_dal_attested_slots actx level attested_slots let launch actx _source = Lwt_stream.iter_p @@ -137,3 +151,6 @@ let add_rights ~level rights = chunk_feeder (Some (Rights (level, rights))) let add_dal_shards ~level shard_assignments = chunk_feeder (Some (Dal_shards (level, shard_assignments))) + +let add_dal_attested_slots ~level attested_slots = + chunk_feeder (Some (Dal_attested_slots (level, attested_slots))) diff --git a/teztale/bin_teztale_archiver/server_archiver.mli b/teztale/bin_teztale_archiver/server_archiver.mli index 24c61502ab1d..fde34996b0e5 100644 --- a/teztale/bin_teztale_archiver/server_archiver.mli +++ b/teztale/bin_teztale_archiver/server_archiver.mli @@ -20,6 +20,7 @@ type chunk = | Mempool of Int32.t (* level *) * Consensus_ops.delegate_ops | Rights of (Int32.t (* level *) * Consensus_ops.rights) | Dal_shards of Int32.t (* level *) * Data.Dal.shard_assignment list + | Dal_attested_slots of Int32.t (* level *) * Data.Dal.attested_slots list type ctx = { cohttp_ctx : Cohttp_lwt_unix.Net.ctx; diff --git a/teztale/bin_teztale_archiver/teztale_archiver_main.ml b/teztale/bin_teztale_archiver/teztale_archiver_main.ml index 267b72b934d2..76620499c495 100644 --- a/teztale/bin_teztale_archiver/teztale_archiver_main.ml +++ b/teztale/bin_teztale_archiver/teztale_archiver_main.ml @@ -91,6 +91,7 @@ let server_to_json_chunk : Server_archiver.chunk -> Json_archiver.chunk option = | Mempool (level, ops) -> Some (Mempool (None, level, ops)) | Rights (_, _) -> None | Dal_shards (_, _) -> None + | Dal_attested_slots (_, _) -> None let select_commands _ctxt Client_config.{chain; _} = return @@ -234,6 +235,8 @@ let select_commands _ctxt Client_config.{chain; _} = | Mempool (level, _) -> (level, "/mempool") | Rights (level, _) -> (level, "/rights") | Dal_shards (level, _) -> (level, "/dal_shards") + | Dal_attested_slots (level, _) -> + (level, "/dal_attested_slots") in Printf.sprintf "(%ld) Failed to send %s data and --backup-dir is \ -- GitLab From c57eb3cdca79e8572d43637d3214a66af148ee4a Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Thu, 4 Dec 2025 14:36:18 +0000 Subject: [PATCH 2/5] Teztale: All attested slots to blocks type and collect then in archiver --- .../Proxford_machine.real.ml | 8 +++-- .../PsBabyM1_machine.real.ml | 1 + .../PsCARTHA_machine.real.ml | 1 + .../PsDELPH1_machine.real.ml | 1 + .../PsFLoren_machine.real.ml | 4 ++- .../PsParisC_machine.real.ml | 8 +++-- .../PsQuebec_machine.real.ml | 8 +++-- .../PsRiotum_machine.real.ml | 8 +++-- .../PsYLVpVv_machine.real.ml | 1 + .../PsddFKi3_machine.real.ml | 1 + .../Psithaca_machine.real.ml | 8 +++-- .../Pt24m4xi_machine.real.ml | 1 + .../PtCJ7pwo_machine.real.ml | 1 + .../PtEdo2Zk_machine.real.ml | 1 + .../PtGRANAD_machine.real.ml | 4 ++- .../PtHangz2_machine.real.ml | 4 ++- .../PtJakart_machine.real.ml | 8 +++-- .../PtKathma_machine.real.ml | 8 +++-- .../PtLimaPt_machine.real.ml | 8 +++-- .../PtMumbai_machine.real.ml | 8 +++-- .../PtNairob_machine.real.ml | 8 +++-- .../PtParisB_machine.real.ml | 8 +++-- .../PtSeouLo_machine.real.ml | 9 +++-- .../PtTALLiN_machine.real.ml | 9 +++-- .../alpha_machine.real.ml | 9 +++-- teztale/bin_teztale_archiver/converter.ml | 1 + .../bin_teztale_archiver/general_archiver.ml | 33 ++++++++++++++++++- .../protocol_machinery.ml | 3 +- .../protocol_machinery.mli | 3 +- teztale/lib_teztale_base/consensus_ops.ml | 12 ++++--- teztale/lib_teztale_base/consensus_ops.mli | 1 + 31 files changed, 150 insertions(+), 38 deletions(-) diff --git a/teztale/bin_teztale_archiver/Proxford_machine.real.ml b/teztale/bin_teztale_archiver/Proxford_machine.real.ml index f4bd381cc7b9..16d5ba13b37b 100644 --- a/teztale/bin_teztale_archiver/Proxford_machine.real.ml +++ b/teztale/bin_teztale_archiver/Proxford_machine.real.ml @@ -76,7 +76,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -92,7 +93,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -243,6 +245,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | Receipt @@ -263,6 +266,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | _ -> acc) diff --git a/teztale/bin_teztale_archiver/PsBabyM1_machine.real.ml b/teztale/bin_teztale_archiver/PsBabyM1_machine.real.ml index 1bae8307acad..715da138c6b2 100644 --- a/teztale/bin_teztale_archiver/PsBabyM1_machine.real.ml +++ b/teztale/bin_teztale_archiver/PsBabyM1_machine.real.ml @@ -196,6 +196,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct op = {hash; round = None; kind = Consensus_ops.Attestation}; delegate = public_key_hash_of_v0 delegate; power = List.length slots; + dal_attested_slots = []; } | _ -> None) ops diff --git a/teztale/bin_teztale_archiver/PsCARTHA_machine.real.ml b/teztale/bin_teztale_archiver/PsCARTHA_machine.real.ml index 7a6faa08148d..f5d68efd97f5 100644 --- a/teztale/bin_teztale_archiver/PsCARTHA_machine.real.ml +++ b/teztale/bin_teztale_archiver/PsCARTHA_machine.real.ml @@ -196,6 +196,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct op = {hash; round = None; kind = Consensus_ops.Attestation}; delegate = public_key_hash_of_v0 delegate; power = List.length slots; + dal_attested_slots = []; } | _ -> None) ops diff --git a/teztale/bin_teztale_archiver/PsDELPH1_machine.real.ml b/teztale/bin_teztale_archiver/PsDELPH1_machine.real.ml index 1a33aa52d137..c159b1bc7292 100644 --- a/teztale/bin_teztale_archiver/PsDELPH1_machine.real.ml +++ b/teztale/bin_teztale_archiver/PsDELPH1_machine.real.ml @@ -196,6 +196,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct op = {hash; round = None; kind = Consensus_ops.Attestation}; delegate = public_key_hash_of_v0 delegate; power = List.length slots; + dal_attested_slots = []; } | _ -> None) ops diff --git a/teztale/bin_teztale_archiver/PsFLoren_machine.real.ml b/teztale/bin_teztale_archiver/PsFLoren_machine.real.ml index 9155f9d92168..79a122bb7e69 100644 --- a/teztale/bin_teztale_archiver/PsFLoren_machine.real.ml +++ b/teztale/bin_teztale_archiver/PsFLoren_machine.real.ml @@ -84,7 +84,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, None ), - slot ) + slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -211,6 +212,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct op = {hash; round = None; kind = Consensus_ops.Attestation}; delegate = public_key_hash_of_v0 delegate; power = List.length slots; + dal_attested_slots = []; } | _ -> None) ops diff --git a/teztale/bin_teztale_archiver/PsParisC_machine.real.ml b/teztale/bin_teztale_archiver/PsParisC_machine.real.ml index f19e7600df8a..b3f24eed33bd 100644 --- a/teztale/bin_teztale_archiver/PsParisC_machine.real.ml +++ b/teztale/bin_teztale_archiver/PsParisC_machine.real.ml @@ -81,7 +81,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -97,7 +98,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -265,6 +267,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | Receipt @@ -285,6 +288,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | _ -> acc) diff --git a/teztale/bin_teztale_archiver/PsQuebec_machine.real.ml b/teztale/bin_teztale_archiver/PsQuebec_machine.real.ml index 5538c0f6f0f1..14fa23a3a837 100644 --- a/teztale/bin_teztale_archiver/PsQuebec_machine.real.ml +++ b/teztale/bin_teztale_archiver/PsQuebec_machine.real.ml @@ -81,7 +81,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -97,7 +98,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -265,6 +267,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | Receipt @@ -285,6 +288,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | _ -> acc) diff --git a/teztale/bin_teztale_archiver/PsRiotum_machine.real.ml b/teztale/bin_teztale_archiver/PsRiotum_machine.real.ml index 16272dd52f66..e81c0f7efd90 100644 --- a/teztale/bin_teztale_archiver/PsRiotum_machine.real.ml +++ b/teztale/bin_teztale_archiver/PsRiotum_machine.real.ml @@ -81,7 +81,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -97,7 +98,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -265,6 +267,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | Receipt @@ -285,6 +288,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | _ -> acc) diff --git a/teztale/bin_teztale_archiver/PsYLVpVv_machine.real.ml b/teztale/bin_teztale_archiver/PsYLVpVv_machine.real.ml index 4d887c96cd69..e5d3c9d05340 100644 --- a/teztale/bin_teztale_archiver/PsYLVpVv_machine.real.ml +++ b/teztale/bin_teztale_archiver/PsYLVpVv_machine.real.ml @@ -196,6 +196,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct op = {hash; round = None; kind = Consensus_ops.Attestation}; delegate = public_key_hash_of_v0 delegate; power = List.length slots; + dal_attested_slots = []; } | _ -> None) ops diff --git a/teztale/bin_teztale_archiver/PsddFKi3_machine.real.ml b/teztale/bin_teztale_archiver/PsddFKi3_machine.real.ml index cb087bae500b..7ce1a52cf68d 100644 --- a/teztale/bin_teztale_archiver/PsddFKi3_machine.real.ml +++ b/teztale/bin_teztale_archiver/PsddFKi3_machine.real.ml @@ -196,6 +196,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct op = {hash; round = None; kind = Consensus_ops.Attestation}; delegate = public_key_hash_of_v0 delegate; power = List.length slots; + dal_attested_slots = []; } | _ -> None) ops diff --git a/teztale/bin_teztale_archiver/Psithaca_machine.real.ml b/teztale/bin_teztale_archiver/Psithaca_machine.real.ml index 61922d0a42ae..8ffb583e9620 100644 --- a/teztale/bin_teztale_archiver/Psithaca_machine.real.ml +++ b/teztale/bin_teztale_archiver/Psithaca_machine.real.ml @@ -82,7 +82,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -98,7 +99,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -246,6 +248,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = public_key_hash_of_v0 delegate; power = preendorsement_power; + dal_attested_slots = []; } :: acc | Receipt @@ -266,6 +269,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = public_key_hash_of_v0 delegate; power = endorsement_power; + dal_attested_slots = []; } :: acc | _ -> acc) diff --git a/teztale/bin_teztale_archiver/Pt24m4xi_machine.real.ml b/teztale/bin_teztale_archiver/Pt24m4xi_machine.real.ml index 98474167ebd4..cd9fb51fb665 100644 --- a/teztale/bin_teztale_archiver/Pt24m4xi_machine.real.ml +++ b/teztale/bin_teztale_archiver/Pt24m4xi_machine.real.ml @@ -196,6 +196,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct op = {hash; round = None; kind = Consensus_ops.Attestation}; delegate = public_key_hash_of_v0 delegate; power = List.length slots; + dal_attested_slots = []; } | _ -> None) ops diff --git a/teztale/bin_teztale_archiver/PtCJ7pwo_machine.real.ml b/teztale/bin_teztale_archiver/PtCJ7pwo_machine.real.ml index 44933f66a11d..7bd2a0f0335f 100644 --- a/teztale/bin_teztale_archiver/PtCJ7pwo_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtCJ7pwo_machine.real.ml @@ -196,6 +196,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct op = {hash; round = None; kind = Consensus_ops.Attestation}; delegate = public_key_hash_of_v0 delegate; power = List.length slots; + dal_attested_slots = []; } | _ -> None) ops diff --git a/teztale/bin_teztale_archiver/PtEdo2Zk_machine.real.ml b/teztale/bin_teztale_archiver/PtEdo2Zk_machine.real.ml index d897c2ed5237..192739c90b55 100644 --- a/teztale/bin_teztale_archiver/PtEdo2Zk_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtEdo2Zk_machine.real.ml @@ -196,6 +196,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct op = {hash; round = None; kind = Consensus_ops.Attestation}; delegate = public_key_hash_of_v0 delegate; power = List.length slots; + dal_attested_slots = []; } | _ -> None) ops diff --git a/teztale/bin_teztale_archiver/PtGRANAD_machine.real.ml b/teztale/bin_teztale_archiver/PtGRANAD_machine.real.ml index 708099c5f9e6..2a1a61f8f0cf 100644 --- a/teztale/bin_teztale_archiver/PtGRANAD_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtGRANAD_machine.real.ml @@ -84,7 +84,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, None ), - slot ) + slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -211,6 +212,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct op = {hash; round = None; kind = Consensus_ops.Attestation}; delegate = public_key_hash_of_v0 delegate; power = List.length slots; + dal_attested_slots = []; } | _ -> None) ops diff --git a/teztale/bin_teztale_archiver/PtHangz2_machine.real.ml b/teztale/bin_teztale_archiver/PtHangz2_machine.real.ml index 5f40c4ca9576..9564cc55b964 100644 --- a/teztale/bin_teztale_archiver/PtHangz2_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtHangz2_machine.real.ml @@ -84,7 +84,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, None ), - slot ) + slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -211,6 +212,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct op = {hash; round = None; kind = Consensus_ops.Attestation}; delegate = public_key_hash_of_v0 delegate; power = List.length slots; + dal_attested_slots = []; } | _ -> None) ops diff --git a/teztale/bin_teztale_archiver/PtJakart_machine.real.ml b/teztale/bin_teztale_archiver/PtJakart_machine.real.ml index 8f9165ee1f69..72bbe7edbe9d 100644 --- a/teztale/bin_teztale_archiver/PtJakart_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtJakart_machine.real.ml @@ -82,7 +82,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -98,7 +99,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -246,6 +248,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = public_key_hash_of_v0 delegate; power = preendorsement_power; + dal_attested_slots = []; } :: acc | Receipt @@ -266,6 +269,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = public_key_hash_of_v0 delegate; power = endorsement_power; + dal_attested_slots = []; } :: acc | _ -> acc) diff --git a/teztale/bin_teztale_archiver/PtKathma_machine.real.ml b/teztale/bin_teztale_archiver/PtKathma_machine.real.ml index 935c66a8c356..b772eeee1e98 100644 --- a/teztale/bin_teztale_archiver/PtKathma_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtKathma_machine.real.ml @@ -82,7 +82,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -98,7 +99,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -246,6 +248,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = public_key_hash_of_v0 delegate; power = preendorsement_power; + dal_attested_slots = []; } :: acc | Receipt @@ -266,6 +269,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = public_key_hash_of_v0 delegate; power = endorsement_power; + dal_attested_slots = []; } :: acc | _ -> acc) diff --git a/teztale/bin_teztale_archiver/PtLimaPt_machine.real.ml b/teztale/bin_teztale_archiver/PtLimaPt_machine.real.ml index 61af5e1fdf98..e32a3092d469 100644 --- a/teztale/bin_teztale_archiver/PtLimaPt_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtLimaPt_machine.real.ml @@ -82,7 +82,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -98,7 +99,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -247,6 +249,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = public_key_hash_of_v0 delegate; power = preendorsement_power; + dal_attested_slots = []; } :: acc | Receipt @@ -267,6 +270,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = public_key_hash_of_v0 delegate; power = endorsement_power; + dal_attested_slots = []; } :: acc | _ -> acc) diff --git a/teztale/bin_teztale_archiver/PtMumbai_machine.real.ml b/teztale/bin_teztale_archiver/PtMumbai_machine.real.ml index d1bd33c43392..83c52bd37c16 100644 --- a/teztale/bin_teztale_archiver/PtMumbai_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtMumbai_machine.real.ml @@ -76,7 +76,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -92,7 +93,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -243,6 +245,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = preendorsement_power; + dal_attested_slots = []; } :: acc | Receipt @@ -263,6 +266,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = endorsement_power; + dal_attested_slots = []; } :: acc | _ -> acc) diff --git a/teztale/bin_teztale_archiver/PtNairob_machine.real.ml b/teztale/bin_teztale_archiver/PtNairob_machine.real.ml index 217ba7938735..90c643576528 100644 --- a/teztale/bin_teztale_archiver/PtNairob_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtNairob_machine.real.ml @@ -76,7 +76,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -92,7 +93,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -243,6 +245,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = preendorsement_power; + dal_attested_slots = []; } :: acc | Receipt @@ -263,6 +266,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = endorsement_power; + dal_attested_slots = []; } :: acc | _ -> acc) diff --git a/teztale/bin_teztale_archiver/PtParisB_machine.real.ml b/teztale/bin_teztale_archiver/PtParisB_machine.real.ml index 23447e7c9ae5..ebafa0335c1f 100644 --- a/teztale/bin_teztale_archiver/PtParisB_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtParisB_machine.real.ml @@ -81,7 +81,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -97,7 +98,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -265,6 +267,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | Receipt @@ -285,6 +288,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V1.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | _ -> acc) diff --git a/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml b/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml index 180d52a80a0e..8cf3512c4f4e 100644 --- a/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml @@ -81,7 +81,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -97,7 +98,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -257,6 +259,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct }; delegate = Tezos_crypto.Signature.Of_V2.public_key_hash ck.delegate; power; + dal_attested_slots = []; } :: acc) acc @@ -293,6 +296,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct delegate = Tezos_crypto.Signature.Of_V2.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | Receipt @@ -315,6 +319,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct delegate = Tezos_crypto.Signature.Of_V2.public_key_hash delegate; power = consensus_power; + dal_attested_slots = []; } :: acc | Receipt diff --git a/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml b/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml index ed842de7ba4d..4c520c2fa82b 100644 --- a/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml @@ -81,7 +81,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -97,7 +98,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -258,6 +260,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct delegate = Tezos_crypto.Signature.Of_V2.public_key_hash ck.delegate; power = Protocol.Alpha_context.Attesting_power.get_slots_from_result power; + dal_attested_slots = []; } :: acc) acc @@ -297,6 +300,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Attesting_power .get_slots_from_result consensus_power; + dal_attested_slots = []; } :: acc | Receipt @@ -322,6 +326,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Attesting_power .get_slots_from_result consensus_power; + dal_attested_slots = []; } :: acc | Receipt diff --git a/teztale/bin_teztale_archiver/alpha_machine.real.ml b/teztale/bin_teztale_archiver/alpha_machine.real.ml index cd31a5f9c488..4c6dad95d91c 100644 --- a/teztale/bin_teztale_archiver/alpha_machine.real.ml +++ b/teztale/bin_teztale_archiver/alpha_machine.real.ml @@ -81,7 +81,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -97,7 +98,8 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Preattestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), - slot_to_int slot ) + slot_to_int slot, + [] ) | _ -> None let consensus_operation_stream cctxt = @@ -258,6 +260,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct delegate = Tezos_crypto.Signature.Of_V2.public_key_hash ck.delegate; power = Protocol.Alpha_context.Attesting_power.get_slots_from_result power; + dal_attested_slots = []; } :: acc) acc @@ -297,6 +300,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Attesting_power .get_slots_from_result consensus_power; + dal_attested_slots = []; } :: acc | Receipt @@ -322,6 +326,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Attesting_power .get_slots_from_result consensus_power; + dal_attested_slots = []; } :: acc | Receipt diff --git a/teztale/bin_teztale_archiver/converter.ml b/teztale/bin_teztale_archiver/converter.ml index 4ffc63cb64f0..e384428bc973 100644 --- a/teztale/bin_teztale_archiver/converter.ml +++ b/teztale/bin_teztale_archiver/converter.ml @@ -127,6 +127,7 @@ let included_ops_map level data = op = {kind; round; hash = maybe_faked_hash}; delegate; power = attesting_power; + dal_attested_slots = []; } acc) acc diff --git a/teztale/bin_teztale_archiver/general_archiver.ml b/teztale/bin_teztale_archiver/general_archiver.ml index ef09c18d6ffa..c684177ecb51 100644 --- a/teztale/bin_teztale_archiver/general_archiver.ml +++ b/teztale/bin_teztale_archiver/general_archiver.ml @@ -43,6 +43,8 @@ let registered_rights_levels = Ring.create 120 let registered_dal_shards_levels = Ring.create 120 +let registerd_dal_slots_levels = Ring.create 120 + let rights_machine = Protocol_hash.Table.create 10 let past_block_machine = Protocol_hash.Table.create 10 @@ -65,6 +67,12 @@ let maybe_add_dal_shards (module A : Archiver.S) level shard_assignments = Ring.add registered_dal_shards_levels level ; A.add_dal_shards ~level shard_assignments) +let maybe_add_dal_attested_slots (module A : Archiver.S) level attested_slots = + if Ring.mem registerd_dal_slots_levels level then () + else ( + Ring.add registerd_dal_slots_levels level ; + A.add_dal_attested_slots ~level attested_slots) + let dump_my_current_attestations (module A : Archiver.S) ~unaccurate ~level rights attestations = let () = maybe_add_rights (module A) level rights in @@ -188,7 +196,10 @@ module Define (Services : Protocol_machinery.PROTOCOL_SERVICES) = struct let* op_stream, _stopper = Services.consensus_operation_stream cctx' in let*! out = Lwt_stream.fold - (fun ((hash, ((block, level, kind, round), slot)), errors) acc -> + (fun ( (hash, ((block, level, kind, round), slot, _dal_attested_slots)), + errors ) + acc + -> let reception_time = Time.System.now () in let op = Consensus_ops.{op = {hash; kind; round}; errors; reception_time} @@ -345,6 +356,14 @@ module Loops (Archiver : Archiver.S) = struct in Lwt.return_unit + let dal_attested_slots_of_ops = + List.filter_map + (fun Consensus_ops.{op = {hash; _}; dal_attested_slots; _} -> + match dal_attested_slots with + | [] -> None + | slots -> + Some Data.Dal.{operation_hash = hash; attested_slot_indices = slots}) + let maybe_register_rights_and_dal_shards ~rights_of ~dal_shards_of cctx ~level ops = if List.is_empty ops then return_unit @@ -354,6 +373,10 @@ module Loops (Archiver : Archiver.S) = struct let () = maybe_add_rights (module Archiver) pred_level rights in let* dal_shards = dal_shards_of cctx pred_level in let () = maybe_add_dal_shards (module Archiver) pred_level dal_shards in + let attested_slots = dal_attested_slots_of_ops ops in + let () = + maybe_add_dal_attested_slots (module Archiver) level attested_slots + in return_unit let reception_blocks_loop cctx = @@ -437,6 +460,14 @@ module Loops (Archiver : Archiver.S) = struct ~level preattestations in + let dal_attested_slots = + dal_attested_slots_of_ops attestations + in + let () = + Archiver.add_dal_attested_slots + ~level + dal_attested_slots + in let () = Archiver.add_block ~level block_data in return_unit in diff --git a/teztale/bin_teztale_archiver/protocol_machinery.ml b/teztale/bin_teztale_archiver/protocol_machinery.ml index 6743947fdded..88af09e2d293 100644 --- a/teztale/bin_teztale_archiver/protocol_machinery.ml +++ b/teztale/bin_teztale_archiver/protocol_machinery.ml @@ -26,7 +26,8 @@ module type PROTOCOL_SERVICES = sig wrap_full -> (((Operation_hash.t * ((block_id * Int32.t * Consensus_ops.operation_kind * Int32.t option) - * int)) + * int + * int list)) * error trace option) Lwt_stream.t * Tezos_rpc.Context.stopper) diff --git a/teztale/bin_teztale_archiver/protocol_machinery.mli b/teztale/bin_teztale_archiver/protocol_machinery.mli index 6743947fdded..88af09e2d293 100644 --- a/teztale/bin_teztale_archiver/protocol_machinery.mli +++ b/teztale/bin_teztale_archiver/protocol_machinery.mli @@ -26,7 +26,8 @@ module type PROTOCOL_SERVICES = sig wrap_full -> (((Operation_hash.t * ((block_id * Int32.t * Consensus_ops.operation_kind * Int32.t option) - * int)) + * int + * int list)) * error trace option) Lwt_stream.t * Tezos_rpc.Context.stopper) diff --git a/teztale/lib_teztale_base/consensus_ops.ml b/teztale/lib_teztale_base/consensus_ops.ml index 5f259e4e394e..0ea985c05d03 100644 --- a/teztale/lib_teztale_base/consensus_ops.ml +++ b/teztale/lib_teztale_base/consensus_ops.ml @@ -73,14 +73,18 @@ type block_op = { op : operation; delegate : Tezos_crypto.Signature.public_key_hash; power : int; + dal_attested_slots : int list; } let block_op_encoding = let open Data_encoding in conv - (fun {op; delegate; power} -> (op, delegate, power)) - (fun (op, delegate, power) -> {op; delegate; power}) - (obj3 + (fun {op; delegate; power; dal_attested_slots} -> + (op, delegate, power, dal_attested_slots)) + (fun (op, delegate, power, dal_attested_slots) -> + {op; delegate; power; dal_attested_slots}) + (obj4 (req "operation" operation_encoding) (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) - (req "endorsing_power" int16)) + (req "endorsing_power" int16) + (dft "dal_attested_slots" (list int31) [])) diff --git a/teztale/lib_teztale_base/consensus_ops.mli b/teztale/lib_teztale_base/consensus_ops.mli index 32ef2a3445d7..6292c0309494 100644 --- a/teztale/lib_teztale_base/consensus_ops.mli +++ b/teztale/lib_teztale_base/consensus_ops.mli @@ -41,6 +41,7 @@ type block_op = { op : operation; delegate : Tezos_crypto.Signature.public_key_hash; power : int; + dal_attested_slots : int list; } val block_op_encoding : block_op Data_encoding.encoding -- GitLab From 821966cd96cfde85fc51ad5bb603178a43d7207e Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Thu, 4 Dec 2025 14:48:39 +0000 Subject: [PATCH 3/5] Teztale: Protocol machines: hook attested slots --- .../PtSeouLo_machine.real.ml | 71 +++++++++++++++++-- .../PtTALLiN_machine.real.ml | 71 +++++++++++++++++-- .../alpha_machine.real.ml | 71 +++++++++++++++++-- 3 files changed, 198 insertions(+), 15 deletions(-) diff --git a/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml b/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml index 8cf3512c4f4e..5e82851203b7 100644 --- a/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml @@ -54,11 +54,36 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct answer.Plugin.RPC.Attestation_rights.delegates_rights) | [] -> return_nil + let dal_attested_slots_of_dal_content ~number_of_slots dal_content = + match dal_content with + | None -> [] + | Some Protocol.Alpha_context.{attestation} -> + let acc = + List.fold_left + (fun acc i -> + match + Protocol.Alpha_context.Dal.Slot_index.of_int_opt + ~number_of_slots + i + with + | None -> acc + | Some slot_index -> + if + Protocol.Alpha_context.Dal.Attestation.is_attested + attestation + slot_index + then i :: acc + else acc) + [] + (Stdlib.List.init number_of_slots Fun.id) + in + List.rev acc + type block_id = Protocol.Block_payload_hash.t module BlockIdMap = Map.Make (Protocol.Block_payload_hash) - let extract_attestation + let extract_attestation ~number_of_slots (operation_content : Protocol.Alpha_context.packed_operation) = match operation_content with | { @@ -70,19 +95,22 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct (Attestation { consensus_content = {slot; level; round; block_payload_hash}; - _; + dal_content; }); signature = _; }; shell = _; } -> + let attested_slots = + dal_attested_slots_of_dal_content ~number_of_slots dal_content + in Some ( ( block_payload_hash, Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), slot_to_int slot, - [] ) + attested_slots ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -102,7 +130,24 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct [] ) | _ -> None + let dal_number_of_slots = + let ans = ref None in + fun cctxt ref_block -> + match !ans with + | Some x -> return x + | None -> + let* constants = + Plugin.Alpha_services.Constants.parametric cctxt ref_block + in + let dal_constants = + constants.Protocol.Alpha_context.Constants.Parametric.dal + in + let out = dal_constants.number_of_slots in + ans := Some out ; + return out + let consensus_operation_stream cctxt = + let* number_of_slots = dal_number_of_slots cctxt (cctxt#chain, `Head 0) in let* ops_stream, stopper = Block_services.Mempool.monitor_operations cctxt @@ -119,7 +164,9 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct return ( Lwt_stream.filter_map (fun ((hash, op), errors) -> - Option.map (fun x -> ((hash, x), errors)) (extract_attestation op)) + Option.map + (fun x -> ((hash, x), errors)) + (extract_attestation ~number_of_slots op)) op_stream, stopper ) @@ -273,8 +320,22 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct ~block:(`Hash (hash, 0)) 0 in + let* number_of_slots = + dal_number_of_slots cctxt (cctxt#chain, `Hash (hash, 0)) + in + let dal_attested_slots_of_protocol_data protocol_data = + match protocol_data with + | Protocol.Alpha_context.Operation_data {contents; _} -> ( + match contents with + | Single (Attestation {dal_content; _}) -> + dal_attested_slots_of_dal_content ~number_of_slots dal_content + | _ -> []) + in List.fold_left_es (fun acc Block_services.{hash; receipt; protocol_data; _} -> + let dal_attested_slots = + dal_attested_slots_of_protocol_data protocol_data + in match receipt with | Receipt (Protocol.Apply_results.Operation_metadata @@ -319,7 +380,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct delegate = Tezos_crypto.Signature.Of_V2.public_key_hash delegate; power = consensus_power; - dal_attested_slots = []; + dal_attested_slots; } :: acc | Receipt diff --git a/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml b/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml index 4c520c2fa82b..a8243aaa3f25 100644 --- a/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml @@ -54,11 +54,36 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct answer.Plugin.RPC.Attestation_rights.delegates_rights) | [] -> return_nil + let dal_attested_slots_of_dal_content ~number_of_slots dal_content = + match dal_content with + | None -> [] + | Some Protocol.Alpha_context.{attestation} -> + let acc = + List.fold_left + (fun acc i -> + match + Protocol.Alpha_context.Dal.Slot_index.of_int_opt + ~number_of_slots + i + with + | None -> acc + | Some slot_index -> + if + Protocol.Alpha_context.Dal.Attestation.is_attested + attestation + slot_index + then i :: acc + else acc) + [] + (Stdlib.List.init number_of_slots Fun.id) + in + List.rev acc + type block_id = Protocol.Block_payload_hash.t module BlockIdMap = Map.Make (Protocol.Block_payload_hash) - let extract_attestation + let extract_attestation ~number_of_slots (operation_content : Protocol.Alpha_context.packed_operation) = match operation_content with | { @@ -70,19 +95,22 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct (Attestation { consensus_content = {slot; level; round; block_payload_hash}; - _; + dal_content; }); signature = _; }; shell = _; } -> + let attested_slots = + dal_attested_slots_of_dal_content ~number_of_slots dal_content + in Some ( ( block_payload_hash, Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), slot_to_int slot, - [] ) + attested_slots ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -102,7 +130,24 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct [] ) | _ -> None + let dal_number_of_slots = + let ans = ref None in + fun cctxt ref_block -> + match !ans with + | Some x -> return x + | None -> + let* constants = + Plugin.Alpha_services.Constants.parametric cctxt ref_block + in + let dal_constants = + constants.Protocol.Alpha_context.Constants.Parametric.dal + in + let out = dal_constants.number_of_slots in + ans := Some out ; + return out + let consensus_operation_stream cctxt = + let* number_of_slots = dal_number_of_slots cctxt (cctxt#chain, `Head 0) in let* ops_stream, stopper = Block_services.Mempool.monitor_operations cctxt @@ -119,7 +164,9 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct return ( Lwt_stream.filter_map (fun ((hash, op), errors) -> - Option.map (fun x -> ((hash, x), errors)) (extract_attestation op)) + Option.map + (fun x -> ((hash, x), errors)) + (extract_attestation ~number_of_slots op)) op_stream, stopper ) @@ -274,8 +321,22 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct ~block:(`Hash (hash, 0)) 0 in + let* number_of_slots = + dal_number_of_slots cctxt (cctxt#chain, `Hash (hash, 0)) + in + let dal_attested_slots_of_protocol_data protocol_data = + match protocol_data with + | Protocol.Alpha_context.Operation_data {contents; _} -> ( + match contents with + | Single (Attestation {dal_content; _}) -> + dal_attested_slots_of_dal_content ~number_of_slots dal_content + | _ -> []) + in List.fold_left_es (fun acc Block_services.{hash; receipt; protocol_data; _} -> + let dal_attested_slots = + dal_attested_slots_of_protocol_data protocol_data + in match receipt with | Receipt (Protocol.Apply_results.Operation_metadata @@ -300,7 +361,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Attesting_power .get_slots_from_result consensus_power; - dal_attested_slots = []; + dal_attested_slots; } :: acc | Receipt diff --git a/teztale/bin_teztale_archiver/alpha_machine.real.ml b/teztale/bin_teztale_archiver/alpha_machine.real.ml index 4c6dad95d91c..dc29b3945b44 100644 --- a/teztale/bin_teztale_archiver/alpha_machine.real.ml +++ b/teztale/bin_teztale_archiver/alpha_machine.real.ml @@ -54,11 +54,36 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct answer.Plugin.RPC.Attestation_rights.delegates_rights) | [] -> return_nil + let dal_attested_slots_of_dal_content ~number_of_slots dal_content = + match dal_content with + | None -> [] + | Some Protocol.Alpha_context.{attestation} -> + let acc = + List.fold_left + (fun acc i -> + match + Protocol.Alpha_context.Dal.Slot_index.of_int_opt + ~number_of_slots + i + with + | None -> acc + | Some slot_index -> + if + Protocol.Alpha_context.Dal.Attestation.is_attested + attestation + slot_index + then i :: acc + else acc) + [] + (Stdlib.List.init number_of_slots Fun.id) + in + List.rev acc + type block_id = Protocol.Block_payload_hash.t module BlockIdMap = Map.Make (Protocol.Block_payload_hash) - let extract_attestation + let extract_attestation ~number_of_slots (operation_content : Protocol.Alpha_context.packed_operation) = match operation_content with | { @@ -70,19 +95,22 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct (Attestation { consensus_content = {slot; level; round; block_payload_hash}; - _; + dal_content; }); signature = _; }; shell = _; } -> + let attested_slots = + dal_attested_slots_of_dal_content ~number_of_slots dal_content + in Some ( ( block_payload_hash, Protocol.Alpha_context.Raw_level.to_int32 level, Consensus_ops.Attestation, Some (Protocol.Alpha_context.Round.to_int32 round) ), slot_to_int slot, - [] ) + attested_slots ) | { Protocol.Main.protocol_data = Protocol.Alpha_context.Operation_data @@ -102,7 +130,24 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct [] ) | _ -> None + let dal_number_of_slots = + let ans = ref None in + fun cctxt ref_block -> + match !ans with + | Some x -> return x + | None -> + let* constants = + Plugin.Alpha_services.Constants.parametric cctxt ref_block + in + let dal_constants = + constants.Protocol.Alpha_context.Constants.Parametric.dal + in + let out = dal_constants.number_of_slots in + ans := Some out ; + return out + let consensus_operation_stream cctxt = + let* number_of_slots = dal_number_of_slots cctxt (cctxt#chain, `Head 0) in let* ops_stream, stopper = Block_services.Mempool.monitor_operations cctxt @@ -119,7 +164,9 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct return ( Lwt_stream.filter_map (fun ((hash, op), errors) -> - Option.map (fun x -> ((hash, x), errors)) (extract_attestation op)) + Option.map + (fun x -> ((hash, x), errors)) + (extract_attestation ~number_of_slots op)) op_stream, stopper ) @@ -274,8 +321,22 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct ~block:(`Hash (hash, 0)) 0 in + let* number_of_slots = + dal_number_of_slots cctxt (cctxt#chain, `Hash (hash, 0)) + in + let dal_attested_slots_of_protocol_data protocol_data = + match protocol_data with + | Protocol.Alpha_context.Operation_data {contents; _} -> ( + match contents with + | Single (Attestation {dal_content; _}) -> + dal_attested_slots_of_dal_content ~number_of_slots dal_content + | _ -> []) + in List.fold_left_es (fun acc Block_services.{hash; receipt; protocol_data; _} -> + let dal_attested_slots = + dal_attested_slots_of_protocol_data protocol_data + in match receipt with | Receipt (Protocol.Apply_results.Operation_metadata @@ -300,7 +361,7 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct Protocol.Alpha_context.Attesting_power .get_slots_from_result consensus_power; - dal_attested_slots = []; + dal_attested_slots; } :: acc | Receipt -- GitLab From 620b6ce4edf8e3ae6848ebca474bc1fa40860733 Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Thu, 11 Dec 2025 15:34:08 +0000 Subject: [PATCH 4/5] Teztale: Server: Add DAL attested slots from operations from blocks --- .../bin_teztale_server/teztale_server_main.ml | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/teztale/bin_teztale_server/teztale_server_main.ml b/teztale/bin_teztale_server/teztale_server_main.ml index 96ef508410b3..2b8ac1c80566 100644 --- a/teztale/bin_teztale_server/teztale_server_main.ml +++ b/teztale/bin_teztale_server/teztale_server_main.ml @@ -595,13 +595,30 @@ let insert_operations_from_block (module Db : Caqti_lwt.CONNECTION) conf level (block_hash, level) )) operations in - maybe_with_metrics conf "insert_included_operations" @@ fun () -> + let* () = + maybe_with_metrics conf "insert_included_operations" @@ fun () -> + without_cache + Sql_requests.Mutex.operations_inclusion + Sql_requests.insert_included_operation + (module Db) + conf + operation_inclusion + in + let dal_slots = + List.concat_map + (fun {Lib_teztale_base.Consensus_ops.op; dal_attested_slots; _} -> + List.map + (fun slot_index -> (level, op.hash, slot_index)) + dal_attested_slots) + operations + in + maybe_with_metrics conf "insert_dal_attested_slots" @@ fun () -> without_cache - Sql_requests.Mutex.operations_inclusion - Sql_requests.insert_included_operation + Sql_requests.Mutex.dal_attested_slots + Sql_requests.insert_dal_attested_slot (module Db) conf - operation_inclusion + dal_slots module Block_lru_cache = Aches.Vache.Set (Aches.Vache.LRU_Precise) (Aches.Vache.Strong) -- GitLab From e0383724b43a72c9142c1ff3bd0fad1064efdc04 Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Thu, 11 Dec 2025 15:38:18 +0000 Subject: [PATCH 5/5] Teztale: Protocol machines: hook attested slots in aggregated attestations --- .../PtSeouLo_machine.real.ml | 51 ++++++++++++++++-- .../PtTALLiN_machine.real.ml | 54 +++++++++++++++++-- .../alpha_machine.real.ml | 54 +++++++++++++++++-- 3 files changed, 144 insertions(+), 15 deletions(-) diff --git a/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml b/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml index 5e82851203b7..610bc7bd3319 100644 --- a/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtSeouLo_machine.real.ml @@ -395,13 +395,54 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct balance_updates = _; }); }) -> + let committee_with_dal_content = + match protocol_data with + | Protocol.Alpha_context.Operation_data {contents; _} -> ( + match contents with + | Single + (Attestations_aggregate {committee = dal_committee; _}) -> + List.fold_left + (fun (acc, dal_list) (ck, power) -> + let dal_slots, remianing = + match dal_list with + | (_slot, dal_content_opt) :: rest -> + let dal_attested_slots = + dal_attested_slots_of_dal_content + ~number_of_slots + dal_content_opt + in + (dal_attested_slots, rest) + | [] -> ([], []) + in + (((ck, power), dal_slots) :: acc, remianing)) + ([], dal_committee) + committee + |> fst |> List.rev + | _ -> List.map (fun x -> (x, [])) committee) + in return - @@ consensus_ops_from_aggregate + @@ List.fold_left + (fun acc + ( ((ck : Protocol.Alpha_context.Consensus_key.t), power), + dal_attested_slots ) + -> + Consensus_ops. + { + op = + { + hash; + round = Some (get_attestation_round protocol_data); + kind = Consensus_ops.Attestation; + }; + delegate = + Tezos_crypto.Signature.Of_V2.public_key_hash + ck.delegate; + power; + dal_attested_slots; + } + :: acc) acc - hash - protocol_data - committee - Consensus_ops.Attestation + committee_with_dal_content | Receipt (Protocol.Apply_results.Operation_metadata { diff --git a/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml b/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml index a8243aaa3f25..bf80c20ef8dc 100644 --- a/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml +++ b/teztale/bin_teztale_archiver/PtTALLiN_machine.real.ml @@ -402,13 +402,57 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct balance_updates = _; }); }) -> + let committee_with_dal_content = + match protocol_data with + | Protocol.Alpha_context.Operation_data {contents; _} -> ( + match contents with + | Single + (Attestations_aggregate {committee = dal_committee; _}) -> + List.fold_left + (fun (acc, dal_list) (ck, power) -> + let dal_slots, remianing = + match dal_list with + | (_slot, dal_content_opt) :: rest -> + let dal_attested_slots = + dal_attested_slots_of_dal_content + ~number_of_slots + dal_content_opt + in + (dal_attested_slots, rest) + | [] -> ([], []) + in + (((ck, power), dal_slots) :: acc, remianing)) + ([], dal_committee) + committee + |> fst |> List.rev + | _ -> List.map (fun x -> (x, [])) committee) + in return - @@ consensus_ops_from_aggregate + @@ List.fold_left + (fun acc + ( ((ck : Protocol.Alpha_context.Consensus_key.t), power), + dal_attested_slots ) + -> + Consensus_ops. + { + op = + { + hash; + round = Some (get_attestation_round protocol_data); + kind = Consensus_ops.Attestation; + }; + delegate = + Tezos_crypto.Signature.Of_V2.public_key_hash + ck.delegate; + power = + Protocol.Alpha_context.Attesting_power + .get_slots_from_result + power; + dal_attested_slots; + } + :: acc) acc - hash - protocol_data - committee - Consensus_ops.Attestation + committee_with_dal_content | Receipt (Protocol.Apply_results.Operation_metadata { diff --git a/teztale/bin_teztale_archiver/alpha_machine.real.ml b/teztale/bin_teztale_archiver/alpha_machine.real.ml index dc29b3945b44..52a9fd14c3cb 100644 --- a/teztale/bin_teztale_archiver/alpha_machine.real.ml +++ b/teztale/bin_teztale_archiver/alpha_machine.real.ml @@ -402,13 +402,57 @@ module Services : Protocol_machinery.PROTOCOL_SERVICES = struct balance_updates = _; }); }) -> + let committee_with_dal_content = + match protocol_data with + | Protocol.Alpha_context.Operation_data {contents; _} -> ( + match contents with + | Single + (Attestations_aggregate {committee = dal_committee; _}) -> + List.fold_left + (fun (acc, dal_list) (ck, power) -> + let dal_slots, remianing = + match dal_list with + | (_slot, dal_content_opt) :: rest -> + let dal_attested_slots = + dal_attested_slots_of_dal_content + ~number_of_slots + dal_content_opt + in + (dal_attested_slots, rest) + | [] -> ([], []) + in + (((ck, power), dal_slots) :: acc, remianing)) + ([], dal_committee) + committee + |> fst |> List.rev + | _ -> List.map (fun x -> (x, [])) committee) + in return - @@ consensus_ops_from_aggregate + @@ List.fold_left + (fun acc + ( ((ck : Protocol.Alpha_context.Consensus_key.t), power), + dal_attested_slots ) + -> + Consensus_ops. + { + op = + { + hash; + round = Some (get_attestation_round protocol_data); + kind = Consensus_ops.Attestation; + }; + delegate = + Tezos_crypto.Signature.Of_V2.public_key_hash + ck.delegate; + power = + Protocol.Alpha_context.Attesting_power + .get_slots_from_result + power; + dal_attested_slots; + } + :: acc) acc - hash - protocol_data - committee - Consensus_ops.Attestation + committee_with_dal_content | Receipt (Protocol.Apply_results.Operation_metadata { -- GitLab