diff --git a/src/bin_dal_node/accuser.ml b/src/bin_dal_node/accuser.ml index e4021f2443a686bad23dcd73814d34a752f3056a..e79821bf6a5856fda647582c73912867e2d4348d 100644 --- a/src/bin_dal_node/accuser.ml +++ b/src/bin_dal_node/accuser.ml @@ -13,9 +13,9 @@ let get_attestation_map (type block_info attestation_operation dal_attestation) with type block_info = block_info and type attestation_operation = attestation_operation and type dal_attestation = dal_attestation) block = - let attestations = Plugin.get_attestation_operations block in + let attestations = Plugin.get_attestations block in List.fold_left - (fun map (delegate_opt, operation, dal_attestation) -> + (fun map (_tb_slot, delegate_opt, operation, dal_attestation) -> match delegate_opt with | None -> map | Some delegate -> diff --git a/src/bin_dal_node/daemon.ml b/src/bin_dal_node/daemon.ml index 0a64179e6f7977525ce99046b3133854c8c8dcb8..9d21b270c8de9f619d7ac43de87873f816fd75be 100644 --- a/src/bin_dal_node/daemon.ml +++ b/src/bin_dal_node/daemon.ml @@ -439,7 +439,7 @@ module Handler = struct let get_attestable_slots attestations committee ~number_of_slots is_attested = let count_per_slot = Array.make number_of_slots 0 in List.iter - (fun (_tb_slot, delegate_opt, dal_attestation_opt) -> + (fun (_tb_slot, delegate_opt, _attestation_op, dal_attestation_opt) -> match (delegate_opt, dal_attestation_opt) with | Some delegate, Some dal_attestation -> ( match Signature.Public_key_hash.Map.find delegate committee with @@ -488,11 +488,11 @@ module Handler = struct in let*! () = List.iter_s - (fun (_tb_slot, delegate_opt, bitset_opt) -> + (fun (_, delegate_opt, _attestation_op, dal_attestation_opt) -> match delegate_opt with | Some delegate when Signature.Public_key_hash.Set.mem delegate attesters -> ( - match bitset_opt with + match dal_attestation_opt with | None -> let in_committee = match @@ -611,9 +611,7 @@ module Handler = struct in let* () = may_update_topics ctxt proto_parameters ~block_level in let* () = - let get_attestations () = - Plugin.get_dal_content_of_attestations block_info - in + let get_attestations () = Plugin.get_attestations block_info in check_attesters_attested ctxt proto_parameters diff --git a/src/lib_dal_node/dal_plugin.ml b/src/lib_dal_node/dal_plugin.ml index a4442e48bc794ccb4edc3f972593b88592a7bfd6..50abdc0a4e252189d9fe6bd7550ed1b33ce03df4 100644 --- a/src/lib_dal_node/dal_plugin.ml +++ b/src/lib_dal_node/dal_plugin.ml @@ -146,17 +146,14 @@ module type T = sig block_info -> (slot_header * operation_application_result) list tzresult Lwt.t - val get_attestation_operations : + val get_attestations : block_info -> - (Signature.public_key_hash option + (int + * Signature.public_key_hash option * attestation_operation * dal_attestation option) list - val get_dal_content_of_attestations : - block_info -> - (int * Signature.Public_key_hash.t option * dal_attestation option) list - val get_committee : Tezos_rpc.Context.generic -> level:int32 -> diff --git a/src/lib_dal_node/dal_plugin.mli b/src/lib_dal_node/dal_plugin.mli index 07ca19ada91d5e7c97054f7d3aba0211b03e6d37..ab66a17f5e991a8efe7a11967566b0b7224d68ce 100644 --- a/src/lib_dal_node/dal_plugin.mli +++ b/src/lib_dal_node/dal_plugin.mli @@ -89,23 +89,18 @@ module type T = sig (slot_header * operation_application_result) list tzresult Lwt.t (** For a given block, returns for each included attestation, as a - list, its attester if available, its [attestation] operation - and, if it exists, its [dal_attestation] to be passed to the - [is_attested] function. *) - val get_attestation_operations : + list, its Tenderbake slot, its attester if available in the + operation receipt, its [attestation] operation and, if it + exists, its [dal_attestation] to be passed to the [is_attested] + function. *) + val get_attestations : block_info -> - (Signature.public_key_hash option + (int + * Signature.public_key_hash option * attestation_operation * dal_attestation option) list - (** For a given block, returns for each included attestation, as a list, its - Tenderbake slot, its attester (if available in the operation receipt), and - its DAL attestation. *) - val get_dal_content_of_attestations : - block_info -> - (int * Signature.Public_key_hash.t option * dal_attestation option) list - (** [get_committee ctxt ~level] retrieves the DAL committee at [level] from L1 as a map that associates to the public key hash [pkh] of the member of the committee its assigned shard indexes. *) diff --git a/src/proto_020_PsParisC/lib_dal/dal_plugin_registration.ml b/src/proto_020_PsParisC/lib_dal/dal_plugin_registration.ml index dadbaff371a0cab70c6dc5c467df6cf74cb26eb7..bb9902374da088cb5bf9c1244f1393f56de1d657 100644 --- a/src/proto_020_PsParisC/lib_dal/dal_plugin_registration.ml +++ b/src/proto_020_PsParisC/lib_dal/dal_plugin_registration.ml @@ -136,40 +136,7 @@ module Plugin = struct let slot_index = Dal.Slot_index.to_int slot_index in return Dal_plugin.({published_level; slot_index; commitment}, status)) - let get_dal_content_of_attestations (block : block_info) = - let open Protocol.Alpha_context in - match List.hd block.operations with - | None -> - (* that should be unreachable, as there are 4 operation passes *) [] - | Some consensus_ops -> - List.filter_map - (fun Protocol_client_context.Alpha_block_services. - {receipt; protocol_data; _} -> - let delegate_opt = - match receipt with - | Receipt (Operation_metadata {contents; _}) -> ( - match contents with - | Single_result (Attestation_result {delegate; _}) -> - Some delegate - | _ -> None) - | Empty | Too_large | Receipt No_operation_metadata -> None - in - match protocol_data with - | Operation_data - { - contents = - Single (Attestation {consensus_content; dal_content; _}); - _; - } -> - Some - ( Slot.to_int consensus_content.slot, - delegate_opt, - (Option.map (fun d -> d.attestation) dal_content - :> Bitset.t option) ) - | _ -> None) - consensus_ops - - let get_attestation_operations block_info = + let get_attestations block_info = let open Protocol.Alpha_context in let open Protocol_client_context.Alpha_block_services in match block_info.operations with @@ -186,6 +153,7 @@ module Plugin = struct protocol_data = operation_data; } in + let tb_slot = Slot.to_int attestation.consensus_content.slot in let dal_attestation : dal_attestation option = Option.map (fun x -> (x.attestation :> dal_attestation)) @@ -196,12 +164,14 @@ module Plugin = struct match operation_metadata.contents with | Single_result (Attestation_result result) -> Some - ( Some result.delegate, + ( tb_slot, + Some result.delegate, packed_operation, dal_attestation ) - | _ -> Some (None, packed_operation, dal_attestation)) + | _ -> + Some (tb_slot, None, packed_operation, dal_attestation)) | Empty | Too_large | Receipt No_operation_metadata -> - Some (None, packed_operation, dal_attestation)) + Some (tb_slot, None, packed_operation, dal_attestation)) | _ -> None) consensus_ops | _ -> diff --git a/src/proto_021_PsQuebec/lib_dal/dal_plugin_registration.ml b/src/proto_021_PsQuebec/lib_dal/dal_plugin_registration.ml index 04990e5fe9d5eefa3a458479eb04cec3c050a3b2..bb6943c11d37c9ee8355ded55e6394748c47d9e2 100644 --- a/src/proto_021_PsQuebec/lib_dal/dal_plugin_registration.ml +++ b/src/proto_021_PsQuebec/lib_dal/dal_plugin_registration.ml @@ -136,40 +136,7 @@ module Plugin = struct let slot_index = Dal.Slot_index.to_int slot_index in return Dal_plugin.({published_level; slot_index; commitment}, status)) - let get_dal_content_of_attestations (block : block_info) = - let open Protocol.Alpha_context in - match List.hd block.operations with - | None -> - (* that should be unreachable, as there are 4 operation passes *) [] - | Some consensus_ops -> - List.filter_map - (fun Protocol_client_context.Alpha_block_services. - {receipt; protocol_data; _} -> - let delegate_opt = - match receipt with - | Receipt (Operation_metadata {contents; _}) -> ( - match contents with - | Single_result (Attestation_result {delegate; _}) -> - Some delegate - | _ -> None) - | Empty | Too_large | Receipt No_operation_metadata -> None - in - match protocol_data with - | Operation_data - { - contents = - Single (Attestation {consensus_content; dal_content; _}); - _; - } -> - Some - ( Slot.to_int consensus_content.slot, - delegate_opt, - (Option.map (fun d -> d.attestation) dal_content - :> Bitset.t option) ) - | _ -> None) - consensus_ops - - let get_attestation_operations block_info = + let get_attestations block_info = let open Protocol.Alpha_context in let open Protocol_client_context.Alpha_block_services in match block_info.operations with @@ -186,6 +153,7 @@ module Plugin = struct protocol_data = operation_data; } in + let tb_slot = Slot.to_int attestation.consensus_content.slot in let dal_attestation : dal_attestation option = Option.map (fun x -> (x.attestation :> dal_attestation)) @@ -196,12 +164,14 @@ module Plugin = struct match operation_metadata.contents with | Single_result (Attestation_result result) -> Some - ( Some result.delegate, + ( tb_slot, + Some result.delegate, packed_operation, dal_attestation ) - | _ -> Some (None, packed_operation, dal_attestation)) + | _ -> + Some (tb_slot, None, packed_operation, dal_attestation)) | Empty | Too_large | Receipt No_operation_metadata -> - Some (None, packed_operation, dal_attestation)) + Some (tb_slot, None, packed_operation, dal_attestation)) | _ -> None) consensus_ops | _ -> diff --git a/src/proto_alpha/lib_dal/dal_plugin_registration.ml b/src/proto_alpha/lib_dal/dal_plugin_registration.ml index 615fb8c8e7d475459e7c87cc8eab468dae57ae5c..52c418c72fcc553d252f18ea14400ee3529b9938 100644 --- a/src/proto_alpha/lib_dal/dal_plugin_registration.ml +++ b/src/proto_alpha/lib_dal/dal_plugin_registration.ml @@ -175,40 +175,7 @@ module Plugin = struct let slot_index = Dal.Slot_index.to_int slot_index in return Dal_plugin.({published_level; slot_index; commitment}, status)) - let get_dal_content_of_attestations (block : block_info) = - let open Protocol.Alpha_context in - match List.hd block.operations with - | None -> - (* that should be unreachable, as there are 4 operation passes *) [] - | Some consensus_ops -> - List.filter_map - (fun Protocol_client_context.Alpha_block_services. - {receipt; protocol_data; _} -> - let delegate_opt = - match receipt with - | Receipt (Operation_metadata {contents; _}) -> ( - match contents with - | Single_result (Attestation_result {delegate; _}) -> - Some delegate - | _ -> None) - | Empty | Too_large | Receipt No_operation_metadata -> None - in - match protocol_data with - | Operation_data - { - contents = - Single (Attestation {consensus_content; dal_content; _}); - _; - } -> - Some - ( Slot.to_int consensus_content.slot, - delegate_opt, - (Option.map (fun d -> d.attestation) dal_content - :> Environment.Bitset.t option) ) - | _ -> None) - consensus_ops - - let get_attestation_operations block_info = + let get_attestations block_info = let open Protocol.Alpha_context in let open Protocol_client_context.Alpha_block_services in match block_info.operations with @@ -225,6 +192,7 @@ module Plugin = struct protocol_data = operation_data; } in + let tb_slot = Slot.to_int attestation.consensus_content.slot in let dal_attestation : dal_attestation option = Option.map (fun x -> (x.attestation :> dal_attestation)) @@ -235,12 +203,14 @@ module Plugin = struct match operation_metadata.contents with | Single_result (Attestation_result result) -> Some - ( Some result.delegate, + ( tb_slot, + Some result.delegate, packed_operation, dal_attestation ) - | _ -> Some (None, packed_operation, dal_attestation)) + | _ -> + Some (tb_slot, None, packed_operation, dal_attestation)) | Empty | Too_large | Receipt No_operation_metadata -> - Some (None, packed_operation, dal_attestation)) + Some (tb_slot, None, packed_operation, dal_attestation)) | _ -> None) consensus_ops | _ ->