package octez-l2-libs

  1. Overview
  2. Docs
type ('a, 'b) map_kont = {
  1. origin : 'a Tezos_webassembly_interpreter.Instance.Vector.t;
  2. destination : 'b Tezos_webassembly_interpreter.Instance.Vector.t;
  3. offset : int32;
}
exception Trap of Source.region * string
exception Crash of Source.region * string
exception Exhaustion of Source.region * string
type init_state =
  1. | Init_step
  2. | Map_step
  3. | Map_concat_step
  4. | Join_step
  5. | Section_step
  6. | Eval_const
  7. | Create_global_step
  8. | Run_data_step

Possible states of the small-step initializer, used for error reporting.

exception Init_step_error of init_state

Exception raised on irreducible states of the small step initialization.

type eval_state =
  1. | Invoke_step of string
  2. | Label_step
  3. | Frame_step
  4. | Eval_step

Possible erroneous states of the small-step evaluation, used for error reporting.

exception Evaluation_step_error of eval_state

Exception raised on irreducible states of the small step evaluation.

type admin_instr = admin_instr' Source.phrase
and admin_instr' =
  1. | From_block of Ast.block_label * int32
  2. | Plain of Ast.instr'
  3. | Refer of Values.ref_
  4. | Invoke of Instance.func_inst
  5. | Trapping of string
  6. | Returning of Values.value Tezos_webassembly_interpreter.Instance.Vector.t
  7. | Breaking of int32 * Values.value Tezos_webassembly_interpreter.Instance.Vector.t
  8. | Table_init_meta of int32 * Values.ref_ * int32 * int32 * int32 * Ast.var * Ast.var
  9. | Table_fill_meta of int32 * int32 * int32 * Values.ref_ * Ast.var
  10. | Table_copy_meta of int32 * int32 * int32 * int32 * Ast.var * Ast.var * bool
  11. | Memory_init_meta of int32 * int32 * int32 * int32 * int32 * Ast.var
  12. | Memory_fill_meta of int32 * int32 * Values.num * int32
  13. | Memory_copy_meta of int32 * int32 * int32 * int32 * bool
type label = {
  1. label_arity : int32 option;
  2. label_break : Ast.instr option;
  3. label_code : code;
}
type ongoing =
  1. | Ongoing_kind
type finished =
  1. | Finished_kind
type 'a frame_stack = {
  1. frame_arity : int32 option;
  2. frame_specs : frame;
  3. frame_label_kont : 'a label_kont;
}
type invoke_step_kont =
  1. | Inv_start of {
    1. func : Instance.func_inst;
    2. code : code;
    }
  2. | Inv_prepare_locals of {
    1. arity : int32;
    2. args : Values.value Tezos_webassembly_interpreter.Instance.Vector.t;
    3. vs : Values.value Tezos_webassembly_interpreter.Instance.Vector.t;
    4. instructions : admin_instr Tezos_webassembly_interpreter.Instance.Vector.t;
    5. inst : Instance.module_key;
    6. func : Ast.func;
    7. locals_kont : (Types.value_type, Values.value) map_kont;
    }
  3. | Inv_prepare_args of {
    1. arity : int32;
    2. vs : Values.value Tezos_webassembly_interpreter.Instance.Vector.t;
    3. instructions : admin_instr Tezos_webassembly_interpreter.Instance.Vector.t;
    4. inst : Instance.module_key;
    5. func : Ast.func;
    6. locals : Values.value Tezos_webassembly_interpreter.Instance.Vector.t;
    7. args_kont : (Values.value, Values.value) map_kont;
    }
  4. | Inv_concat of {
    1. arity : int32;
    2. vs : Values.value Tezos_webassembly_interpreter.Instance.Vector.t;
    3. instructions : admin_instr Tezos_webassembly_interpreter.Instance.Vector.t;
    4. inst : Instance.module_key;
    5. func : Ast.func;
    6. concat_kont : Values.value concat_kont;
    }
  5. | Inv_reveal_tick of {
    1. reveal : Host_funcs.reveal;
    2. base_destination : int32;
    3. max_bytes : int32;
    4. code : code;
    }
  6. | Inv_stop of {
    1. code : code;
    2. fresh_frame : ongoing frame_stack option;
    3. remaining_ticks : Z.t;
    }
type buffers = {
  1. input : Instance.input_inst;
  2. output : Instance.output_inst;
}
type config = {
  1. step_kont : step_kont;
  2. stack_size_limit : int;
}
type ('a, 'b, 'acc) fold_right2_kont = {
  1. acc : 'acc;
  2. lv : 'a Tezos_webassembly_interpreter.Instance.Vector.t;
  3. rv : 'b Tezos_webassembly_interpreter.Instance.Vector.t;
  4. offset : int32;
}
type ('a, 'b) fold_left_kont = {
  1. origin : 'a Tezos_webassembly_interpreter.Instance.Vector.t;
  2. acc : 'b;
  3. offset : int32;
}
type eval_const_kont =
  1. | EC_Next of config
  2. | EC_Stop of Values.value
