package tezos-tx-rollup-015-PtLimaPt

  1. Overview
  2. Docs

The RPC server and the Daemon main loop are sharing a variable of the type stored in the Irmin store. The State module allows access to this stored data.

Similar to MAP but the promises resolve to meaningful option: When a promise resolve to None it is interpreted as a failure by the cache and the binding is removed. When a promise resolve to Some _ is interpreted as success and the binding is kept.

type rollup_info = Stores.rollup_info = {
  1. rollup_id : Tezos_protocol_015_PtLimaPt.Protocol.Alpha_context.Tx_rollup.t;
  2. origination_level : int32 option;
}

Information about the rollup that is kept in the state.

type sync_levels = {
  1. processed_tezos_level : int32;
  2. known_tezos_level : int32;
}
type sync_info = {
  1. mutable synchronized : bool;
  2. on_synchronized : unit Lwt_condition.t;
  3. mutable current_levels : sync_levels;
  4. sync_level_input : sync_levels Lwt_watcher.input;
}

init cctxt config creates a new state for the rollup node with a new store and context. If the rollup_genesis block hash is provided in config, checks that the rollup rollup_id is created inside the block identified by the hash. Otherwise, the genesis information is read from the disk. Note that if a rollup_genesis is provided, it must also match the one on disk. L2 block are cached (controlled by l2_blocks_cache_size) for performance improvements w.r.t. access to the store.

Reading the state from disk

val get_head : t -> L2block.t option

Retrieve the current head of the rollup. Note that the current head can go in the past or change in case of reorganisations at the L1 layer.

val get_block : t -> L2block.hash -> L2block.t option Lwt.t

Retrieve an L2 block by its hash

val get_level : t -> L2block.level -> L2block.hash option Lwt.t

Retrieve the block hash associated to a given level in the current chain. Note that levels can be reaffected in case of reorganisation at the L1 layer.

val get_inbox : t -> L2block.hash -> Inbox.t option Lwt.t

Retrieve an inbox associated to an L2 block

val get_header : t -> L2block.hash -> L2block.header option Lwt.t

Retrieve the header of an L2 block

val get_tezos_l2_block_hash : t -> Tezos_base.TzPervasives.Block_hash.t -> L2block.hash option Lwt.t

Retrieve the L2 block hash corresponding to the given Tezos block. When there is no inbox for an L1 block, we associate to it the L2 block of its predecessor. So get_tezos_l2_block_hash state h returns L2 block hash at which the rollup was when the Tezos node was at block h.

val get_tezos_l2_block : t -> Tezos_base.TzPervasives.Block_hash.t -> L2block.t option Lwt.t

Same as get_tezos_block but retrieves the associated L2 block at the same time.

val get_level_l2_block_header : t -> L2block.level -> L2block.header option Lwt.t

Same as get_level but retrieves the associated header at the same time.

val get_level_l2_block : t -> L2block.level -> L2block.t option Lwt.t

Same as get_level but retrieves the associated L2 block at the same time.

val tezos_block_already_processed : t -> Tezos_base.TzPervasives.Block_hash.t -> [> `Known of L2block.t option | `Unknown ] Lwt.t

Returns `Known block if the Tezos block was already processed by the rollup node where block is either Some l2_block, when there is an L2 block for the Tezos block, or None otherwise. It returns `Unknown when the Tezos block has never been processed.

Returns the inclusion info for a commitment.

Returns the last finalized (on L1) rollup level.

val get_block_metadata : t -> L2block.header -> L2block.metadata Lwt.t

Retrieve an L2 block metadata from its header

val get_block_and_metadata : t -> L2block.hash -> (L2block.t * L2block.metadata) option Lwt.t

Retrieve an L2 block and associated metadata by its hash

Saving the state to disk

Set the current head of the rollup and return the blocks (hashes) that were reorganized.

val save_block : t -> L2block.t -> unit Lwt.t

Save an L2 block to disk:

  • Save both the header and the inbox
  • Make the level point to this block
val save_level : t -> L2block.level -> L2block.hash -> unit Lwt.t

Make a level point to a given L2 block. If the level already points to a block, it is changed.

val save_tezos_block_info : t -> Tezos_base.TzPervasives.Block_hash.t -> L2block.hash option -> level:int32 -> predecessor:Tezos_base.TzPervasives.Block_hash.t -> unit Lwt.t

Associate an L2 block to a Tezos block, and register its level and predecessor as well.

Register a commitment as not included on L1.

Register the last finalized (on L1) rollup level.

val delete_finalized_level : t -> unit Lwt.t

Delete the last finalized (on L1) rollup level.

Register the origination level of the rollup for this node.

Misc

val rollup_operation_index : int

rollup_operation_index returns the index in which the rollup operation are stored into a Block_info.t. Currently, the manager operation validation pass is used.

Compute the reorganization of L2 blocks from the chain whose head is old_head_hash and the chain whose head new_head_hash.

val synchronized : t -> unit Lwt.t

synchronized state is a promise that resolves when the rollup node whose state is state is synchronized with L1. If the node is already synchronized, it resolves immediately.

val notify_processed_tezos_level : t -> int32 -> unit

Notify the processed Tezos level to watchers on the sync_levels input.

val set_known_tezos_level : t -> int32 -> unit

Set the latest known Tezos level but do not notify sync levels input.

OCaml

Innovation. Community. Security.