From a7cbe84ae1d788891198378b22cd6488fd89f73e Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Wed, 7 Sep 2022 16:43:36 +0200 Subject: [PATCH 1/3] lib_crypto_dal: export a function COMMITMENT.equal --- src/lib_crypto_dal/cryptobox.ml | 2 ++ src/lib_crypto_dal/cryptobox_intf.ml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/lib_crypto_dal/cryptobox.ml b/src/lib_crypto_dal/cryptobox.ml index 218c9c189bac..d798653b61f9 100644 --- a/src/lib_crypto_dal/cryptobox.ml +++ b/src/lib_crypto_dal/cryptobox.ml @@ -196,6 +196,8 @@ module Inner = struct let zero = Bls12_381.G1.zero + let equal = Bls12_381.G1.eq + let commitment_to_bytes = Bls12_381.G1.to_compressed_bytes let commitment_of_bytes_opt = Bls12_381.G1.of_compressed_bytes_opt diff --git a/src/lib_crypto_dal/cryptobox_intf.ml b/src/lib_crypto_dal/cryptobox_intf.ml index 6504a0cfc0d2..a7db897600a6 100644 --- a/src/lib_crypto_dal/cryptobox_intf.ml +++ b/src/lib_crypto_dal/cryptobox_intf.ml @@ -41,6 +41,8 @@ module type COMMITMENT = sig val pp : Format.formatter -> t -> unit + val equal : t -> t -> bool + val zero : t end -- GitLab From 3aad4ab372cb32849f7b7680e011dfe988d593d4 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Wed, 7 Sep 2022 16:44:12 +0200 Subject: [PATCH 2/3] Environment: expose function Commitment.equal in env --- src/lib_protocol_environment/sigs/v7.ml | 2 ++ src/lib_protocol_environment/sigs/v7/dal.mli | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/lib_protocol_environment/sigs/v7.ml b/src/lib_protocol_environment/sigs/v7.ml index 1532e3d519a7..858a6365c401 100644 --- a/src/lib_protocol_environment/sigs/v7.ml +++ b/src/lib_protocol_environment/sigs/v7.ml @@ -11768,6 +11768,8 @@ module Commitment : sig val zero : commitment + val equal : commitment -> commitment -> bool + val pp : Format.formatter -> commitment -> unit end diff --git a/src/lib_protocol_environment/sigs/v7/dal.mli b/src/lib_protocol_environment/sigs/v7/dal.mli index 3435c92f28f7..60680553abc0 100644 --- a/src/lib_protocol_environment/sigs/v7/dal.mli +++ b/src/lib_protocol_environment/sigs/v7/dal.mli @@ -56,6 +56,8 @@ module Commitment : sig val zero : commitment + val equal : commitment -> commitment -> bool + val pp : Format.formatter -> commitment -> unit end -- GitLab From 36fecc4aef7ff7c12d00a123d997ec17820cc6d6 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Tue, 6 Sep 2022 13:58:59 +0200 Subject: [PATCH 3/3] Proto/Dal: export a function Dal_slot_repr.equal --- src/proto_alpha/lib_protocol/alpha_context.mli | 2 ++ src/proto_alpha/lib_protocol/dal_slot_repr.ml | 9 +++++++++ src/proto_alpha/lib_protocol/dal_slot_repr.mli | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 2d05931eb1db..1aed19be7618 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2817,6 +2817,8 @@ module Dal : sig val pp : Format.formatter -> t -> unit + val equal : t -> t -> bool + val register_slot : context -> t -> (context * bool) tzresult val find : context -> Raw_level.t -> t list option tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.ml b/src/proto_alpha/lib_protocol/dal_slot_repr.ml index 4cbcbf56a6da..252986e9be93 100644 --- a/src/proto_alpha/lib_protocol/dal_slot_repr.ml +++ b/src/proto_alpha/lib_protocol/dal_slot_repr.ml @@ -30,6 +30,8 @@ module Header = struct commitment should be given here. *) type t = Dal.commitment + let equal = Dal.Commitment.equal + let encoding = Dal.Commitment.encoding let pp ppf commitment = @@ -55,6 +57,8 @@ module Index = struct let to_int slot_index = slot_index [@@ocaml.inline always] let compare = Compare.Int.compare + + let equal = Compare.Int.equal end type header = Header.t @@ -65,6 +69,11 @@ type t = {level : Raw_level_repr.t; index : Index.t; header : header} type slot = t +let equal ({level; index; header} : t) s2 = + Raw_level_repr.equal level s2.level + && Index.equal index s2.index + && Header.equal header s2.header + let encoding = let open Data_encoding in conv diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.mli b/src/proto_alpha/lib_protocol/dal_slot_repr.mli index 7dd3e921990c..6ea6004d57e6 100644 --- a/src/proto_alpha/lib_protocol/dal_slot_repr.mli +++ b/src/proto_alpha/lib_protocol/dal_slot_repr.mli @@ -80,6 +80,8 @@ module Index : sig val to_int : t -> int val compare : t -> t -> int + + val equal : t -> t -> bool end type header = Header.t @@ -88,6 +90,8 @@ type t = {level : Raw_level_repr.t; index : Index.t; header : header} type slot = t +val equal : t -> t -> bool + (** The encoding ensures the slot is always a non-negative number. *) val encoding : t Data_encoding.t -- GitLab