package tezos-protocol-016-PtMumbai

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type unparsing_mode =
  1. | Optimized
  2. | Readable
  3. | Optimized_legacy

Flag that drives unparsing of typed values to nodes.

  • Optimized_legacy must be kept backward-compatible in order to compute valid hashes (of big map keys).
  • Optimized may be used as long as the result can be read by Script_translator.parse_data.
  • Readable produces with string values instead of bytes when feasible.
type ('ty, 'depth) comb_witness =
  1. | Comb_Pair : ('t, 'd) comb_witness -> (_ * 't, unit -> 'd) comb_witness
  2. | Comb_Any : (_, _) comb_witness

('t, 'd) comb_witness describes types of values belonging to a comb of type 't and size 'd.

val serialize_ty_for_error : ('a, 'b) Script_typed_ir.ty -> Alpha_context.Script.expr

serialize_ty_for_error ty returns the Micheline representation of ty suitable for rendering in an error message. Does not consume gas, since when this function is called, the operation must have already failed.

val serialize_stack_for_error : Alpha_context.context -> ('a, 'b) Script_typed_ir.stack_ty -> Alpha_context.Script.expr list

serialize_stack_for_error ctxt stack_ty returns a Micheline representation of stack_ty as a list of Micheline expressions ONLY IF gas is unlimited in ctxt. Otherwise returns an empty list.

unparse_ty ~loc ctxt ty returns the Micheline representation of a given type and an update context, where gas has been properly consumed.

val unparse_comparable_ty_uncarbonated : loc:'loc -> 'a Script_typed_ir.comparable_ty -> 'loc Alpha_context.Script.michelson_node

unparse_comparable_ty_uncarbonated ~loc ty returns the Michelson representation of comparable type ty without consuming gas.

val unparse_stack_uncarbonated : ('a, 's) Script_typed_ir.stack_ty -> Alpha_context.Script.expr list

unparse_stack_uncarbonated stack_ty returns the Micheline representation of stack_ty. Does not consume gas.

unparse_parameter_ty ~loc ctxt ty ~entrypoints is a specialised version of unparse_ty, which also analyses entrypoints in order to annotate the returned type with adequate annotations.

unparse_operation ~loc ctxt op returns the Micheline representation of op and consumes gas from ctxt. Useful only for producing execution traces in the interpreter.

unparse_comparable_data ctxt unparsing_mode ty v returns the Micheline representation of v of type ty, consuming gas from ctxt.

unparse_contract ~loc ctxt unparsin_mode contract returns a Micheline representation of a given contract in a given unparsing_mode. Consumes gas ctxt.

Lambdas are normalized at parsing and also at unparsing. These normalizations require to parse and unparse data appearing inside PUSH and introduces a mutual dependency between this module and Script_ir_translator which is resolved as follows:

  • Script_ir_translator.parse_data takes the normalization function unparse_code_rec as argument,
  • the unparsing function unparse_data_rec and the normalization function unparse_code_rec are mutually defined in a functor parameterized by the missing bits from Script_ir_translator; see the module signature MICHELSON_PARSER below.

The unparse_code_rec function is not exported (except through the Internal_for_benchmarking module), but needs to be called by parse_data to normalize lambdas so it is passed as argument to the parse_data of the MICHELSON_PARSER signature below and to several functions of Script_ir_translator. To avoid repeating the signature of this function we define a type alias for it.

MICHELSON_PARSER signature describes a set of dependencies required to unparse arbitrary values in the IR. Because some of those values contain just a Michelson code that does not need to be parsed immediately, unparsing them requires extracting information from that code – that's why we depend on the parser here.

module type MICHELSON_PARSER = sig ... end
module Data_unparser (P : MICHELSON_PARSER) : sig ... end
OCaml

Innovation. Community. Security.