diff --git a/src/proto_alpha/lib_delegate/baking_actions.ml b/src/proto_alpha/lib_delegate/baking_actions.ml index c03c099c50d18f77acb62607b74901b752aefb25..42153493a602d3982b94f3796abb07a916c89b9f 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.ml +++ b/src/proto_alpha/lib_delegate/baking_actions.ml @@ -526,7 +526,8 @@ let sign_dal_attestations state attestations = Operation_data {contents; signature = Some signature} in let operation : Operation.packed = {shell; protocol_data} in - return_some (delegate, operation)) + return_some + (delegate, operation, consensus_content.Dal.Attestation.attestation)) attestations let inject_endorsements state ~endorsements = @@ -553,7 +554,7 @@ let inject_dal_attestations state attestations = let chain_id = state.global_state.chain_id in sign_dal_attestations state attestations >>=? fun signed_operations -> List.iter_ep - (fun (delegate, signed_operation) -> + (fun (delegate, signed_operation, (attestation : Dal.Attestation.t)) -> let encoded_op = Data_encoding.Binary.to_bytes_exn Operation.encoding signed_operation in @@ -562,8 +563,9 @@ let inject_dal_attestations state attestations = ~chain:(`Hash chain_id) encoded_op >>=? fun oph -> - Events.(emit attestation_injected (oph, delegate)) >>= fun () -> - return_unit) + let bitset_int = Bitset.to_z (attestation :> Bitset.t) in + Events.(emit attestation_injected (oph, delegate, bitset_int)) + >>= fun () -> return_unit) signed_operations let no_dal_node_warning_counter = ref 0 diff --git a/src/proto_alpha/lib_delegate/baking_actions.mli b/src/proto_alpha/lib_delegate/baking_actions.mli index 2033e7442926bfad75b9cb6dc915984222f672bd..07665261acea2a7be09334c4f9d64e5c0d99313f 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.mli +++ b/src/proto_alpha/lib_delegate/baking_actions.mli @@ -103,7 +103,9 @@ val inject_endorsements : val sign_dal_attestations : state -> (consensus_key_and_delegate * Dal.Attestation.operation) list -> - (consensus_key_and_delegate * packed_operation) list tzresult Lwt.t + (consensus_key_and_delegate * packed_operation * Dal.Attestation.t) list + tzresult + Lwt.t val get_dal_attestations : state -> diff --git a/src/proto_alpha/lib_delegate/baking_events.ml b/src/proto_alpha/lib_delegate/baking_events.ml index c7f75ca4c5a3b803f4eb406e7560093aeace9407..4983b02ac7d4ceb9bdccf2e041f435cbb646929d 100644 --- a/src/proto_alpha/lib_delegate/baking_events.ml +++ b/src/proto_alpha/lib_delegate/baking_events.ml @@ -571,15 +571,17 @@ module Actions = struct ("delegate", Baking_state.consensus_key_and_delegate_encoding) let attestation_injected = - declare_2 + declare_3 ~section ~name:"attestation_injected" ~level:Notice - ~msg:"injected attestation {ophash} for {delegate}" + ~msg:"injected attestation {ophash} with bitset {bitset} for {delegate}" ~pp1:Operation_hash.pp ("ophash", Operation_hash.encoding) ~pp2:Baking_state.pp_consensus_key_and_delegate ("delegate", Baking_state.consensus_key_and_delegate_encoding) + ~pp3:Z.pp_print + ("bitset", Data_encoding.n) let synchronizing_round = declare_1 diff --git a/src/proto_alpha/lib_delegate/baking_lib.ml b/src/proto_alpha/lib_delegate/baking_lib.ml index c2b68be694902210b73a0ad5239683b43e7da36e..113cab5a0a571df5f65fceb30cabe1959021ab64 100644 --- a/src/proto_alpha/lib_delegate/baking_lib.ml +++ b/src/proto_alpha/lib_delegate/baking_lib.ml @@ -477,7 +477,9 @@ let baking_minimal_timestamp state = Baking_actions.sign_dal_attestations state own_dal_attestations in let pool = - Operation_pool.add_operations pool (List.map snd signed_dal_attestations) + Operation_pool.add_operations + pool + (List.map (fun (_delegate, op, _bitset) -> op) signed_dal_attestations) in let kind = Baking_actions.Fresh pool in let block_to_bake : Baking_actions.block_to_bake = diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 369521dfd40cdc4ae5af2cedbfb4ce23acd4f9fb..9b9920262e33e8e4c565f06813be429cd67cfb2d 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2949,7 +2949,7 @@ module Dal : sig (** This module re-exports definitions from {!Dal_attestation_repr} and {!Raw_context.Dal}. *) module Attestation : sig - type t + type t = private Bitset.t type operation = { attestor : public_key_hash; diff --git a/src/proto_alpha/lib_protocol/bitset.ml b/src/proto_alpha/lib_protocol/bitset.ml index 6a1511e9336edace437109b500a6d4174e7fe9ae..25963119f550001e49374f87d826150f3672950e 100644 --- a/src/proto_alpha/lib_protocol/bitset.ml +++ b/src/proto_alpha/lib_protocol/bitset.ml @@ -62,6 +62,4 @@ let () = let occupied_size_in_bits = Z.numbits -module Internal_for_tests = struct - let to_z z = z -end +let to_z z = z diff --git a/src/proto_alpha/lib_protocol/bitset.mli b/src/proto_alpha/lib_protocol/bitset.mli index 1c4a69db2d13d5e3f1acf9bc9b65880aca66be3e..a3837c3d7a88997ec2dab59a08022b9b42e1b9fd 100644 --- a/src/proto_alpha/lib_protocol/bitset.mli +++ b/src/proto_alpha/lib_protocol/bitset.mli @@ -70,6 +70,5 @@ val diff : t -> t -> t occupied by the [bitset]. *) val occupied_size_in_bits : t -> int -module Internal_for_tests : sig - val to_z : t -> Z.t -end +(** [to_z t] Returns the sum of powers of two of the given bitset. *) +val to_z : t -> Z.t diff --git a/src/proto_alpha/lib_protocol/dal_attestation_repr.mli b/src/proto_alpha/lib_protocol/dal_attestation_repr.mli index 40c3d8ea56cc2a2a5decc0ebde6b3d2db4a5dc93..17139107101eb977f46e00be646e995891b9ee65 100644 --- a/src/proto_alpha/lib_protocol/dal_attestation_repr.mli +++ b/src/proto_alpha/lib_protocol/dal_attestation_repr.mli @@ -42,7 +42,7 @@ that aims to be provided with endorsement operations. To avoid overloading the network, this representation should be compact. *) -type t +type t = private Bitset.t (** The shape of Dal attestation operations injected by delegates. *) type operation = { diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_bitset.ml b/src/proto_alpha/lib_protocol/test/pbt/test_bitset.ml index 39cdc4c2ee1319a9fff70e816a72d6d2d6170fca..0931bda11d100d18429db8a3aa3e33e0072e7514 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_bitset.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_bitset.ml @@ -87,10 +87,8 @@ let test_diff (c1, c2) = let test_fill = let two = Z.of_int 2 in fun length -> - let f1 = fill ~length |> value_of |> Internal_for_tests.to_z in - let f2 = - from_list (0 -- (length - 1)) |> value_of |> Internal_for_tests.to_z - in + let f1 = fill ~length |> value_of |> to_z in + let f2 = from_list (0 -- (length - 1)) |> value_of |> to_z in let f3 = Z.(pow two length |> pred) in Z.equal f1 f2 && Z.equal f2 f3