package tezos-protocol-012-Psithaca

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

This module represents access to a global table of constant Micheline values. Users may register a Micheline value in the table, paying the cost of storage. Once stored, contracts source code may reference this value by its hash.

Note: the table does not typecheck the values stored in it. Instead, any place that uses constants must first call expand before typechecking the code. This decision was made to make it as easy as possible for users to register values to the table, and also to allow maximum flexibility in the use of constants for different parts of a Michelson script (code, types, data, etc.).

type Tezos_protocol_environment_012_Psithaca.Error_monad.error +=
  1. | Expression_already_registered
type Tezos_protocol_environment_012_Psithaca.Error_monad.error +=
  1. | Badly_formed_constant_expression

A constant is the prim of the literal characters "constant". A constant must have a single argument, being a string with a well formed hash of a Micheline expression (i.e generated by Script_expr_hash.to_b58check).

get context hash retrieves the Micheline value with the given hash.

Fails with Nonexistent_global if no value is found at the given hash.

Fails with Storage_error Corrupted_data if the deserialisation fails.

Consumes Gas_repr.read_bytes_cost <size of the value>.

register context value registers a constant in the global table of constants, returning the hash and storage bytes consumed.

Does not type-check the Micheline code being registered, allow potentially ill-typed Michelson values to be stored in the table (see note at top of module).

The constant is stored unexpanded, but it is temporarily expanded at registration time only to check the expanded version respects the following limits. This also ensures there are no cyclic dependencies between constants.

Fails with Expression_too_deep if, after fully expanding all constants, the expression would have a depth greater than Constant_repr.max_allowed_global_constant_depth.

Fails with Badly_formed_constant_expression if constants are not well-formed (see declaration of Badly_formed_constant_expression) or with Nonexistent_global if a referenced constant does not exist in the table.

Consumes serialization cost. Consumes Gas_repr.write_bytes_cost <size> where size is the number of bytes in the binary serialization provided by Script_repr.expr_encoding.

expand context expr replaces every constant in the given Michelson expression with its value stored in the global table.

The expansion is applied recursively so that the returned expression contains no constant.

Fails with Badly_formed_constant_expression if constants are not well-formed (see declaration of Badly_formed_constant_expression) or with Nonexistent_global if a referenced constant does not exist in the table.

module Internal_for_tests : sig ... end
OCaml

Innovation. Community. Security.