package tezos-protocol-013-PtJakart

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

The following module acts on the whole cache, not on a specific sub-cache, unlike Interface. It is used to administrate the protocol cache, e.g., to maintain the cache in a consistent state with respect to the chain. This module is typically used by low-level layers of the protocol and by the shell.

type key

A key uniquely identifies a cached value in some subcache.

type value

Cached values.

pp fmt ctxt is a pretty printter for the cache of ctxt.

sync ctxt ~cache_nonce updates the context with the domain of the cache computed so far. Such function is expected to be called at the end of the validation of a block, when there is no more accesses to the cache.

cache_nonce identifies the block that introduced new cache entries. The nonce should identify uniquely the block which modifies this value. It cannot be the block hash for circularity reasons: The value of the nonce is stored onto the context and consequently influences the context hash of the very same block. Such nonce cannot be determined by the shell and its computation is delegated to the economic protocol.

Cache helpers for RPCs

val future_cache_expectation : ?blocks_before_activation:int32 -> Raw_context.t -> time_in_blocks:int -> Raw_context.t Tezos_protocol_environment_013_PtJakart.Error_monad.tzresult Tezos_protocol_environment_013_PtJakart.Lwt.t

future_cache_expectation ?blocks_before_activation ctxt ~time_in_blocks returns ctxt except that the entries of the caches that are presumably too old to still be in the caches in n_blocks are removed.

This function is based on a heuristic. The context maintains the median of the number of removed entries: this number is multipled by `n_blocks` to determine the entries that are likely to be removed in `n_blocks`.

If blocks_before_activation is set to Some n, then the cache is considered empty if 0 <= n <= time_in_blocks. Otherwise, if blocks_before_activation is set to None and if the voting period is the adoption, the cache is considered empty if blocks <= time_in_blocks remaining for adoption phase.

val cache_size : Raw_context.t -> cache_index:int -> size option

cache_size ctxt ~cache_index returns an overapproximation of the size of the cache. Returns None if cache_index is greater than the number of subcaches declared by the cache layout.

val cache_size_limit : Raw_context.t -> cache_index:int -> size option

cache_size_limit ctxt ~cache_index returns the maximal size of the cache indexed by cache_index. Returns None if cache_index is greater than the number of subcaches declared by the cache layout.

value_of_key ctxt k interprets the functions introduced by register to construct a cacheable value for a key k.

value_of_key is a maintenance operation: it is typically run when a node reboots. For this reason, this operation is not carbonated.

OCaml

Innovation. Community. Security.