From f6c4be2b404e731e58533d77a9627a98878d941e Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Thu, 28 Jun 2018 02:40:20 +0200 Subject: [PATCH] Alpha, Client: don't count gas for unparsing in logging --- .../lib_protocol/src/script_ir_translator.ml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/proto_alpha/lib_protocol/src/script_ir_translator.ml b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml index bfcb05d67..ebd664490 100644 --- a/src/proto_alpha/lib_protocol/src/script_ir_translator.ml +++ b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml @@ -1561,15 +1561,18 @@ and parse_instr Lwt.return check in let check_item_ty exp got loc n = check_item (ty_eq ctxt exp got) loc n in - let log_stack ctxt loc stack_ty aft : context tzresult Lwt.t = + let log_stack ctxt loc stack_ty aft = match type_logger, script_instr with | None, _ - | Some _, (Seq (-1, _) | Int _ | String _ | Bytes _) -> return ctxt + | Some _, (Seq (-1, _) | Int _ | String _ | Bytes _) -> return () | Some log, (Prim _ | Seq _) -> - unparse_stack ctxt stack_ty >>=? fun (stack_ty, ctxt) -> - unparse_stack ctxt aft >>=? fun (aft, ctxt) -> + (* Unparsing for logging done in an unlimited context as this + is used only by the client and not the protocol *) + let ctxt = Gas.set_unlimited ctxt in + unparse_stack ctxt stack_ty >>=? fun (stack_ty, _) -> + unparse_stack ctxt aft >>=? fun (aft, _) -> log loc stack_ty aft; - return ctxt + return () in let return : context -> bef judgement -> (bef judgement * context) tzresult Lwt.t = fun ctxt judgement -> @@ -1586,7 +1589,7 @@ and parse_instr | Failed _ -> return (judgement, ctxt) in let typed ctxt loc instr aft = - log_stack ctxt loc stack_ty aft >>=? fun ctxt -> + log_stack ctxt loc stack_ty aft >>=? fun () -> return ctxt (Typed { loc ; instr ; bef = stack_ty ; aft }) in match script_instr, stack_ty with (* stack ops *) @@ -2036,7 +2039,7 @@ and parse_instr Item_t (v, _rest, _) -> fail_unexpected_annot loc annot >>=? fun () -> let descr aft = { loc ; instr = Failwith v ; bef = stack_ty ; aft } in - log_stack ctxt loc stack_ty Empty_t >>=? fun ctxt -> + log_stack ctxt loc stack_ty Empty_t >>=? fun () -> return ctxt (Failed { descr }) (* timestamp operations *) | Prim (loc, I_ADD, [], annot),