From 6ee4a4822683503864ab091f46a1cff7ac679e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Sat, 19 Feb 2022 07:51:17 +0100 Subject: [PATCH 1/3] RPC Plugin/Michelson: add normalize_stack --- src/proto_alpha/lib_plugin/RPC.ml | 99 +++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index cd6422db6074..ac07a4f1a423 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -227,6 +227,12 @@ module Scripts = struct (req "trace" trace_encoding) (opt "lazy_storage_diff" Lazy_storage.encoding)) + let stack_encoding = + list + (obj2 + (req "type" Script.expr_encoding) + (req "val" Script.expr_encoding)) + let run_tzip4_view_encoding = let open Data_encoding in obj10 @@ -257,6 +263,14 @@ module Scripts = struct (opt "now" Script_timestamp.encoding)) (obj1 (opt "level" Script_int.n_encoding)) + let normalize_stack_input_encoding = + obj3 + (req "input" stack_encoding) + (req "unparsing_mode" unparsing_mode_encoding) + (opt "legacy" bool) + + let normalize_stack_output_encoding = obj1 (req "output" stack_encoding) + let run_code = RPC_service.post_service ~description:"Run a piece of code in the current context" @@ -365,6 +379,15 @@ module Scripts = struct ~query:RPC_query.empty RPC_path.(path / "normalize_data") + let normalize_stack = + RPC_service.post_service + ~description: + "Normalize a Michelson stack using the requested unparsing mode" + ~query:RPC_query.empty + ~input:normalize_stack_input_encoding + ~output:normalize_stack_output_encoding + RPC_path.(path / "normalize_stack") + let normalize_script = RPC_service.post_service ~description: @@ -675,6 +698,61 @@ module Scripts = struct | Chest_key_t -> return (T_chest_key, [], []) end + module Normalize_stack = struct + type ex_stack = + | Ex_stack : ('a, 's) Script_typed_ir.stack_ty * 'a * 's -> ex_stack + + let rec parse_stack : + context -> + legacy:bool -> + (Script.node * Script.node) list -> + (ex_stack * context) tzresult Lwt.t = + fun ctxt ~legacy l -> + match l with + | [] -> return (Ex_stack (Bot_t, EmptyCell, EmptyCell), ctxt) + | (ty_node, data_node) :: l -> + Lwt.return + @@ Script_ir_translator.parse_ty + ctxt + ~legacy + ~allow_lazy_storage:true + ~allow_operation:true + ~allow_contract:true + ~allow_ticket:true + ty_node + >>=? fun (Ex_ty ty, ctxt) -> + let elab_conf = elab_conf ~legacy () in + Script_ir_translator.parse_data + ctxt + ~elab_conf + ~allow_forged:true + ty + data_node + >>=? fun (x, ctxt) -> + parse_stack ctxt ~legacy l >>=? fun (Ex_stack (sty, y, st), ctxt) -> + return (Ex_stack (Item_t (ty, sty), x, (y, st)), ctxt) + + let rec unparse_stack : + type a s. + context -> + Script_ir_unparser.unparsing_mode -> + (a, s) Script_typed_ir.stack_ty -> + a -> + s -> + ((Script.expr * Script.expr) list * context) tzresult Lwt.t = + let loc = Micheline.dummy_location in + fun ctxt unparsing_mode sty x st -> + match (sty, x, st) with + | Bot_t, EmptyCell, EmptyCell -> return ([], ctxt) + | Item_t (ty, sty), x, (y, st) -> + Script_ir_unparser.unparse_ty ~loc ctxt ty + >>?= fun (ty_node, ctxt) -> + Script_ir_translator.unparse_data ctxt unparsing_mode ty x + >>=? fun (data_node, ctxt) -> + unparse_stack ctxt unparsing_mode sty y st >>=? fun (l, ctxt) -> + return ((Micheline.strip_locations ty_node, data_node) :: l, ctxt) + end + let rec pp_instr_name : type a b c d. Format.formatter -> (a, b, c, d) Script_typed_ir.kinstr -> unit = @@ -1479,6 +1557,19 @@ module Scripts = struct >>=? fun (data, ctxt) -> Script_ir_translator.unparse_data ctxt unparsing_mode typ data >|=? fun (normalized, _ctxt) -> normalized) ; + Registration.register0 + ~chunked:true + S.normalize_stack + (fun ctxt () (stack, unparsing_mode, legacy) -> + let legacy = Option.value ~default:false legacy in + let ctxt = Gas.set_unlimited ctxt in + let nodes = + List.map (fun (a, b) -> (Micheline.root a, Micheline.root b)) stack + in + Normalize_stack.parse_stack ctxt ~legacy nodes + >>=? fun (Normalize_stack.Ex_stack (st_ty, x, st), ctxt) -> + Normalize_stack.unparse_stack ctxt unparsing_mode st_ty x st + >|=? fun (normalized, _ctxt) -> normalized) ; Registration.register0 ~chunked:true S.normalize_script @@ -1652,6 +1743,14 @@ module Scripts = struct () (data, ty, unparsing_mode, legacy) + let normalize_stack ?legacy ~stack ~unparsing_mode ctxt block = + RPC_context.make_call0 + S.normalize_stack + ctxt + block + () + (stack, unparsing_mode, legacy) + let normalize_script ~script ~unparsing_mode ctxt block = RPC_context.make_call0 S.normalize_script -- GitLab From 06cea36c5f793031c14f0ad9adf9609c26241e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Sat, 18 Feb 2023 00:10:10 +0100 Subject: [PATCH 2/3] Client/Michelson: command for stack normalization --- .../lib_client/client_proto_args.ml | 12 ++ .../lib_client/client_proto_args.mli | 3 + .../lib_client/michelson_v1_error_reporter.ml | 22 ++++ .../lib_client/michelson_v1_printer.ml | 12 ++ .../lib_client/michelson_v1_printer.mli | 3 + .../lib_client/michelson_v1_stack.ml | 109 ++++++++++++++++++ .../client_proto_programs_commands.ml | 42 +++++++ 7 files changed, 203 insertions(+) create mode 100644 src/proto_alpha/lib_client/michelson_v1_stack.ml diff --git a/src/proto_alpha/lib_client/client_proto_args.ml b/src/proto_alpha/lib_client/client_proto_args.ml index ffbecef28e71..e9e97abf5358 100644 --- a/src/proto_alpha/lib_client/client_proto_args.ml +++ b/src/proto_alpha/lib_client/client_proto_args.ml @@ -256,6 +256,18 @@ let binary_encoded_parameter ~name encoding = in file_or_text_parameter ~from_text () +let micheline_parameter = + Tezos_clic.parameter (fun _ source -> + Lwt.return @@ Tezos_micheline.Micheline_parser.no_parsing_error + @@ + let tokens, lexing_errors = + Tezos_micheline.Micheline_parser.tokenize source + in + let ast, parsing_errors = + Tezos_micheline.Micheline_parser.parse_expression tokens + in + ((ast, source), lexing_errors @ parsing_errors)) + let entrypoint_parameter = Tezos_clic.parameter (fun _ str -> Lwt.return @@ Environment.wrap_tzresult @@ Entrypoint.of_string_lax str) diff --git a/src/proto_alpha/lib_client/client_proto_args.mli b/src/proto_alpha/lib_client/client_proto_args.mli index 065a52870b35..c06cac6974e3 100644 --- a/src/proto_alpha/lib_client/client_proto_args.mli +++ b/src/proto_alpha/lib_client/client_proto_args.mli @@ -194,6 +194,9 @@ val data_parameter : (Michelson_v1_parser.parsed, full) Tezos_clic.parameter val raw_level_parameter : (Raw_level.t, full) Tezos_clic.parameter +val micheline_parameter : + (Tezos_micheline.Micheline_parser.node * string, full) Tezos_clic.parameter + val unparsing_mode_arg : default:string -> (Script_ir_unparser.unparsing_mode, full) Tezos_clic.arg diff --git a/src/proto_alpha/lib_client/michelson_v1_error_reporter.ml b/src/proto_alpha/lib_client/michelson_v1_error_reporter.ml index b842cd9e82a7..8115358e6776 100644 --- a/src/proto_alpha/lib_client/michelson_v1_error_reporter.ml +++ b/src/proto_alpha/lib_client/michelson_v1_error_reporter.ml @@ -187,6 +187,28 @@ let report_errors ~details ~show_source ?parsed ppf errs = in match errs with | [] -> () + | Michelson_v1_stack.Wrong_stack_item (loc, expr) :: rest -> + Format.fprintf + ppf + "@[%s,@ wrong syntax for a stack element, expecting something \ + of the following shape: Stack_elt ; got %a.@]" + (String.capitalize_ascii + (Format.asprintf "%a" Micheline_parser.print_location loc)) + Micheline_printer.print_expr_unwrapped + expr ; + if rest <> [] then Format.fprintf ppf "@," ; + print_trace locations rest + | Michelson_v1_stack.Wrong_stack (loc, expr) :: rest -> + Format.fprintf + ppf + "@[%s,@ wrong syntax for stack, expecting a sequence of \ + elements of the following shape: Stack_elt ; got %a.@]" + (String.capitalize_ascii + (Format.asprintf "%a" Micheline_parser.print_location loc)) + Micheline_printer.print_expr_unwrapped + expr ; + if rest <> [] then Format.fprintf ppf "@," ; + print_trace locations rest | Environment.Ecoproto_error (Michelson_v1_primitives.Invalid_primitive_name (expr, loc)) :: rest -> diff --git a/src/proto_alpha/lib_client/michelson_v1_printer.ml b/src/proto_alpha/lib_client/michelson_v1_printer.ml index d4c0eeeeb611..13d16dc254a8 100644 --- a/src/proto_alpha/lib_client/michelson_v1_printer.ml +++ b/src/proto_alpha/lib_client/michelson_v1_printer.ml @@ -52,6 +52,18 @@ let print_stack ppf = function print_expr_unwrapped) more +let print_stack_elt out (ty, x) = + Format.fprintf out "Stack_elt %a %a" print_expr ty print_expr x + +let print_typed_stack out l = + Format.fprintf + out + "{%a}" + (Format.pp_print_list + ~pp_sep:(fun out () -> Format.fprintf out "; ") + print_stack_elt) + l + let print_execution_trace ppf (trace : Script_typed_ir.execution_trace) = Format.pp_print_list (fun ppf (loc, gas, stack) -> diff --git a/src/proto_alpha/lib_client/michelson_v1_printer.mli b/src/proto_alpha/lib_client/michelson_v1_printer.mli index 78e200929221..c719145fa8b5 100644 --- a/src/proto_alpha/lib_client/michelson_v1_printer.mli +++ b/src/proto_alpha/lib_client/michelson_v1_printer.mli @@ -31,6 +31,9 @@ val print_expr : Format.formatter -> Script_repr.expr -> unit val print_expr_unwrapped : Format.formatter -> Script_repr.expr -> unit +val print_typed_stack : + Format.formatter -> (Script_repr.expr * Script_repr.expr) list -> unit + val print_execution_trace : Format.formatter -> Script_typed_ir.execution_trace -> unit diff --git a/src/proto_alpha/lib_client/michelson_v1_stack.ml b/src/proto_alpha/lib_client/michelson_v1_stack.ml new file mode 100644 index 000000000000..c278311703fb --- /dev/null +++ b/src/proto_alpha/lib_client/michelson_v1_stack.ml @@ -0,0 +1,109 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Nomadic Labs *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +open Tezos_micheline +open Protocol +open Alpha_context + +type error += + | Wrong_stack_item of Micheline_parser.location * Micheline_printer.node + | Wrong_stack of Micheline_parser.location * Micheline_printer.node + +let micheline_printer_location_encoding : + Micheline_printer.location Data_encoding.encoding = + let open Data_encoding in + conv + (fun loc -> loc.Micheline_printer.comment) + (fun comment -> {comment}) + (option string) + +let micheline_printer_node_encoding : + Micheline_printer.node Data_encoding.encoding = + Micheline_encoding.table_encoding + ~variant:"" + micheline_printer_location_encoding + Data_encoding.string + +let () = + let open Data_encoding in + register_error_kind + `Permanent + ~id:"michelson.stack.wrong_stack_item" + ~title:"Wrong stack item" + ~description:"Failed to parse an item in a typed stack." + ~pp:(fun ppf (_loc, node) -> + Format.fprintf + ppf + "Unexpected format for an item in a typed stack. Expected: Stack_elt \ + ; got %a." + Micheline_printer.print_expr_unwrapped + node) + (obj2 + (req "location" Micheline_parser.location_encoding) + (req "node" micheline_printer_node_encoding)) + (function Wrong_stack_item (loc, node) -> Some (loc, node) | _ -> None) + (fun (loc, node) -> Wrong_stack_item (loc, node)) ; + register_error_kind + `Permanent + ~id:"michelson.stack.wrong_stack" + ~title:"Wrong stack" + ~description:"Failed to parse a typed stack." + ~pp:(fun ppf (_loc, node) -> + Format.fprintf + ppf + "Unexpected format for a typed stack. Expected a sequence of Stack_elt \ + ; got %a." + Micheline_printer.print_expr_unwrapped + node) + (obj2 + (req "location" Micheline_parser.location_encoding) + (req "node" micheline_printer_node_encoding)) + (function Wrong_stack (loc, node) -> Some (loc, node) | _ -> None) + (fun (loc, node) -> Wrong_stack (loc, node)) + +let parse_expression ~source (node : Micheline_parser.node) : + Script.expr tzresult = + let open Result_syntax in + let parsing_result = Michelson_v1_parser.expand_all ~source ~original:node in + let+ parsed = Micheline_parser.no_parsing_error parsing_result in + parsed.expanded + +let printable node = + Micheline_printer.printable Fun.id (Micheline.strip_locations node) + +let parse_stack_item ~source = + let open Result_syntax in + function + | Micheline.Prim (_loc, "Stack_elt", [ty; v], _annot) -> + let* ty = parse_expression ~source ty in + let+ v = parse_expression ~source v in + (ty, v) + | e -> error (Wrong_stack_item (Micheline.location e, printable e)) + +let parse_stack ~source = function + | Micheline.Seq (loc, l) as e -> + record_trace (Wrong_stack (loc, printable e)) + @@ List.map_e (parse_stack_item ~source) l + | e -> error (Wrong_stack (Micheline.location e, printable e)) diff --git a/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml index 75ab5c017002..b032a655f4d6 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml @@ -685,6 +685,48 @@ let commands () = errs in cctxt#error "ill-typed data expression"); + command + ~group + ~desc:"Ask the node to normalize a typed Michelson stack." + (args2 (unparsing_mode_arg ~default:"Readable") legacy_switch) + (prefixes ["normalize"; "stack"] + @@ param + ~name:"stack" + ~desc: + "the stack to normalize, in the following format: {Stack_elt \ + ; ...; Stack_elt }, where each \ + is a Michelson value of type . The topmost element \ + of the stack is ." + micheline_parameter + @@ stop) + (fun (unparsing_mode, legacy) (stack, source) cctxt -> + let open Lwt_result_syntax in + let*? stack = Michelson_v1_stack.parse_stack ~source stack in + let*! r = + Plugin.RPC.Scripts.normalize_stack + cctxt + (cctxt#chain, cctxt#block) + ~legacy + ~stack + ~unparsing_mode + in + match r with + | Ok expr -> + let*! () = + cctxt#message "%a" Michelson_v1_printer.print_typed_stack expr + in + return_unit + | Error errs -> + let*! () = + cctxt#warning + "%a" + (Michelson_v1_error_reporter.report_errors + ~details:false + ~show_source:false + ?parsed:None) + errs + in + cctxt#error "ill-typed stack"); command ~group ~desc:"Ask the node to normalize a type." -- GitLab From 909f4a5ffbd0087a3b2bcd70cc30f9f0b3377eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Sat, 18 Feb 2023 01:33:08 +0100 Subject: [PATCH 3/3] Tests: tests for the new "normalize stack" command --- tezt/lib_tezos/client.ml | 16 + tezt/lib_tezos/client.mli | 18 + ...ha- Test Michelson stack normalization.out | 468 ++++++++++++++++++ tezt/tests/normalize.ml | 56 ++- 4 files changed, 557 insertions(+), 1 deletion(-) create mode 100644 tezt/tests/expected/normalize.ml/Alpha- Test Michelson stack normalization.out diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index c96fd28baa47..1f1754ff6deb 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -1945,6 +1945,22 @@ let normalize_data ?hooks ?mode ?legacy ~data ~typ client = spawn_normalize_data ?hooks ?mode ?legacy ~data ~typ client |> Process.check_and_read_stdout +let spawn_normalize_stack ?hooks ?mode ?(legacy = false) ~stack client = + let mode_cmd = + Option.map normalize_mode_to_string mode + |> Option.map (fun s -> ["--unparsing-mode"; s]) + in + let cmd = + ["normalize"; "stack"; stack] + @ Option.value ~default:[] mode_cmd + @ if legacy then ["--legacy"] else [] + in + spawn_command ?hooks client cmd + +let normalize_stack ?hooks ?mode ?legacy ~stack client = + spawn_normalize_stack ?hooks ?mode ?legacy ~stack client + |> Process.check_and_read_stdout + let spawn_normalize_script ?hooks ?mode ~script client = let mode_cmd = Option.map normalize_mode_to_string mode diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index 519ef4193c0e..fb6e66732ddd 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -1483,6 +1483,24 @@ val spawn_normalize_data : t -> Process.t +(** Run [octez-client normalize stack ...]*) +val normalize_stack : + ?hooks:Process_hooks.t -> + ?mode:normalize_mode -> + ?legacy:bool -> + stack:string -> + t -> + string Lwt.t + +(** Same as [normalize_stack], but do not wait for the process to exit. *) +val spawn_normalize_stack : + ?hooks:Process_hooks.t -> + ?mode:normalize_mode -> + ?legacy:bool -> + stack:string -> + t -> + Process.t + (** Run [octez-client normalize script ..]*) val normalize_script : ?hooks:Process_hooks.t -> diff --git a/tezt/tests/expected/normalize.ml/Alpha- Test Michelson stack normalization.out b/tezt/tests/expected/normalize.ml/Alpha- Test Michelson stack normalization.out new file mode 100644 index 000000000000..f589e253f3f7 --- /dev/null +++ b/tezt/tests/expected/normalize.ml/Alpha- Test Michelson stack normalization.out @@ -0,0 +1,468 @@ + +./octez-client --mode mockup normalize stack '{}' +{} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9)}' +{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9)} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat (pair nat (pair nat nat))) (Pair 1 (Pair 4 (Pair 7 10)))}' +{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat nat nat nat) (Pair 1 4 7 10)} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat (pair nat (pair nat nat))) (Pair 1 (Pair 4 (Pair 7 10))); Stack_elt (pair nat nat (pair nat nat)) {2; 5; 8; 11}}' +{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat nat nat nat) (Pair 1 4 7 10); Stack_elt (pair nat nat nat nat) (Pair 2 5 8 11)} + +./octez-client --mode mockup normalize stack '{}' --unparsing-mode Readable +{} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9)}' --unparsing-mode Readable +{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9)} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat (pair nat (pair nat nat))) (Pair 1 (Pair 4 (Pair 7 10)))}' --unparsing-mode Readable +{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat nat nat nat) (Pair 1 4 7 10)} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat (pair nat (pair nat nat))) (Pair 1 (Pair 4 (Pair 7 10))); Stack_elt (pair nat nat (pair nat nat)) {2; 5; 8; 11}}' --unparsing-mode Readable +{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat nat nat nat) (Pair 1 4 7 10); Stack_elt (pair nat nat nat nat) (Pair 2 5 8 11)} + +./octez-client --mode mockup normalize stack '{}' --unparsing-mode Optimized +{} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9)}' --unparsing-mode Optimized +{Stack_elt (pair nat nat nat nat) { 0 ; 3 ; 6 ; 9 }} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat (pair nat (pair nat nat))) (Pair 1 (Pair 4 (Pair 7 10)))}' --unparsing-mode Optimized +{Stack_elt (pair nat nat nat nat) { 0 ; 3 ; 6 ; 9 }; Stack_elt (pair nat nat nat nat) { 1 ; 4 ; 7 ; 10 }} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat (pair nat (pair nat nat))) (Pair 1 (Pair 4 (Pair 7 10))); Stack_elt (pair nat nat (pair nat nat)) {2; 5; 8; 11}}' --unparsing-mode Optimized +{Stack_elt (pair nat nat nat nat) { 0 ; 3 ; 6 ; 9 }; Stack_elt (pair nat nat nat nat) { 1 ; 4 ; 7 ; 10 }; Stack_elt (pair nat nat nat nat) { 2 ; 5 ; 8 ; 11 }} + +./octez-client --mode mockup normalize stack '{}' --unparsing-mode Optimized_legacy +{} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9)}' --unparsing-mode Optimized_legacy +{Stack_elt (pair nat nat nat nat) (Pair 0 (Pair 3 (Pair 6 9)))} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat (pair nat (pair nat nat))) (Pair 1 (Pair 4 (Pair 7 10)))}' --unparsing-mode Optimized_legacy +{Stack_elt (pair nat nat nat nat) (Pair 0 (Pair 3 (Pair 6 9))); Stack_elt (pair nat nat nat nat) (Pair 1 (Pair 4 (Pair 7 10)))} + +./octez-client --mode mockup normalize stack '{Stack_elt (pair nat nat nat nat) (Pair 0 3 6 9); Stack_elt (pair nat (pair nat (pair nat nat))) (Pair 1 (Pair 4 (Pair 7 10))); Stack_elt (pair nat nat (pair nat nat)) {2; 5; 8; 11}}' --unparsing-mode Optimized_legacy +{Stack_elt (pair nat nat nat nat) (Pair 0 (Pair 3 (Pair 6 9))); Stack_elt (pair nat nat nat nat) (Pair 1 (Pair 4 (Pair 7 10))); Stack_elt (pair nat nat nat nat) (Pair 2 (Pair 5 (Pair 8 11)))} + +./octez-client --mode mockup normalize stack +Error: + Erroneous command line argument 3 (). + empty expression + +Usage: + octez-client [global options] command [command options] + octez-client --help (for global options) + octez-client [global options] command --help (for command options) + octez-client --version (for version information) + +To browse the documentation: + octez-client [global options] man (for a list of commands) + octez-client [global options] man -v 3 (for the full manual) + +Global options (must come before the command): + -d --base-dir : client data directory (absent: TEZOS_CLIENT_DIR env) + -n --no-base-dir-warnings: silence warnings about client data directory + -c --config-file : configuration file + -t --timings: show RPC request times + --chain : chain on which to apply contextual commands (commands dependent on the context associated with the specified chain). Possible tags are 'main' and 'test'. + -b --block : block on which to apply contextual commands (commands dependent on the context associated with the specified block). Possible tags include 'head' and 'genesis' +/- an optional offset (e.g. "octez-client -b head-1 get timestamp"). Note that block queried must exist in node's storage. + -w --wait >: how many confirmation blocks are needed before an operation is considered included + -p --protocol : use commands of a specific protocol + -l --log-requests: log all requests to the node + --better-errors: Error reporting is more detailed. Can be used if a call to an RPC fails or if you don't know the input accepted by the RPC. It may happen that the RPC calls take more time however. + -A --addr : [DEPRECATED: use --endpoint instead] IP address of the node + -P --port : [DEPRECATED: use --endpoint instead] RPC port of the node + -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node. + -m --media-type : Sets the "media-type" value for the "accept" header for RPC requests to the node. The media accept header indicates to the node which format of data serialisation is supported. Use the value "json" for serialisation to the JSON format. + -E --endpoint : HTTP(S) endpoint of the node RPC interface; e.g. 'http://localhost:8732' + -s --sources : path to JSON file containing sources for --mode light. Example file content: {"min_agreement": 1.0, "uris": ["http://localhost:8732", "https://localhost:8733"]} + -R --remote-signer : URI of the remote signer + -f --password-filename : path to the password filename + -M --mode : how to interact with the node + +./octez-client --mode mockup normalize stack '{' +Error: + Erroneous command line argument 3 ({). + At line 1 characters 0 to 1, unclosed curly brace + +Usage: + octez-client [global options] command [command options] + octez-client --help (for global options) + octez-client [global options] command --help (for command options) + octez-client --version (for version information) + +To browse the documentation: + octez-client [global options] man (for a list of commands) + octez-client [global options] man -v 3 (for the full manual) + +Global options (must come before the command): + -d --base-dir : client data directory (absent: TEZOS_CLIENT_DIR env) + -n --no-base-dir-warnings: silence warnings about client data directory + -c --config-file : configuration file + -t --timings: show RPC request times + --chain : chain on which to apply contextual commands (commands dependent on the context associated with the specified chain). Possible tags are 'main' and 'test'. + -b --block : block on which to apply contextual commands (commands dependent on the context associated with the specified block). Possible tags include 'head' and 'genesis' +/- an optional offset (e.g. "octez-client -b head-1 get timestamp"). Note that block queried must exist in node's storage. + -w --wait >: how many confirmation blocks are needed before an operation is considered included + -p --protocol : use commands of a specific protocol + -l --log-requests: log all requests to the node + --better-errors: Error reporting is more detailed. Can be used if a call to an RPC fails or if you don't know the input accepted by the RPC. It may happen that the RPC calls take more time however. + -A --addr : [DEPRECATED: use --endpoint instead] IP address of the node + -P --port : [DEPRECATED: use --endpoint instead] RPC port of the node + -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node. + -m --media-type : Sets the "media-type" value for the "accept" header for RPC requests to the node. The media accept header indicates to the node which format of data serialisation is supported. Use the value "json" for serialisation to the JSON format. + -E --endpoint : HTTP(S) endpoint of the node RPC interface; e.g. 'http://localhost:8732' + -s --sources : path to JSON file containing sources for --mode light. Example file content: {"min_agreement": 1.0, "uris": ["http://localhost:8732", "https://localhost:8733"]} + -R --remote-signer : URI of the remote signer + -f --password-filename : path to the password filename + -M --mode : how to interact with the node + +./octez-client --mode mockup normalize stack 0 +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got 0. + +./octez-client --mode mockup normalize stack '{Stack_elt}' +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt. + +./octez-client --mode mockup normalize stack '{Stack_elt nat}' +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt nat. + +./octez-client --mode mockup normalize stack '{Stack_elt 0 nat}' +At (unshown) location 0, unexpected int, only a primitive can be used here. +Fatal error: + ill-typed stack + +./octez-client --mode mockup normalize stack '{Stack_elt nat 0 1}' +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat 0 1 }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt nat 0 1. + +./octez-client --mode mockup normalize stack 'Stack_elt nat 0' +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got Stack_elt nat 0. + +./octez-client --mode mockup normalize stack '{Stack_elt nat 0; Stack_elt}' +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat 0 ; Stack_elt }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt. + +./octez-client --mode mockup normalize stack --unparsing-mode Readable +Error: + Erroneous command line argument 3 (). + empty expression + +Usage: + octez-client [global options] command [command options] + octez-client --help (for global options) + octez-client [global options] command --help (for command options) + octez-client --version (for version information) + +To browse the documentation: + octez-client [global options] man (for a list of commands) + octez-client [global options] man -v 3 (for the full manual) + +Global options (must come before the command): + -d --base-dir : client data directory (absent: TEZOS_CLIENT_DIR env) + -n --no-base-dir-warnings: silence warnings about client data directory + -c --config-file : configuration file + -t --timings: show RPC request times + --chain : chain on which to apply contextual commands (commands dependent on the context associated with the specified chain). Possible tags are 'main' and 'test'. + -b --block : block on which to apply contextual commands (commands dependent on the context associated with the specified block). Possible tags include 'head' and 'genesis' +/- an optional offset (e.g. "octez-client -b head-1 get timestamp"). Note that block queried must exist in node's storage. + -w --wait >: how many confirmation blocks are needed before an operation is considered included + -p --protocol : use commands of a specific protocol + -l --log-requests: log all requests to the node + --better-errors: Error reporting is more detailed. Can be used if a call to an RPC fails or if you don't know the input accepted by the RPC. It may happen that the RPC calls take more time however. + -A --addr : [DEPRECATED: use --endpoint instead] IP address of the node + -P --port : [DEPRECATED: use --endpoint instead] RPC port of the node + -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node. + -m --media-type : Sets the "media-type" value for the "accept" header for RPC requests to the node. The media accept header indicates to the node which format of data serialisation is supported. Use the value "json" for serialisation to the JSON format. + -E --endpoint : HTTP(S) endpoint of the node RPC interface; e.g. 'http://localhost:8732' + -s --sources : path to JSON file containing sources for --mode light. Example file content: {"min_agreement": 1.0, "uris": ["http://localhost:8732", "https://localhost:8733"]} + -R --remote-signer : URI of the remote signer + -f --password-filename : path to the password filename + -M --mode : how to interact with the node + +./octez-client --mode mockup normalize stack '{' --unparsing-mode Readable +Error: + Erroneous command line argument 3 ({). + At line 1 characters 0 to 1, unclosed curly brace + +Usage: + octez-client [global options] command [command options] + octez-client --help (for global options) + octez-client [global options] command --help (for command options) + octez-client --version (for version information) + +To browse the documentation: + octez-client [global options] man (for a list of commands) + octez-client [global options] man -v 3 (for the full manual) + +Global options (must come before the command): + -d --base-dir : client data directory (absent: TEZOS_CLIENT_DIR env) + -n --no-base-dir-warnings: silence warnings about client data directory + -c --config-file : configuration file + -t --timings: show RPC request times + --chain : chain on which to apply contextual commands (commands dependent on the context associated with the specified chain). Possible tags are 'main' and 'test'. + -b --block : block on which to apply contextual commands (commands dependent on the context associated with the specified block). Possible tags include 'head' and 'genesis' +/- an optional offset (e.g. "octez-client -b head-1 get timestamp"). Note that block queried must exist in node's storage. + -w --wait >: how many confirmation blocks are needed before an operation is considered included + -p --protocol : use commands of a specific protocol + -l --log-requests: log all requests to the node + --better-errors: Error reporting is more detailed. Can be used if a call to an RPC fails or if you don't know the input accepted by the RPC. It may happen that the RPC calls take more time however. + -A --addr : [DEPRECATED: use --endpoint instead] IP address of the node + -P --port : [DEPRECATED: use --endpoint instead] RPC port of the node + -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node. + -m --media-type : Sets the "media-type" value for the "accept" header for RPC requests to the node. The media accept header indicates to the node which format of data serialisation is supported. Use the value "json" for serialisation to the JSON format. + -E --endpoint : HTTP(S) endpoint of the node RPC interface; e.g. 'http://localhost:8732' + -s --sources : path to JSON file containing sources for --mode light. Example file content: {"min_agreement": 1.0, "uris": ["http://localhost:8732", "https://localhost:8733"]} + -R --remote-signer : URI of the remote signer + -f --password-filename : path to the password filename + -M --mode : how to interact with the node + +./octez-client --mode mockup normalize stack 0 --unparsing-mode Readable +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got 0. + +./octez-client --mode mockup normalize stack '{Stack_elt}' --unparsing-mode Readable +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt. + +./octez-client --mode mockup normalize stack '{Stack_elt nat}' --unparsing-mode Readable +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt nat. + +./octez-client --mode mockup normalize stack '{Stack_elt 0 nat}' --unparsing-mode Readable +At (unshown) location 0, unexpected int, only a primitive can be used here. +Fatal error: + ill-typed stack + +./octez-client --mode mockup normalize stack '{Stack_elt nat 0 1}' --unparsing-mode Readable +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat 0 1 }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt nat 0 1. + +./octez-client --mode mockup normalize stack 'Stack_elt nat 0' --unparsing-mode Readable +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got Stack_elt nat 0. + +./octez-client --mode mockup normalize stack '{Stack_elt nat 0; Stack_elt}' --unparsing-mode Readable +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat 0 ; Stack_elt }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt. + +./octez-client --mode mockup normalize stack --unparsing-mode Optimized +Error: + Erroneous command line argument 3 (). + empty expression + +Usage: + octez-client [global options] command [command options] + octez-client --help (for global options) + octez-client [global options] command --help (for command options) + octez-client --version (for version information) + +To browse the documentation: + octez-client [global options] man (for a list of commands) + octez-client [global options] man -v 3 (for the full manual) + +Global options (must come before the command): + -d --base-dir : client data directory (absent: TEZOS_CLIENT_DIR env) + -n --no-base-dir-warnings: silence warnings about client data directory + -c --config-file : configuration file + -t --timings: show RPC request times + --chain : chain on which to apply contextual commands (commands dependent on the context associated with the specified chain). Possible tags are 'main' and 'test'. + -b --block : block on which to apply contextual commands (commands dependent on the context associated with the specified block). Possible tags include 'head' and 'genesis' +/- an optional offset (e.g. "octez-client -b head-1 get timestamp"). Note that block queried must exist in node's storage. + -w --wait >: how many confirmation blocks are needed before an operation is considered included + -p --protocol : use commands of a specific protocol + -l --log-requests: log all requests to the node + --better-errors: Error reporting is more detailed. Can be used if a call to an RPC fails or if you don't know the input accepted by the RPC. It may happen that the RPC calls take more time however. + -A --addr : [DEPRECATED: use --endpoint instead] IP address of the node + -P --port : [DEPRECATED: use --endpoint instead] RPC port of the node + -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node. + -m --media-type : Sets the "media-type" value for the "accept" header for RPC requests to the node. The media accept header indicates to the node which format of data serialisation is supported. Use the value "json" for serialisation to the JSON format. + -E --endpoint : HTTP(S) endpoint of the node RPC interface; e.g. 'http://localhost:8732' + -s --sources : path to JSON file containing sources for --mode light. Example file content: {"min_agreement": 1.0, "uris": ["http://localhost:8732", "https://localhost:8733"]} + -R --remote-signer : URI of the remote signer + -f --password-filename : path to the password filename + -M --mode : how to interact with the node + +./octez-client --mode mockup normalize stack '{' --unparsing-mode Optimized +Error: + Erroneous command line argument 3 ({). + At line 1 characters 0 to 1, unclosed curly brace + +Usage: + octez-client [global options] command [command options] + octez-client --help (for global options) + octez-client [global options] command --help (for command options) + octez-client --version (for version information) + +To browse the documentation: + octez-client [global options] man (for a list of commands) + octez-client [global options] man -v 3 (for the full manual) + +Global options (must come before the command): + -d --base-dir : client data directory (absent: TEZOS_CLIENT_DIR env) + -n --no-base-dir-warnings: silence warnings about client data directory + -c --config-file : configuration file + -t --timings: show RPC request times + --chain : chain on which to apply contextual commands (commands dependent on the context associated with the specified chain). Possible tags are 'main' and 'test'. + -b --block : block on which to apply contextual commands (commands dependent on the context associated with the specified block). Possible tags include 'head' and 'genesis' +/- an optional offset (e.g. "octez-client -b head-1 get timestamp"). Note that block queried must exist in node's storage. + -w --wait >: how many confirmation blocks are needed before an operation is considered included + -p --protocol : use commands of a specific protocol + -l --log-requests: log all requests to the node + --better-errors: Error reporting is more detailed. Can be used if a call to an RPC fails or if you don't know the input accepted by the RPC. It may happen that the RPC calls take more time however. + -A --addr : [DEPRECATED: use --endpoint instead] IP address of the node + -P --port : [DEPRECATED: use --endpoint instead] RPC port of the node + -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node. + -m --media-type : Sets the "media-type" value for the "accept" header for RPC requests to the node. The media accept header indicates to the node which format of data serialisation is supported. Use the value "json" for serialisation to the JSON format. + -E --endpoint : HTTP(S) endpoint of the node RPC interface; e.g. 'http://localhost:8732' + -s --sources : path to JSON file containing sources for --mode light. Example file content: {"min_agreement": 1.0, "uris": ["http://localhost:8732", "https://localhost:8733"]} + -R --remote-signer : URI of the remote signer + -f --password-filename : path to the password filename + -M --mode : how to interact with the node + +./octez-client --mode mockup normalize stack 0 --unparsing-mode Optimized +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got 0. + +./octez-client --mode mockup normalize stack '{Stack_elt}' --unparsing-mode Optimized +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt. + +./octez-client --mode mockup normalize stack '{Stack_elt nat}' --unparsing-mode Optimized +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt nat. + +./octez-client --mode mockup normalize stack '{Stack_elt 0 nat}' --unparsing-mode Optimized +At (unshown) location 0, unexpected int, only a primitive can be used here. +Fatal error: + ill-typed stack + +./octez-client --mode mockup normalize stack '{Stack_elt nat 0 1}' --unparsing-mode Optimized +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat 0 1 }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt nat 0 1. + +./octez-client --mode mockup normalize stack 'Stack_elt nat 0' --unparsing-mode Optimized +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got Stack_elt nat 0. + +./octez-client --mode mockup normalize stack '{Stack_elt nat 0; Stack_elt}' --unparsing-mode Optimized +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat 0 ; Stack_elt }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt. + +./octez-client --mode mockup normalize stack --unparsing-mode Optimized_legacy +Error: + Erroneous command line argument 3 (). + empty expression + +Usage: + octez-client [global options] command [command options] + octez-client --help (for global options) + octez-client [global options] command --help (for command options) + octez-client --version (for version information) + +To browse the documentation: + octez-client [global options] man (for a list of commands) + octez-client [global options] man -v 3 (for the full manual) + +Global options (must come before the command): + -d --base-dir : client data directory (absent: TEZOS_CLIENT_DIR env) + -n --no-base-dir-warnings: silence warnings about client data directory + -c --config-file : configuration file + -t --timings: show RPC request times + --chain : chain on which to apply contextual commands (commands dependent on the context associated with the specified chain). Possible tags are 'main' and 'test'. + -b --block : block on which to apply contextual commands (commands dependent on the context associated with the specified block). Possible tags include 'head' and 'genesis' +/- an optional offset (e.g. "octez-client -b head-1 get timestamp"). Note that block queried must exist in node's storage. + -w --wait >: how many confirmation blocks are needed before an operation is considered included + -p --protocol : use commands of a specific protocol + -l --log-requests: log all requests to the node + --better-errors: Error reporting is more detailed. Can be used if a call to an RPC fails or if you don't know the input accepted by the RPC. It may happen that the RPC calls take more time however. + -A --addr : [DEPRECATED: use --endpoint instead] IP address of the node + -P --port : [DEPRECATED: use --endpoint instead] RPC port of the node + -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node. + -m --media-type : Sets the "media-type" value for the "accept" header for RPC requests to the node. The media accept header indicates to the node which format of data serialisation is supported. Use the value "json" for serialisation to the JSON format. + -E --endpoint : HTTP(S) endpoint of the node RPC interface; e.g. 'http://localhost:8732' + -s --sources : path to JSON file containing sources for --mode light. Example file content: {"min_agreement": 1.0, "uris": ["http://localhost:8732", "https://localhost:8733"]} + -R --remote-signer : URI of the remote signer + -f --password-filename : path to the password filename + -M --mode : how to interact with the node + +./octez-client --mode mockup normalize stack '{' --unparsing-mode Optimized_legacy +Error: + Erroneous command line argument 3 ({). + At line 1 characters 0 to 1, unclosed curly brace + +Usage: + octez-client [global options] command [command options] + octez-client --help (for global options) + octez-client [global options] command --help (for command options) + octez-client --version (for version information) + +To browse the documentation: + octez-client [global options] man (for a list of commands) + octez-client [global options] man -v 3 (for the full manual) + +Global options (must come before the command): + -d --base-dir : client data directory (absent: TEZOS_CLIENT_DIR env) + -n --no-base-dir-warnings: silence warnings about client data directory + -c --config-file : configuration file + -t --timings: show RPC request times + --chain : chain on which to apply contextual commands (commands dependent on the context associated with the specified chain). Possible tags are 'main' and 'test'. + -b --block : block on which to apply contextual commands (commands dependent on the context associated with the specified block). Possible tags include 'head' and 'genesis' +/- an optional offset (e.g. "octez-client -b head-1 get timestamp"). Note that block queried must exist in node's storage. + -w --wait >: how many confirmation blocks are needed before an operation is considered included + -p --protocol : use commands of a specific protocol + -l --log-requests: log all requests to the node + --better-errors: Error reporting is more detailed. Can be used if a call to an RPC fails or if you don't know the input accepted by the RPC. It may happen that the RPC calls take more time however. + -A --addr : [DEPRECATED: use --endpoint instead] IP address of the node + -P --port : [DEPRECATED: use --endpoint instead] RPC port of the node + -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node. + -m --media-type : Sets the "media-type" value for the "accept" header for RPC requests to the node. The media accept header indicates to the node which format of data serialisation is supported. Use the value "json" for serialisation to the JSON format. + -E --endpoint : HTTP(S) endpoint of the node RPC interface; e.g. 'http://localhost:8732' + -s --sources : path to JSON file containing sources for --mode light. Example file content: {"min_agreement": 1.0, "uris": ["http://localhost:8732", "https://localhost:8733"]} + -R --remote-signer : URI of the remote signer + -f --password-filename : path to the password filename + -M --mode : how to interact with the node + +./octez-client --mode mockup normalize stack 0 --unparsing-mode Optimized_legacy +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got 0. + +./octez-client --mode mockup normalize stack '{Stack_elt}' --unparsing-mode Optimized_legacy +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt. + +./octez-client --mode mockup normalize stack '{Stack_elt nat}' --unparsing-mode Optimized_legacy +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt nat. + +./octez-client --mode mockup normalize stack '{Stack_elt 0 nat}' --unparsing-mode Optimized_legacy +At (unshown) location 0, unexpected int, only a primitive can be used here. +Fatal error: + ill-typed stack + +./octez-client --mode mockup normalize stack '{Stack_elt nat 0 1}' --unparsing-mode Optimized_legacy +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat 0 1 }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt nat 0 1. + +./octez-client --mode mockup normalize stack 'Stack_elt nat 0' --unparsing-mode Optimized_legacy +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got Stack_elt nat 0. + +./octez-client --mode mockup normalize stack '{Stack_elt nat 0; Stack_elt}' --unparsing-mode Optimized_legacy +Error: + Unexpected format for a typed stack. Expected a sequence of Stack_elt ; got { Stack_elt nat 0 ; Stack_elt }. + Unexpected format for an item in a typed stack. Expected: Stack_elt ; got Stack_elt. diff --git a/tezt/tests/normalize.ml b/tezt/tests/normalize.ml index c9af986a9932..19151ff94670 100644 --- a/tezt/tests/normalize.ml +++ b/tezt/tests/normalize.ml @@ -28,7 +28,7 @@ ------- Component: Client Invocation: dune exec tezt/tests/main.exe -- --file normalize.ml - Subject: Regression tests for the "normalize data" command. + Subject: Regression tests for Michelson normalization commands. *) let hooks = Tezos_regression.hooks @@ -71,6 +71,59 @@ let test_normalize_legacy_flag = in unit +let test_normalize_stack = + Protocol.register_regression_test + ~__FILE__ + ~title:"Test Michelson stack normalization" + ~tags:["client"; "normalize"] + ~supports:(From_protocol 17) + @@ fun protocol -> + let* client = Client.init_mockup ~protocol () in + let stack_elt ty v = sf "Stack_elt %s %s" ty v in + let elt1 = stack_elt "(pair nat nat nat nat)" "(Pair 0 3 6 9)" in + let elt2 = + stack_elt + "(pair nat (pair nat (pair nat nat)))" + "(Pair 1 (Pair 4 (Pair 7 10)))" + in + let elt3 = stack_elt "(pair nat nat (pair nat nat))" "{2; 5; 8; 11}" in + let* () = + modes + |> Lwt_list.iter_s @@ fun mode -> + [[]; [elt1]; [elt1; elt2]; [elt1; elt2; elt3]] + |> Lwt_list.iter_s @@ fun stack -> + let print_stack fmt = + Format.fprintf + fmt + "{%a}" + (Format.pp_print_list + ~pp_sep:(fun fmt () -> Format.pp_print_string fmt "; ") + Format.pp_print_string) + in + let stack = Format.asprintf "%a" print_stack stack in + let* _ = Client.normalize_stack client ~hooks ?mode ~stack in + unit + in + let* () = + modes + |> Lwt_list.iter_s @@ fun mode -> + [ + ""; + "{"; + "0"; + "{Stack_elt}"; + "{Stack_elt nat}"; + "{Stack_elt 0 nat}"; + "{Stack_elt nat 0 1}"; + "Stack_elt nat 0"; + "{Stack_elt nat 0; Stack_elt}"; + ] + |> Lwt_list.iter_s @@ fun stack -> + Client.spawn_normalize_stack client ~hooks ?mode ~stack + |> Process.check_error + in + unit + let test_normalize_script = Protocol.register_regression_test ~__FILE__ @@ -116,5 +169,6 @@ let test_normalize_type = let register ~protocols = test_normalize_unparsing_mode protocols ; test_normalize_legacy_flag protocols ; + test_normalize_stack protocols ; test_normalize_script protocols ; test_normalize_type protocols -- GitLab