package tezos-tx-rollup-015-PtLimaPt

  1. Overview
  2. Docs

Module Tezos_tx_rollup_015_PtLimaPt.StateSource

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.

Sourcemodule Tezos_blocks_cache : Aches_lwt.Lache.MAP_OPTION with type key = Tezos_base.TzPervasives.Block_hash.t
Sourcetype 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.

Sourcetype sync_levels = {
  1. processed_tezos_level : int32;
  2. known_tezos_level : int32;
}
Sourcetype 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;
}
Sourcetype t = private {
  1. stores : Stores.t;
  2. cctxt : Tezos_client_015_PtLimaPt.Protocol_client_context.full;
  3. context_index : Context.index;
  4. mutable head : L2block.t option;
  5. rollup_info : rollup_info;
  6. tezos_blocks_cache : Tezos_client_015_PtLimaPt.Protocol_client_context.Alpha_block_services.block_info Tezos_blocks_cache.t;
  7. constants : Tezos_protocol_015_PtLimaPt.Protocol.Alpha_context.Constants.t;
  8. signers : Node_config.signers;
  9. caps : Node_config.caps;
  10. sync : sync_info;
}

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

Sourceval 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.

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

Retrieve an L2 block by its hash

Sourceval 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.

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

Retrieve an inbox associated to an L2 block

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

Retrieve the header of an L2 block

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourceval get_included_commitment : t -> Tezos_protocol_015_PtLimaPt.Protocol.Alpha_context.Tx_rollup_commitment_hash.t -> L2block.commitment_included_info option Lwt.t

Returns the inclusion info for a commitment.

Sourceval get_finalized_level : t -> Tezos_protocol_015_PtLimaPt.Protocol.Alpha_context.Tx_rollup_level.t option Lwt.t

Returns the last finalized (on L1) rollup level.

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

Retrieve an L2 block metadata from its header

Sourceval 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.

Sourceval 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
Sourceval 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.

Sourceval 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.

Sourceval set_commitment_included : t -> Tezos_protocol_015_PtLimaPt.Protocol.Alpha_context.Tx_rollup_commitment_hash.t -> Tezos_base.TzPervasives.Block_hash.t -> Tezos_base.TzPervasives.Operation_hash.t -> unit Lwt.t

Register a commitment as included on L1.

Sourceval unset_commitment_included : t -> Tezos_protocol_015_PtLimaPt.Protocol.Alpha_context.Tx_rollup_commitment_hash.t -> unit Lwt.t

Register a commitment as not included on L1.

Sourceval set_finalized_level : t -> Tezos_protocol_015_PtLimaPt.Protocol.Alpha_context.Tx_rollup_level.t -> unit Tezos_base.TzPervasives.tzresult Lwt.t

Register the last finalized (on L1) rollup level.

Sourceval delete_finalized_level : t -> unit Lwt.t

Delete the last finalized (on L1) rollup level.

Sourceval set_rollup_info : t -> Tezos_protocol_015_PtLimaPt.Protocol.Alpha_context.Tx_rollup.t -> origination_level:int32 -> unit Tezos_base.TzPervasives.tzresult Lwt.t

Register the origination level of the rollup for this node.

Misc

Sourceval 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.

Sourceval rollup_reorg : t -> old_head:L2block.t -> new_head:L2block.t -> L2block.t Tezos_injector_015_PtLimaPt.Injector_common.reorg Lwt.t

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

Sourceval 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.

Sourceval notify_processed_tezos_level : t -> int32 -> unit

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

Sourceval set_known_tezos_level : t -> int32 -> unit

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