diff --git a/src/proto_alpha/lib_plugin/view_helpers.ml b/src/proto_alpha/lib_plugin/view_helpers.ml index b04bbcaf9f1f1b4ad40b56080a08c3ca12306725..29074e758af2ee0038718c3af0a8c439894f446b 100644 --- a/src/proto_alpha/lib_plugin/view_helpers.ml +++ b/src/proto_alpha/lib_plugin/view_helpers.ml @@ -220,9 +220,9 @@ let extract_parameter_from_operations entrypoint operations callback = Script_typed_ir.Internal_operation { operation = - Transaction_to_contract + Transaction_to_smart_contract { - destination = Originated destination; + destination; unparsed_parameters; entrypoint = _; amount = _; diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index c9c5fe2456a842f3c5ff4d41ae3f7e596d08434b..3462c7fb0d97a24d59a7a2a42a971948946e78ae 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1098,9 +1098,9 @@ let apply_internal_manager_operation_content : comparing it with the [ctxt] we will have at the end of the application). *) match operation with - | Transaction_to_contract + | Transaction_to_implicit { - destination = Implicit pkh; + destination = pkh; amount; unparsed_parameters = _; entrypoint; @@ -1121,10 +1121,10 @@ let apply_internal_manager_operation_content : (ITransaction_result res : kind successful_internal_manager_operation_result), ops ) - | Transaction_to_contract + | Transaction_to_smart_contract { amount; - destination = Originated contract_hash; + destination = contract_hash; entrypoint; location; parameters_ty; @@ -1406,44 +1406,44 @@ let apply_external_manager_operation_content : } in return (ctxt, result, []) - | Transfer_ticket {contents; ty; ticketer; amount; destination; entrypoint} -> + | Transfer_ticket {contents; ty; ticketer; amount; destination; entrypoint} + -> ( (* The encoding ensures that the amount is in a natural number. Here is mainly to check that it is non-zero.*) error_when Compare.Z.(amount <= Z.zero) Ticket_scanner.Forbidden_zero_ticket_quantity >>?= fun () -> - error_when - (match destination with Implicit _ -> true | Originated _ -> false) - Cannot_transfer_ticket_to_implicit - >>?= fun () -> - Tx_rollup_ticket.parse_ticket_and_operation - ~consume_deserialization_gas - ~ticketer - ~contents - ~ty - ~source:source_contract - ~destination - ~entrypoint - ~amount - ctxt - >>=? fun (ctxt, ticket_token, op) -> - Tx_rollup_ticket.transfer_ticket - ctxt - ~src:(Contract source_contract) - ~dst:(Contract destination) - ticket_token - amount - >>=? fun (ctxt, paid_storage_size_diff) -> - let result = - Transfer_ticket_result - { - balance_updates = []; - consumed_gas = Gas.consumed ~since:ctxt_before_op ~until:ctxt; - paid_storage_size_diff; - } - in - return (ctxt, result, [op]) + match destination with + | Implicit _ -> fail Cannot_transfer_ticket_to_implicit + | Originated destination_hash -> + Tx_rollup_ticket.parse_ticket_and_operation + ~consume_deserialization_gas + ~ticketer + ~contents + ~ty + ~source:source_contract + ~destination:destination_hash + ~entrypoint + ~amount + ctxt + >>=? fun (ctxt, ticket_token, op) -> + Tx_rollup_ticket.transfer_ticket + ctxt + ~src:(Contract source_contract) + ~dst:(Contract destination) + ticket_token + amount + >>=? fun (ctxt, paid_storage_size_diff) -> + let result = + Transfer_ticket_result + { + balance_updates = []; + consumed_gas = Gas.consumed ~since:ctxt_before_op ~until:ctxt; + paid_storage_size_diff; + } + in + return (ctxt, result, [op])) | Origination {delegate; script; credit} -> (* Internal originations have their address generated in the interpreter so that the script can use it immediately. diff --git a/src/proto_alpha/lib_protocol/apply_internal_results.ml b/src/proto_alpha/lib_protocol/apply_internal_results.ml index 2a4ddcf7d2e876ac192044257b5478f12d670d28..01dc7fd8a2daf87bb6bce80b50839b77429e3ecf 100644 --- a/src/proto_alpha/lib_protocol/apply_internal_results.ml +++ b/src/proto_alpha/lib_protocol/apply_internal_results.ml @@ -64,11 +64,20 @@ let contents_of_internal_operation (type kind) kind internal_contents = let operation : kind internal_manager_operation = match operation with - | Transaction_to_contract + | Transaction_to_implicit {destination; amount; entrypoint; unparsed_parameters; _} -> Transaction { - destination = Contract destination; + destination = Contract (Implicit destination); + amount; + entrypoint; + parameters = Script.lazy_expr unparsed_parameters; + } + | Transaction_to_smart_contract + {destination; amount; entrypoint; unparsed_parameters; _} -> + Transaction + { + destination = Contract (Originated destination); amount; entrypoint; parameters = Script.lazy_expr unparsed_parameters; diff --git a/src/proto_alpha/lib_protocol/sc_rollup_operations.ml b/src/proto_alpha/lib_protocol/sc_rollup_operations.ml index 378b2891d3fa3d07a2206f5069fde9bb3084aae7..607bd36b690e52c76fad2e5616962fddbbdf7a3b 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_operations.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_operations.ml @@ -200,9 +200,9 @@ let to_transaction_operation ctxt ~source *) let* ctxt = validate_parameters_ty ctxt parameters_ty in let operation = - Script_typed_ir.Transaction_to_contract + Script_typed_ir.Transaction_to_smart_contract { - destination = Contract.Originated destination; + destination; amount = Tez.zero; entrypoint; location = Micheline.dummy_location; diff --git a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml index 15655fe1757f30112d4bf3a1c1f025b4e88f2373..bb8b2c51d31a78ac514db023868e0e12b02ad269 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml @@ -479,25 +479,39 @@ let apply ctxt gas capture_ty capture lam = let gas, ctxt = local_gas_counter_and_outdated_context ctxt in return (lam', ctxt, gas) -let make_transaction_to_contract ctxt ~destination ~amount ~entrypoint ~location - ~parameters_ty ~parameters = +let make_transaction_to_contract ctxt ~(destination : Contract.t) ~amount + ~entrypoint ~location ~parameters_ty ~parameters = unparse_data ctxt Optimized parameters_ty parameters >>=? fun (unparsed_parameters, ctxt) -> Lwt.return ( Gas.consume ctxt (Script.strip_locations_cost unparsed_parameters) >|? fun ctxt -> let unparsed_parameters = Micheline.strip_locations unparsed_parameters in - ( Transaction_to_contract - { - destination; - amount; - entrypoint; - location; - parameters_ty; - parameters; - unparsed_parameters; - }, - ctxt ) ) + match destination with + | Implicit destination -> + ( Transaction_to_implicit + { + destination; + amount; + entrypoint; + location; + parameters_ty; + parameters; + unparsed_parameters; + }, + ctxt ) + | Originated destination -> + ( Transaction_to_smart_contract + { + destination; + amount; + entrypoint; + location; + parameters_ty; + parameters; + unparsed_parameters; + }, + ctxt ) ) let make_transaction_to_tx_rollup (type t tc) ctxt ~destination ~amount ~entrypoint ~(parameters_ty : (t, tc) ty) ~parameters = diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.ml b/src/proto_alpha/lib_protocol/script_typed_ir.ml index cc5879aa236bfd5c8992b06f9d66e75cfd742d88..acf49b862290e3be39e6829316269e3f567ec160 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.ml +++ b/src/proto_alpha/lib_protocol/script_typed_ir.ml @@ -1340,8 +1340,18 @@ and ('input, 'output) view_signature = -> ('input, 'output) view_signature and 'kind manager_operation = - | Transaction_to_contract : { - destination : Contract.t; + | Transaction_to_implicit : { + destination : Signature.Public_key_hash.t; + amount : Tez.tez; + entrypoint : Entrypoint.t; + location : Script.location; + parameters_ty : ('a, _) ty; + parameters : 'a; + unparsed_parameters : Script.expr; + } + -> Kind.transaction manager_operation + | Transaction_to_smart_contract : { + destination : Contract_hash.t; amount : Tez.tez; entrypoint : Entrypoint.t; location : Script.location; @@ -1424,7 +1434,8 @@ type packed_manager_operation = let manager_kind : type kind. kind manager_operation -> kind Kind.manager = function - | Transaction_to_contract _ -> Kind.Transaction_manager_kind + | Transaction_to_implicit _ -> Kind.Transaction_manager_kind + | Transaction_to_smart_contract _ -> Kind.Transaction_manager_kind | Transaction_to_tx_rollup _ -> Kind.Transaction_manager_kind | Transaction_to_sc_rollup _ -> Kind.Transaction_manager_kind | Transaction_to_event _ -> Kind.Transaction_manager_kind diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.mli b/src/proto_alpha/lib_protocol/script_typed_ir.mli index 35eee3e9b30a72ab6d7f8f12ec0d169155bfb143..51b35351a73f2172735edf8b8721f6f1a7cbecfa 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.mli +++ b/src/proto_alpha/lib_protocol/script_typed_ir.mli @@ -1471,13 +1471,28 @@ and ('input, 'output) view_signature = -> ('input, 'output) view_signature and 'kind manager_operation = - | Transaction_to_contract : { + | Transaction_to_implicit : { (* The [unparsed_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]). *) - destination : Contract.t; + destination : Signature.Public_key_hash.t; + amount : Tez.tez; + entrypoint : Entrypoint.t; + location : Script.location; + parameters_ty : ('a, _) ty; + parameters : 'a; + unparsed_parameters : Script.expr; + } + -> Kind.transaction manager_operation + | Transaction_to_smart_contract : { + (* The [unparsed_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]). *) + destination : Contract_hash.t; amount : Tez.tez; entrypoint : Entrypoint.t; location : Script.location; 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 ca3b2d839afc9a676273feed7defcb467f95457b..61068795b30ad6e6f11aa392e0e3bcb492ab9a8a 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 @@ -391,7 +391,7 @@ let transfer_operation ctxt ~src ~destination ~arg_type ~arg = { source = src; operation = - Transaction_to_contract + Transaction_to_smart_contract { amount = Tez.zero; unparsed_parameters = Micheline.strip_locations params_node; @@ -882,7 +882,6 @@ let test_update_invalid_transfer () = ~storage:"{}" ~forges_tickets:false in - let destination = Contract.Originated destination in let ctxt = Incremental.alpha_ctxt incr in let arg_type = ticket_string_list_type in let arg = @@ -954,7 +953,6 @@ let test_update_self_ticket_transfer () = ~storage:"{}" ~forges_tickets:false in - let ticket_receiver = Contract.Originated ticket_receiver in (* Ticket is self. That means we can transfer an unlimited amounts of such ticket-tokens. *) let ticketer = Contract.to_b58check self in @@ -994,7 +992,7 @@ let test_update_self_ticket_transfer () = wrap @@ Ticket_balance_key.of_ex_token ctxt - ~owner:(Destination.Contract ticket_receiver) + ~owner:(Destination.Contract (Originated ticket_receiver)) red_token in assert_balance ~loc:__LOC__ ctxt red_receiver_token_hash (Some 10) @@ -1014,7 +1012,6 @@ let test_update_valid_transfer () = ~storage:"{}" ~forges_tickets:false in - let destination = Contract.Originated destination in let ticketer = "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" in assert (ticketer <> Contract.to_b58check self) ; let ctxt = Incremental.alpha_ctxt incr in @@ -1030,7 +1027,7 @@ let test_update_valid_transfer () = wrap @@ Ticket_balance_key.of_ex_token ctxt - ~owner:(Destination.Contract destination) + ~owner:(Destination.Contract (Originated destination)) red_token in (* Set up the balance so that the self contract owns one ticket. *) @@ -1068,7 +1065,7 @@ let test_update_valid_transfer () = let test_update_transfer_tickets_to_self () = let open Lwt_result_syntax in let* baker, src, block = init_for_operation () in - let* self, _script, incr = + let* self_hash, _script, incr = originate block ~src @@ -1078,8 +1075,8 @@ let test_update_transfer_tickets_to_self () = ~forges_tickets:false in let ticketer = "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" in - assert (ticketer <> Contract_hash.to_b58check self) ; - let self = Contract.Originated self in + assert (ticketer <> Contract_hash.to_b58check self_hash) ; + let self = Contract.Originated self_hash in let ctxt = Incremental.alpha_ctxt incr in let* red_token = string_ticket_token ticketer "red" in let* red_self_token_hash, ctxt = @@ -1100,7 +1097,7 @@ let test_update_transfer_tickets_to_self () = let* operation, ctxt = let arg_type = ticket_string_list_type in let arg = boxed_list [string_ticket ticketer "red" 1] in - transfer_operation ctxt ~src:self ~destination:self ~arg_type ~arg + transfer_operation ctxt ~src:self ~destination:self_hash ~arg_type ~arg in let* _, ctxt = (* Ticket diff removes 5 tickets. *) @@ -1128,7 +1125,7 @@ let test_update_transfer_tickets_to_self () = let test_update_invalid_origination () = let open Lwt_result_syntax in let* baker, src, block = init_for_operation () in - let* destination, script, incr = + let* orig_contract, script, incr = let storage = let ticketer = "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" in Printf.sprintf @@ -1147,7 +1144,7 @@ let test_update_invalid_origination () = in let ctxt = Incremental.alpha_ctxt incr in let* operation, ctxt = - origination_operation ctxt ~src ~orig_contract:destination ~script + origination_operation ctxt ~src ~orig_contract ~script in assert_fail_with ~loc:__LOC__ @@ -1167,7 +1164,7 @@ let test_update_valid_origination () = let* baker, self, block = init_for_operation () in let ticketer = "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" in assert (ticketer <> Contract.to_b58check self) ; - let* originated, script, incr = + let* orig_contract, script, incr = let storage = Printf.sprintf {|{ Pair %S "red" 1; }|} ticketer in originate block @@ -1191,7 +1188,7 @@ let test_update_valid_origination () = wrap @@ Ticket_balance.adjust_balance ctxt red_self_token_hash ~delta:Z.one in let* operation, ctxt = - origination_operation ctxt ~src:self ~orig_contract:originated ~script + origination_operation ctxt ~src:self ~orig_contract ~script in let* _, ctxt = let* ticket_diffs, ctxt = @@ -1214,7 +1211,7 @@ let test_update_valid_origination () = wrap @@ Ticket_balance_key.of_ex_token ctxt - ~owner:(Destination.Contract (Originated originated)) + ~owner:(Destination.Contract (Originated orig_contract)) red_token in assert_balance ~loc:__LOC__ ctxt red_originated_token_hash (Some 1) @@ -1223,7 +1220,7 @@ let test_update_self_origination () = let open Lwt_result_syntax in let* baker, self, block = init_for_operation () in let ticketer = Contract.to_b58check self in - let* originated, script, incr = + let* orig_contract, script, incr = let storage = Printf.sprintf {|{ Pair %S "red" 1; }|} ticketer in originate block @@ -1239,11 +1236,11 @@ let test_update_self_origination () = wrap @@ Ticket_balance_key.of_ex_token ctxt - ~owner:(Destination.Contract (Originated originated)) + ~owner:(Destination.Contract (Originated orig_contract)) red_token in let* operation, ctxt = - origination_operation ctxt ~src:self ~orig_contract:originated ~script + origination_operation ctxt ~src:self ~orig_contract ~script in let* _, ctxt = wrap 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 b035358a36869f4ffa8f8bdc2aed48d15b1ec99e..2080c05f9014a3a112e91cb3011f4af87b032b0d 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 @@ -301,7 +301,7 @@ let originate block ~src ~baker ~script ~storage ~forges_tickets = let* incr = Incremental.begin_construction ~policy:Block.(By_account baker) block in - return (Contract.Originated orig_contract, incr) + return (orig_contract, incr) let transfer_operation ~incr ~src ~destination ~parameters_ty ~parameters = let open Lwt_result_syntax in @@ -320,7 +320,7 @@ let transfer_operation ~incr ~src ~destination ~parameters_ty ~parameters = { source = src; operation = - Transaction_to_contract + Transaction_to_smart_contract { amount = Tez.zero; unparsed_parameters = Micheline.strip_locations params_node; @@ -497,7 +497,8 @@ let test_transfer_one_ticket () = { ticket_token = string_token ~ticketer "white"; total_amount = nat 1; - destinations = [(Destination.Contract orig_contract, nat 1)]; + destinations = + [(Destination.Contract (Originated orig_contract), nat 1)]; }; ] @@ -528,6 +529,7 @@ let test_transfer_multiple_tickets () = (ticketer, "red", 4); ] in + let orig_contract = Contract.Originated orig_contract in let test allow_zero_amount_tickets = let* ticket_diffs, ctxt = ticket_diffs_of_operations incr ~allow_zero_amount_tickets [operation] @@ -589,6 +591,7 @@ let test_transfer_different_tickets () = (ticketer1, "blue", 1); ] in + let destination = Destination.Contract (Originated destination) in let* ticket_diffs, ctxt = ticket_diffs_of_operations incr ~allow_zero_amount_tickets:true [operation] in @@ -601,32 +604,32 @@ let test_transfer_different_tickets () = { ticket_token = string_token ~ticketer:ticketer1 "red"; total_amount = nat 2; - destinations = [(Destination.Contract destination, nat 2)]; + destinations = [(destination, nat 2)]; }; { ticket_token = string_token ~ticketer:ticketer1 "green"; total_amount = nat 2; - destinations = [(Destination.Contract destination, nat 2)]; + destinations = [(destination, nat 2)]; }; { ticket_token = string_token ~ticketer:ticketer1 "blue"; total_amount = nat 2; - destinations = [(Destination.Contract destination, nat 2)]; + destinations = [(destination, nat 2)]; }; { ticket_token = string_token ~ticketer:ticketer2 "red"; total_amount = nat 1; - destinations = [(Destination.Contract destination, nat 1)]; + destinations = [(destination, nat 1)]; }; { ticket_token = string_token ~ticketer:ticketer2 "green"; total_amount = nat 1; - destinations = [(Destination.Contract destination, nat 1)]; + destinations = [(destination, nat 1)]; }; { ticket_token = string_token ~ticketer:ticketer2 "blue"; total_amount = nat 1; - destinations = [(Destination.Contract destination, nat 1)]; + destinations = [(destination, nat 1)]; }; ] @@ -679,8 +682,8 @@ let test_transfer_to_two_contracts_with_different_tickets () = total_amount = nat 2; destinations = [ - (Destination.Contract destination2, nat 1); - (Destination.Contract destination1, nat 1); + (Destination.Contract (Originated destination2), nat 1); + (Destination.Contract (Originated destination1), nat 1); ]; }; { @@ -688,8 +691,8 @@ let test_transfer_to_two_contracts_with_different_tickets () = total_amount = nat 2; destinations = [ - (Destination.Contract destination2, nat 1); - (Destination.Contract destination1, nat 1); + (Destination.Contract (Originated destination2), nat 1); + (Destination.Contract (Originated destination1), nat 1); ]; }; { @@ -697,8 +700,8 @@ let test_transfer_to_two_contracts_with_different_tickets () = total_amount = nat 2; destinations = [ - (Destination.Contract destination2, nat 1); - (Destination.Contract destination1, nat 1); + (Destination.Contract (Originated destination2), nat 1); + (Destination.Contract (Originated destination1), nat 1); ]; }; ] @@ -1029,7 +1032,7 @@ let test_originate_and_transfer () = total_amount = nat 2; destinations = [ - (Destination.Contract destination2, nat 1); + (Destination.Contract (Originated destination2), nat 1); (Destination.Contract orig_contract1, nat 1); ]; }; @@ -1038,7 +1041,7 @@ let test_originate_and_transfer () = total_amount = nat 2; destinations = [ - (Destination.Contract destination2, nat 1); + (Destination.Contract (Originated destination2), nat 1); (Destination.Contract orig_contract1, nat 1); ]; }; @@ -1047,7 +1050,7 @@ let test_originate_and_transfer () = total_amount = nat 2; destinations = [ - (Destination.Contract destination2, nat 1); + (Destination.Contract (Originated destination2), nat 1); (Destination.Contract orig_contract1, nat 1); ]; }; @@ -1172,6 +1175,7 @@ let test_transfer_big_map_with_tickets () = let* ticket_diffs, ctxt = ticket_diffs_of_operations incr ~allow_zero_amount_tickets:true [operation] in + let destination = Destination.Contract (Originated orig_contract) in assert_equal_ticket_token_diffs ctxt ~loc:__LOC__ @@ -1181,17 +1185,17 @@ let test_transfer_big_map_with_tickets () = { ticket_token = string_token ~ticketer:ticketer_contract "red"; total_amount = nat 1; - destinations = [(Destination.Contract orig_contract, nat 1)]; + destinations = [(destination, nat 1)]; }; { ticket_token = string_token ~ticketer:ticketer_contract "green"; total_amount = nat 1; - destinations = [(Destination.Contract orig_contract, nat 1)]; + destinations = [(destination, nat 1)]; }; { ticket_token = string_token ~ticketer:ticketer_contract "blue"; total_amount = nat 1; - destinations = [(Destination.Contract orig_contract, nat 1)]; + destinations = [(destination, nat 1)]; }; ] @@ -1284,6 +1288,7 @@ let test_transfer_multiple_zero_tickets () = let* ticket_diffs, ctxt = ticket_diffs_of_operations incr ~allow_zero_amount_tickets:true [operation] in + let orig_contract = Contract.Originated orig_contract in assert_equal_ticket_token_diffs ctxt ~loc:__LOC__ diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml index c3fc19848a938db99535cbb791ea61165583e3f7..c3286cc863d860ae9e537d144b20b9092e0e1c86 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml @@ -236,7 +236,7 @@ let verify_execute_outbox_message_operations incr ~loc ~source ~operations { source = op_source; operation = - Transaction_to_contract + Transaction_to_smart_contract { destination; amount; @@ -264,13 +264,8 @@ let verify_execute_outbox_message_operations incr ~loc ~source ~operations (* Load the arg-type and entrypoints of the destination script. *) let* ( Script_ir_translator.Ex_script (Script {arg_type; entrypoints; _}), ctxt ) = - let* contract_hash = - match destination with - | Contract.Originated ch -> return ch - | _ -> failwith "Expected originated contract at %s" loc - in let* ctxt, _cache_key, cached = - wrap @@ Script_cache.find ctxt contract_hash + wrap @@ Script_cache.find ctxt destination in match cached with | Some (_script, ex_script) -> return (ex_script, ctxt) @@ -309,14 +304,15 @@ let verify_execute_outbox_message_operations incr ~loc ~source ~operations return (ctxt, (destination, entrypoint, unparsed_parameters)) | _ -> failwith - "Expected an internal transaction operation, called from %s" + "Expected an internal transaction operation to a smart-contract, \ + called from %s" loc in let* _ctxt, operations_data = List.fold_left_map_es validate_and_extract_operation_params ctxt operations in let compare_data (d1, e1, p1) (d2, e2, p2) = - Contract.equal d1 d2 + Contract_hash.equal d1 d2 && Entrypoint_repr.(e1 = e2) && String.equal (Expr.to_string p1) (Expr.to_string p2) in @@ -324,16 +320,16 @@ let verify_execute_outbox_message_operations incr ~loc ~source ~operations Format.fprintf fmt "(%a, %a, %s)" - Contract.pp + Contract_hash.pp d Entrypoint_repr.pp e (Expr.to_string p) in let transactions_data = - let data_of_transaction (ty, entrypoint, params) = + let data_of_transaction (contract, entrypoint, params) = let params = Expr.from_string params in - (ty, entrypoint, params) + (contract, entrypoint, params) in List.map data_of_transaction expected_transactions in @@ -350,12 +346,6 @@ let make_output ~outbox_level ~message_index transactions = let transactions = List.map (fun (destination, entrypoint, parameters) -> - let destination = - match destination with - | Contract.Originated ch -> ch - | Contract.Implicit _ -> - Stdlib.failwith "Expected an originated contract." - in let unparsed_parameters = Expr.from_string parameters in {Sc_rollup.Outbox.Message.unparsed_parameters; destination; entrypoint}) transactions @@ -381,7 +371,7 @@ let string_ticket_token ticketer content = let originate_contract incr ~script ~baker ~storage ~source_contract = let* block = Incremental.finalize_block incr in let* contract, _, block = - Contract_helpers.originate_contract_from_string + Contract_helpers.originate_contract_from_string_hash ~script ~storage ~source_contract @@ -895,7 +885,7 @@ let test_single_transaction_batch () = ~loc:__LOC__ incr red_token - (Destination.Contract ticket_receiver) + (Destination.Contract (Originated ticket_receiver)) (Some 1) let test_multi_transaction_batch () = @@ -981,7 +971,7 @@ let test_multi_transaction_batch () = ~loc:__LOC__ incr red_token - (Destination.Contract ticket_receiver) + (Destination.Contract (Originated ticket_receiver)) (Some 10) (** Test that executing an L2 to L1 transaction that involves an invalid diff --git a/src/proto_alpha/lib_protocol/ticket_operations_diff.ml b/src/proto_alpha/lib_protocol/ticket_operations_diff.ml index d965bb84155a86449fa4ce0089acbfc354428319..4608d462c31477c36b86f425593f0d360cfaeefd 100644 --- a/src/proto_alpha/lib_protocol/ticket_operations_diff.ml +++ b/src/proto_alpha/lib_protocol/ticket_operations_diff.ml @@ -174,13 +174,13 @@ let tickets_of_origination ctxt ~allow_zero_amount_tickets ~preorigination let tickets_of_operation ctxt ~allow_zero_amount_tickets (Script_typed_ir.Internal_operation {source = _; operation; nonce = _}) = match operation with - | Transaction_to_contract {destination = Implicit _; _} -> return (None, ctxt) - | Transaction_to_contract + | Transaction_to_implicit _ -> return (None, ctxt) + | Transaction_to_smart_contract { amount = _; unparsed_parameters = _; entrypoint = _; - destination = Originated _ as contract; + destination; location = _; parameters_ty; parameters; @@ -188,7 +188,7 @@ let tickets_of_operation ctxt ~allow_zero_amount_tickets tickets_of_transaction ctxt ~allow_zero_amount_tickets - ~destination:(Destination.Contract contract) + ~destination:(Destination.Contract (Originated destination)) ~parameters_ty ~parameters | Transaction_to_tx_rollup diff --git a/src/proto_alpha/lib_protocol/tx_rollup_ticket.ml b/src/proto_alpha/lib_protocol/tx_rollup_ticket.ml index d4549894b9f79c6c76387d66f6a2e356d337998b..368d6b9045598ffea6a725916fa0d1e2e220266a 100644 --- a/src/proto_alpha/lib_protocol/tx_rollup_ticket.ml +++ b/src/proto_alpha/lib_protocol/tx_rollup_ticket.ml @@ -78,7 +78,7 @@ let parse_ticket_and_operation ~consume_deserialization_gas ~ticketer ~contents source; nonce; operation = - Transaction_to_contract + Transaction_to_smart_contract { amount = Tez.zero; unparsed_parameters; diff --git a/src/proto_alpha/lib_protocol/tx_rollup_ticket.mli b/src/proto_alpha/lib_protocol/tx_rollup_ticket.mli index 281fb79289e6aafb4ecff8cce63738b9804ed100..77865d9e7dca569073b5f4825c9bf24785d1bf57 100644 --- a/src/proto_alpha/lib_protocol/tx_rollup_ticket.mli +++ b/src/proto_alpha/lib_protocol/tx_rollup_ticket.mli @@ -48,7 +48,7 @@ val parse_ticket_and_operation : contents:Script.lazy_expr -> ty:Script.lazy_expr -> source:Contract.t -> - destination:Contract.t -> + destination:Contract_hash.t -> entrypoint:Entrypoint.t -> amount:Z.t -> context ->