diff --git a/src/proto_alpha/lib_plugin/plugin.ml b/src/proto_alpha/lib_plugin/plugin.ml index c97734653748399c0a6a8ffcfbc4eda9cd90421a..8667af203ee0839f56770830d2ced4e8134c4fa9 100644 --- a/src/proto_alpha/lib_plugin/plugin.ml +++ b/src/proto_alpha/lib_plugin/plugin.ml @@ -1465,7 +1465,19 @@ module View_helpers = struct match operations with | [ Script_typed_ir.Internal_operation - {operation = Transaction {destination; parameters; _}; _}; + { + operation = + Transaction + { + transaction = + {destination; parameters; entrypoint = _; amount = _}; + parameters = _; + parameters_ty = _; + location = _; + }; + source = _; + nonce = _; + }; ] when Destination.equal destination (Contract callback) -> ok parameters @@ -1927,11 +1939,10 @@ module RPC = struct ~entrypoint ~parameter ~internal:true - >>=? fun ( {ctxt; storage; lazy_storage_diff; operations; ticket_diffs}, - _ ) -> + >>=? fun res -> logger.get_log () >|=? fun trace -> let trace = Option.value ~default:[] trace in - ({ctxt; storage; lazy_storage_diff; operations; ticket_diffs}, trace) + (res, trace) end let typecheck_data : @@ -2297,7 +2308,8 @@ module RPC = struct ~parameter ~internal:true >|=? fun ( { - ctxt = _; + script = _; + code_size = _; Script_interpreter.storage; operations; lazy_storage_diff; @@ -2366,13 +2378,15 @@ module RPC = struct ~script:{storage; code} ~entrypoint ~parameter - >|=? fun ( { - ctxt = _; - Script_interpreter.storage; - operations; - lazy_storage_diff; - ticket_diffs = _; - }, + >|=? fun ( ( { + script = _; + code_size = _; + Script_interpreter.storage; + operations; + lazy_storage_diff; + ticket_diffs = _; + }, + _ctxt ), trace ) -> ( storage, Apply_results.contents_of_packed_internal_operations operations, @@ -2463,7 +2477,15 @@ module RPC = struct ~entrypoint ~parameter ~internal:true - >>=? fun ({Script_interpreter.operations; _}, (_, _)) -> + >>=? fun ( { + Script_interpreter.operations; + script = _; + code_size = _; + storage = _; + lazy_storage_diff = _; + ticket_diffs = _; + }, + _ctxt ) -> View_helpers.extract_parameter_from_operations entrypoint operations diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 15a84149bcf27387bdc310f1b3cae4df120f1f14..0d578b6229956c45e048cca1ec8c46d652da98ac 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -876,16 +876,28 @@ let apply_delegation ~ctxt ~source ~delegate ~since = Delegate.set ctxt source delegate >|=? fun ctxt -> (ctxt, Delegation_result {consumed_gas = Gas.consumed ~since ~until:ctxt}, []) +type execution_arg = + | Typed_arg : Script.location * 'a Script_typed_ir.ty * 'a -> execution_arg + | Untyped_arg : Script.expr -> execution_arg + let apply_transaction_to_implicit ~ctxt ~contract ~parameter ~entrypoint ~before_operation ~balance_updates ~allocated_destination_contract = + let is_unit = + match parameter with + | Typed_arg (_, Unit_t, ()) -> true + | Typed_arg _ -> false + | Untyped_arg parameter -> ( + match Micheline.root parameter with + | Prim (_, Michelson_v1_primitives.D_Unit, [], _) -> true + | _ -> false) + in ( (if Entrypoint.is_default entrypoint then Result.return_unit else error (Script_tc_errors.No_such_entrypoint entrypoint)) >>? fun () -> - match Micheline.root parameter with - | Prim (_, Michelson_v1_primitives.D_Unit, [], _) -> - (* Allow [Unit] parameter to non-scripted contracts. *) - ok ctxt - | _ -> error (Script_interpreter.Bad_contract_parameter contract) ) + if is_unit then + (* Only allow [Unit] parameter to implicit accounts. *) + ok ctxt + else error (Script_interpreter.Bad_contract_parameter contract) ) >|? fun ctxt -> let result = Transaction_result @@ -928,17 +940,26 @@ let apply_transaction_to_smart_contract ~ctxt ~source ~contract ~amount level; } in - Script_interpreter.execute - ctxt - ~cached_script:(Some script_ir) - mode - step_constants - ~script - ~parameter - ~entrypoint - ~internal - >>=? fun ( {ctxt; storage; lazy_storage_diff; operations; ticket_diffs}, - (updated_cached_script, updated_size) ) -> + let execute = + match parameter with + | Untyped_arg parameter -> Script_interpreter.execute ~parameter + | Typed_arg (location, parameter_ty, parameter) -> + Script_interpreter.execute_with_typed_parameter + ~location + ~parameter_ty + ~parameter + in + let cached_script = Some script_ir in + execute ctxt ~cached_script mode step_constants ~script ~entrypoint ~internal + >>=? fun ( { + script = updated_cached_script; + code_size = updated_size; + storage; + lazy_storage_diff; + operations; + ticket_diffs; + }, + ctxt ) -> update_script_storage_and_ticket_balances ctxt ~self:contract @@ -974,11 +995,8 @@ let apply_transaction_to_smart_contract ~ctxt ~source ~contract ~amount in (ctxt, result, operations) ) -let apply_transaction ~consume_deserialization_gas ~ctxt ~parameters ~source - ~contract ~amount ~entrypoint ~before_operation ~payer ~chain_id ~mode - ~internal = - Script.force_decode_in_context ~consume_deserialization_gas ctxt parameters - >>?= fun (parameter, ctxt) -> +let apply_transaction ~ctxt ~parameter ~source ~contract ~amount ~entrypoint + ~before_operation ~payer ~chain_id ~mode ~internal = (match Contract.is_implicit contract with | None -> (if Tez.(amount = zero) then @@ -1234,11 +1252,16 @@ let apply_internal_manager_operation_content : >>=? fun (ctxt, before_operation, consume_deserialization_gas) -> match operation with | Transaction - {amount; parameters; destination = Contract contract; entrypoint} -> + { + transaction = + {amount; parameters = _; destination = Contract contract; entrypoint}; + location; + parameters_ty; + parameters = typed_parameters; + } -> apply_transaction - ~consume_deserialization_gas ~ctxt - ~parameters + ~parameter:(Typed_arg (location, parameters_ty, typed_parameters)) ~source ~contract ~amount @@ -1252,7 +1275,14 @@ let apply_internal_manager_operation_content : ( ctxt, (manager_result : kind successful_manager_operation_result), operations ) - | Transaction {amount; parameters; destination = Tx_rollup dst; entrypoint} -> + | Transaction + { + transaction = + {amount; parameters; destination = Tx_rollup dst; entrypoint}; + location = _; + parameters_ty = _; + parameters = _; + } -> apply_transaction_to_rollup ~consume_deserialization_gas ~ctxt @@ -1315,10 +1345,14 @@ let apply_external_manager_operation_content : [] ) | Transaction {amount; parameters; destination = Contract contract; entrypoint} -> - apply_transaction + Script.force_decode_in_context ~consume_deserialization_gas + ctxt + parameters + >>?= fun (parameters, ctxt) -> + apply_transaction ~ctxt - ~parameters + ~parameter:(Untyped_arg parameters) ~source ~contract ~amount @@ -1405,25 +1439,26 @@ let apply_external_manager_operation_content : this ticket is owns by the tx_rollup *) (* Now reconstruct the ticket sent as the parameter destination. *) - ( Script_ir_translator.parse_comparable_ty ctxt (Micheline.root ty) + Script_ir_translator.parse_comparable_ty ctxt (Micheline.root ty) >>?= fun (Ex_comparable_ty ty, ctxt) -> - Script_ir_translator.parse_comparable_data - ctxt - ty - (Micheline.root contents) - >>=? fun (contents, ctxt) -> - let amount = - Option.value - ~default:Script_int.zero_n - Script_int.(is_nat @@ of_int64 @@ Tx_rollup_l2_qty.to_int64 amount) - in - let ticket = Script_typed_ir.{ticketer; contents; amount} in - Script_typed_ir.ticket_t Micheline.dummy_location ty >>?= fun ty -> - return (ticket, ty, ctxt) >>=? fun (ticket, ticket_ty, ctxt) -> - Script_ir_translator.unparse_data ctxt Optimized ticket_ty ticket - >|=? fun (parameters, ctxt) -> - (Script.lazy_expr (Micheline.strip_locations parameters), ctxt) ) + Script_ir_translator.parse_comparable_data + ctxt + ty + (Micheline.root contents) + >>=? fun (contents, ctxt) -> + let amount = + Option.value + ~default:Script_int.zero_n + Script_int.(is_nat @@ of_int64 @@ Tx_rollup_l2_qty.to_int64 amount) + in + let ticket = Script_typed_ir.{ticketer; contents; amount} in + Script_typed_ir.ticket_t Micheline.dummy_location ty >>?= fun ty -> + return (ticket, ty, ctxt) >>=? fun (ticket, ticket_ty, ctxt) -> + Script_ir_translator.unparse_data ctxt Optimized ticket_ty ticket >>=? fun (parameters, ctxt) -> + let parameters = + Script.lazy_expr (Micheline.strip_locations parameters) + in (* FIXME/TORU: #2488 the returned op will fail when ticket hardening is merged, it must be commented or fixed *) let op = @@ -1435,10 +1470,16 @@ let apply_external_manager_operation_content : operation = Transaction { - amount = Tez.zero; - parameters; - destination = Contract destination; - entrypoint; + transaction = + { + amount = Tez.zero; + parameters; + destination = Contract destination; + entrypoint; + }; + location = Micheline.location ticketer_node; + parameters_ty = ticket_ty; + parameters = ticket; }; } in @@ -3037,13 +3078,14 @@ let apply_liquidity_baking_subsidy ctxt ~toggle_vote = ~entrypoint:Entrypoint.default ~internal:false >>=? fun ( { - ctxt; + script = updated_cached_script; + code_size = updated_size; storage; lazy_storage_diff; operations; ticket_diffs; }, - (updated_cached_script, updated_size) ) -> + ctxt ) -> match operations with | _ :: _ -> (* No internal operations are expected here. Something bad may be happening. *) diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index fa162275d20aeddf74e751a9ecf3649d83b8f639..68b4aafcdada3843c2cac1e4667920bd9427209f 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -80,7 +80,7 @@ let contents_of_internal_operation (type kind) kind internal_contents = let operation : kind internal_manager_operation = match operation with - | Transaction transaction -> Transaction transaction + | Transaction {transaction; _} -> Transaction transaction | Origination origination -> Origination origination | Delegation delegate -> Delegation delegate in diff --git a/src/proto_alpha/lib_protocol/script_interpreter.ml b/src/proto_alpha/lib_protocol/script_interpreter.ml index 8ccf59eaed1465c10daf1385d67475e22a9702eb..a066cc50351c5d1e858a568c607fe474e9996f2d 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter.ml @@ -1009,11 +1009,19 @@ and step : type a s b t r f. (a, s, b, t, r, f) step_type = let accu = maybe_contract in (step [@ocaml.tailcall]) (ctxt, sc) gas k ks accu stack | None -> (step [@ocaml.tailcall]) (ctxt, sc) gas k ks None stack) - | ITransfer_tokens (_, k) -> + | ITransfer_tokens (kinfo, k) -> let p = accu in let (amount, (Typed_contract {arg_ty; address}, stack)) = stack in let {destination; entrypoint} = address in - transfer (ctxt, sc) gas amount arg_ty p destination entrypoint + transfer + (ctxt, sc) + gas + amount + kinfo.iloc + arg_ty + p + destination + entrypoint >>=? fun (accu, ctxt, gas) -> (step [@ocaml.tailcall]) (ctxt, sc) gas k ks accu stack | IImplicit_account (_, k) -> @@ -1704,17 +1712,41 @@ let step logger ctxt step_constants descr stack = ==================== *) -let execute logger ctxt mode step_constants ~entrypoint ~internal - unparsed_script cached_script arg : - (Script.expr - * packed_internal_operation list - * context - * Lazy_storage.diffs option - * ex_script - * int - * Z.t Ticket_token_map.t) - tzresult - Lwt.t = +type execution_arg = + | Typed_arg : Script.location * 'a Script_typed_ir.ty * 'a -> execution_arg + | Untyped_arg : Script.expr -> execution_arg + +let lift_execution_arg (type a) ctxt ~internal (entrypoint_ty : a ty) + (box : a -> 'b) arg : ('b * context) tzresult Lwt.t = + (match arg with + | Untyped_arg arg -> + let arg = Micheline.root arg in + parse_data ctxt ~legacy:false ~allow_forged:internal entrypoint_ty arg + | Typed_arg (location, parsed_arg_ty, parsed_arg) -> + Gas_monad.run + ctxt + (Script_ir_translator.ty_eq + ~error_details:Informative + location + entrypoint_ty + parsed_arg_ty) + >>?= fun (res, ctxt) -> + res >>?= fun Eq -> + let parsed_arg : a = parsed_arg in + return (parsed_arg, ctxt)) + >>=? fun (entrypoint_arg, ctxt) -> return (box entrypoint_arg, ctxt) + +type execution_result = { + script : Script_ir_translator.ex_script; + code_size : int; + storage : Script.expr; + lazy_storage_diff : Lazy_storage.diffs option; + operations : packed_internal_operation list; + ticket_diffs : Z.t Ticket_token_map.t; +} + +let execute_any_arg logger ctxt mode step_constants ~entrypoint ~internal + unparsed_script cached_script arg = (match cached_script with | None -> parse_script @@ -1742,9 +1774,8 @@ let execute logger ctxt mode step_constants ~entrypoint ~internal >>?= fun (Ex_ty_cstr (entrypoint_ty, box)) -> trace (Bad_contract_parameter step_constants.self) - (parse_data ctxt ~legacy:false ~allow_forged:internal entrypoint_ty arg) + (lift_execution_arg ctxt ~internal entrypoint_ty box arg) >>=? fun (arg, ctxt) -> - let arg = box arg in Script_ir_translator.collect_lazy_storage ctxt arg_type arg >>?= fun (to_duplicate, ctxt) -> Script_ir_translator.collect_lazy_storage ctxt storage_type old_storage @@ -1772,7 +1803,7 @@ let execute logger ctxt mode step_constants ~entrypoint ~internal ) >>=? fun (unparsed_storage, ctxt) -> let op_to_couple op = (op.piop, op.lazy_storage_diff) in - let (op_elems, op_diffs) = + let (operations, op_diffs) = ops.elements |> List.map op_to_couple |> List.split in let lazy_storage_diff_all = @@ -1808,25 +1839,32 @@ let execute logger ctxt mode step_constants ~entrypoint ~internal let (size, cost) = Script_ir_translator.script_size script in Gas.consume ctxt cost >>?= fun ctxt -> return - ( unparsed_storage, - op_elems, - ctxt, - lazy_storage_diff_all, - script, - size, - ticket_diffs ) - -type execution_result = { - ctxt : context; - storage : Script.expr; - lazy_storage_diff : Lazy_storage.diffs option; - operations : packed_internal_operation list; - ticket_diffs : Z.t Ticket_token_map.t; -} + ( { + script; + code_size = size; + storage = unparsed_storage; + lazy_storage_diff = lazy_storage_diff_all; + operations; + ticket_diffs; + }, + ctxt ) + +let execute_with_typed_parameter ?logger ctxt ~cached_script mode step_constants + ~script ~entrypoint ~parameter_ty ~location ~parameter ~internal = + execute_any_arg + logger + ctxt + mode + step_constants + ~entrypoint + ~internal + script + cached_script + (Typed_arg (location, parameter_ty, parameter)) let execute ?logger ctxt ~cached_script mode step_constants ~script ~entrypoint ~parameter ~internal = - execute + execute_any_arg logger ctxt mode @@ -1835,16 +1873,7 @@ let execute ?logger ctxt ~cached_script mode step_constants ~script ~entrypoint ~internal script cached_script - (Micheline.root parameter) - >|=? fun ( storage, - operations, - ctxt, - lazy_storage_diff, - ex_script, - approx_size, - ticket_diffs ) -> - ( {ctxt; storage; lazy_storage_diff; operations; ticket_diffs}, - (ex_script, approx_size) ) + (Untyped_arg parameter) (* diff --git a/src/proto_alpha/lib_protocol/script_interpreter.mli b/src/proto_alpha/lib_protocol/script_interpreter.mli index 36403a19473290834d8639095a4db461874cdb5f..bfbde28e35d1d6579d178f2bf853de5d66bb9a84 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter.mli +++ b/src/proto_alpha/lib_protocol/script_interpreter.mli @@ -51,7 +51,8 @@ type error += Cannot_serialize_storage type error += Michelson_too_many_recursive_calls type execution_result = { - ctxt : context; + script : Script_ir_translator.ex_script; + code_size : int; storage : Script.expr; lazy_storage_diff : Lazy_storage.diffs option; operations : packed_internal_operation list; @@ -109,7 +110,27 @@ val execute : entrypoint:Entrypoint.t -> parameter:Script.expr -> internal:bool -> - (execution_result * (Script_ir_translator.ex_script * int)) tzresult Lwt.t + (execution_result * context) tzresult Lwt.t + +(** [execute_with_typed_parameter ?logger ctxt ~cached_script mode + step_constant ~script ~entrypoint loc ~parameter_ty ~parameter ~internal] + interprets the [script]'s [entrypoint] for a given (typed) [parameter]. + + See {!execute} for more details about the function's arguments. +*) +val execute_with_typed_parameter : + ?logger:logger -> + Alpha_context.context -> + cached_script:Script_ir_translator.ex_script option -> + Script_ir_translator.unparsing_mode -> + step_constants -> + script:Script.t -> + entrypoint:Entrypoint.t -> + parameter_ty:'a Script_typed_ir.ty -> + location:Script.location -> + parameter:'a -> + internal:bool -> + (execution_result * context) tzresult Lwt.t (** [kstep logger ctxt step_constants kinstr accu stack] interprets the script represented by [kinstr] under the context [ctxt]. This will diff --git a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml index bbd7c5a8a457546f8f563a33b094062f6f55089b..2bd9dbf35d27aa8a6217598aeb3252a7598ea5eb 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml @@ -500,11 +500,12 @@ let apply ctxt gas capture_ty capture lam = let (gas, ctxt) = local_gas_counter_and_outdated_context ctxt in return (lam', ctxt, gas) -(* [transfer (ctxt, sc) gas tez tp p destination entrypoint] +(* [transfer (ctxt, sc) gas tez parameters_ty parameters destination entrypoint] creates an operation that transfers an amount of [tez] to a contract determined by [(destination, entrypoint)] - instantiated with argument [p] of type [tp]. *) -let transfer (ctxt, sc) gas amount tp p destination entrypoint = + instantiated with argument [parameters] of type [parameters_ty]. *) +let transfer (ctxt, sc) gas amount location parameters_ty parameters destination + entrypoint = (* [craft_transfer_parameters ctxt tp p] reorganizes, if need be, the parameters submitted by the interpreter to prepare them for the [Transaction] operation. *) @@ -548,28 +549,32 @@ let transfer (ctxt, sc) gas amount tp p destination entrypoint = in let ctxt = update_context gas ctxt in - collect_lazy_storage ctxt tp p >>?= fun (to_duplicate, ctxt) -> + collect_lazy_storage ctxt parameters_ty parameters + >>?= fun (to_duplicate, ctxt) -> let to_update = no_lazy_storage_id in extract_lazy_storage_diff ctxt Optimized - tp - p + parameters_ty + parameters ~to_duplicate ~to_update ~temporary:true - >>=? fun (p, lazy_storage_diff, ctxt) -> - unparse_data ctxt Optimized tp p >>=? fun (p, ctxt) -> - Gas.consume ctxt (Script.strip_locations_cost p) >>?= fun ctxt -> - craft_transfer_parameters ctxt tp p destination >>?= fun (p, ctxt) -> + >>=? fun (parameters, lazy_storage_diff, ctxt) -> + unparse_data ctxt Optimized parameters_ty parameters + >>=? fun (unparsed_parameters, ctxt) -> + Gas.consume ctxt (Script.strip_locations_cost unparsed_parameters) + >>?= fun ctxt -> + craft_transfer_parameters ctxt parameters_ty unparsed_parameters destination + >>?= fun (unparsed_parameters, ctxt) -> + let transaction = + let parameters = + Script.lazy_expr (Micheline.strip_locations unparsed_parameters) + in + {amount; destination; entrypoint; parameters} + in let operation = - Transaction - { - amount; - destination; - entrypoint; - parameters = Script.lazy_expr (Micheline.strip_locations p); - } + Transaction {transaction; location; parameters_ty; parameters} in fresh_internal_nonce ctxt >>?= fun (ctxt, nonce) -> let iop = {source = sc.self; operation; nonce} in diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.ml b/src/proto_alpha/lib_protocol/script_typed_ir.ml index 98c5c1849ffc1b2bef0082fc5e9cfc4996154f05..38aeb1b605f2c1de83c3c0705a415c5de5f79316 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.ml +++ b/src/proto_alpha/lib_protocol/script_typed_ir.ml @@ -1349,8 +1349,12 @@ and ('input, 'output) view_signature = -> ('input, 'output) view_signature and 'kind manager_operation = - | Transaction : - Alpha_context.transaction + | Transaction : { + transaction : Alpha_context.transaction; + location : Script.location; + parameters_ty : 'a ty; + parameters : 'a; + } -> Kind.transaction manager_operation | Origination : Alpha_context.origination diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.mli b/src/proto_alpha/lib_protocol/script_typed_ir.mli index 05a9e889c05d1c6d33657be08900bc775b81e879..d7e8496272e2148f6927a05e5babb3b971d9898e 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.mli +++ b/src/proto_alpha/lib_protocol/script_typed_ir.mli @@ -1487,8 +1487,17 @@ and ('input, 'output) view_signature = -> ('input, 'output) view_signature and 'kind manager_operation = - | Transaction : - Alpha_context.transaction + | Transaction : { + (* The [transaction.parameters] field may seem useless since we have + access to a typed version of the field (with [parameters_ty] and + [parameters]), but we keep it so that we do not have to unparse the + typed version in order to produce the receipt + ([Apply_results.internal_manager_operation]). *) + transaction : Alpha_context.transaction; + location : Script.location; + parameters_ty : 'a ty; + parameters : 'a; + } -> Kind.transaction manager_operation | Origination : Alpha_context.origination diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_accounting.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_accounting.ml index a6076037f8eb2ff448d1f76f3d4dd8391cbb5b17..86c5c4002d72b6c21b58fc5dee2443d46dda7c8d 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_accounting.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_accounting.ml @@ -372,11 +372,17 @@ let transfer_operation ctxt ~src ~destination ~arg_type ~arg = operation = Transaction { - amount = Tez.zero; - parameters = - Script.lazy_expr @@ Micheline.strip_locations params_node; - entrypoint = Entrypoint.default; - destination = Destination.Contract destination; + transaction = + { + amount = Tez.zero; + parameters = + Script.lazy_expr @@ Micheline.strip_locations params_node; + entrypoint = Entrypoint.default; + destination = Destination.Contract destination; + }; + location = Micheline.dummy_location; + parameters_ty = arg_type; + parameters = arg; }; nonce = 1; }, diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_operations_diff.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_operations_diff.ml index e5745ccabecaf2a50c83b943f76fd66a78648070..04e7b5ca8f9d45d6c8977557a5bce0967d3717cd 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_operations_diff.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_operations_diff.ml @@ -34,6 +34,7 @@ open Protocol open Alpha_context +open Script_typed_ir (** A local non-private type that mirrors [Ticket_operations_diff.ticket_token_diff]. *) @@ -259,20 +260,40 @@ let originate block ~src ~baker ~script ~storage ~forges_tickets = in return (orig_contract, incr) -let transfer_operation ~src ~destination ~parameters = - Script_typed_ir.Internal_operation - { - source = src; - operation = - Transaction - { - amount = Tez.zero; - parameters = Script.lazy_expr @@ Expr.from_string parameters; - entrypoint = Entrypoint.default; - destination = Destination.Contract destination; - }; - nonce = 1; - } +let transfer_operation ~incr ~src ~destination ~parameters_ty ~parameters = + let open Lwt_tzresult_syntax in + let ctxt = Incremental.alpha_ctxt incr in + let* (params_node, ctxt) = + wrap + (Script_ir_translator.unparse_data + ctxt + Script_ir_translator.Readable + parameters_ty + parameters) + in + let incr = Incremental.set_alpha_ctxt incr ctxt in + return + ( Script_typed_ir.Internal_operation + { + source = src; + operation = + Transaction + { + transaction = + { + amount = Tez.zero; + parameters = + Script.lazy_expr @@ Micheline.strip_locations params_node; + entrypoint = Entrypoint.default; + destination = Destination.Contract destination; + }; + location = Micheline.dummy_location; + parameters_ty; + parameters; + }; + nonce = 1; + }, + incr ) let ticket_diffs_of_operations incr operations = wrap @@ -301,6 +322,24 @@ let ticket_big_map_script = code { CAR; NIL operation ; PAIR } } |} +let list_ticket_string_ty = + ticket_t Micheline.dummy_location string_key >>? fun ticket_ty -> + list_t Micheline.dummy_location ticket_ty + +let make_ticket (ticketer, contents, amount) = + Script_string.of_string contents >>?= fun contents -> + return {ticketer; contents; amount = nat amount} + +let make_tickets ts = + let* elements = List.map_es make_ticket ts in + return {elements; length = List.length elements} + +let transfer_tickets_operation ~incr ~src ~destination tickets = + let open Lwt_tzresult_syntax in + let*? parameters_ty = Environment.wrap_tzresult list_ticket_string_ty in + let* parameters = wrap @@ make_tickets tickets in + transfer_operation ~incr ~src ~destination ~parameters_ty ~parameters + (** Test that no tickets are returned for operations that do not contain tickets. *) let test_non_ticket_operations () = @@ -322,8 +361,13 @@ let test_transfer_to_non_ticket_contract () = ~storage:"Unit" ~forges_tickets:false in - let operation = - transfer_operation ~src ~destination:orig_contract ~parameters:"Unit" + let* (operation, incr) = + transfer_operation + ~incr + ~src + ~destination:orig_contract + ~parameters_ty:unit_t + ~parameters:() in let* (ticket_diffs, ctxt) = ticket_diffs_of_operations incr [operation] in assert_equal_ticket_token_diffs ctxt ~loc:__LOC__ ticket_diffs ~expected:[] @@ -340,8 +384,8 @@ let test_transfer_empty_ticket_list () = ~storage:"{}" ~forges_tickets:false in - let operation = - transfer_operation ~src ~destination:orig_contract ~parameters:"{}" + let* (operation, incr) = + transfer_tickets_operation ~incr ~src ~destination:orig_contract [] in let* (ticket_diffs, ctxt) = ticket_diffs_of_operations incr [operation] in assert_equal_ticket_token_diffs ctxt ~loc:__LOC__ ticket_diffs ~expected:[] @@ -359,11 +403,12 @@ let test_transfer_one_ticket () = ~storage:"{}" ~forges_tickets:false in - let parameters = - Printf.sprintf {|{Pair %S "white" 1}|} (Contract.to_b58check ticketer) - in - let operation = - transfer_operation ~src ~destination:orig_contract ~parameters + let* (operation, incr) = + transfer_tickets_operation + ~incr + ~src + ~destination:orig_contract + [(ticketer, "white", 1)] in let* (ticket_diffs, ctxt) = ticket_diffs_of_operations incr [operation] in assert_equal_ticket_token_diffs @@ -392,22 +437,17 @@ let test_transfer_multiple_tickets () = ~storage:"{}" ~forges_tickets:false in - let operation = - let parameters = - let ticketer_addr = Contract.to_b58check ticketer in - Printf.sprintf - {|{ - Pair %S "red" 1; - Pair %S "blue" 2 ; - Pair %S "green" 3; - Pair %S "red" 4;} - |} - ticketer_addr - ticketer_addr - ticketer_addr - ticketer_addr - in - transfer_operation ~src ~destination:orig_contract ~parameters + let* (operation, incr) = + transfer_tickets_operation + ~incr + ~src + ~destination:orig_contract + [ + (ticketer, "red", 1); + (ticketer, "blue", 2); + (ticketer, "green", 3); + (ticketer, "red", 4); + ] in let* (ticket_diffs, ctxt) = ticket_diffs_of_operations incr [operation] in assert_equal_ticket_token_diffs @@ -437,31 +477,6 @@ let test_transfer_multiple_tickets () = let test_transfer_different_tickets () = let* (baker, src, block) = init () in let* (ticketer1, ticketer2) = two_ticketers block in - let parameters = - let ticketer1_addr = Contract.to_b58check ticketer1 in - let ticketer2_addr = Contract.to_b58check ticketer2 in - Printf.sprintf - {|{ - Pair %S "red" 1; - Pair %S "green" 1; - Pair %S "blue" 1; - Pair %S "red" 1; - Pair %S "green" 1; - Pair %S "blue" 1 ; - Pair %S "red" 1; - Pair %S "green" 1; - Pair %S "blue" 1; } - |} - ticketer1_addr - ticketer1_addr - ticketer1_addr - ticketer2_addr - ticketer2_addr - ticketer2_addr - ticketer1_addr - ticketer1_addr - ticketer1_addr - in let* (destination, incr) = originate block @@ -471,7 +486,23 @@ let test_transfer_different_tickets () = ~storage:"{}" ~forges_tickets:false in - let operation = transfer_operation ~src ~destination ~parameters in + let* (operation, incr) = + transfer_tickets_operation + ~incr + ~src + ~destination + [ + (ticketer1, "red", 1); + (ticketer1, "green", 1); + (ticketer1, "blue", 1); + (ticketer2, "red", 1); + (ticketer2, "green", 1); + (ticketer2, "blue", 1); + (ticketer1, "red", 1); + (ticketer1, "green", 1); + (ticketer1, "blue", 1); + ] + in let* (ticket_diffs, ctxt) = ticket_diffs_of_operations incr [operation] in assert_equal_ticket_token_diffs ctxt @@ -516,12 +547,7 @@ let test_transfer_to_two_contracts_with_different_tickets () = let* (baker, src, block) = init () in let* ticketer = one_ticketer block in let parameters = - let ticketer_addr = Contract.to_b58check ticketer in - Printf.sprintf - {|{Pair %S "red" 1; Pair %S "green" 1; Pair %S "blue" 1; }|} - ticketer_addr - ticketer_addr - ticketer_addr + [(ticketer, "red", 1); (ticketer, "green", 1); (ticketer, "blue", 1)] in let* (destination1, incr) = originate @@ -532,8 +558,8 @@ let test_transfer_to_two_contracts_with_different_tickets () = ~storage:"{}" ~forges_tickets:false in - let operation1 = - transfer_operation ~src ~destination:destination1 ~parameters + let* (operation1, incr) = + transfer_tickets_operation ~incr ~src ~destination:destination1 parameters in let* block = Incremental.finalize_block incr in let* (destination2, incr) = @@ -545,8 +571,8 @@ let test_transfer_to_two_contracts_with_different_tickets () = ~storage:"{}" ~forges_tickets:false in - let operation2 = - transfer_operation ~src ~destination:destination2 ~parameters + let* (operation2, incr) = + transfer_tickets_operation ~incr ~src ~destination:destination2 parameters in let* (ticket_diffs, ctxt) = ticket_diffs_of_operations incr [operation1; operation2] @@ -851,15 +877,12 @@ let test_originate_and_transfer () = ~storage:"{}" ~forges_tickets:false in - let parameters = - Printf.sprintf - {|{Pair %S "red" 1; Pair %S "green" 1; Pair %S "blue" 1; }|} - ticketer_addr - ticketer_addr - ticketer_addr - in - let operation2 = - transfer_operation ~src ~destination:destination2 ~parameters + let* (operation2, incr) = + transfer_tickets_operation + ~incr + ~src + ~destination:destination2 + [(ticketer, "red", 1); (ticketer, "green", 1); (ticketer, "blue", 1)] in let* (ticket_diffs, ctxt) = ticket_diffs_of_operations incr [operation1; operation2] @@ -976,13 +999,29 @@ let test_transfer_big_map_with_tickets () = ~storage:"{}" ~forges_tickets:false in + let open Lwt_tzresult_syntax in + let*? value_type = + Environment.wrap_tzresult @@ ticket_t Micheline.dummy_location string_key + in + let*? parameters_ty = + Environment.wrap_tzresult + @@ big_map_t Micheline.dummy_location int_key value_type + in let parameters = - Printf.sprintf "%d" @@ Z.to_int (Big_map.Id.unparse_to_z big_map_id) + Big_map + { + id = Some big_map_id; + diff = {map = Big_map_overlay.empty; size = 0}; + key_type = int_key; + value_type; + } in - let operation = + let* (operation, incr) = transfer_operation + ~incr ~src:ticketer_contract ~destination:orig_contract + ~parameters_ty ~parameters in let* (ticket_diffs, ctxt) = ticket_diffs_of_operations incr [operation] in diff --git a/src/proto_alpha/lib_protocol/ticket_operations_diff.ml b/src/proto_alpha/lib_protocol/ticket_operations_diff.ml index 061acd015468b53fe825baebaf77d3c756866496..25810b64df277d8ab7cfac46fda7cb789c969688 100644 --- a/src/proto_alpha/lib_protocol/ticket_operations_diff.ml +++ b/src/proto_alpha/lib_protocol/ticket_operations_diff.ml @@ -149,14 +149,28 @@ let parse_and_cache_script ctxt ~destination ~get_non_cached_script = Script_cache.insert ctxt destination (script, ex_script) size >>?= fun ctxt -> return (ex_script, ctxt) -let tickets_of_transaction ctxt ~destination ~parameters ~entrypoint = +let cast_transaction_parameter (type a b) ctxt location + (entry_arg_ty : a Script_typed_ir.ty) (parameters_ty : b Script_typed_ir.ty) + (parameters : b) : (a * context) tzresult Lwt.t = + Gas_monad.run + ctxt + (Script_ir_translator.ty_eq + ~error_details:Informative + location + entry_arg_ty + parameters_ty) + >>?= fun (res, ctxt) -> + res >>?= fun Script_ir_translator.Eq -> return ((parameters : a), ctxt) + +let tickets_of_transaction ctxt ~destination ~entrypoint ~location + ~parameters_ty ~parameters = match Contract.is_implicit destination with | Some _ -> return (None, ctxt) | None -> - (* TODO: #2351 + (* TODO: #2653 Avoid having to load the script from the cache. - After internal operations are in place we should be able to use the - typed script directly. + This is currently in place to avoid regressions for type-checking + errors. We should be able to remove it. *) parse_and_cache_script ctxt @@ -181,22 +195,20 @@ let tickets_of_transaction ctxt ~destination ~parameters ~entrypoint = res >>?= fun (Ex_ty_cstr (entry_arg_ty, _f)) -> Ticket_scanner.type_has_tickets ctxt entry_arg_ty >>?= fun (has_tickets, ctxt) -> - (* Load the tickets from the parameters. *) - (* TODO: #2350 - Avoid having to decode and parse the [parameters] node. - After internal operations are in place we should be able to use the - typed script directly. - *) - Script.force_decode_in_context + (* Check that the parameter's type matches that of the entry-point, and + cast the parameter if this is the case. *) + cast_transaction_parameter ctxt - ~consume_deserialization_gas:When_needed + location + entry_arg_ty + parameters_ty parameters - >>?= fun (expr, ctxt) -> - Ticket_scanner.tickets_of_node + >>=? fun (parameters, ctxt) -> + Ticket_scanner.tickets_of_value ~include_lazy:true ctxt has_tickets - (Micheline.root expr) + parameters >>=? fun (tickets, ctxt) -> return (Some {destination; tickets}, ctxt) (** Extract tickets of an origination operation by scanning the storage. *) @@ -247,13 +259,25 @@ let tickets_of_operation ctxt match operation with | Transaction { - amount = _; + transaction = + { + amount = _; + parameters = _; + entrypoint; + destination = Destination.Contract destination; + }; + location; + parameters_ty; parameters; - entrypoint; - destination = Destination.Contract destination; } -> - tickets_of_transaction ctxt ~destination ~parameters ~entrypoint - | Transaction {destination = Destination.Tx_rollup _; _} -> + tickets_of_transaction + ctxt + ~destination + ~entrypoint + ~location + ~parameters_ty + ~parameters + | Transaction {transaction = {destination = Destination.Tx_rollup _; _}; _} -> (* TODO: #2488 The ticket accounting for the recipient of rollup transactions is currently done in the apply function, but should rather be diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestSelfAddressTransfer::test_send_self_address.out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestSelfAddressTransfer::test_send_self_address.out index aacbe58ac6b420b1114d87ac0ab36f95cdbfb789..ba446f3e7d4a2b709cef42fdd048b43737a00c4b 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestSelfAddressTransfer::test_send_self_address.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestSelfAddressTransfer::test_send_self_address.out @@ -1,7 +1,7 @@ tests_alpha/test_contract.py::TestSelfAddressTransfer::test_send_self_address Node is bootstrapped. -Estimated gas: 5195.305 units (will add 100 for safety) +Estimated gas: 5195.785 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. Operation hash is '[BLOCK_HASH]' @@ -27,7 +27,7 @@ This sequence of operations was run: This transaction was successfully applied Updated storage: Unit Storage size: 82 bytes - Consumed gas: 3990.539 + Consumed gas: 3991.559 Internal operations: Transaction: Amount: ꜩ0 @@ -37,6 +37,6 @@ This sequence of operations was run: This transaction was successfully applied Updated storage: Unit Storage size: 83 bytes - Consumed gas: 1204.766 + Consumed gas: 1204.226 Injected block at minimal timestamp diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_source.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_source.out index 0b389ee474653bf7a2347b65cd5732127c5fe7b2..2e4c88afa6d4dbd43e57bbcb1b780a29cd730a03 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_source.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_source.out @@ -78,7 +78,7 @@ Injected block at minimal timestamp [CONTRACT_HASH] Node is bootstrapped. -Estimated gas: 4341.193 units (will add 100 for safety) +Estimated gas: 4341.893 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. Operation hash is '[BLOCK_HASH]' @@ -104,7 +104,7 @@ This sequence of operations was run: This transaction was successfully applied Updated storage: Unit Storage size: 55 bytes - Consumed gas: 3127.533 + Consumed gas: 3128.113 Internal operations: Transaction: Amount: ꜩ0 @@ -113,7 +113,7 @@ This sequence of operations was run: This transaction was successfully applied Updated storage: 0x0000e7670f32038107a59a2b9cfefae36ea21f5aa63c Storage size: 65 bytes - Consumed gas: 1213.660 + Consumed gas: 1213.780 Injected block at minimal timestamp "[CONTRACT_HASH]" diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_transfer_tokens.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_transfer_tokens.out index 10c08220eea03e84ac947f5c1223fb96c53e2998..b2eea45973406861f884e6d80685138a4a72df0a 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_transfer_tokens.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_transfer_tokens.out @@ -143,7 +143,7 @@ Injected block at minimal timestamp [CONTRACT_HASH] Node is bootstrapped. -Estimated gas: 5179.356 units (will add 100 for safety) +Estimated gas: 5180.056 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. Operation hash is '[BLOCK_HASH]' @@ -154,13 +154,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [CONTRACT_HASH] - Fee to the baker: ꜩ0.000825 + Fee to the baker: ꜩ0.000826 Expected counter: [EXPECTED_COUNTER] - Gas limit: 5280 + Gas limit: 5281 Storage limit: 0 bytes Balance updates: - [CONTRACT_HASH] ... -ꜩ0.000825 - payload fees(the block proposer) ....... +ꜩ0.000825 + [CONTRACT_HASH] ... -ꜩ0.000826 + payload fees(the block proposer) ....... +ꜩ0.000826 Transaction: Amount: ꜩ100 From: [CONTRACT_HASH] @@ -169,7 +169,7 @@ This sequence of operations was run: This transaction was successfully applied Updated storage: Unit Storage size: 66 bytes - Consumed gas: 3975.931 + Consumed gas: 3976.511 Balance updates: [CONTRACT_HASH] ... -ꜩ100 [CONTRACT_HASH] ... +ꜩ100 @@ -181,7 +181,7 @@ This sequence of operations was run: This transaction was successfully applied Updated storage: Unit Storage size: 38 bytes - Consumed gas: 1203.425 + Consumed gas: 1203.545 Balance updates: [CONTRACT_HASH] ... -ꜩ100 [CONTRACT_HASH] ... +ꜩ100 @@ -191,7 +191,7 @@ Injected block at minimal timestamp [CONTRACT_HASH] Node is bootstrapped. -Estimated gas: 4326.329 units (will add 100 for safety) +Estimated gas: 4327.029 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. Operation hash is '[BLOCK_HASH]' @@ -204,7 +204,7 @@ This sequence of operations was run: From: [CONTRACT_HASH] Fee to the baker: ꜩ0.00074 Expected counter: [EXPECTED_COUNTER] - Gas limit: 4427 + Gas limit: 4428 Storage limit: 0 bytes Balance updates: [CONTRACT_HASH] ... -ꜩ0.00074 @@ -217,7 +217,7 @@ This sequence of operations was run: This transaction was successfully applied Updated storage: Unit Storage size: 66 bytes - Consumed gas: 3122.904 + Consumed gas: 3123.484 Balance updates: [CONTRACT_HASH] ... -ꜩ100 [CONTRACT_HASH] ... +ꜩ100 @@ -229,7 +229,7 @@ This sequence of operations was run: This transaction was successfully applied Updated storage: Unit Storage size: 38 bytes - Consumed gas: 1203.425 + Consumed gas: 1203.545 Balance updates: [CONTRACT_HASH] ... -ꜩ100 [CONTRACT_HASH] ... +ꜩ100 diff --git a/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestAddApproveTransferRemove::test_add_liquidity.out b/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestAddApproveTransferRemove::test_add_liquidity.out index e9ae9c33a18da0a299b95352c42d5a07f19e8903..6c341efec4dde433637f05e245e9710b1c4c0eb7 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestAddApproveTransferRemove::test_add_liquidity.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestAddApproveTransferRemove::test_add_liquidity.out @@ -1,7 +1,7 @@ tests_alpha/test_liquidity_baking.py::TestAddApproveTransferRemove::test_add_liquidity Node is bootstrapped. -Estimated gas: 11830.290 units (will add 100 for safety) +Estimated gas: 9883.730 units (will add 100 for safety) Estimated storage: 141 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[BLOCK_HASH]' @@ -12,13 +12,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [CONTRACT_HASH] - Fee to the baker: ꜩ0.001549 + Fee to the baker: ꜩ0.001354 Expected counter: [EXPECTED_COUNTER] - Gas limit: 11931 + Gas limit: 9984 Storage limit: 161 bytes Balance updates: - [CONTRACT_HASH] ... -ꜩ0.001549 - payload fees(the block proposer) ....... +ꜩ0.001549 + [CONTRACT_HASH] ... -ꜩ0.001354 + payload fees(the block proposer) ....... +ꜩ0.001354 Transaction: Amount: ꜩ9001 From: [CONTRACT_HASH] @@ -34,7 +34,7 @@ This sequence of operations was run: 0x0115eb0104481a6d7921160bc982c5e0a561cd8a3a00 } Storage size: 4633 bytes Paid storage size diff: 3 bytes - Consumed gas: 5089.049 + Consumed gas: 5091.529 Balance updates: [CONTRACT_HASH] ... -ꜩ0.00075 storage fees ........................... +ꜩ0.00075 @@ -58,7 +58,7 @@ This sequence of operations was run: Set map(0)[0x01d496def47a3be89f5d54c6e6bb13cc6645d6e16600] to 721 Storage size: 2263 bytes Paid storage size diff: 68 bytes - Consumed gas: 4396.576 + Consumed gas: 3097.176 Balance updates: [CONTRACT_HASH] ... -ꜩ0.017 storage fees ........................... +ꜩ0.017 @@ -75,7 +75,7 @@ This sequence of operations was run: Set map(2)[0x000002298c03ed7d454a101eb7022bc95f7e5f41ac78] to 72007 Storage size: 2048 bytes Paid storage size diff: 70 bytes - Consumed gas: 2344.665 + Consumed gas: 1695.025 Balance updates: [CONTRACT_HASH] ... -ꜩ0.0175 storage fees ........................... +ꜩ0.0175 diff --git a/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestAddApproveTransferRemove::test_remove_liquidity.out b/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestAddApproveTransferRemove::test_remove_liquidity.out index ed478c3e5efa9c39f7caf2b52e4cb15e9354e9bd..60f287e1ce240856ed020eb0a35784e5deb1d577 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestAddApproveTransferRemove::test_remove_liquidity.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestAddApproveTransferRemove::test_remove_liquidity.out @@ -1,7 +1,7 @@ tests_alpha/test_liquidity_baking.py::TestAddApproveTransferRemove::test_remove_liquidity Node is bootstrapped. -Estimated gas: 10541.746 units (will add 100 for safety) +Estimated gas: 8595.186 units (will add 100 for safety) Estimated storage: 67 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[BLOCK_HASH]' @@ -12,13 +12,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [CONTRACT_HASH] - Fee to the baker: ꜩ0.001417 + Fee to the baker: ꜩ0.001222 Expected counter: [EXPECTED_COUNTER] - Gas limit: 10642 + Gas limit: 8696 Storage limit: 87 bytes Balance updates: - [CONTRACT_HASH] ... -ꜩ0.001417 - payload fees(the block proposer) ....... +ꜩ0.001417 + [CONTRACT_HASH] ... -ꜩ0.001222 + payload fees(the block proposer) ....... +ꜩ0.001222 Transaction: Amount: ꜩ0 From: [CONTRACT_HASH] @@ -33,7 +33,7 @@ This sequence of operations was run: 0x01e927f00ef734dfc85919635e9afc9166c83ef9fc00 ; 0x0115eb0104481a6d7921160bc982c5e0a561cd8a3a00 } Storage size: 4633 bytes - Consumed gas: 2917.676 + Consumed gas: 2920.156 Internal operations: Transaction: Amount: ꜩ0 @@ -47,7 +47,7 @@ This sequence of operations was run: Updated big_maps: Unset map(2)[0x0000e7670f32038107a59a2b9cfefae36ea21f5aa63c] Storage size: 2048 bytes - Consumed gas: 2524.739 + Consumed gas: 1875.099 Transaction: Amount: ꜩ0 From: [CONTRACT_HASH] @@ -63,7 +63,7 @@ This sequence of operations was run: Set map(0)[0x0000e7670f32038107a59a2b9cfefae36ea21f5aa63c] to 10 Storage size: 2330 bytes Paid storage size diff: 67 bytes - Consumed gas: 3679.331 + Consumed gas: 2379.931 Balance updates: [CONTRACT_HASH] ... -ꜩ0.01675 storage fees ........................... +ꜩ0.01675 diff --git a/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_add_liquidity.out b/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_add_liquidity.out index c0262d3a125e5ee1addd19f151fe6c919eaa702e..bf6e975dd8e5bb71e4c558e7f35b75d6daf03d03 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_add_liquidity.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_add_liquidity.out @@ -1,7 +1,7 @@ tests_alpha/test_liquidity_baking.py::TestTrades::test_add_liquidity Node is bootstrapped. -Estimated gas: 11830.290 units (will add 100 for safety) +Estimated gas: 9883.730 units (will add 100 for safety) Estimated storage: 141 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[BLOCK_HASH]' @@ -12,13 +12,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [CONTRACT_HASH] - Fee to the baker: ꜩ0.001549 + Fee to the baker: ꜩ0.001354 Expected counter: [EXPECTED_COUNTER] - Gas limit: 11931 + Gas limit: 9984 Storage limit: 161 bytes Balance updates: - [CONTRACT_HASH] ... -ꜩ0.001549 - payload fees(the block proposer) ....... +ꜩ0.001549 + [CONTRACT_HASH] ... -ꜩ0.001354 + payload fees(the block proposer) ....... +ꜩ0.001354 Transaction: Amount: ꜩ9001 From: [CONTRACT_HASH] @@ -34,7 +34,7 @@ This sequence of operations was run: 0x0115eb0104481a6d7921160bc982c5e0a561cd8a3a00 } Storage size: 4633 bytes Paid storage size diff: 3 bytes - Consumed gas: 5089.049 + Consumed gas: 5091.529 Balance updates: [CONTRACT_HASH] ... -ꜩ0.00075 storage fees ........................... +ꜩ0.00075 @@ -58,7 +58,7 @@ This sequence of operations was run: Set map(0)[0x01d496def47a3be89f5d54c6e6bb13cc6645d6e16600] to 721 Storage size: 2263 bytes Paid storage size diff: 68 bytes - Consumed gas: 4396.576 + Consumed gas: 3097.176 Balance updates: [CONTRACT_HASH] ... -ꜩ0.017 storage fees ........................... +ꜩ0.017 @@ -75,7 +75,7 @@ This sequence of operations was run: Set map(2)[0x000002298c03ed7d454a101eb7022bc95f7e5f41ac78] to 72007 Storage size: 2048 bytes Paid storage size diff: 70 bytes - Consumed gas: 2344.665 + Consumed gas: 1695.025 Balance updates: [CONTRACT_HASH] ... -ꜩ0.0175 storage fees ........................... +ꜩ0.0175 diff --git a/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_buy_tok.out b/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_buy_tok.out index 6bc37f131318a4cc959899a3ac57f25ddc5ca04d..8b0d852194af4cbbc3e34d9a0a51d28f3857b4df 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_buy_tok.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_buy_tok.out @@ -1,7 +1,7 @@ tests_alpha/test_liquidity_baking.py::TestTrades::test_buy_tok Node is bootstrapped. -Estimated gas: 7504.968 units (will add 100 for safety) +Estimated gas: 6207.028 units (will add 100 for safety) Estimated storage: 326 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[BLOCK_HASH]' @@ -12,13 +12,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [CONTRACT_HASH] - Fee to the baker: ꜩ0.001108 + Fee to the baker: ꜩ0.000978 Expected counter: [EXPECTED_COUNTER] - Gas limit: 7605 + Gas limit: 6308 Storage limit: 346 bytes Balance updates: - [CONTRACT_HASH] ... -ꜩ0.001108 - payload fees(the block proposer) ....... +ꜩ0.001108 + [CONTRACT_HASH] ... -ꜩ0.000978 + payload fees(the block proposer) ....... +ꜩ0.000978 Transaction: Amount: ꜩ9001 From: [CONTRACT_HASH] @@ -34,7 +34,7 @@ This sequence of operations was run: 0x0115eb0104481a6d7921160bc982c5e0a561cd8a3a00 } Storage size: 4634 bytes Paid storage size diff: 1 bytes - Consumed gas: 2405.633 + Consumed gas: 2407.093 Balance updates: [CONTRACT_HASH] ... -ꜩ0.00025 storage fees ........................... +ꜩ0.00025 @@ -56,7 +56,7 @@ This sequence of operations was run: Set map(0)[0x0000e7670f32038107a59a2b9cfefae36ea21f5aa63c] to 360 Storage size: 2331 bytes Paid storage size diff: 68 bytes - Consumed gas: 3679.335 + Consumed gas: 2379.935 Balance updates: [CONTRACT_HASH] ... -ꜩ0.017 storage fees ........................... +ꜩ0.017 diff --git a/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_sell_tok.out b/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_sell_tok.out index 8aa45e2468de512f1a89035d09690a4d9d2db8a3..26eb5380491698b406da1b10cb1855e8c2d0d1c0 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_sell_tok.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_liquidity_baking.TestTrades::test_sell_tok.out @@ -1,7 +1,7 @@ tests_alpha/test_liquidity_baking.py::TestTrades::test_sell_tok Node is bootstrapped. -Estimated gas: 9823.364 units (will add 100 for safety) +Estimated gas: 8525.424 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. Operation hash is '[BLOCK_HASH]' @@ -12,13 +12,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [CONTRACT_HASH] - Fee to the baker: ꜩ0.001338 + Fee to the baker: ꜩ0.001208 Expected counter: [EXPECTED_COUNTER] - Gas limit: 9924 + Gas limit: 8626 Storage limit: 0 bytes Balance updates: - [CONTRACT_HASH] ... -ꜩ0.001338 - payload fees(the block proposer) ....... +ꜩ0.001338 + [CONTRACT_HASH] ... -ꜩ0.001208 + payload fees(the block proposer) ....... +ꜩ0.001208 Transaction: Amount: ꜩ0 From: [CONTRACT_HASH] @@ -33,7 +33,7 @@ This sequence of operations was run: 0x01e927f00ef734dfc85919635e9afc9166c83ef9fc00 ; 0x0115eb0104481a6d7921160bc982c5e0a561cd8a3a00 } Storage size: 4633 bytes - Consumed gas: 2406.752 + Consumed gas: 2408.212 Internal operations: Transaction: Amount: ꜩ0 @@ -51,7 +51,7 @@ This sequence of operations was run: Unset map(0)[0x0000dac9f52543da1aed0bc1d6b46bf7c10db7014cd6] Set map(0)[0x01d496def47a3be89f5d54c6e6bb13cc6645d6e16600] to 461 Storage size: 2331 bytes - Consumed gas: 4576.612 + Consumed gas: 3277.212 Transaction: Amount: ꜩ3891.966034 From: [CONTRACT_HASH]