package tezos-protocol-alpha

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type type_logger = Alpha_context.Script.location -> stack_ty_before:Alpha_context.Script.expr list -> stack_ty_after:Alpha_context.Script.expr list -> unit

type_logger is a function, whose task is to log how a stack's type is altered by some operation being logged.

LEGACY MODE is the feature of the Translator and Interpreter which allows us to distinguish between scripts already originated on chain and new ones.

The reason to treat those types of scripts differently is the evolving nature of Michelson, which sometimes requires disabling features available in previous versions. These features must be supported at all times for already originated contracts, but we still want to disable them at least for new contracts.

This distinction gives us a handy deprecation mechanism, which allows us to make sure that from a certain point on no more contract will be originated using these deprecated features. When that point time is reached, it becomes possible to patch existing contracts so that they no longer use the feature and remove it entirely.

As a side effect, legacy mode can also be used to skip checks that have already been performed and hence are guaranteed to pass.

type elab_config = {
  1. type_logger : type_logger option;
    (*

    A function responsible for logging stack types during typechecking. Used especially in plugins for editors and IDEs.

    *)
  2. keep_extra_types_for_interpreter_logging : bool;
    (*

    If set to true, it instructs the elaborator to retain some additional type information necessary for logging. This should never be enabled during validation to save memory occupied by cached contracts.

    NOTE: if this option wasn't passed to the elaborator and the interpreter was still called with logging enabled, it might result in a crash. This cannot be helped at the moment, but since logging is never enabled during validation, we should be safe.

    *)
  3. legacy : bool;
    (*

    If set to true, it enables the legacy mode (see above).

    *)
}

elab_config is a record grouping together some flags and options shared by many of the functions in Script_ir_translator. It's convenient to group them together, because they're of similar types (bool or 'a option), so they're easier not to mix together. It also makes for shorter and more readable function calls.

val make : ?type_logger:type_logger -> ?keep_extra_types_for_interpreter_logging:bool -> legacy:bool -> unit -> elab_config

make ?type_logger ?logging_enabled ~legacy () creates an elab_config record to be passed to parsing functions in Script_ir_translator.

Note: ?logging_enabled defaults to false, because it only ever should be set to true if the Translator is called from outside the protocol (i.e. from the Plugin).

OCaml

Innovation. Community. Security.