package octez-l2-libs

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
module type S = sig ... end
include S with type memory = Tezos_webassembly_interpreter.Instance.memory_inst
val input_output_max_size : int

max size of intputs and outputs.

val load_bytes : memory:memory -> addr:int32 -> size:int32 -> (string, int32) Stdlib.result Lwt.t

load_bytes ~memory ~addr ~size extracts the bytes from the given adress.

val write_output : output_buffer:Tezos_webassembly_interpreter.Output_buffer.t -> memory:memory -> src:int32 -> num_bytes:int32 -> int32 Lwt.t

aux_write_output ~input_buffer ~output_buffer ~module_inst ~src ~num_bytes reads num_bytes from the memory of module_inst starting at src and writes this to the output_buffer. It also checks that the input payload is no larger than `max_output`. It returns 0 for Ok and 1 for `output too large`.

val read_input : input_buffer:Tezos_webassembly_interpreter.Input_buffer.t -> memory:memory -> info_addr:int32 -> dst:int32 -> max_bytes:int32 -> int32 Lwt.t

aux_write_memory ~input_buffer ~module_inst ~level_offset ~id_offset ~dst ~max_bytes reads `input_buffer` and writes its components to the memory of `module_inst` based on the memory addreses offsets described. It also checks that the input payload is no larger than `max_input` and crashes with `input too large` otherwise. It returns the size of the payload. Note also that, if the level increases this function also updates the level of the output buffer and resets its id to zero.

val store_exists : durable:Durable.t -> memory:memory -> key_offset:int32 -> key_length:int32 -> int32 Lwt.t
  • since 2.0.0~r2
val store_has : durable:Durable.t -> memory:memory -> key_offset:int32 -> key_length:int32 -> int32 Lwt.t
val generic_store_delete : kind:Durable.kind -> durable:Durable.t -> memory:memory -> key_offset:int32 -> key_length:int32 -> (Durable.t * int32) Lwt.t

generic_store_delete ~kind ~durable ~memory ~key_offset ~key_length either removes the value if kind = Value or the complete directory if kind = Directory at the given key.

store_delete from version 2.0.0 is actually generic_store_delete ~kind:Durable.Directory.

  • since 2.0.0~r1
val store_copy : durable:Durable.t -> memory:memory -> from_key_offset:int32 -> from_key_length:int32 -> to_key_offset:int32 -> to_key_length:int32 -> (Durable.t * int32) Lwt.t
val store_move : durable:Durable.t -> memory:memory -> from_key_offset:int32 -> from_key_length:int32 -> to_key_offset:int32 -> to_key_length:int32 -> (Durable.t * int32) Lwt.t
val store_create : durable:Durable.t -> memory:memory -> key_offset:int32 -> key_length:int32 -> size:int32 -> (Durable.t * int32) Lwt.t

store_create ~durable ~memory ~key_offset ~key_length ~size allocates a new value under the given key if it doesn't exist. Returns 0 if the new value has been allocated, and Error.code Store_value_already_exists (`-13`) if there was already a value. The function is tick safe: allocating won't write the data itself, hence the size is not limited by the maximum size of an IO. It is limited to the maximum size of values, which is 2GB (`Int32.max_int`).

  • since 2.0.0~r1
val store_value_size : durable:Durable.t -> memory:memory -> key_offset:int32 -> key_length:int32 -> int32 Lwt.t
val store_read : durable:Durable.t -> memory:memory -> key_offset:int32 -> key_length:int32 -> value_offset:int32 -> dest:int32 -> max_bytes:int32 -> int32 Lwt.t
val store_write : durable:Durable.t -> memory:memory -> key_offset:int32 -> key_length:int32 -> value_offset:int32 -> src:int32 -> num_bytes:int32 -> (Durable.t * int32) Lwt.t
val store_list_size : durable:Durable.t -> memory:memory -> key_offset:int32 -> key_length:int32 -> (Durable.t * int64) Lwt.t
val store_get_nth_key : durable:Durable.t -> memory:memory -> key_offset:int32 -> key_length:int32 -> index:int64 -> dst:int32 -> max_size:int32 -> int32 Lwt.t

The current implementation of store_get_nth_key is not deterministic, and should not be used in kernel development. It cannot be removed from the PVM for backward compatibility reason, but it should not be used in any new kernel development.

See issue https://gitlab.com/tezos/tezos/-/issues/5301

val store_get_hash : durable:Durable.t -> memory:memory -> key_offset:int32 -> key_length:int32 -> dst:int32 -> max_size:int32 -> int32 Lwt.t
val reveal : memory:memory -> dst:int32 -> max_bytes:int32 -> payload:bytes -> int32 Lwt.t

reveal mem base size payload is intended to be the function used by the PVM to load at most size bytes of the result payload of a reveal step in mem, at address base

val read_mem_for_debug : memory:memory -> src:int32 -> num_bytes:int32 -> string Lwt.t
val write_debug : implem:Builtins.write_debug -> memory:memory -> src:int32 -> num_bytes:int32 -> unit Lwt.t
OCaml

Innovation. Community. Security.