diff --git a/src/proto_alpha/lib_benchmark/execution_context.ml b/src/proto_alpha/lib_benchmark/execution_context.ml index a7212fc9ee040ac08b24b19e12797e17dc801a6c..5a7da32f4b158a98667cb8cdcf3fa7c3a6934936 100644 --- a/src/proto_alpha/lib_benchmark/execution_context.ml +++ b/src/proto_alpha/lib_benchmark/execution_context.ml @@ -59,12 +59,12 @@ let make ~rng_state = let open Script_interpreter in (match context with | `Mem_block (block, (bs1, _, _, _, _)) -> - let source = Alpha_context.Destination.Contract bs1 in + let sender = Alpha_context.Destination.Contract bs1 in let payer = Contract_helpers.default_payer in let self = Contract_helpers.default_self in let step_constants = { - source; + sender; payer; self; amount; diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml index f969267408128709389754c5ff5a49752bab3055..48c7e81303c8e1ac83af3ef3baa14619d14c2d8f 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -3304,7 +3304,7 @@ module Registration_section = struct let open Alpha_context in let step_constants = { - source = Contract (Implicit Signature.Public_key_hash.zero); + sender = Contract (Implicit Signature.Public_key_hash.zero); payer = Signature.Public_key_hash.zero; self = Contract_hash.zero; amount = Tez.zero; diff --git a/src/proto_alpha/lib_client/client_proto_fa12.ml b/src/proto_alpha/lib_client/client_proto_fa12.ml index 32a02bcda9a5c846b4549ce57810ffa01104b119..110cf20bd68c5cc2151335bf27cb9cedcd435015 100644 --- a/src/proto_alpha/lib_client/client_proto_fa12.ml +++ b/src/proto_alpha/lib_client/client_proto_fa12.ml @@ -960,7 +960,7 @@ let is_viewable_action action = | _ -> fail (Not_a_viewable_entrypoint (action_to_entrypoint action)) let run_view_action (cctxt : #Protocol_client_context.full) ~chain ~block - ?source ~contract ~action ?payer ?gas ~unparsing_mode () = + ?sender ~contract ~action ?payer ?gas ~unparsing_mode () = is_viewable_action action >>=? fun () -> contract_has_fa12_interface cctxt ~chain ~block ~contract () >>=? fun () -> let entrypoint = action_to_entrypoint action in @@ -972,7 +972,7 @@ let run_view_action (cctxt : #Protocol_client_context.full) ~chain ~block ~contract ~input ~chain_id - ?source + ?sender ?payer ?gas ~entrypoint diff --git a/src/proto_alpha/lib_client/client_proto_fa12.mli b/src/proto_alpha/lib_client/client_proto_fa12.mli index cfd100f44a46010c0ae3f41c03fd67493bec7ed4..3c11c7340043e9563220cc395657d4aa85201e59 100644 --- a/src/proto_alpha/lib_client/client_proto_fa12.mli +++ b/src/proto_alpha/lib_client/client_proto_fa12.mli @@ -152,7 +152,7 @@ val run_view_action : full -> chain:Shell_services.chain -> block:Shell_services.block -> - ?source:Contract.t -> + ?sender:Contract.t -> contract:Contract_hash.t -> action:action -> ?payer:Signature.public_key_hash -> diff --git a/src/proto_alpha/lib_client/client_proto_programs.ml b/src/proto_alpha/lib_client/client_proto_programs.ml index 4412d16c001cfa50d1f5e337291dff3aec789fce..0384c2bcbd90b0f2a351209d6ae2c0778886c90c 100644 --- a/src/proto_alpha/lib_client/client_proto_programs.ml +++ b/src/proto_alpha/lib_client/client_proto_programs.ml @@ -125,7 +125,7 @@ type simulation_params = { unparsing_mode : Script_ir_unparser.unparsing_mode; now : Script_timestamp.t option; level : Script_int.n Script_int.num option; - source : Contract.t option; + sender : Contract.t option; payer : Signature.public_key_hash option; gas : Gas.Arith.integral option; } @@ -156,7 +156,7 @@ type run_params = { let run_view (cctxt : #Protocol_client_context.rpc_context) ~(chain : Chain_services.chain) ~block (params : run_view_params) = let { - shared_params = {input; unparsing_mode; now; level; source; payer; gas}; + shared_params = {input; unparsing_mode; now; level; sender; payer; gas}; contract; entrypoint; } = @@ -171,7 +171,7 @@ let run_view (cctxt : #Protocol_client_context.rpc_context) ~entrypoint ~input:input.expanded ~chain_id - ?source + ?sender ?payer ~unparsing_mode ~now @@ -180,7 +180,7 @@ let run_view (cctxt : #Protocol_client_context.rpc_context) let run_script_view (cctxt : #Protocol_client_context.rpc_context) ~(chain : Chain_services.chain) ~block (params : run_script_view_params) = let { - shared_params = {input; unparsing_mode; now; level; source; payer; gas}; + shared_params = {input; unparsing_mode; now; level; sender; payer; gas}; contract; view; unlimited_gas; @@ -197,7 +197,7 @@ let run_script_view (cctxt : #Protocol_client_context.rpc_context) ~input:input.expanded ~unlimited_gas ~chain_id - ?source + ?sender ?payer ~unparsing_mode ~now @@ -207,7 +207,7 @@ let run (cctxt : #Protocol_client_context.rpc_context) ~(chain : Chain_services.chain) ~block (params : run_params) = Chain_services.chain_id cctxt ~chain () >>=? fun chain_id -> let { - shared_params = {input; unparsing_mode; now; level; source; payer; gas}; + shared_params = {input; unparsing_mode; now; level; sender; payer; gas}; program; amount; balance; @@ -230,7 +230,7 @@ let run (cctxt : #Protocol_client_context.rpc_context) ~amount ?balance ~chain_id - ~source + ~sender ~payer ~self ~now @@ -240,7 +240,7 @@ let trace (cctxt : #Protocol_client_context.rpc_context) ~(chain : Chain_services.chain) ~block (params : run_params) = Chain_services.chain_id cctxt ~chain () >>=? fun chain_id -> let { - shared_params = {input; unparsing_mode; now; level; source; payer; gas}; + shared_params = {input; unparsing_mode; now; level; sender; payer; gas}; program; amount; balance; @@ -263,7 +263,7 @@ let trace (cctxt : #Protocol_client_context.rpc_context) ~amount ?balance ~chain_id - ~source + ~sender ~payer ~self ~now diff --git a/src/proto_alpha/lib_client/client_proto_programs.mli b/src/proto_alpha/lib_client/client_proto_programs.mli index 383d2116b10b99715efff23e87098ecd22c4b7cc..d3aa73130f6ea1e97a3c933ac918aeff6a0ab313 100644 --- a/src/proto_alpha/lib_client/client_proto_programs.mli +++ b/src/proto_alpha/lib_client/client_proto_programs.mli @@ -38,7 +38,7 @@ type simulation_params = { unparsing_mode : Script_ir_unparser.unparsing_mode; now : Script_timestamp.t option; level : Script_int.n Script_int.num option; - source : Contract.t option; + sender : Contract.t option; payer : Signature.public_key_hash option; gas : Gas.Arith.integral option; } diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index 486452b4d90601026615ecd1655486c7a68cf064..696a52972d879fa49c81f4573d449832cd427c82 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -43,7 +43,7 @@ let pp_micheline_from_lazy_expr ppf expr = in pp_micheline_expr ppf expr -let pp_internal_operation ppf (Internal_operation {operation; source; _}) = +let pp_internal_operation ppf (Internal_operation {operation; sender; _}) = (* For now, try to use the same format as in [pp_manager_operation_content]. *) Format.fprintf ppf "@[Internal " ; (match operation with @@ -55,7 +55,7 @@ let pp_internal_operation ppf (Internal_operation {operation; source; _}) = Tez.pp amount Destination.pp - source + sender Destination.pp destination ; if not (Entrypoint.is_default entrypoint) then @@ -71,7 +71,7 @@ let pp_internal_operation ppf (Internal_operation {operation; source; _}) = ppf "Origination:@,From: %a@,Credit: %s%a" Destination.pp - source + sender tez_sym Tez.pp credit ; @@ -99,7 +99,7 @@ let pp_internal_operation ppf (Internal_operation {operation; source; _}) = Signature.Public_key_hash.pp delegate) | Delegation delegate_opt -> ( - Format.fprintf ppf "Delegation:@,Contract: %a@,To: " Destination.pp source ; + Format.fprintf ppf "Delegation:@,Contract: %a@,To: " Destination.pp sender ; match delegate_opt with | None -> Format.pp_print_string ppf "nobody" | Some delegate -> Signature.Public_key_hash.pp ppf delegate) @@ -108,7 +108,7 @@ let pp_internal_operation ppf (Internal_operation {operation; source; _}) = ppf "Event:@,From: %a@,Type: %a" Destination.pp - source + sender pp_micheline_expr ty ; if not (Entrypoint.is_default tag) then diff --git a/src/proto_alpha/lib_client_commands/client_proto_fa12_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_fa12_commands.ml index 3072a31c76abf9bb5d0eee98d1acd6d36a485050..18ed0d440551a2c7acbb4e05dfb44385d233da1d 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_fa12_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_fa12_commands.ml @@ -176,7 +176,7 @@ let commands_ro () : #Protocol_client_context.full Tezos_clic.command list = ~block:cctxt#block ~contract ~action - ~source:addr + ~sender:addr ?gas ?payer ~unparsing_mode @@ -200,13 +200,13 @@ let commands_ro () : #Protocol_client_context.full Tezos_clic.command list = @@ stop) (fun (gas, payer, unparsing_mode) contract - source + sender destination (cctxt : #Protocol_client_context.full) -> let open Lwt_syntax in let action = Client_proto_fa12.Get_allowance - (source, destination, (dummy_callback, None)) + (sender, destination, (dummy_callback, None)) in let* res = Client_proto_fa12.run_view_action @@ -215,7 +215,7 @@ let commands_ro () : #Protocol_client_context.full Tezos_clic.command list = ~block:cctxt#block ~contract ~action - ~source + ~sender ?gas ?payer ~unparsing_mode 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 b032a655f4d6b1dc7ef30689d2059633a02c28ad..54af4e66f46e94e474e9261e4ff84da594ecbc90 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 @@ -271,7 +271,7 @@ let commands () = (fun ( trace_exec, amount, balance, - source, + sender, payer, self, no_print_source, @@ -299,7 +299,7 @@ let commands () = program; storage; shared_params = - {input; unparsing_mode; now; level; source; payer; gas}; + {input; unparsing_mode; now; level; sender; payer; gas}; entrypoint; self; } @@ -317,7 +317,7 @@ let commands () = program; storage; shared_params = - {input; unparsing_mode; now; level; source; payer; gas}; + {input; unparsing_mode; now; level; sender; payer; gas}; entrypoint; self; } @@ -1095,7 +1095,7 @@ let commands () = @@ prefixes ["with"; "input"] @@ param ~name:"input" ~desc:"the input data" data_parameter @@ stop) - (fun (source, payer, gas, unparsing_mode, now, level) + (fun (sender, payer, gas, unparsing_mode, now, level) entrypoint contract input @@ -1108,7 +1108,7 @@ let commands () = ~block:cctxt#block { shared_params = - {input; unparsing_mode; now; level; source; payer; gas}; + {input; unparsing_mode; now; level; sender; payer; gas}; contract; entrypoint; } @@ -1132,7 +1132,7 @@ let commands () = ~name:"contract" ~desc:"the contract containing the view" @@ stop) - (fun (source, payer, gas, unlimited_gas, unparsing_mode, now, level) + (fun (sender, payer, gas, unlimited_gas, unparsing_mode, now, level) view contract cctxt -> @@ -1148,7 +1148,7 @@ let commands () = ~block:cctxt#block { shared_params = - {input; unparsing_mode; now; level; source; payer; gas}; + {input; unparsing_mode; now; level; sender; payer; gas}; contract; view; unlimited_gas; @@ -1178,7 +1178,7 @@ let commands () = ~desc:"the argument provided to the view" data_parameter @@ stop) - (fun (source, payer, gas, unlimited_gas, unparsing_mode, now, level) + (fun (sender, payer, gas, unlimited_gas, unparsing_mode, now, level) view contract input @@ -1191,7 +1191,7 @@ let commands () = ~block:cctxt#block { shared_params = - {input; unparsing_mode; now; level; source; payer; gas}; + {input; unparsing_mode; now; level; sender; payer; gas}; contract; view; unlimited_gas; diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index 09f5b2adbea4497c4a51d116c685307c994ed70c..265e937c9664479b06697028b20666bb1e4d4de6 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -181,6 +181,8 @@ module Scripts = struct (req "amount" Tez.encoding) (opt "balance" Tez.encoding) (req "chain_id" Chain_id.encoding) + (* TODO: https://gitlab.com/tezos/tezos/-/issues/710 + Rename the "source" field into "sender" *) (opt "source" Contract.encoding) (opt "payer" Contract.implicit_encoding) (opt "self" Contract.originated_encoding) @@ -240,6 +242,8 @@ module Scripts = struct (req "entrypoint" Entrypoint.simple_encoding) (req "input" Script.expr_encoding) (req "chain_id" Chain_id.encoding) + (* TODO: https://gitlab.com/tezos/tezos/-/issues/710 + Rename the "source" field into "sender" *) (opt "source" Contract.encoding) (opt "payer" Contract.implicit_encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -256,6 +260,8 @@ module Scripts = struct (req "input" Script.expr_encoding) (dft "unlimited_gas" bool false) (req "chain_id" Chain_id.encoding) + (* TODO: https://gitlab.com/tezos/tezos/-/issues/710 + Rename the "source" field into "sender" *) (opt "source" Contract.encoding) (opt "payer" Contract.implicit_encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -1004,7 +1010,7 @@ module Scripts = struct balance : Tez.t; self : Contract_hash.t; payer : Signature.public_key_hash; - source : Contract.t; + sender : Contract.t; } (* 4_000_000 ęś© *) @@ -1030,15 +1036,16 @@ module Scripts = struct balance >>=? fun (ctxt, _) -> return (ctxt, dummy_contract_hash) in - let source_and_payer ~src_opt ~pay_opt ~default_src = - match (src_opt, pay_opt) with + let sender_and_payer ~sender_opt ~payer_opt ~default_sender = + match (sender_opt, payer_opt) with | None, None -> - (Contract.Originated default_src, Signature.Public_key_hash.zero) + (Contract.Originated default_sender, Signature.Public_key_hash.zero) | Some c, None -> (c, Signature.Public_key_hash.zero) | None, Some c -> (Contract.Implicit c, c) - | Some src, Some pay -> (src, pay) + | Some sender, Some payer -> (sender, payer) in - let configure_contracts ctxt script balance ~src_opt ~pay_opt ~self_opt = + let configure_contracts ctxt script balance ~sender_opt ~payer_opt ~self_opt + = (match self_opt with | None -> let balance = Option.value ~default:default_balance balance in @@ -1051,10 +1058,10 @@ module Scripts = struct balance >>=? fun bal -> return (ctxt, addr, bal)) >>=? fun (ctxt, self, balance) -> - let source, payer = - source_and_payer ~src_opt ~pay_opt ~default_src:self + let sender, payer = + sender_and_payer ~sender_opt ~payer_opt ~default_sender:self in - return (ctxt, {balance; self; source; payer}) + return (ctxt, {balance; self; sender; payer}) in let script_entrypoint_type ctxt expr entrypoint = let ctxt = Gas.set_unlimited ctxt in @@ -1098,8 +1105,8 @@ module Scripts = struct amount, balance, chain_id, - src_opt, - pay_opt, + sender_opt, + payer_opt, self_opt, entrypoint ), (unparsing_mode, gas, now, level) ) @@ -1111,10 +1118,10 @@ module Scripts = struct ctxt {storage; code} balance - ~src_opt - ~pay_opt + ~sender_opt + ~payer_opt ~self_opt - >>=? fun (ctxt, {self; source; payer; balance}) -> + >>=? fun (ctxt, {self; sender; payer; balance}) -> let gas = match gas with | Some gas -> gas @@ -1133,8 +1140,8 @@ module Scripts = struct in let step_constants = let open Script_interpreter in - let source = Destination.Contract source in - {source; payer; self; amount; balance; chain_id; now; level} + let sender = Destination.Contract sender in + {sender; payer; self; amount; balance; chain_id; now; level} in Script_interpreter.execute ctxt @@ -1170,8 +1177,8 @@ module Scripts = struct amount, balance, chain_id, - src_opt, - pay_opt, + sender_opt, + payer_opt, self_opt, entrypoint ), (unparsing_mode, gas, now, level) ) @@ -1183,10 +1190,10 @@ module Scripts = struct ctxt {storage; code} balance - ~src_opt - ~pay_opt + ~sender_opt + ~payer_opt ~self_opt - >>=? fun (ctxt, {self; source; payer; balance}) -> + >>=? fun (ctxt, {self; sender; payer; balance}) -> let gas = match gas with | Some gas -> gas @@ -1205,8 +1212,8 @@ module Scripts = struct in let step_constants = let open Script_interpreter in - let source = Destination.Contract source in - {source; payer; self; amount; balance; chain_id; now; level} + let sender = Destination.Contract sender in + {sender; payer; self; amount; balance; chain_id; now; level} in let module Unparsing_mode = struct let unparsing_mode = unparsing_mode @@ -1243,8 +1250,8 @@ module Scripts = struct entrypoint, input, chain_id, - src_opt, - pay_opt, + sender_opt, + payer_opt, gas, unparsing_mode, now, @@ -1268,8 +1275,8 @@ module Scripts = struct (View_helpers.make_tzip4_viewer_script ty) Tez.zero >>=? fun (ctxt, viewer_contract) -> - let source, payer = - source_and_payer ~src_opt ~pay_opt ~default_src:contract_hash + let sender, payer = + sender_and_payer ~sender_opt ~payer_opt ~default_sender:contract_hash in let gas = Option.value @@ -1289,9 +1296,9 @@ module Scripts = struct in let step_constants = let open Script_interpreter in - let source = Destination.Contract source in + let sender = Destination.Contract sender in { - source; + sender; payer; self = contract_hash; amount = Tez.zero; @@ -1341,8 +1348,8 @@ module Scripts = struct input, unlimited_gas, chain_id, - src_opt, - pay_opt, + sender_opt, + payer_opt, gas, unparsing_mode, now ), @@ -1359,8 +1366,8 @@ module Scripts = struct script_view_type ctxt contract_hash decoded_script view >>=? fun (input_ty, output_ty) -> Contract.get_balance ctxt contract >>=? fun balance -> - let source, payer = - source_and_payer ~src_opt ~pay_opt ~default_src:contract_hash + let sender, payer = + sender_and_payer ~sender_opt ~payer_opt ~default_sender:contract_hash in let now = match now with None -> Script_timestamp.now ctxt | Some t -> t @@ -1388,9 +1395,9 @@ module Scripts = struct |> Script_int.of_int32 |> Script_int.abs) in let step_constants = - let source = Destination.Contract source in + let sender = Destination.Contract sender in { - Script_interpreter.source; + Script_interpreter.sender; payer; self = contract_hash; amount = Tez.zero; @@ -1620,7 +1627,7 @@ module Scripts = struct [] ) )) let run_code ?unparsing_mode ?gas ?(entrypoint = Entrypoint.default) ?balance - ~script ~storage ~input ~amount ~chain_id ~source ~payer ~self ~now ~level + ~script ~storage ~input ~amount ~chain_id ~sender ~payer ~self ~now ~level ctxt block = RPC_context.make_call0 S.run_code @@ -1633,14 +1640,14 @@ module Scripts = struct amount, balance, chain_id, - source, + sender, payer, self, entrypoint ), (unparsing_mode, gas, now, level) ) let trace_code ?unparsing_mode ?gas ?(entrypoint = Entrypoint.default) - ?balance ~script ~storage ~input ~amount ~chain_id ~source ~payer ~self + ?balance ~script ~storage ~input ~amount ~chain_id ~sender ~payer ~self ~now ~level ctxt block = RPC_context.make_call0 S.trace_code @@ -1653,14 +1660,14 @@ module Scripts = struct amount, balance, chain_id, - source, + sender, payer, self, entrypoint ), (unparsing_mode, gas, now, level) ) let run_tzip4_view ?gas ~contract ~entrypoint ~input ~chain_id ~now ~level - ?source ?payer ~unparsing_mode ctxt block = + ?sender ?payer ~unparsing_mode ctxt block = RPC_context.make_call0 S.run_tzip4_view ctxt @@ -1670,7 +1677,7 @@ module Scripts = struct entrypoint, input, chain_id, - source, + sender, payer, gas, unparsing_mode, @@ -1680,7 +1687,7 @@ module Scripts = struct (** [run_script_view] is an helper function to call the corresponding RPC. [unlimited_gas] is set to [false] by default. *) let run_script_view ?gas ~contract ~view ~input ?(unlimited_gas = false) - ~chain_id ~now ~level ?source ?payer ~unparsing_mode ctxt block = + ~chain_id ~now ~level ?sender ?payer ~unparsing_mode ctxt block = RPC_context.make_call0 S.run_script_view ctxt @@ -1691,7 +1698,7 @@ module Scripts = struct input, unlimited_gas, chain_id, - source, + sender, payer, gas, unparsing_mode, diff --git a/src/proto_alpha/lib_plugin/view_helpers.ml b/src/proto_alpha/lib_plugin/view_helpers.ml index 29074e758af2ee0038718c3af0a8c439894f446b..20a6b0201cefb85a10157114aa8ef64a68b275a7 100644 --- a/src/proto_alpha/lib_plugin/view_helpers.ml +++ b/src/proto_alpha/lib_plugin/view_helpers.ml @@ -230,7 +230,7 @@ let extract_parameter_from_operations entrypoint operations callback = parameters_ty = _; location = _; }; - source = _; + sender = _; nonce = _; }; ] diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index da24759fa3d544314f79239f277f5c45c1d8b7bf..eaae79440e065bf0de1fd61ec590009e7ad3d205 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -42,7 +42,7 @@ type error += Apply_internal_results.packed_internal_operation | Multiple_revelation | Invalid_transfer_to_sc_rollup - | Invalid_source of Destination.t + | Invalid_sender of Destination.t let () = register_error_kind @@ -196,28 +196,28 @@ let () = ~pp:(fun ppf () -> Format.fprintf ppf - "Invalid source for transfer operation to smart rollup. Only \ + "Invalid sender for transfer operation to smart rollup. Only \ originated accounts are allowed.") Data_encoding.empty (function Invalid_transfer_to_sc_rollup -> Some () | _ -> None) (fun () -> Invalid_transfer_to_sc_rollup) ; register_error_kind `Permanent - ~id:"operations.invalid_source" - ~title:"Invalid source for an internal operation" + ~id:"operations.invalid_sender" + ~title:"Invalid sender for an internal operation" ~description: - "Invalid source for an internal operation restricted to implicit and \ + "Invalid sender for an internal operation restricted to implicit and \ originated accounts." ~pp:(fun ppf c -> Format.fprintf ppf - "Invalid source (%a) for this internal operation. Only implicit and \ + "Invalid sender (%a) for this internal operation. Only implicit and \ originated accounts are allowed" Destination.pp c) Data_encoding.(obj1 (req "contract" Destination.encoding)) - (function Invalid_source c -> Some c | _ -> None) - (fun c -> Invalid_source c) + (function Invalid_sender c -> Some c | _ -> None) + (fun c -> Invalid_sender c) open Apply_results open Apply_operation_result @@ -237,22 +237,22 @@ let update_script_storage_and_ticket_balances ctxt ~self_contract storage ~ticket_diffs operations -let apply_delegation ~ctxt ~source ~delegate ~before_operation = - Contract.Delegate.set ctxt source delegate >|=? fun ctxt -> +let apply_delegation ~ctxt ~sender ~delegate ~before_operation = + Contract.Delegate.set ctxt sender delegate >|=? fun ctxt -> (ctxt, Gas.consumed ~since:before_operation ~until:ctxt, []) type 'loc execution_arg = | Typed_arg : 'loc * ('a, _) Script_typed_ir.ty * 'a -> 'loc execution_arg | Untyped_arg : Script.expr -> _ execution_arg -let apply_transaction_to_implicit ~ctxt ~source ~amount ~pkh ~before_operation = +let apply_transaction_to_implicit ~ctxt ~sender ~amount ~pkh ~before_operation = let contract = Contract.Implicit pkh in (* Transfers of zero to implicit accounts are forbidden. *) error_when Tez.(amount = zero) (Empty_transaction contract) >>?= fun () -> (* If the implicit contract is not yet allocated at this point then the next transfer of tokens will allocate it. *) Contract.allocated ctxt contract >>= fun already_allocated -> - Token.transfer ctxt (`Contract source) (`Contract contract) amount + Token.transfer ctxt (`Contract sender) (`Contract contract) amount >>=? fun (ctxt, balance_updates) -> let result = Transaction_to_contract_result @@ -270,16 +270,16 @@ let apply_transaction_to_implicit ~ctxt ~source ~amount ~pkh ~before_operation = in return (ctxt, result, []) -let transfer_from_any_address ctxt source destination amount = - match source with - | Destination.Contract source -> - Token.transfer ctxt (`Contract source) (`Contract destination) amount +let transfer_from_any_address ctxt sender destination amount = + match sender with + | Destination.Contract sender -> + Token.transfer ctxt (`Contract sender) (`Contract destination) amount | Destination.Sc_rollup _ | Destination.Zk_rollup _ -> (* We do not allow transferring tez from rollups to other contracts. *) - error_unless Tez.(amount = zero) (Non_empty_transaction_from source) + error_unless Tez.(amount = zero) (Non_empty_transaction_from sender) >>?= fun () -> return (ctxt, []) -let apply_transaction_to_implicit_with_ticket ~source ~destination ~ty ~ticket +let apply_transaction_to_implicit_with_ticket ~sender ~destination ~ty ~ticket ~amount ~before_operation ctxt = let destination = Contract.Implicit destination in Contract.allocated ctxt destination >>= fun already_allocated -> @@ -288,7 +288,7 @@ let apply_transaction_to_implicit_with_ticket ~source ~destination ~ty ~ticket @@ Ticket_scanner.Ex_ticket (ty, ticket) in Ticket_token_unparser.unparse ctxt ex_token >>=? fun (ticket_token, ctxt) -> - transfer_from_any_address ctxt source destination amount + transfer_from_any_address ctxt sender destination amount >>=? fun (ctxt, balance_updates) -> let ticket_receipt = Ticket_receipt. @@ -321,7 +321,7 @@ let apply_transaction_to_implicit_with_ticket ~source ~destination ~ty ~ticket }, [] ) -let apply_transaction_to_smart_contract ~ctxt ~source ~contract_hash ~amount +let apply_transaction_to_smart_contract ~ctxt ~sender ~contract_hash ~amount ~entrypoint ~before_operation ~payer ~chain_id ~internal ~parameter = let contract = Contract.Originated contract_hash in (* Since the contract is originated, nothing will be allocated or this @@ -330,7 +330,7 @@ let apply_transaction_to_smart_contract ~ctxt ~source ~contract_hash ~amount does not exist, [Script_cache.find] will signal that by returning [None] and we'll fail. *) - transfer_from_any_address ctxt source contract amount + transfer_from_any_address ctxt sender contract amount >>=? fun (ctxt, balance_updates) -> Script_cache.find ctxt contract_hash >>=? fun (ctxt, cache_key, script) -> match script with @@ -347,7 +347,7 @@ let apply_transaction_to_smart_contract ~ctxt ~source ~contract_hash ~amount let step_constants = let open Script_interpreter in { - source; + sender; payer; self = contract_hash; amount; @@ -427,7 +427,7 @@ let apply_transaction_to_smart_contract ~ctxt ~source ~contract_hash ~amount (ctxt, result, operations) ) let apply_origination ~ctxt ~storage_type ~storage ~unparsed_code - ~contract:contract_hash ~delegate ~source ~credit ~before_operation = + ~contract:contract_hash ~delegate ~sender ~credit ~before_operation = Script_ir_translator.collect_lazy_storage ctxt storage_type storage >>?= fun (to_duplicate, ctxt) -> let to_update = Script_ir_translator.no_lazy_storage_id in @@ -462,7 +462,7 @@ let apply_origination ~ctxt ~storage_type ~storage ~unparsed_code | None -> return ctxt | Some delegate -> Contract.Delegate.init ctxt contract delegate) >>=? fun ctxt -> - Token.transfer ctxt (`Contract source) (`Contract contract) credit + Token.transfer ctxt (`Contract sender) (`Contract contract) credit >>=? fun (ctxt, balance_updates) -> Fees.record_paid_storage_space ctxt contract_hash >|=? fun (ctxt, size, paid_storage_size_diff) -> @@ -480,7 +480,7 @@ let apply_origination ~ctxt ~storage_type ~storage ~unparsed_code (** - Retrieving the source code of a contract from its address is costly + Retrieving the script of a contract from its address is costly because it requires I/Os. For this reason, we put the corresponding Micheline expression in the cache. @@ -490,15 +490,15 @@ let apply_origination ~ctxt ~storage_type ~storage ~unparsed_code *) -let assert_source_is_contract = function - | Destination.Contract source -> ok source - | source -> error (Invalid_source source) +let assert_sender_is_contract = function + | Destination.Contract sender -> ok sender + | sender -> error (Invalid_sender sender) let apply_internal_operation_contents : type kind. context -> payer:public_key_hash -> - source:Destination.t -> + sender:Destination.t -> chain_id:Chain_id.t -> kind Script_typed_ir.internal_operation_contents -> (context @@ -506,8 +506,8 @@ let apply_internal_operation_contents : * Script_typed_ir.packed_internal_operation list) tzresult Lwt.t = - fun ctxt_before_op ~payer ~source ~chain_id operation -> - Destination.must_exist ctxt_before_op source >>=? fun ctxt -> + fun ctxt_before_op ~payer ~sender ~chain_id operation -> + Destination.must_exist ctxt_before_op sender >>=? fun ctxt -> (* There is no signature being checked for internal operations so in this case the fixed cost is exactly [Michelson_v1_gas.Cost_of.manager_operation]. *) @@ -518,10 +518,10 @@ let apply_internal_operation_contents : application). *) match operation with | Transaction_to_implicit {destination = pkh; amount} -> - assert_source_is_contract source >>?= fun source -> + assert_sender_is_contract sender >>?= fun sender -> apply_transaction_to_implicit ~ctxt - ~source + ~sender ~amount ~pkh ~before_operation:ctxt_before_op @@ -538,7 +538,7 @@ let apply_internal_operation_contents : unparsed_ticket = _; } -> apply_transaction_to_implicit_with_ticket - ~source + ~sender ~destination ~ty ~ticket @@ -561,7 +561,7 @@ let apply_internal_operation_contents : } -> apply_transaction_to_smart_contract ~ctxt - ~source + ~sender ~contract_hash ~amount ~entrypoint @@ -580,7 +580,7 @@ let apply_internal_operation_contents : unparsed_parameters = payload; } -> assert_sc_rollup_feature_enabled ctxt >>?= fun () -> - (match source with + (match sender with | Destination.Contract (Originated hash) -> ok hash | _ -> error Invalid_transfer_to_sc_rollup) >>?= fun sender -> @@ -652,7 +652,7 @@ let apply_internal_operation_contents : storage_type; storage; } -> - assert_source_is_contract source >>?= fun source -> + assert_sender_is_contract sender >>?= fun sender -> apply_origination ~ctxt ~storage_type @@ -660,14 +660,14 @@ let apply_internal_operation_contents : ~unparsed_code ~contract:preorigination ~delegate - ~source + ~sender ~credit ~before_operation:ctxt_before_op >|=? fun (ctxt, origination_result, ops) -> (ctxt, IOrigination_result origination_result, ops) | Delegation delegate -> - assert_source_is_contract source >>?= fun source -> - apply_delegation ~ctxt ~source ~delegate ~before_operation:ctxt_before_op + assert_sender_is_contract sender >>?= fun sender -> + apply_delegation ~ctxt ~sender ~delegate ~before_operation:ctxt_before_op >|=? fun (ctxt, consumed_gas, ops) -> (ctxt, IDelegation_result {consumed_gas}, ops) @@ -750,7 +750,7 @@ let apply_manager_operation : >>?= fun () -> apply_transaction_to_implicit ~ctxt - ~source:source_contract + ~sender:source_contract ~amount ~pkh ~before_operation:ctxt_before_op @@ -765,7 +765,7 @@ let apply_manager_operation : >>?= fun (parameters, ctxt) -> apply_transaction_to_smart_contract ~ctxt - ~source:(Destination.Contract source_contract) + ~sender:(Destination.Contract source_contract) ~contract_hash ~amount ~entrypoint @@ -792,7 +792,7 @@ let apply_manager_operation : >>=? fun (ctxt, ticket) -> Ticket_transfer.transfer_ticket ctxt - ~src:(Contract source_contract) + ~sender:(Contract source_contract) ~dst:(Contract destination) ticket amount @@ -829,7 +829,7 @@ let apply_manager_operation : ~ticketer ~contents ~ty - ~source:(Destination.Contract source_contract) + ~sender:(Destination.Contract source_contract) ~destination:destination_hash ~entrypoint ~amount @@ -837,7 +837,7 @@ let apply_manager_operation : >>=? fun (ctxt, token, op) -> Ticket_transfer.transfer_ticket ctxt - ~src:(Contract source_contract) + ~sender:(Contract source_contract) ~dst:(Contract destination) token amount @@ -909,7 +909,7 @@ let apply_manager_operation : ~unparsed_code ~contract ~delegate - ~source:source_contract + ~sender:source_contract ~credit ~before_operation:ctxt_before_op >|=? fun (ctxt, origination_result, ops) -> @@ -917,7 +917,7 @@ let apply_manager_operation : | Delegation delegate -> apply_delegation ~ctxt - ~source:source_contract + ~sender:source_contract ~delegate ~before_operation:ctxt_before_op >|=? fun (ctxt, consumed_gas, ops) -> @@ -1144,7 +1144,7 @@ let apply_internal_operations ctxt ~payer ~chain_id ops = let rec apply ctxt applied worklist = match worklist with | [] -> Lwt.return (Success ctxt, List.rev applied) - | Script_typed_ir.Internal_operation ({source; operation; nonce} as op) + | Script_typed_ir.Internal_operation ({sender; operation; nonce} as op) :: rest -> ( (if internal_nonce_already_recorded ctxt nonce then let op_res = Apply_internal_results.internal_operation op in @@ -1153,7 +1153,7 @@ let apply_internal_operations ctxt ~payer ~chain_id ops = let ctxt = record_internal_nonce ctxt nonce in apply_internal_operation_contents ctxt - ~source + ~sender ~payer ~chain_id operation) @@ -1943,10 +1943,10 @@ let apply_contents_list (type kind) ctxt chain_id (mode : mode) let blinded_pkh = Blinded_public_key_hash.of_ed25519_pkh activation_code pkh in - let src = `Collected_commitments blinded_pkh in + let sender = `Collected_commitments blinded_pkh in let contract = Contract.Implicit (Signature.Ed25519 pkh) in - Token.balance ctxt src >>=? fun (ctxt, amount) -> - Token.transfer ctxt src (`Contract contract) amount + Token.balance ctxt sender >>=? fun (ctxt, amount) -> + Token.transfer ctxt sender (`Contract contract) amount >>=? fun (ctxt, bupds) -> return (ctxt, Single_result (Activate_account_result bupds)) | Single (Proposals _ as contents) -> @@ -2092,7 +2092,7 @@ let apply_liquidity_baking_subsidy ctxt ~toggle_vote = since they are not used within the CPMM default entrypoint. *) { - source = Destination.Contract liquidity_baking_cpmm_contract; + sender = Destination.Contract liquidity_baking_cpmm_contract; payer = Signature.Public_key_hash.zero; self = liquidity_baking_cpmm_contract_hash; amount = liquidity_baking_subsidy; diff --git a/src/proto_alpha/lib_protocol/apply_internal_results.ml b/src/proto_alpha/lib_protocol/apply_internal_results.ml index f3c5d96e49ca41b8578862d64965fb1cd107ab68..6fc7f20048bc0809c2e691ed1ebe5b8f94e95435 100644 --- a/src/proto_alpha/lib_protocol/apply_internal_results.ml +++ b/src/proto_alpha/lib_protocol/apply_internal_results.ml @@ -57,7 +57,7 @@ type packed_internal_operation_contents = -> packed_internal_operation_contents type 'kind internal_operation = { - source : Destination.t; + sender : Destination.t; operation : 'kind internal_operation_contents; nonce : int; } @@ -66,7 +66,7 @@ type packed_internal_operation = | Internal_operation : 'kind internal_operation -> packed_internal_operation let internal_operation (type kind) - ({source; operation; nonce} : kind Script_typed_ir.internal_operation) : + ({sender; operation; nonce} : kind Script_typed_ir.internal_operation) : kind internal_operation = let operation : kind internal_operation_contents = match operation with @@ -124,7 +124,7 @@ let internal_operation (type kind) Origination {delegate; script; credit} | Delegation delegate -> Delegation delegate in - {source; operation; nonce} + {sender; operation; nonce} let packed_internal_operation (Script_typed_ir.Internal_operation op) = Internal_operation (internal_operation op) @@ -472,11 +472,13 @@ end let internal_operation_encoding : packed_internal_operation Data_encoding.t = def "apply_internal_results.alpha.operation_result" @@ conv - (fun (Internal_operation {source; operation; nonce}) -> - ((source, nonce), Internal_operation_contents operation)) - (fun ((source, nonce), Internal_operation_contents operation) -> - Internal_operation {source; operation; nonce}) + (fun (Internal_operation {sender; operation; nonce}) -> + ((sender, nonce), Internal_operation_contents operation)) + (fun ((sender, nonce), Internal_operation_contents operation) -> + Internal_operation {sender; operation; nonce}) (merge_objs + (* TODO: https://gitlab.com/tezos/tezos/-/issues/710 + Rename the "source" field into "sender" *) (obj2 (req "source" Destination.encoding) (req "nonce" uint16)) Internal_operation.encoding) @@ -653,6 +655,8 @@ let internal_operation_result_encoding : case (Tag op_case.tag) ~title:op_case.name + (* TODO: https://gitlab.com/tezos/tezos/-/issues/710 + Rename the "source" field into "sender" *) (merge_objs (obj3 (req "kind" (constant op_case.name)) @@ -662,10 +666,10 @@ let internal_operation_result_encoding : (fun op -> match ires_case.iselect op with | Some (op, res) -> - Some (((), op.source, op.nonce), (ires_case.proj op.operation, res)) + Some (((), op.sender, op.nonce), (ires_case.proj op.operation, res)) | None -> None) - (fun (((), source, nonce), (op, res)) -> - let op = {source; operation = ires_case.inj op; nonce} in + (fun (((), sender, nonce), (op, res)) -> + let op = {sender; operation = ires_case.inj op; nonce} in Internal_operation_result (op, res)) in def "apply_internal_results.alpha.operation_result" diff --git a/src/proto_alpha/lib_protocol/apply_internal_results.mli b/src/proto_alpha/lib_protocol/apply_internal_results.mli index 5fb1df9b81dd4a37b36fa0bb12d3678ee37f6556..e2ec98399e11ac05a004b868b318af8a40d43820 100644 --- a/src/proto_alpha/lib_protocol/apply_internal_results.mli +++ b/src/proto_alpha/lib_protocol/apply_internal_results.mli @@ -60,7 +60,7 @@ type 'kind internal_operation_contents = -> Kind.event internal_operation_contents type 'kind internal_operation = { - source : Destination.t; + sender : Destination.t; operation : 'kind internal_operation_contents; nonce : int; } diff --git a/src/proto_alpha/lib_protocol/global_constants_storage.mli b/src/proto_alpha/lib_protocol/global_constants_storage.mli index 096143c3c2af6aa0fe32057859cc98513c336712..eb71374ade5bb7a961989b135b37e92bf7ab9eb3 100644 --- a/src/proto_alpha/lib_protocol/global_constants_storage.mli +++ b/src/proto_alpha/lib_protocol/global_constants_storage.mli @@ -25,7 +25,7 @@ (** This module represents access to a global table of constant Micheline values. Users may register a Micheline value in the - table, paying the cost of storage. Once stored, contracts source code may + table, paying the cost of storage. Once stored, scripts may reference this value by its hash. Note: the table does not typecheck the values stored in it. diff --git a/src/proto_alpha/lib_protocol/sc_rollup_operations.ml b/src/proto_alpha/lib_protocol/sc_rollup_operations.ml index 9a476f77d7ea7281189ba9dedc31690c30215fc1..09502a249dd5c463f7b9ccabd1b8faac097bb7f7 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_operations.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_operations.ml @@ -302,7 +302,7 @@ let to_transaction_operation ctxt rollup in return ( Script_typed_ir.Internal_operation - {source = Destination.Sc_rollup rollup; operation; nonce}, + {sender = Destination.Sc_rollup rollup; operation; nonce}, ctxt ) let transfer_ticket_tokens ctxt ~source_destination ~acc_storage_diff @@ -314,7 +314,7 @@ let transfer_ticket_tokens ctxt ~source_destination ~acc_storage_diff let* ctxt, storage_diff = Ticket_transfer.transfer_ticket ctxt - ~src:source_destination + ~sender:source_destination ~dst:target_destination ticket_token Ticket_amount.((amount :> t)) diff --git a/src/proto_alpha/lib_protocol/script_cache.mli b/src/proto_alpha/lib_protocol/script_cache.mli index 03a856926c3875cd27c5063e89989c797c6ad44d..b9ee28639a7f8cf641c81e93f59618fa914293b1 100644 --- a/src/proto_alpha/lib_protocol/script_cache.mli +++ b/src/proto_alpha/lib_protocol/script_cache.mli @@ -45,7 +45,7 @@ type cached_contract = Script.t * Script_ir_translator.ex_script - [identifier] is the identifier identifying the [contract] in the cache; - [script = None] if there is no such contract in [ctxt]; - [script = Some (unparsed_script, ir_script)] where - - [unparsed_script] is the contract source code and storage; + - [unparsed_script] is the contract code and storage; - [script_ir] is a typed internal representation of the contract, i.e., the abstract syntax tree of its code as well as its storage. diff --git a/src/proto_alpha/lib_protocol/script_interpreter.ml b/src/proto_alpha/lib_protocol/script_interpreter.ml index 95fa6617a67e6281231b17b6362dd3db180c25f4..f6cf653a36587fae3b15805b6e66470d1ce08541 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter.ml @@ -91,7 +91,7 @@ open Script_interpreter_defs module S = Saturation_repr type step_constants = Script_typed_ir.step_constants = { - source : Destination.t; + sender : Destination.t; payer : Signature.public_key_hash; self : Contract_hash.t; amount : Tez.t; @@ -608,7 +608,7 @@ module Raw = struct (step [@ocaml.tailcall]) ( ctxt, { - source = + sender = Destination.Contract (Contract.Originated sc.self); self = contract_hash; amount = Tez.zero; @@ -1257,7 +1257,7 @@ module Raw = struct let piop = Internal_operation { - source = Destination.Contract (Contract.Originated sc.self); + sender = Destination.Contract (Contract.Originated sc.self); operation; nonce; } @@ -1308,7 +1308,7 @@ module Raw = struct let res = {destination; entrypoint = Entrypoint.default} in (step [@ocaml.tailcall]) g gas k ks res (accu, stack) | ISender (_, k) -> - let destination : Destination.t = sc.source in + let destination : Destination.t = sc.sender in let res = {destination; entrypoint = Entrypoint.default} in (step [@ocaml.tailcall]) g gas k ks res (accu, stack) | ISelf (_, ty, entrypoint, k) -> diff --git a/src/proto_alpha/lib_protocol/script_interpreter.mli b/src/proto_alpha/lib_protocol/script_interpreter.mli index 37225b513a4c825e652e18e497bffd148c824bfb..c491cceaae80e1327978b2d6c24bafb876d8ceb4 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter.mli +++ b/src/proto_alpha/lib_protocol/script_interpreter.mli @@ -62,7 +62,7 @@ type execution_result = { } type step_constants = Script_typed_ir.step_constants = { - source : Destination.t; + sender : Destination.t; payer : Signature.public_key_hash; self : Contract_hash.t; amount : Tez.t; @@ -78,7 +78,7 @@ type step_constants = Script_typed_ir.step_constants = { This will update the local storage of the contract [step_constants.self]. Other pieces of contextual information - ([source], [payer], [amount], and [chaind_id]) are also passed in + ([sender], [payer], [amount], and [chaind_id]) are also passed in [step_constant]. [internal] is [true] if and only if the execution happens within an diff --git a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml index 187a2f68216115423b9f9bd745b85974f9137e5c..0e92de38d5d22002cab8e65e813a7a812cae5e84 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml @@ -595,7 +595,7 @@ let emit_event (type t tc) (ctxt, sc) gas ~(event_type : (t, tc) ty) let operation = Event {ty = unparsed_ty; tag; unparsed_data} in let iop = { - source = Destination.Contract (Contract.Originated sc.self); + sender = Destination.Contract (Contract.Originated sc.self); operation; nonce; } @@ -689,7 +689,7 @@ let transfer (type t) (ctxt, sc) gas amount location fresh_internal_nonce ctxt >>?= fun (ctxt, nonce) -> let iop = { - source = Destination.Contract (Contract.Originated sc.self); + sender = Destination.Contract (Contract.Originated sc.self); operation; nonce; } @@ -732,8 +732,8 @@ let create_contract (ctxt, sc) gas storage_type code delegate credit init = } in fresh_internal_nonce ctxt >>?= fun (ctxt, nonce) -> - let source = Destination.Contract (Contract.Originated sc.self) in - let piop = Internal_operation {source; operation; nonce} in + let sender = Destination.Contract (Contract.Originated sc.self) in + let piop = Internal_operation {sender; operation; nonce} in let res = {piop; lazy_storage_diff} in let gas, ctxt = local_gas_counter_and_outdated_context ctxt in return (res, preorigination, ctxt, gas) diff --git a/src/proto_alpha/lib_protocol/script_ir_translator.mli b/src/proto_alpha/lib_protocol/script_ir_translator.mli index dd9af56c6fdc32fcb42a625b7a554efac43e19fa..b945d3347db3c794132838fae80df1cd0cbab3e0 100644 --- a/src/proto_alpha/lib_protocol/script_ir_translator.mli +++ b/src/proto_alpha/lib_protocol/script_ir_translator.mli @@ -104,7 +104,7 @@ type ('arg, 'storage) code = entrypoints : 'arg Script_typed_ir.entrypoints; code_size : Cache_memory_helpers.sint; (** This is an over-approximation of the value size in memory, in - bytes, of the contract's static part, that is its source + bytes, of the contract's static part, that is its code. This includes the code of the contract as well as the code of the views. The storage size is not taken into account by this field as it has a dynamic size. *) diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.ml b/src/proto_alpha/lib_protocol/script_typed_ir.ml index f9c1d7cebc5d37feb2b8474ee765d9b897a3559d..02d4b692cc92a7815bb9024a88f7975dd6da7754 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.ml +++ b/src/proto_alpha/lib_protocol/script_typed_ir.ml @@ -34,13 +34,13 @@ open Dependent_bool The step function of the interpreter is parametrized by a bunch of values called the step constants. These values are indeed constants during the call of a smart contract with the notable exception of - the IView instruction which modifies `source`, `self`, and `amount` and the KView_exit continuation + the IView instruction which modifies `sender`, `self`, and `amount` and the KView_exit continuation which restores them. ====================== *) type step_constants = { - source : Destination.t; + sender : Destination.t; (** The address calling this contract, as returned by SENDER. *) payer : Signature.public_key_hash; (** The address of the implicit account that initiated the chain of contract calls, as returned by SOURCE. *) @@ -1493,7 +1493,7 @@ and 'kind internal_operation_contents = -> Kind.delegation internal_operation_contents and 'kind internal_operation = { - source : Destination.t; + sender : Destination.t; operation : 'kind internal_operation_contents; nonce : int; } diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.mli b/src/proto_alpha/lib_protocol/script_typed_ir.mli index 5acbffbfe445c6cd4196806a1c6261db33381cab..8930f6cd54b129daa7539bc654932d4fb90fbc70 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.mli +++ b/src/proto_alpha/lib_protocol/script_typed_ir.mli @@ -33,13 +33,13 @@ open Dependent_bool The step function of the interpreter is parametrized by a bunch of values called the step constants. These values are indeed constants during the call of a smart contract with the notable exception of - the IView instruction which modifies `source`, `self`, and `amount` and the KView_exit continuation + the IView instruction which modifies `sender`, `self`, and `amount` and the KView_exit continuation which restores them. ====================== *) type step_constants = { - source : Destination.t; + sender : Destination.t; (** The address calling this contract, as returned by SENDER. *) payer : Signature.public_key_hash; (** The address of the implicit account that initiated the chain of contract calls, as returned by SOURCE. *) @@ -1656,7 +1656,7 @@ and 'kind internal_operation_contents = -> Kind.delegation internal_operation_contents and 'kind internal_operation = { - source : Destination.t; + sender : Destination.t; operation : 'kind internal_operation_contents; nonce : int; } diff --git a/src/proto_alpha/lib_protocol/test/helpers/contract_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/contract_helpers.ml index 3c3a8e44880f915d52afadf75f30b9b7185ae38b..5a663eb848308059b5b6bdc33d21e996b30dda80 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/contract_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/contract_helpers.ml @@ -69,12 +69,12 @@ let default_self = fake_KT1 let default_payer = Signature.Public_key_hash.zero -let default_source = Contract.Implicit default_payer +let default_sender = Contract.Implicit default_payer let default_step_constants = Script_interpreter. { - source = Contract default_source; + sender = Contract default_sender; payer = default_payer; self = default_self; amount = Tez.zero; 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 f7b3e4bcbc350362da702a434602d8eade2882e8..8f3fc93ea3084c62b2dfabfacb1227e04a4d18e0 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 @@ -310,7 +310,7 @@ let make_big_map ctxt contract ~key_type ~value_type entries = }, ctxt ) -let originate_script block ~script ~storage ~src ~baker ~forges_tickets = +let originate_script block ~script ~storage ~sender ~baker ~forges_tickets = let open Lwt_result_syntax in let code = Expr.toplevel_from_string script in let storage = Expr.from_string storage in @@ -318,7 +318,11 @@ let originate_script block ~script ~storage ~src ~baker ~forges_tickets = let script = Alpha_context.Script.{code = lazy_expr code; storage = lazy_expr storage} in - Op.contract_origination_hash (B block) src ~fee:(Test_tez.of_int 10) ~script + Op.contract_origination_hash + (B block) + sender + ~fee:(Test_tez.of_int 10) + ~script in let* incr = Incremental.begin_construction ~policy:Block.(By_account baker) block @@ -333,7 +337,7 @@ let originate_script block ~script ~storage ~src ~baker ~forges_tickets = let script = (code, storage) in Incremental.finalize_block incr >|=? fun block -> (destination, script, block) -let origination_operation ctxt ~src ~script:(code, storage) ~orig_contract = +let origination_operation ctxt ~sender ~script:(code, storage) ~orig_contract = let open Lwt_result_wrap_syntax in let script = Script.{code = lazy_expr code; storage = lazy_expr storage} in let unparsed_storage = storage in @@ -358,7 +362,7 @@ let origination_operation ctxt ~src ~script:(code, storage) ~orig_contract = let operation = Internal_operation { - source = src; + sender; operation = Origination { @@ -375,17 +379,17 @@ let origination_operation ctxt ~src ~script:(code, storage) ~orig_contract = in return (operation, ctxt) -let originate block ~src ~baker ~script ~storage ~forges_tickets = +let originate block ~sender ~baker ~script ~storage ~forges_tickets = let open Lwt_result_syntax in let* orig_contract, script, block = - originate_script block ~script ~storage ~src ~baker ~forges_tickets + originate_script block ~script ~storage ~sender ~baker ~forges_tickets in let* incr = Incremental.begin_construction ~policy:Block.(By_account baker) block in return (orig_contract, script, incr) -let transfer_operation ctxt ~src ~destination ~arg_type ~arg = +let transfer_operation ctxt ~sender ~destination ~arg_type ~arg = let open Lwt_result_wrap_syntax in let*@ params_node, ctxt = Script_ir_translator.unparse_data @@ -397,7 +401,7 @@ let transfer_operation ctxt ~src ~destination ~arg_type ~arg = return ( Internal_operation { - source = src; + sender; operation = Transaction_to_smart_contract { @@ -964,11 +968,11 @@ let test_diffs_args_storage_and_lazy_diffs () = (** Test that attempting to transfer a ticket that exceeds the budget fails. *) let test_update_invalid_transfer () = let open Lwt_result_syntax in - let* baker, src, block = init_for_operation () in + let* baker, sender, block = init_for_operation () in let* destination, _script, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" @@ -980,7 +984,12 @@ let test_update_invalid_transfer () = boxed_list [string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "red" 1] in let* operation, ctxt = - transfer_operation ctxt ~src:(Contract src) ~destination ~arg_type ~arg + transfer_operation + ctxt + ~sender:(Contract sender) + ~destination + ~arg_type + ~arg in assert_fail_with ~loc:__LOC__ @@ -990,7 +999,7 @@ let test_update_invalid_transfer () = (fun () -> Ticket_accounting.update_ticket_balances ctxt - ~self_contract:src + ~self_contract:sender ~ticket_diffs:Ticket_token_map.empty [operation]) @@ -998,11 +1007,11 @@ let test_update_invalid_transfer () = results in a balance update. *) let test_update_ticket_self_diff () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init_for_operation () in + let* baker, sender, block = init_for_operation () in let* self, _script, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" @@ -1041,7 +1050,7 @@ let test_update_self_ticket_transfer () = let* ticket_receiver, _script, incr = originate block - ~src:self + ~sender:self ~baker ~script:ticket_list_script ~storage:"{}" @@ -1066,7 +1075,7 @@ let test_update_self_ticket_transfer () = in transfer_operation ctxt - ~src:(Contract self) + ~sender:(Contract self) ~destination:ticket_receiver ~arg_type ~arg @@ -1098,7 +1107,7 @@ let test_update_valid_transfer () = let* destination, _script, incr = originate block - ~src:self + ~sender:self ~baker ~script:ticket_list_script ~storage:"{}" @@ -1124,7 +1133,7 @@ let test_update_valid_transfer () = 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:(Contract self) ~destination ~arg_type ~arg + transfer_operation ctxt ~sender:(Contract self) ~destination ~arg_type ~arg in let* _, ctxt = let*@ ticket_diffs, ctxt = @@ -1150,11 +1159,11 @@ let test_update_valid_transfer () = the balance. *) let test_update_transfer_tickets_to_self () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init_for_operation () in + let* baker, sender, block = init_for_operation () in let* self_hash, _script, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" @@ -1180,7 +1189,7 @@ let test_update_transfer_tickets_to_self () = let arg = boxed_list [string_ticket ticketer "red" 1] in transfer_operation ctxt - ~src:(Contract self) + ~sender:(Contract self) ~destination:self_hash ~arg_type ~arg @@ -1208,7 +1217,7 @@ let test_update_transfer_tickets_to_self () = budget fails. *) let test_update_invalid_origination () = let open Lwt_result_syntax in - let* baker, src, block = init_for_operation () in + let* baker, sender, block = init_for_operation () in let* orig_contract, script, incr = let storage = let ticketer = "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" in @@ -1220,7 +1229,7 @@ let test_update_invalid_origination () = in originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage @@ -1228,7 +1237,7 @@ let test_update_invalid_origination () = in let ctxt = Incremental.alpha_ctxt incr in let* operation, ctxt = - origination_operation ctxt ~src:(Contract src) ~orig_contract ~script + origination_operation ctxt ~sender:(Contract sender) ~orig_contract ~script in assert_fail_with ~loc:__LOC__ @@ -1238,7 +1247,7 @@ let test_update_invalid_origination () = (fun () -> Ticket_accounting.update_ticket_balances ctxt - ~self_contract:src + ~self_contract:sender ~ticket_diffs:Ticket_token_map.empty [operation]) @@ -1252,7 +1261,7 @@ let test_update_valid_origination () = let storage = Printf.sprintf {|{ Pair %S "red" 1; }|} ticketer in originate block - ~src:self + ~sender:self ~baker ~script:ticket_list_script ~storage @@ -1271,7 +1280,7 @@ let test_update_valid_origination () = Ticket_balance.adjust_balance ctxt red_self_token_hash ~delta:Z.one in let* operation, ctxt = - origination_operation ctxt ~src:(Contract self) ~orig_contract ~script + origination_operation ctxt ~sender:(Contract self) ~orig_contract ~script in let*@ _, ctxt = let* ticket_diffs, ctxt = @@ -1304,7 +1313,7 @@ let test_update_self_origination () = let storage = Printf.sprintf {|{ Pair %S "red" 1; }|} ticketer in originate block - ~src:self + ~sender:self ~baker ~script:ticket_list_script ~storage @@ -1319,7 +1328,7 @@ let test_update_self_origination () = red_token in let* operation, ctxt = - origination_operation ctxt ~src:(Contract self) ~orig_contract ~script + origination_operation ctxt ~sender:(Contract self) ~orig_contract ~script in let*@ _, ctxt = Ticket_accounting.update_ticket_balances @@ -1335,11 +1344,11 @@ let test_update_self_origination () = (** Test ticket-token map of list with duplicates. *) let test_ticket_token_map_of_list_with_duplicates () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init_for_operation () in + let* baker, sender, block = init_for_operation () in let* self, _script, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" 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 b2da9d99fb58f013ef41a7f1cd9c6a75c4248b48..4fba40926f69854f750284165be46edd9def7de6 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 @@ -204,7 +204,7 @@ let init () = let baker = Context.Contract.pkh src0 in (baker, src1, block) -let originate block ~script ~storage ~src ~baker ~forges_tickets = +let originate block ~script ~storage ~sender ~baker ~forges_tickets = let open Lwt_result_wrap_syntax in let code = Expr.toplevel_from_string script in let storage = Expr.from_string storage in @@ -212,7 +212,11 @@ let originate block ~script ~storage ~src ~baker ~forges_tickets = let script = Alpha_context.Script.{code = lazy_expr code; storage = lazy_expr storage} in - Op.contract_origination_hash (B block) src ~fee:(Test_tez.of_int 10) ~script + Op.contract_origination_hash + (B block) + sender + ~fee:(Test_tez.of_int 10) + ~script in let* incr = Incremental.begin_construction ~policy:Block.(By_account baker) block @@ -239,10 +243,11 @@ let one_ticketer block = two_ticketers block >|=? fst let nat n = Script_int.(abs @@ of_int n) -let origination_operation block ~src ~baker ~script ~storage ~forges_tickets = +let origination_operation block ~sender ~baker ~script ~storage ~forges_tickets + = let open Lwt_result_wrap_syntax in let* orig_contract, (code, storage), block = - originate block ~script ~storage ~src ~baker ~forges_tickets + originate block ~script ~storage ~sender ~baker ~forges_tickets in let* incr = Incremental.begin_construction ~policy:Block.(By_account baker) block @@ -273,7 +278,7 @@ let origination_operation block ~src ~baker ~script ~storage ~forges_tickets = let operation = Script_typed_ir.Internal_operation { - source = Contract src; + sender = Contract sender; operation = Origination { @@ -291,21 +296,21 @@ let origination_operation block ~src ~baker ~script ~storage ~forges_tickets = let incr = Incremental.set_alpha_ctxt incr ctxt in return (Contract.Originated orig_contract, operation, incr) -let delegation_operation ~src = +let delegation_operation ~sender = Script_typed_ir.Internal_operation - {source = src; operation = Delegation None; nonce = 1} + {sender; operation = Delegation None; nonce = 1} -let originate block ~src ~baker ~script ~storage ~forges_tickets = +let originate block ~sender ~baker ~script ~storage ~forges_tickets = let open Lwt_result_wrap_syntax in let* orig_contract, _script, block = - originate block ~script ~storage ~src ~baker ~forges_tickets + originate block ~script ~storage ~sender ~baker ~forges_tickets in let* incr = Incremental.begin_construction ~policy:Block.(By_account baker) block in return (orig_contract, incr) -let transfer_operation ~incr ~src ~destination ~parameters_ty ~parameters = +let transfer_operation ~incr ~sender ~destination ~parameters_ty ~parameters = let open Lwt_result_wrap_syntax in let ctxt = Incremental.alpha_ctxt incr in let*@ params_node, ctxt = @@ -319,7 +324,7 @@ let transfer_operation ~incr ~src ~destination ~parameters_ty ~parameters = return ( Script_typed_ir.Internal_operation { - source = src; + sender; operation = Transaction_to_smart_contract { @@ -380,30 +385,30 @@ let make_tickets ts = let* elements = List.map_es make_ticket ts in return @@ Script_list.of_list elements -let transfer_tickets_operation ~incr ~src ~destination tickets = +let transfer_tickets_operation ~incr ~sender ~destination tickets = let open Lwt_result_wrap_syntax in let*? parameters_ty = Environment.wrap_tzresult list_ticket_string_ty in let*@ parameters = make_tickets tickets in - transfer_operation ~incr ~src ~destination ~parameters_ty ~parameters + transfer_operation ~incr ~sender ~destination ~parameters_ty ~parameters (** Test that no tickets are returned for operations that do not contain tickets. *) let test_non_ticket_operations () = let open Lwt_result_wrap_syntax in - let* _baker, src, block = init () in + let* _baker, sender, block = init () in let* incr = Incremental.begin_construction block in - let operations = [delegation_operation ~src:(Contract src)] in + let operations = [delegation_operation ~sender:(Contract sender)] in let*@ ticket_diffs, ctxt = ticket_diffs_of_operations incr operations in assert_equal_ticket_token_diffs ctxt ~loc:__LOC__ ticket_diffs ~expected:[] (** Test transfer to a contract that does not take tickets. *) let test_transfer_to_non_ticket_contract () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* orig_contract, incr = originate block - ~src + ~sender ~baker ~script:unit_script ~storage:"Unit" @@ -412,7 +417,7 @@ let test_transfer_to_non_ticket_contract () = let* operation, incr = transfer_operation ~incr - ~src:(Contract src) + ~sender:(Contract sender) ~destination:orig_contract ~parameters_ty:unit_t ~parameters:() @@ -423,11 +428,11 @@ let test_transfer_to_non_ticket_contract () = (** Test transfer an empty list of tickets. *) let test_transfer_empty_ticket_list () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* orig_contract, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" @@ -436,7 +441,7 @@ let test_transfer_empty_ticket_list () = let* operation, incr = transfer_tickets_operation ~incr - ~src:(Contract src) + ~sender:(Contract sender) ~destination:orig_contract [] in @@ -454,12 +459,12 @@ let five = Ticket_amount.add three two (** Test transfer a list of one ticket. *) let test_transfer_one_ticket () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* ticketer = one_ticketer block in let* orig_contract, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" @@ -468,7 +473,7 @@ let test_transfer_one_ticket () = let* operation, incr = transfer_tickets_operation ~incr - ~src:(Contract src) + ~sender:(Contract sender) ~destination:orig_contract [(ticketer, "white", 1)] in @@ -492,12 +497,12 @@ let test_transfer_one_ticket () = zero-amount tickets. *) let test_transfer_multiple_tickets () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* ticketer = one_ticketer block in let* orig_contract, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" @@ -506,7 +511,7 @@ let test_transfer_multiple_tickets () = let* operation, incr = transfer_tickets_operation ~incr - ~src:(Contract src) + ~sender:(Contract sender) ~destination:orig_contract [ (ticketer, "red", 1); @@ -543,12 +548,12 @@ let test_transfer_multiple_tickets () = (** Test transfer a list of tickets of different types. *) let test_transfer_different_tickets () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* ticketer1, ticketer2 = two_ticketers block in let* destination, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" @@ -557,7 +562,7 @@ let test_transfer_different_tickets () = let* operation, incr = transfer_tickets_operation ~incr - ~src:(Contract src) + ~sender:(Contract sender) ~destination [ (ticketer1, "red", 1); @@ -614,7 +619,7 @@ let test_transfer_different_tickets () = (** Test transfer to two contracts with different types of tickets. *) let test_transfer_to_two_contracts_with_different_tickets () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* ticketer = one_ticketer block in let parameters = [(ticketer, "red", 1); (ticketer, "green", 1); (ticketer, "blue", 1)] @@ -622,7 +627,7 @@ let test_transfer_to_two_contracts_with_different_tickets () = let* destination1, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" @@ -631,7 +636,7 @@ let test_transfer_to_two_contracts_with_different_tickets () = let* operation1, incr = transfer_tickets_operation ~incr - ~src:(Contract src) + ~sender:(Contract sender) ~destination:destination1 parameters in @@ -639,7 +644,7 @@ let test_transfer_to_two_contracts_with_different_tickets () = let* destination2, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" @@ -648,7 +653,7 @@ let test_transfer_to_two_contracts_with_different_tickets () = let* operation2, incr = transfer_tickets_operation ~incr - ~src:(Contract src) + ~sender:(Contract sender) ~destination:destination2 parameters in @@ -694,11 +699,11 @@ let test_transfer_to_two_contracts_with_different_tickets () = (** Test originate a contract that does not contain tickets. *) let test_originate_non_ticket_contract () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* _orig_contract, operation, incr = origination_operation block - ~src + ~sender ~baker ~script:unit_script ~storage:"Unit" @@ -710,12 +715,12 @@ let test_originate_non_ticket_contract () = (** Test originate a contract with an empty list of tickets. *) let test_originate_with_empty_tickets_list () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let storage = "{}" in let* _orig_contract, operation, incr = origination_operation block - ~src + ~sender ~baker ~script:ticket_list_script ~storage @@ -727,7 +732,7 @@ let test_originate_with_empty_tickets_list () = (** Test originate a contract with a single ticket. *) let test_originate_with_one_ticket () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* ticketer = one_ticketer block in let storage = Printf.sprintf {|{Pair %S "white" 1}|} (Contract.to_b58check ticketer) @@ -735,7 +740,7 @@ let test_originate_with_one_ticket () = let* orig_contract, operation, ctxt = origination_operation block - ~src + ~sender ~baker ~script:ticket_list_script ~storage @@ -758,7 +763,7 @@ let test_originate_with_one_ticket () = (** Test originate a contract with multiple tickets. *) let test_originate_with_multiple_tickets () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* ticketer = one_ticketer block in let storage = let ticketer_addr = Contract.to_b58check ticketer in @@ -777,7 +782,7 @@ let test_originate_with_multiple_tickets () = let* orig_contract, operation, ctxt = origination_operation block - ~src + ~sender ~baker ~script:ticket_list_script ~storage @@ -810,7 +815,7 @@ let test_originate_with_multiple_tickets () = (** Test originate a contract with multiple tickets of different types. *) let test_originate_with_different_tickets () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* ticketer1, ticketer2 = two_ticketers block in let storage = let ticketer1_addr = Contract.to_b58check ticketer1 in @@ -840,7 +845,7 @@ let test_originate_with_different_tickets () = let* orig_contract, operation, ctxt = origination_operation block - ~src + ~sender ~baker ~script:ticket_list_script ~storage @@ -888,7 +893,7 @@ let test_originate_with_different_tickets () = (** Test originate two contracts with multiple tickets of different types. *) let test_originate_two_contracts_with_different_tickets () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* ticketer = one_ticketer block in let storage = let ticketer_addr = Contract.to_b58check ticketer in @@ -901,7 +906,7 @@ let test_originate_two_contracts_with_different_tickets () = let* orig_contract1, operation1, incr = origination_operation block - ~src + ~sender ~baker ~script:ticket_list_script ~storage @@ -911,7 +916,7 @@ let test_originate_two_contracts_with_different_tickets () = let* orig_contract2, operations2, incr = origination_operation block - ~src + ~sender ~baker ~script:ticket_list_script ~storage @@ -958,7 +963,7 @@ let test_originate_two_contracts_with_different_tickets () = (** Test originate and transfer tickets. *) let test_originate_and_transfer () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* ticketer = one_ticketer block in let ticketer_addr = Contract.to_b58check ticketer in let storage = @@ -971,7 +976,7 @@ let test_originate_and_transfer () = let* orig_contract1, operation1, incr = origination_operation block - ~src + ~sender ~baker ~script:ticket_list_script ~storage @@ -981,7 +986,7 @@ let test_originate_and_transfer () = let* destination2, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" @@ -990,7 +995,7 @@ let test_originate_and_transfer () = let* operation2, incr = transfer_tickets_operation ~incr - ~src:(Contract src) + ~sender:(Contract sender) ~destination:destination2 [(ticketer, "red", 1); (ticketer, "green", 1); (ticketer, "blue", 1)] in @@ -1061,7 +1066,7 @@ let test_originate_big_map_with_tickets () = in origination_operation block - ~src:ticketer + ~sender:ticketer ~baker ~script:ticket_big_map_script ~storage @@ -1120,7 +1125,7 @@ let test_transfer_big_map_with_tickets () = let* orig_contract, incr = originate block - ~src:ticketer_contract + ~sender:ticketer_contract ~baker ~script:ticket_big_map_script ~storage:"{}" @@ -1146,7 +1151,7 @@ let test_transfer_big_map_with_tickets () = let* operation, incr = transfer_operation ~incr - ~src:(Contract ticketer_contract) + ~sender:(Contract ticketer_contract) ~destination:orig_contract ~parameters_ty ~parameters @@ -1180,12 +1185,12 @@ let test_transfer_big_map_with_tickets () = amounts fails. *) let test_transfer_fails_on_multiple_zero_tickets () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* ticketer = one_ticketer block in let* orig_contract, incr = originate block - ~src + ~sender ~baker ~script:ticket_list_script ~storage:"{}" @@ -1197,7 +1202,7 @@ let test_transfer_fails_on_multiple_zero_tickets () = @@ (* let* operation, incr = *) transfer_tickets_operation ~incr - ~src:(Contract src) + ~sender:(Contract sender) ~destination:orig_contract [ (ticketer, "red", 1); @@ -1210,7 +1215,7 @@ let test_transfer_fails_on_multiple_zero_tickets () = (** Test that zero-amount tickets are detected and that an error is yielded. *) let test_fail_on_zero_amount_tickets () = let open Lwt_result_wrap_syntax in - let* baker, src, block = init () in + let* baker, sender, block = init () in let* ticketer = one_ticketer block in let storage = let ticketer_addr = Contract.to_b58check ticketer in @@ -1233,7 +1238,7 @@ let test_fail_on_zero_amount_tickets () = ~error:Script_tc_errors.Forbidden_zero_ticket_quantity @@ origination_operation block - ~src + ~sender ~baker ~script:ticket_list_script ~storage 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 5526a5e4048770e6c3d06298ce4600ae25b01119..bb3490162a63c4f5ce75d0d7f22e6a5ad4b26b85 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 @@ -303,8 +303,8 @@ let bake_blocks_until_next_inbox_level ?predecessor block rollup = let bake_blocks_until_inbox_level block commitment = Block.bake_until_level commitment.Sc_rollup.Commitment.inbox_level block -let publish_op_and_dummy_commitment ~src ?compressed_state ?predecessor rollup - block = +let publish_op_and_dummy_commitment ~sender ?compressed_state ?predecessor + rollup block = let open Lwt_result_syntax in let compressed_state = Option.map @@ -316,7 +316,7 @@ let publish_op_and_dummy_commitment ~src ?compressed_state ?predecessor rollup let* commitment = dummy_commitment ?compressed_state ?predecessor (B block) rollup in - let* publish = Op.sc_rollup_publish (B block) src rollup commitment in + let* publish = Op.sc_rollup_publish (B block) sender rollup commitment in return (publish, commitment) (* Verify that parameters and unparsed parameters match. *) @@ -362,7 +362,7 @@ let verify_execute_outbox_message_operations incr rollup ~loc ~operations match op with | Script_typed_ir.Internal_operation { - source = op_source; + sender = op_sender; operation = Transaction_to_smart_contract { @@ -381,11 +381,11 @@ let verify_execute_outbox_message_operations incr rollup ~loc ~operations verify_params ctxt ~parameters_ty ~parameters ~unparsed_parameters in let* () = - (* Check that the sources match. *) + (* Check that the senders match. *) Assert.equal_string ~loc (Destination.to_b58check (Sc_rollup rollup)) - (Destination.to_b58check op_source) + (Destination.to_b58check op_sender) in (* Assert that the amount is 0. *) let* () = Assert.equal_tez ~loc amount Tez.zero in @@ -2876,14 +2876,14 @@ let test_curfew () = in let* publish1, commitment1 = publish_op_and_dummy_commitment - ~src:account1 + ~sender:account1 ~compressed_state:"first" rollup block in let* publish2, commitment2 = publish_op_and_dummy_commitment - ~src:account2 + ~sender:account2 ~compressed_state:"second" rollup block @@ -2894,21 +2894,21 @@ let test_curfew () = let* publish11, commitment11 = publish_op_and_dummy_commitment - ~src:account1 + ~sender:account1 ~predecessor:commitment1 rollup block in let* publish21, commitment21 = publish_op_and_dummy_commitment - ~src:account2 + ~sender:account2 ~predecessor:commitment2 rollup block in let* publish3, _commitment3 = publish_op_and_dummy_commitment - ~src:account3 + ~sender:account3 ~compressed_state:"third" rollup block @@ -2917,21 +2917,21 @@ let test_curfew () = let* block = Block.bake ~operations:[publish11; publish21; publish3] block in let* publish111, commitment111 = publish_op_and_dummy_commitment - ~src:account1 + ~sender:account1 ~predecessor:commitment11 rollup block in let* publish211, _commitment211 = publish_op_and_dummy_commitment - ~src:account2 + ~sender:account2 ~predecessor:commitment21 rollup block in let* publish4, _commitment4 = publish_op_and_dummy_commitment - ~src:account3 + ~sender:account3 ~compressed_state:"fourth" rollup block diff --git a/src/proto_alpha/lib_protocol/ticket_operations_diff.ml b/src/proto_alpha/lib_protocol/ticket_operations_diff.ml index 41a66b20e7e3ffc07435f4dd906599fffb869b92..6260aef20150462282673e19a3e7c69dc6682603 100644 --- a/src/proto_alpha/lib_protocol/ticket_operations_diff.ml +++ b/src/proto_alpha/lib_protocol/ticket_operations_diff.ml @@ -163,7 +163,7 @@ let tickets_of_origination ctxt ~preorigination ~storage_type ~storage = (Some {tickets; destination}, ctxt) let tickets_of_operation ctxt - (Script_typed_ir.Internal_operation {source = _; operation; nonce = _}) = + (Script_typed_ir.Internal_operation {sender = _; operation; nonce = _}) = match operation with | Transaction_to_implicit _ -> return (None, ctxt) | Transaction_to_implicit_with_ticket diff --git a/src/proto_alpha/lib_protocol/ticket_transfer.ml b/src/proto_alpha/lib_protocol/ticket_transfer.ml index 57b295a6730e3a5238402e47381cdf4c49239b43..ac75f88604fda5ef58bc25770aa34fccf13bc919 100644 --- a/src/proto_alpha/lib_protocol/ticket_transfer.ml +++ b/src/proto_alpha/lib_protocol/ticket_transfer.ml @@ -42,7 +42,7 @@ let parse_ticket ~consume_deserialization_gas ~ticketer ~contents ~ty ctxt = return (ctxt, token) let parse_ticket_and_operation ~consume_deserialization_gas ~ticketer ~contents - ~ty ~source ~destination ~entrypoint ~amount ctxt = + ~ty ~sender ~destination ~entrypoint ~amount ctxt = parse_ticket ~consume_deserialization_gas ~ticketer ~contents ~ty ctxt >>=? fun ( ctxt, (Ticket_token.Ex_token {contents; contents_type; ticketer} as @@ -56,7 +56,7 @@ let parse_ticket_and_operation ~consume_deserialization_gas ~ticketer ~contents let op = Script_typed_ir.Internal_operation { - source; + sender; nonce; operation = Transaction_to_smart_contract @@ -73,21 +73,21 @@ let parse_ticket_and_operation ~consume_deserialization_gas ~ticketer ~contents in return (ctxt, token, op) -let transfer_ticket_with_hashes ctxt ~src_hash ~dst_hash (qty : Ticket_amount.t) - = +let transfer_ticket_with_hashes ctxt ~sender_hash ~dst_hash + (qty : Ticket_amount.t) = let qty = Script_int.(to_zint (qty :> n num)) in - Ticket_balance.adjust_balance ctxt src_hash ~delta:(Z.neg qty) - >>=? fun (src_storage_diff, ctxt) -> + Ticket_balance.adjust_balance ctxt sender_hash ~delta:(Z.neg qty) + >>=? fun (sender_storage_diff, ctxt) -> Ticket_balance.adjust_balance ctxt dst_hash ~delta:qty >>=? fun (dst_storage_diff, ctxt) -> Ticket_balance.adjust_storage_space ctxt - ~storage_diff:(Z.add src_storage_diff dst_storage_diff) + ~storage_diff:(Z.add sender_storage_diff dst_storage_diff) >>=? fun (diff, ctxt) -> return (ctxt, diff) -let transfer_ticket ctxt ~src ~dst ex_token qty = - Ticket_balance_key.of_ex_token ctxt ~owner:src ex_token - >>=? fun (src_hash, ctxt) -> +let transfer_ticket ctxt ~sender ~dst ex_token qty = + Ticket_balance_key.of_ex_token ctxt ~owner:sender ex_token + >>=? fun (sender_hash, ctxt) -> Ticket_balance_key.of_ex_token ctxt ~owner:dst ex_token >>=? fun (dst_hash, ctxt) -> - transfer_ticket_with_hashes ctxt ~src_hash ~dst_hash qty + transfer_ticket_with_hashes ctxt ~sender_hash ~dst_hash qty diff --git a/src/proto_alpha/lib_protocol/ticket_transfer.mli b/src/proto_alpha/lib_protocol/ticket_transfer.mli index 4af678e9c951b012b4914b0dc17b676e3e35d036..f80dd154bb5fdaac7bff00df4a96d2e233ae8246 100644 --- a/src/proto_alpha/lib_protocol/ticket_transfer.mli +++ b/src/proto_alpha/lib_protocol/ticket_transfer.mli @@ -38,14 +38,14 @@ val parse_ticket : (context * Ticket_token.ex_token, error trace) result Lwt.t (** Same as [parse_ticket], but in addition, build a transaction to - let [source] transfers [amount] units of said ticket to + let [sender] transfers [amount] units of said ticket to [destination]. *) val parse_ticket_and_operation : consume_deserialization_gas:Script.consume_deserialization_gas -> ticketer:Contract.t -> contents:Script.lazy_expr -> ty:Script.lazy_expr -> - source:Destination.t -> + sender:Destination.t -> destination:Contract_hash.t -> entrypoint:Entrypoint.t -> amount:Script_typed_ir.ticket_amount -> @@ -54,11 +54,11 @@ val parse_ticket_and_operation : tzresult Lwt.t -(** [transfer_ticket_with_hashes ctxt ~src_hash ~dst_hash qty] updates +(** [transfer_ticket_with_hashes ctxt ~sender_hash ~dst_hash qty] updates the table of tickets moves [qty] units of a given ticket from a - source to a destination, as encoded by [src_hash] and [dst_hash]. + sender to a destination, as encoded by [sender_hash] and [dst_hash]. - Consistency between [src_hash] and [dst_hash] is the + Consistency between [sender_hash] and [dst_hash] is the responsibility of the caller. Whenever possible, [transfer_ticket] should be preferred, but [transfer_ticket_with_hashes] could be preferred to reduce gas comsumption (e.g., to reuse hashes already @@ -69,21 +69,21 @@ val parse_ticket_and_operation : tickets. *) val transfer_ticket_with_hashes : context -> - src_hash:Ticket_hash.t -> + sender_hash:Ticket_hash.t -> dst_hash:Ticket_hash.t -> Ticket_amount.t -> (context * Z.t) tzresult Lwt.t -(** [transfer_ticket ctxt ~src ~dst ex_token qty] updates the table of - tickets moves [qty] units of [ex_token] from [src] to [dst], as - encoded by [src_hash] and [dst_hash]. +(** [transfer_ticket ctxt ~sender ~dst ex_token qty] updates the table of + tickets moves [qty] units of [ex_token] from [sender] to [dst], as + encoded by [sender_hash] and [dst_hash]. In addition to an updated context, this function returns the number of bytes that were newly allocated for the table of tickets. *) val transfer_ticket : context -> - src:Destination.t -> + sender:Destination.t -> dst:Destination.t -> Ticket_token.ex_token -> Ticket_amount.t -> diff --git a/src/proto_alpha/lib_protocol/zk_rollup_apply.ml b/src/proto_alpha/lib_protocol/zk_rollup_apply.ml index 166df1b8bb5afadbbbbfb4decba8aafc8a3342f3..a5c0f1b214e4d07e1f46d40872a79105a9773f8e 100644 --- a/src/proto_alpha/lib_protocol/zk_rollup_apply.ml +++ b/src/proto_alpha/lib_protocol/zk_rollup_apply.ml @@ -413,7 +413,7 @@ let perform_exits ctxt exits = let* ctxt, diff = Ticket_transfer.transfer_ticket_with_hashes ctxt - ~src_hash:op.price.id + ~sender_hash:op.price.id ~dst_hash:receiver_ticket_hash amount in diff --git a/src/proto_alpha/lib_sc_rollup_node/inbox.ml b/src/proto_alpha/lib_sc_rollup_node/inbox.ml index 39e235d2a6b8f05851770a75388f78a74fd91387..5e6572c4e51c50eff2a2fd4a38ce0743592d6bd8 100644 --- a/src/proto_alpha/lib_sc_rollup_node/inbox.ml +++ b/src/proto_alpha/lib_sc_rollup_node/inbox.ml @@ -57,7 +57,7 @@ let get_messages Node_context.{cctxt; _} head = match (operation, result) with | ( { operation = Transaction {destination = Sc_rollup rollup; parameters; _}; - source = Contract (Originated sender); + sender = Contract (Originated sender); _; }, ITransaction_result (Transaction_to_sc_rollup_result _) ) ->