Library
Module
Module type
Parameter
Class
Class type
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.
module Tezos_blocks_cache :
Ringo_lwt.Sigs.CACHE_MAP_OPT with type key = Tezos_crypto.Block_hash.t
This is similar to CACHE_MAP
except that it handles option
. Specifically, you can insert 'a option Lwt.t
and promises that are fulfilled with None
are treated like promises that are rejected:
type rollup_info = Stores.rollup_info = {
rollup_id : Tezos_protocol_013_PtJakart.Protocol.Alpha_context.Tx_rollup.t;
origination_level : int32 option;
}
Information about the rollup that is kept in the state.
type sync_info = {
mutable synchronized : bool;
on_synchronized : unit Lwt_condition.t;
mutable current_levels : sync_levels;
sync_level_input : sync_levels Lwt_watcher.input;
}
type t = private {
stores : Stores.t;
cctxt : Tezos_client_013_PtJakart.Protocol_client_context.full;
context_index : Context.index;
mutable head : L2block.t option;
rollup_info : rollup_info;
tezos_blocks_cache : Tezos_client_013_PtJakart.Protocol_client_context.Alpha_block_services.block_info Tezos_blocks_cache.t;
constants : Tezos_protocol_013_PtJakart.Protocol.Alpha_context.Constants.t;
signers : Node_config.signers;
caps : Node_config.caps;
sync : sync_info;
}
val init :
Tezos_client_013_PtJakart.Protocol_client_context.full ->
?readonly:bool ->
Node_config.t ->
t Tezos_base.TzPervasives.tzresult Lwt.t
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
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_crypto.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_crypto.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_crypto.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.
val get_included_commitment :
t ->
Tezos_protocol_013_PtJakart.Protocol.Alpha_context.Tx_rollup_commitment_hash.t ->
L2block.commitment_included_info option Lwt.t
Returns the inclusion info for a commitment.
val get_finalized_level :
t ->
Tezos_protocol_013_PtJakart.Protocol.Alpha_context.Tx_rollup_level.t option
Lwt.t
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
val set_head :
t ->
L2block.t ->
L2block.t Tezos_injector_013_PtJakart.Common.reorg
Tezos_base.TzPervasives.tzresult
Lwt.t
Set the current head of the rollup and return the blocks (hashes) that were reorganized.
val set_tezos_head :
t ->
Tezos_crypto.Block_hash.t ->
Tezos_client_013_PtJakart.Protocol_client_context.Alpha_block_services.block_info
Tezos_injector_013_PtJakart.Common.reorg
Tezos_base.TzPervasives.tzresult
Lwt.t
Set the Tezos head and returns the reorganization of L1 blocks.
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_crypto.Block_hash.t ->
L2block.hash option ->
level:int32 ->
predecessor:Tezos_crypto.Block_hash.t ->
unit Lwt.t
Associate an L2 block to a Tezos block, and register its level and predecessor as well.
val set_commitment_included :
t ->
Tezos_protocol_013_PtJakart.Protocol.Alpha_context.Tx_rollup_commitment_hash.t ->
Tezos_crypto.Block_hash.t ->
Tezos_crypto.Operation_hash.t ->
unit Lwt.t
Register a commitment as included on L1.
val unset_commitment_included :
t ->
Tezos_protocol_013_PtJakart.Protocol.Alpha_context.Tx_rollup_commitment_hash.t ->
unit Lwt.t
Register a commitment as not included on L1.
val set_finalized_level :
t ->
Tezos_protocol_013_PtJakart.Protocol.Alpha_context.Tx_rollup_level.t ->
unit Tezos_base.TzPervasives.tzresult Lwt.t
Register the last finalized (on L1) rollup level.
val set_rollup_info :
t ->
Tezos_protocol_013_PtJakart.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
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.
val fetch_tezos_block :
t ->
Tezos_crypto.Block_hash.t ->
Tezos_client_013_PtJakart.Protocol_client_context.Alpha_block_services.block_info
Tezos_base.TzPervasives.tzresult
Lwt.t
Fetch a Tezos block from the cache or the node
val rollup_reorg :
t ->
old_head:L2block.t ->
new_head:L2block.t ->
L2block.t Tezos_injector_013_PtJakart.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
.
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.