diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index b5c611f4f3c528363604cf2d672c0a151628e7e2..757c90ed3f70f35c008c099082ae26ddab96d48e 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? *) @@ -3368,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 @@ -3378,15 +3391,15 @@ 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 module History : Bounded_history_repr.S diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.mli b/src/proto_alpha/lib_protocol/dal_slot_repr.mli index 443a14ae05a3f825c41c161653869098e7b8dab4..565135e86cd6bf599061c2e46f8fbb49aa13a807 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 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 d82114c7bd9530a7e947f94172297c971da64053..cb5b320707ff43e560d3fc3557378dc423574d0e 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml @@ -229,10 +229,16 @@ 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 + 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 7f6e8c174cd48372c209aa253945129311d5706a..6c000d10d14d208d10cfdfd47c6dd53f1e5cec84 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli @@ -123,21 +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 encoding : t Data_encoding.t +module Skip_list : Skip_list_repr.S - (** [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, @@ -162,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 @@ -191,12 +203,21 @@ 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. *) 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