type create_global_kont = Types.global_type * eval_const_kont
type ('a, 'b) map_concat_kont =
  1. | MC_Map of ('a, 'b Tezos_webassembly_interpreter.Instance.Vector.t) map_kont
  2. | MC_Join of 'b join_kont
type ('kont, 'a, 'b) tick_map_kont = {
  1. tick : 'kont option;
  2. map : ('a, 'b) map_kont;
}
type exports_acc = {
  1. exports : Instance.extern Instance.NameMap.t;
  2. exports_memory_0 : bool;
}
type init_kont =
  1. | IK_Start of Instance.extern Tezos_webassembly_interpreter.Instance.Vector.t
    (*

    Very first tick of the init function

    *)
  2. | IK_Add_import of (Instance.extern, Ast.import, Instance.module_inst) fold_right2_kont
  3. | IK_Type of Instance.module_inst * (Ast.type_, Types.func_type) map_kont
  4. | IK_Aggregate : Instance.module_inst * ('kont, 'a, 'b) init_section * ('kont, 'a, 'b) tick_map_kont -> init_kont
  5. | IK_Aggregate_concat : Instance.module_inst * ('kont, 'a, 'b) init_section * 'b concat_kont -> init_kont
  6. | IK_Exports of Instance.module_inst * (Ast.export, exports_acc) fold_left_kont
  7. | IK_Elems of Instance.module_inst * (create_elem_kont, Ast.elem_segment, Instance.elem_inst) tick_map_kont
  8. | IK_Datas of Instance.module_inst * (Ast.data_segment, Instance.data_inst) map_kont
  9. | IK_Es_elems of Instance.module_inst * (Ast.elem_segment, admin_instr) map_concat_kont
  10. | IK_Es_datas of Instance.module_inst * (Ast.data_segment, admin_instr) map_concat_kont * admin_instr Tezos_webassembly_interpreter.Instance.Vector.t
  11. | IK_Join_admin of Instance.module_inst * admin_instr join_kont
  12. | IK_Eval of config
  13. | IK_Stop
    (*

    Witness that there is no more tick to execute to complete the init process.

    *)
type memory_export_rules =
  1. | Exports_memory_0
  2. | No_memory_export_rules
exception Missing_memory_0_export

This is raised when an initialisation function detects that the module does not export its main memory.

val init_step : stack_size_limit:int -> filter_exports:bool -> ?check_module_exports:memory_export_rules -> module_reg:Instance.module_reg -> self:Instance.module_key -> buffers -> Host_funcs.registry -> Ast.module_ -> init_kont -> init_kont Lwt.t

Small-step execution of the init process. See init.

  • raises Invalid_argument

    if called with IK_Stop. There is no transition from the terminal state.

val init : ?stack_size_limit:int -> module_reg:Instance.module_reg -> self:Instance.module_key -> buffers -> Host_funcs.registry -> Ast.module_ -> Instance.extern list -> Instance.module_inst Lwt.t
val invoke : ?stack_size_limit:int -> module_reg:Instance.module_reg -> caller:Instance.module_key -> ?input:Input_buffer.t -> ?output:Output_buffer.t -> ?durable:Durable_storage.t -> ?init:bool -> Host_funcs.registry -> Instance.func_inst -> Values.value list -> (Durable_storage.t * Values.value list) Lwt.t
val step : ?init:bool -> ?durable:Durable_storage.t -> host_funcs:Host_funcs.registry -> Instance.module_reg -> config -> buffers -> (Durable_storage.t * config) Lwt.t
type reveal_error =
  1. | Reveal_step
  2. | Reveal_hash_decoding of string
  3. | Reveal_payload_decoding of string
exception Reveal_error of reveal_error
val is_reveal_tick : config -> Host_funcs.reveal option

is_reveal_tick config returns Some hash if the evalutation is in a state expecting the payload of a given hash, and returns None otherwise.

val reveal_step : (memory:Instance.memory_inst -> dst:int32 -> max_bytes:int32 -> payload:bytes -> int32 Lwt.t) -> Instance.module_reg -> bytes -> config -> config Lwt.t

reveal_step reveal module_reg payload config loads payload in the memory of the module whose function is being evaluated with config.

This function can only be used when is_reveal_tick returns something (i.e., not None).

val default_output_buffer : unit -> Instance.output_inst
val buffers : ?input:Instance.input_inst -> ?output:Instance.output_inst -> unit -> buffers
OCaml

Innovation. Community. Security.