Mavryk_raw_protocol_alpha.Script_ir_translator
type ex_parameter_ty_and_entrypoints =
| Ex_parameter_ty_and_entrypoints : {
arg_type : ('a, _) Script_typed_ir.ty;
entrypoints : 'a Script_typed_ir.entrypoints;
} -> ex_parameter_ty_and_entrypoints
type toplevel = {
code_field : Alpha_context.Script.node;
arg_type : Alpha_context.Script.node;
storage_type : Alpha_context.Script.node;
views : Script_typed_ir.view_map;
}
type ('arg, 'storage) code =
| Code : {
code : (('arg, 'storage) Script_typed_ir.pair,
(Script_typed_ir.operation Script_list.t, 'storage)
Script_typed_ir.pair)
Script_typed_ir.lambda;
arg_type : ('arg, _) Script_typed_ir.ty;
storage_type : ('storage, _) Script_typed_ir.ty;
views : Script_typed_ir.view_map;
entrypoints : 'arg Script_typed_ir.entrypoints;
code_size : Cache_memory_helpers.sint;
This is an over-approximation of the value size in memory, in bytes, of the contract's static part, that is its code. This includes the code of the contract as well as the code of the views. The storage size is not taken into account by this field as it has a dynamic size.
*)} -> ('arg, 'storage) code
type 'storage typed_view =
| Typed_view : {
input_ty : ('input, _) Script_typed_ir.ty;
output_ty : ('output, _) Script_typed_ir.ty;
kinstr : ('input * 'storage,
Script_typed_ir.end_of_stack,
'output,
Script_typed_ir.end_of_stack)
Script_typed_ir.kinstr;
original_code_expr : Alpha_context.Script.node;
} -> 'storage typed_view
type 'storage typed_view_map =
(Script_string.t, 'storage typed_view) Script_typed_ir.map
type ('a, 's, 'b, 'u) cinstr = {
apply : 'r 'f. ('b, 'u, 'r, 'f) Script_typed_ir.kinstr ->
('a, 's, 'r, 'f) Script_typed_ir.kinstr;
}
type ('a, 's, 'b, 'u) descr = {
loc : Alpha_context.Script.location;
bef : ('a, 's) Script_typed_ir.stack_ty;
aft : ('b, 'u) Script_typed_ir.stack_ty;
instr : ('a, 's, 'b, 'u) cinstr;
}
type tc_context = Script_tc_context.t
type ('a, 's) judgement =
| Typed : ('a, 's, 'b, 'u) descr -> ('a, 's) judgement
| Failed : {
descr : 'b 'u. ('b, 'u) Script_typed_ir.stack_ty -> ('a, 's, 'b, 'u) descr;
} -> ('a, 's) judgement
val close_descr :
('a, 'b, 'c, 'd) descr ->
('a, 'b, 'c, 'd) Script_typed_ir.kdescr
val ty_eq :
error_details:
(Alpha_context.Script.location, 'error_trace)
Script_tc_errors.error_details ->
('a, 'ac) Script_typed_ir.ty ->
('b, 'bc) Script_typed_ir.ty ->
((('a, 'ac) Script_typed_ir.ty, ('b, 'bc) Script_typed_ir.ty) eq,
'error_trace)
Gas_monad.t
High-level Michelson Data Types
val parse_comparable_data :
?type_logger:Script_ir_translator_config.type_logger ->
Alpha_context.context ->
'a Script_typed_ir.comparable_ty ->
Alpha_context.Script.node ->
('a * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
Parsing and Typechecking Michelson
val parse_data :
elab_conf:Script_ir_translator_config.elab_config ->
Alpha_context.context ->
allow_forged_tickets:bool ->
allow_forged_lazy_storage_id:bool ->
('a, _) Script_typed_ir.ty ->
Alpha_context.Script.node ->
('a * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
module Internal_for_benchmarking : sig ... end
For benchmarking purpose, we also export versions of the unparsing functions which don't call location stripping. These functions are not carbonated and should not be called directly from the protocol.
val parse_instr :
elab_conf:Script_ir_translator_config.elab_config ->
tc_context ->
Alpha_context.context ->
Alpha_context.Script.node ->
('a, 's) Script_typed_ir.stack_ty ->
(('a, 's) judgement * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
val parse_big_map_value_ty :
Alpha_context.context ->
legacy:bool ->
Alpha_context.Script.node ->
(Script_typed_ir.ex_ty * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
parse_ty
specialized for the right-hand side part of a big map type, i.e. the `value` in `big_map key value`.
val parse_packable_ty :
Alpha_context.context ->
legacy:bool ->
Alpha_context.Script.node ->
(Script_typed_ir.ex_ty * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
val parse_passable_ty :
Alpha_context.context ->
legacy:bool ->
Alpha_context.Script.node ->
(Script_typed_ir.ex_ty * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
val parse_comparable_ty :
Alpha_context.context ->
Alpha_context.Script.node ->
(ex_comparable_ty * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
val parse_parameter_ty_and_entrypoints :
Alpha_context.context ->
legacy:bool ->
Alpha_context.Script.node ->
(ex_parameter_ty_and_entrypoints * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
val parse_view_input_ty :
Alpha_context.context ->
stack_depth:int ->
legacy:bool ->
Alpha_context.Script.node ->
(Script_typed_ir.ex_ty * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
val parse_view_output_ty :
Alpha_context.context ->
stack_depth:int ->
legacy:bool ->
Alpha_context.Script.node ->
(Script_typed_ir.ex_ty * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
val parse_view :
elab_conf:Script_ir_translator_config.elab_config ->
Alpha_context.context ->
('storage, _) Script_typed_ir.ty ->
Script_typed_ir.view ->
('storage typed_view * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
val parse_views :
elab_conf:Script_ir_translator_config.elab_config ->
Alpha_context.context ->
('storage, _) Script_typed_ir.ty ->
Script_typed_ir.view_map ->
('storage typed_view_map * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
val parse_any_ty :
Alpha_context.context ->
legacy:bool ->
Alpha_context.Script.node ->
(Script_typed_ir.ex_ty * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
parse_ty
allowing big_map values, operations, contract and tickets.
val parse_ty :
Alpha_context.context ->
legacy:bool ->
allow_lazy_storage:bool ->
allow_operation:bool ->
allow_contract:bool ->
allow_ticket:bool ->
Alpha_context.Script.node ->
(Script_typed_ir.ex_ty * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
We expose parse_ty
for convenience to external tools. Please use specialized versions such as parse_packable_ty
, parse_passable_ty
, parse_comparable_ty
, or parse_big_map_value_ty
if possible.
val typecheck_code :
legacy:bool ->
show_types:bool ->
Alpha_context.context ->
Alpha_context.Script.expr ->
(Script_tc_errors.type_map * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
High-level function to typecheck a Michelson script. This function is not used for validating operations but only for the typecheck_code
RPC.
If show_types
is set to true
, details of the typechecking are returned in the type_map
, otherwise the returned type_map
is empty.
val parse_storage :
elab_conf:Script_ir_translator_config.elab_config ->
Alpha_context.context ->
allow_forged_tickets:bool ->
allow_forged_lazy_storage_id:bool ->
('storage, _) Script_typed_ir.ty ->
storage:Alpha_context.Script.lazy_expr ->
('storage * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
val parse_script :
elab_conf:Script_ir_translator_config.elab_config ->
Alpha_context.context ->
allow_forged_tickets_in_storage:bool ->
allow_forged_lazy_storage_id_in_storage:bool ->
Alpha_context.Script.t ->
(ex_script * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
Combines parse_code
and parse_storage
val parse_and_unparse_script_unaccounted :
Alpha_context.context ->
legacy:bool ->
allow_forged_tickets_in_storage:bool ->
allow_forged_lazy_storage_id_in_storage:bool ->
Script_ir_unparser.unparsing_mode ->
normalize_types:bool ->
Alpha_context.Script.t ->
(Alpha_context.Script.t * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
val parse_contract_data :
Alpha_context.context ->
Alpha_context.Script.location ->
('a, _) Script_typed_ir.ty ->
Alpha_context.Destination.t ->
entrypoint:Alpha_context.Entrypoint.t ->
(Alpha_context.context * 'a Script_typed_ir.typed_contract)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
val parse_contract_for_script :
Alpha_context.context ->
Alpha_context.Script.location ->
('a, _) Script_typed_ir.ty ->
Alpha_context.Destination.t ->
entrypoint:Alpha_context.Entrypoint.t ->
(Alpha_context.context * 'a Script_typed_ir.typed_contract option)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
type 'a ex_ty_cstr =
| Ex_ty_cstr : {
ty : ('b, _) Script_typed_ir.ty;
construct : 'b -> 'a;
original_type_expr : Alpha_context.Script.node;
} -> 'a ex_ty_cstr
'a ex_ty_cstr
is like ex_ty
, but also adds to the existential a function used to reconstruct a value of type 'a
from the internal type of the existential. Typically, it will be used to go from the type of an entry-point to the full type of a contract.
val find_entrypoint :
error_details:(_, 'error_trace) Script_tc_errors.error_details ->
('t, _) Script_typed_ir.ty ->
't Script_typed_ir.entrypoints ->
Alpha_context.Entrypoint.t ->
('t ex_ty_cstr, 'error_trace) Gas_monad.t
val list_entrypoints_uncarbonated :
('t, _) Script_typed_ir.ty ->
't Script_typed_ir.entrypoints ->
Michelson_v1_primitives.prim list list
* (Script_typed_ir.ex_ty * Alpha_context.Script.node)
Alpha_context.Entrypoint.Map.t
val pack_data :
Alpha_context.context ->
('a, _) Script_typed_ir.ty ->
'a ->
(bytes * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
val hash_comparable_data :
Alpha_context.context ->
'a Script_typed_ir.comparable_ty ->
'a ->
(Script_expr_hash.t * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
val hash_data :
Alpha_context.context ->
('a, _) Script_typed_ir.ty ->
'a ->
(Script_expr_hash.t * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
val no_lazy_storage_id : lazy_storage_ids
val collect_lazy_storage :
Alpha_context.context ->
('a, _) Script_typed_ir.ty ->
'a ->
(lazy_storage_ids * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Traverse the given type, producing a lazy_storage_ids
for use with extract_lazy_storage_diff
.
val list_of_big_map_ids : lazy_storage_ids -> Alpha_context.Big_map.Id.t list
val extract_lazy_storage_diff :
Alpha_context.context ->
Script_ir_unparser.unparsing_mode ->
temporary:bool ->
to_duplicate:lazy_storage_ids ->
to_update:lazy_storage_ids ->
('a, _) Script_typed_ir.ty ->
'a ->
('a * Alpha_context.Lazy_storage.diffs option * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
Mavryk_protocol_environment_alpha.Lwt.t
Produce a lazy storage diff, containing in-memory writes to lazy data structures such as big_maps yet to be committed.
The resulting diff can be committed to the underlying storage (context) using Lazy_storage_diff.apply
.
val get_single_sapling_state :
Alpha_context.context ->
('a, _) Script_typed_ir.ty ->
'a ->
(Alpha_context.Sapling.Id.t option * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
val code_size :
Alpha_context.context ->
('a, 'b) Script_typed_ir.lambda ->
Script_typed_ir.view_map ->
(Cache_memory_helpers.sint * Alpha_context.context)
Mavryk_protocol_environment_alpha.Error_monad.tzresult
code_size ctxt code views
returns an overapproximation of the size of the in-memory representation of code
and views
in bytes in the context ctxt
.
val script_size : ex_script -> int * Gas_limit_repr.cost
script_size script
returns an overapproximation of the size of the in-memory representation of script
in bytes as well as the cost associated to computing that overapproximation.