From 2a176fdb948ed55b6876de80fa1803e34f2acb83 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Thu, 15 Dec 2022 22:23:13 +0100 Subject: [PATCH 1/4] Proto/DAL: expose slot history hash structure --- src/proto_alpha/lib_protocol/alpha_context.mli | 4 +++- src/proto_alpha/lib_protocol/dal_slot_repr.mli | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index b5c611f4f3c5..34652ce8b05d 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3095,7 +3095,9 @@ module Dal : sig module Slots_history : sig type t - type hash + module Pointer_hash : S.HASH + + type hash = Pointer_hash.t (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/3766 Do we need to export this? *) diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.mli b/src/proto_alpha/lib_protocol/dal_slot_repr.mli index 443a14ae05a3..565135e86cd6 100644 --- a/src/proto_alpha/lib_protocol/dal_slot_repr.mli +++ b/src/proto_alpha/lib_protocol/dal_slot_repr.mli @@ -204,8 +204,10 @@ module History : sig confirmed slot headers. *) type t + module Pointer_hash : S.HASH + (** Type of hashes of history. *) - type hash + type hash = Pointer_hash.t (** Encoding of the datatype. *) val encoding : t Data_encoding.t -- GitLab From 7be64f1e95cc4eba087bc4269893edc81f2c3146 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Thu, 15 Dec 2022 22:26:51 +0100 Subject: [PATCH 2/4] Proto/SCORU: expose inbox hash function --- src/proto_alpha/lib_protocol/alpha_context.mli | 2 ++ src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml | 2 ++ src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 34652ce8b05d..946a2a350f22 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3390,6 +3390,8 @@ module Sc_rollup : sig module Hash : S.HASH + val hash : t -> Hash.t + module History : Bounded_history_repr.S with type key = Hash.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml index d82114c7bd95..52f079d8f049 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml @@ -229,6 +229,8 @@ module V1 = struct pp_history_proof old_levels_messages + let hash inbox = hash_history_proof inbox.old_levels_messages + let inbox_level inbox = inbox.level let old_levels_messages inbox = inbox.old_levels_messages diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli index 7f6e8c174cd4..a6afe07c2fa0 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli @@ -133,6 +133,8 @@ module V1 : sig val equal : t -> t -> bool + val hash : t -> Hash.t + val encoding : t Data_encoding.t (** [inbox_level inbox] returns the maximum level of message insertion in -- GitLab From 31fb2032b2b126fd28534499384dc21d11dc609d Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Mon, 2 Jan 2023 17:01:56 +0100 Subject: [PATCH 3/4] Proto/SCORU: expose inbox current witness function --- src/proto_alpha/lib_protocol/alpha_context.mli | 2 ++ src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml | 4 ++++ src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 946a2a350f22..f092fb3d71b3 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3392,6 +3392,8 @@ module Sc_rollup : sig val hash : t -> Hash.t + val current_witness : t -> Inbox_merkelized_payload_hashes.Hash.t + module History : Bounded_history_repr.S with type key = Hash.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml index 52f079d8f049..cb5b320707ff 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml @@ -235,6 +235,10 @@ module V1 = struct let old_levels_messages inbox = inbox.old_levels_messages + let current_witness inbox = + let {hash; _} = Skip_list.content inbox.old_levels_messages in + hash + let encoding = Data_encoding.( conv diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli index a6afe07c2fa0..3cadc89f3c5b 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli @@ -193,6 +193,11 @@ module V1 : sig (** [old_levels_messages inbox] returns the latest skip list cell of the inbox history that is not up to change (i.e. not the current level tree). *) val old_levels_messages : t -> history_proof + + (** [current_witness inbox] returns the current witness of the inbox, i.e. the + merkelized payload hash. *) + val current_witness : + t -> Sc_rollup_inbox_merkelized_payload_hashes_repr.Hash.t end (** Versioning, see {!Sc_rollup_data_version_sig.S} for more information. *) -- GitLab From 280b3a94e15c34b0c00dfc0cc2109f3734b912df Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Wed, 4 Jan 2023 14:28:17 +0100 Subject: [PATCH 4/4] Proto/Alpha: expose inbox internal structure with skip list --- .../lib_protocol/alpha_context.mli | 17 +++++-- .../lib_protocol/sc_rollup_inbox_repr.mli | 50 ++++++++++++------- 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index f092fb3d71b3..757c90ed3f70 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3370,7 +3370,18 @@ module Sc_rollup : sig val pp_input_request : Format.formatter -> input_request -> unit module Inbox : sig - type t + module Skip_list : Skip_list_repr.S + + module Hash : S.HASH + + type level_proof = { + hash : Inbox_merkelized_payload_hashes.Hash.t; + level : Raw_level.t; + } + + type history_proof = (level_proof, Hash.t) Skip_list.cell + + type t = {level : Raw_level.t; old_levels_messages : history_proof} val pp : Format.formatter -> t -> unit @@ -3380,16 +3391,12 @@ module Sc_rollup : sig val inbox_level : t -> Raw_level.t - type history_proof - val old_levels_messages : t -> history_proof val equal_history_proof : history_proof -> history_proof -> bool val pp_history_proof : Format.formatter -> history_proof -> unit - module Hash : S.HASH - val hash : t -> Hash.t val current_witness : t -> Inbox_merkelized_payload_hashes.Hash.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli index 3cadc89f3c5b..6c000d10d14d 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli @@ -123,23 +123,13 @@ type error += Inbox_level_reached_messages_limit module Hash : S.HASH -module V1 : sig - (** The type of the inbox for a smart-contract rollup as stored - by the protocol in the context. Values that inhabit this type - only act as fingerprint for inboxes. *) - type t - - val pp : Format.formatter -> t -> unit - - val equal : t -> t -> bool - - val hash : t -> Hash.t +module Skip_list : Skip_list_repr.S - val encoding : t Data_encoding.t - - (** [inbox_level inbox] returns the maximum level of message insertion in - [inbox] or its initial level. *) - val inbox_level : t -> Raw_level_repr.t +module V1 : sig + type level_proof = { + hash : Sc_rollup_inbox_merkelized_payload_hashes_repr.Hash.t; + level : Raw_level_repr.t; + } (** A [history_proof] is a [Skip_list.cell] that stores multiple hashes. [Skip_list.content history_proof] gives the hash of this cell, @@ -164,7 +154,27 @@ module V1 : sig number of non-empty levels between now and the origination level of the rollup. *) - type history_proof + type history_proof = (level_proof, Hash.t) Skip_list.cell + + (** The type of the inbox for a smart-contract rollup as stored + by the protocol in the context. Values that inhabit this type + only act as fingerprint for inboxes and contain: + - [level] : the inbox level ; + - [old_levels_messages] : a witness of the inbox history. + *) + type t = {level : Raw_level_repr.t; old_levels_messages : history_proof} + + val pp : Format.formatter -> t -> unit + + val equal : t -> t -> bool + + val hash : t -> Hash.t + + val encoding : t Data_encoding.t + + (** [inbox_level inbox] returns the maximum level of message insertion in + [inbox] or its initial level. *) + val inbox_level : t -> Raw_level_repr.t (** A [History.t] is basically a lookup table of {!history_proof}s. We need this if we want to produce inbox proofs because it allows us @@ -203,7 +213,11 @@ end (** Versioning, see {!Sc_rollup_data_version_sig.S} for more information. *) include Sc_rollup_data_version_sig.S with type t = V1.t -include module type of V1 with type t = V1.t +include + module type of V1 + with type level_proof = V1.level_proof + and type history_proof = V1.history_proof + and type t = V1.t type serialized_proof -- GitLab