package tezos-protocol-013-PtJakart
Cache: This should always be the number of stakers that are directly or indirectly staked on this commitment.
Let StakersS
mean "looking up the key S in Stakers
".
A staker S
is directly staked on C
if Stakers[S] = C
. A staker S
is indirectly staked on C
if C
is an ancestor of Stakers[S]
.
This ensures we remove unreachable commitments at the end of a dispute in O(n) reads, where n is the length of the rejected branch.
We maintain the invariant that each branch has at least one staker. On rejection, we decrease stake count from the removed staker to the root, and reclaim commitments whose stake count (refcount) thus reaches zero.
In the worst case all commitments are dishonest and on the same branch. In practice we expect the honest branch, to be the longest, and dishonest branches to be of similar lengths, making removal require a small number of steps with respect to the total number of commitments.
type t = Raw_context.t * Sc_rollup_repr.t
type context = t
type key = Sc_rollup_repr.Commitment_hash.t
An abstract type for keys
val mem :
context ->
key ->
(Raw_context.t * bool)
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
Tezos_protocol_environment_013_PtJakart.Lwt.t
Tells if a given key is already bound to a storage bucket. Consumes Gas_repr.read_bytes_cost Z.zero
.
val get :
context ->
key ->
(Raw_context.t * value)
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
Tezos_protocol_environment_013_PtJakart.Lwt.t
Retrieve a value from the storage bucket at a given key ; returns Storage_errorMissing_key
if the key is not set ; returns Storage_errorCorrupted_data
if the deserialisation fails. Consumes Gas_repr.read_bytes_cost <size of the value>
.
val find :
context ->
key ->
(Raw_context.t * value option)
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
Tezos_protocol_environment_013_PtJakart.Lwt.t
Retrieve a value from the storage bucket at a given key ; returns None
if the value is not set ; returns Storage_error
Corrupted_data
if the deserialisation fails. Consumes Gas_repr.read_bytes_cost <size of the value>
if present or Gas_repr.read_bytes_cost Z.zero
.
val update :
context ->
key ->
value ->
(Raw_context.t * int)
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
Tezos_protocol_environment_013_PtJakart.Lwt.t
Updates the content of a bucket ; returns A Storage_Error
Missing_key
if the value does not exists. Consumes serialization cost. Consumes Gas_repr.write_bytes_cost <size of the new value>
. Returns the difference from the old to the new size.
val init :
context ->
key ->
value ->
(Raw_context.t * int)
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
Tezos_protocol_environment_013_PtJakart.Lwt.t
Allocates a storage bucket at the given key and initializes it ; returns a Storage_errorExisting_key
if the bucket exists. Consumes serialization cost. Consumes Gas_repr.write_bytes_cost <size of the value>
. Returns the size.
val add :
context ->
key ->
value ->
(Raw_context.t * int * bool)
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
Tezos_protocol_environment_013_PtJakart.Lwt.t
Allocates a storage bucket at the given key and initializes it with a value ; just updates it if the bucket exists. Consumes serialization cost. Consumes Gas_repr.write_bytes_cost <size of the new value>
. Returns the difference from the old (maybe 0) to the new size, and a boolean indicating if a value was already associated to this key.
val add_or_remove :
context ->
key ->
value option ->
(Raw_context.t * int * bool)
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
Tezos_protocol_environment_013_PtJakart.Lwt.t
When the value is Some v
, allocates the data and initializes it with v
; just updates it if the bucket exists. When the value is None
, delete the storage bucket when the value ; does nothing if the bucket does not exists. Consumes serialization cost. Consumes the same gas cost as either remove
or init_set
. Returns the difference from the old (maybe 0) to the new size, and a boolean indicating if a value was already associated to this key.
val remove_existing :
context ->
key ->
(Raw_context.t * int)
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
Tezos_protocol_environment_013_PtJakart.Lwt.t
Delete a storage bucket and its contents ; returns a Storage_errorMissing_key
if the bucket does not exists. Consumes Gas_repr.write_bytes_cost Z.zero
. Returns the freed size.
val remove :
context ->
key ->
(Raw_context.t * int * bool)
Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult
Tezos_protocol_environment_013_PtJakart.Lwt.t
Removes a storage bucket and its contents ; does nothing if the bucket does not exists. Consumes Gas_repr.write_bytes_cost Z.zero
. Returns the freed size, and a boolean indicating if a value was already associated to this key.