package tezos-protocol-014-PtKathma
The following operations are subject to cross-validation between rollup nodes and the layer 1.
type message = tree
A merkelized message.
type messages = tree
A merkelized sequence of messages.
The history is a merkelized sequence of messages
, one per level. The history is typically used by the rollup node to produce inclusion proofs. The protocol only manipulates an empty history as it does not remember previous messages and only keeps a witness of the latest state of the history.
val history_encoding :
history Tezos_protocol_environment_014_PtKathma.Data_encoding.t
val pp_history :
Tezos_protocol_environment_014_PtKathma.Format.formatter ->
history ->
unit
val history_at_genesis : bound:int64 -> history
The beginning of the history is an empty sequence of messages
. Fail with Invalid_bound_on_history
if bound
is not strictly positive.
val add_external_messages :
history ->
t ->
Raw_level_repr.t ->
string list ->
messages ->
(messages * history * t)
Tezos_protocol_environment_014_PtKathma.Error_monad.tzresult
Tezos_protocol_environment_014_PtKathma.Lwt.t
add_external_messages history inbox level payloads messages
inserts a list of payloads
as new messages in the messages
of the current level
of the inbox
. This function returns the new sequence of messages as well as updated inbox
and history
.
If the inbox
's level is older than level
, the inbox
is updated so that the messages of the levels older than level
are archived. To archive a sequence of messages
for a given level
, we push it at the end of the history
and update the witness of this history in the inbox
. The inbox
's messages for the current level are also emptied to insert the payloads
in a fresh sequence of messages
for level
.
This function fails if level
is older than inbox
's level
.
val add_messages_no_history :
t ->
Raw_level_repr.t ->
Sc_rollup_inbox_message_repr.serialized list ->
messages ->
(messages * t,
Tezos_protocol_environment_014_PtKathma.Error_monad.error
Tezos_protocol_environment_014_PtKathma.Error_monad.trace)
Tezos_protocol_environment_014_PtKathma.Pervasives.result
Tezos_protocol_environment_014_PtKathma.Lwt.t
add_messages_no_history inbox level payloads messages
behaves as add_external_messages
except that it does not remember the inbox history.
val get_message :
messages ->
Tezos_protocol_environment_014_PtKathma.Z.t ->
message option Tezos_protocol_environment_014_PtKathma.Lwt.t
get_message messages idx
returns Some message
if the sequence of messages
has a more than idx
messages and message
is at position idx
in this sequence. Returns None
otherwise.
val get_message_payload :
messages ->
Tezos_protocol_environment_014_PtKathma.Z.t ->
string option Tezos_protocol_environment_014_PtKathma.Lwt.t
get_message_payload messages idx
returns Some payload
if the sequence of messages
has a more than idx
messages, message
is at position idx
in this sequence, and is defined by payload
. Returns None
otherwise.
Given a inbox A
at some level L
and another inbox B
at some level L' >= L
, an inclusion_proof
guarantees that A
is an older version of B
.
To be more precise, an inclusion_proof
guarantees that the previous levels messages of A
are included in the previous levels messages of B
. The current messages of A
and B
are not considered.
The size of this proof is O(log_basis (L' - L)).
val inclusion_proof_encoding :
inclusion_proof Tezos_protocol_environment_014_PtKathma.Data_encoding.t
val pp_inclusion_proof :
Tezos_protocol_environment_014_PtKathma.Format.formatter ->
inclusion_proof ->
unit
val number_of_proof_steps : inclusion_proof -> int
number_of_proof_steps proof
returns the length of proof
.
val produce_inclusion_proof : history -> t -> t -> inclusion_proof option
produce_inclusion_proof history inboxA inboxB
exploits history
to produce a self-contained proof that inboxA
is an older version of inboxB
.
val verify_inclusion_proof : inclusion_proof -> t -> t -> bool
verify_inclusion_proof proof inboxA inboxA
returns true
iff proof
is a minimal and valid proof that inboxA
is included in inboxB
.