From 4932a6bc3fac9d17eb66b315fa89fc747e9f1f7d Mon Sep 17 00:00:00 2001 From: Marcin Pastudzki Date: Fri, 7 Jan 2022 13:06:16 +0100 Subject: [PATCH 1/4] Tezt: Add a regression test measuring gas costs of calling views. --- tezt/_regressions/run_views.out | 252 ++++++++++++++++++++++++++++++++ tezt/lib_tezos/client.ml | 25 ++-- tezt/lib_tezos/client.mli | 18 ++- tezt/tests/main.ml | 1 + tezt/tests/views.ml | 158 ++++++++++++++++++++ 5 files changed, 442 insertions(+), 12 deletions(-) create mode 100644 tezt/_regressions/run_views.out create mode 100644 tezt/tests/views.ml diff --git a/tezt/_regressions/run_views.out b/tezt/_regressions/run_views.out new file mode 100644 index 000000000000..57e07aa1869e --- /dev/null +++ b/tezt/_regressions/run_views.out @@ -0,0 +1,252 @@ +tezt/_regressions/run_views.out + +./tezos-client --mode mockup --base-dir '' --wait none originate contract register_calls transferring 0 from bootstrap1 running ' +parameter unit; +storage (list address); +code { + CDR ; + SOURCE ; + CONS ; + NIL operation ; + PAIR ; + }; +view "calls_count" unit nat { CDR ; SIZE }; +view "last_caller" unit (option address) { CDR ; IF_CONS { DIP { DROP } ; SOME } { NONE address } }; +' --init '{}' --burn-cap 1 +Node is bootstrapped. +Estimated gas: 1417.213 units (will add 100 for safety) +Estimated storage: 409 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is 'oo5VNxswL6HtEs7vaoTekiDz9QE5ZXW2DV6H4h5DnCuEtyUfhmt' +NOT waiting for the operation to be included. +Use command + tezos-client wait for oo5VNxswL6HtEs7vaoTekiDz9QE5ZXW2DV6H4h5DnCuEtyUfhmt to be included --confirmations 1 --branch BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU +and/or an external block explorer to make sure that it has been included. +This sequence of operations was run: + Manager signed operations: + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + Fee to the baker: ꜩ0.000531 + Expected counter: 1 + Gas limit: 1518 + Storage limit: 429 bytes + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.000531 + payload fees(the block proposer) ....... +ꜩ0.000531 + Origination: + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + Credit: ꜩ0 + Script: + { parameter unit ; + storage (list address) ; + code { CDR ; SOURCE ; CONS ; NIL operation ; PAIR } ; + view "calls_count" unit nat { CDR ; SIZE } ; + view "last_caller" + unit + (option address) + { CDR ; IF_CONS { DIP { DROP } ; SOME } { NONE address } } } + Initial storage: {} + No delegate for this contract + This origination was successfully applied + Originated contracts: + KT19P9vLfrXCEwUMpiURQ5vY8Ncp5idkyKTD + Storage size: 152 bytes + Paid storage size diff: 152 bytes + Consumed gas: 1417.213 + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.038 + storage fees ........................... +ꜩ0.038 + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.06425 + storage fees ........................... +ꜩ0.06425 + +New contract KT19P9vLfrXCEwUMpiURQ5vY8Ncp5idkyKTD originated. +Contract memorized as register_calls. + +./tezos-client --mode mockup --base-dir '' --wait none originate contract check_caller transferring 0 from bootstrap1 running ' +parameter address ; +storage (option address) ; +code { + CAR ; + DUP ; + UNIT ; + VIEW "calls_count" nat ; + IF_NONE { UNIT ; FAILWITH } {} ; + DIP { + UNIT ; + VIEW "last_caller" (option address) ; + } ; + PUSH nat 0 ; + /* Check if the caller address is consistent with given calls count. */ + IFCMPEQ { + IF_NONE { UNIT ; FAILWITH } { IF_NONE {} { UNIT ; FAILWITH }} ; + NONE address ; + } + { + IF_NONE { UNIT ; FAILWITH } { IF_NONE { UNIT ; FAILWITH } {}} ; + SOME ; + } ; + NIL operation ; + PAIR ; + } + ' --init None --burn-cap 1 +Node is bootstrapped. +Estimated gas: 1432.729 units (will add 100 for safety) +Estimated storage: 465 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is 'ooYj2QbiRiwv8K5dGfGVn6RhN29WLZsUBSkPHpTWJ68iZhCxBcw' +NOT waiting for the operation to be included. +Use command + tezos-client wait for ooYj2QbiRiwv8K5dGfGVn6RhN29WLZsUBSkPHpTWJ68iZhCxBcw to be included --confirmations 1 --branch BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU +and/or an external block explorer to make sure that it has been included. +This sequence of operations was run: + Manager signed operations: + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + Fee to the baker: ꜩ0.000589 + Expected counter: 2 + Gas limit: 1533 + Storage limit: 485 bytes + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.000589 + payload fees(the block proposer) ....... +ꜩ0.000589 + Origination: + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + Credit: ꜩ0 + Script: + { parameter address ; + storage (option address) ; + code { CAR ; + DUP ; + UNIT ; + VIEW "calls_count" nat ; + IF_NONE { UNIT ; FAILWITH } {} ; + DIP { UNIT ; VIEW "last_caller" (option address) } ; + PUSH nat 0 ; + IFCMPEQ + { IF_NONE { UNIT ; FAILWITH } { IF_NONE {} { UNIT ; FAILWITH } } ; + NONE address } + { IF_NONE { UNIT ; FAILWITH } { IF_NONE { UNIT ; FAILWITH } {} } ; + SOME } ; + NIL operation ; + PAIR } } + Initial storage: None + No delegate for this contract + This origination was successfully applied + Originated contracts: + KT1EYwqeAzgkynYXJnHJ7ZxuXk5bNBBy6R6L + Storage size: 208 bytes + Paid storage size diff: 208 bytes + Consumed gas: 1432.729 + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.052 + storage fees ........................... +ꜩ0.052 + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.06425 + storage fees ........................... +ꜩ0.06425 + +New contract KT1EYwqeAzgkynYXJnHJ7ZxuXk5bNBBy6R6L originated. +Contract memorized as check_caller. + +./tezos-client --mode mockup --base-dir '' --wait none transfer 1 from bootstrap1 to KT1EYwqeAzgkynYXJnHJ7ZxuXk5bNBBy6R6L --burn-cap 1 --arg '"KT19P9vLfrXCEwUMpiURQ5vY8Ncp5idkyKTD"' +Node is bootstrapped. +Estimated gas: 4448.948 units (will add 100 for safety) +Estimated storage: no bytes added +Operation successfully injected in the node. +Operation hash is 'ooeWJ1x8vuNSdxzJnQPjw3Jz9XMJFqJe1Cga8quXXbWcucEujBy' +NOT waiting for the operation to be included. +Use command + tezos-client wait for ooeWJ1x8vuNSdxzJnQPjw3Jz9XMJFqJe1Cga8quXXbWcucEujBy to be included --confirmations 1 --branch BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU +and/or an external block explorer to make sure that it has been included. +This sequence of operations was run: + Manager signed operations: + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + Fee to the baker: ꜩ0.000751 + Expected counter: 3 + Gas limit: 4549 + Storage limit: 0 bytes + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.000751 + payload fees(the block proposer) ....... +ꜩ0.000751 + Transaction: + Amount: ꜩ1 + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + To: KT1EYwqeAzgkynYXJnHJ7ZxuXk5bNBBy6R6L + Parameter: "KT19P9vLfrXCEwUMpiURQ5vY8Ncp5idkyKTD" + This transaction was successfully applied + Updated storage: None + Storage size: 208 bytes + Consumed gas: 4449.746 + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ1 + KT1EYwqeAzgkynYXJnHJ7ZxuXk5bNBBy6R6L ... +ꜩ1 + + +./tezos-client --mode mockup --base-dir '' --wait none transfer 1 from bootstrap1 to KT19P9vLfrXCEwUMpiURQ5vY8Ncp5idkyKTD --burn-cap 1 +Node is bootstrapped. +Estimated gas: 2067.348 units (will add 100 for safety) +Estimated storage: 27 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is 'ooqdCJ1FcbQQtnEg3bJA2CWxvv1To8aVBGgnBT7nYpU7zFM33pW' +NOT waiting for the operation to be included. +Use command + tezos-client wait for ooqdCJ1FcbQQtnEg3bJA2CWxvv1To8aVBGgnBT7nYpU7zFM33pW to be included --confirmations 1 --branch BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU +and/or an external block explorer to make sure that it has been included. +This sequence of operations was run: + Manager signed operations: + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + Fee to the baker: ꜩ0.000467 + Expected counter: 4 + Gas limit: 2168 + Storage limit: 47 bytes + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.000467 + payload fees(the block proposer) ....... +ꜩ0.000467 + Transaction: + Amount: ꜩ1 + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + To: KT19P9vLfrXCEwUMpiURQ5vY8Ncp5idkyKTD + This transaction was successfully applied + Updated storage: { 0x000002298c03ed7d454a101eb7022bc95f7e5f41ac78 } + Storage size: 179 bytes + Paid storage size diff: 27 bytes + Consumed gas: 2068.260 + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.00675 + storage fees ........................... +ꜩ0.00675 + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ1 + KT19P9vLfrXCEwUMpiURQ5vY8Ncp5idkyKTD ... +ꜩ1 + + +./tezos-client --mode mockup --base-dir '' --wait none transfer 1 from bootstrap1 to KT1EYwqeAzgkynYXJnHJ7ZxuXk5bNBBy6R6L --burn-cap 1 --arg '"KT19P9vLfrXCEwUMpiURQ5vY8Ncp5idkyKTD"' +Node is bootstrapped. +Estimated gas: 5761.955 units (will add 100 for safety) +Estimated storage: 27 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is 'oohh2J6m4DnZ9e4d57NeUfNjK3eWQh5xcTxoCLGwCyktxswEYUp' +NOT waiting for the operation to be included. +Use command + tezos-client wait for oohh2J6m4DnZ9e4d57NeUfNjK3eWQh5xcTxoCLGwCyktxswEYUp to be included --confirmations 1 --branch BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU +and/or an external block explorer to make sure that it has been included. +This sequence of operations was run: + Manager signed operations: + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + Fee to the baker: ꜩ0.000883 + Expected counter: 5 + Gas limit: 5862 + Storage limit: 47 bytes + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.000883 + payload fees(the block proposer) ....... +ꜩ0.000883 + Transaction: + Amount: ꜩ1 + From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx + To: KT1EYwqeAzgkynYXJnHJ7ZxuXk5bNBBy6R6L + Parameter: "KT19P9vLfrXCEwUMpiURQ5vY8Ncp5idkyKTD" + This transaction was successfully applied + Updated storage: (Some 0x000002298c03ed7d454a101eb7022bc95f7e5f41ac78) + Storage size: 235 bytes + Paid storage size diff: 27 bytes + Consumed gas: 5762.753 + Balance updates: + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.00675 + storage fees ........................... +ꜩ0.00675 + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ1 + KT1EYwqeAzgkynYXJnHJ7ZxuXk5bNBBy6R6L ... +ꜩ1 + diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index 73a39678f9b5..b90b0a930e22 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -567,10 +567,11 @@ let gen_and_show_keys ?alias client = let* alias = gen_keys ?alias client in show_address ~alias client -let spawn_transfer ?endpoint ?(wait = "none") ?burn_cap ?fee ?gas_limit +let spawn_transfer ?hooks ?endpoint ?(wait = "none") ?burn_cap ?fee ?gas_limit ?storage_limit ?counter ?arg ~amount ~giver ~receiver client = spawn_command ?endpoint + ?hooks client (["--wait"; wait] @ ["transfer"; Tez.to_string amount; "from"; giver; "to"; receiver] @@ -596,10 +597,11 @@ let spawn_transfer ?endpoint ?(wait = "none") ?burn_cap ?fee ?gas_limit counter @ Option.fold ~none:[] ~some:(fun p -> ["--arg"; p]) arg) -let transfer ?endpoint ?wait ?burn_cap ?fee ?gas_limit ?storage_limit ?counter - ?arg ~amount ~giver ~receiver client = +let transfer ?hooks ?endpoint ?wait ?burn_cap ?fee ?gas_limit ?storage_limit + ?counter ?arg ~amount ~giver ~receiver client = spawn_transfer ?endpoint + ?hooks ?wait ?burn_cap ?fee @@ -743,9 +745,10 @@ let spawn_submit_ballot ?(key = Constant.bootstrap1.alias) ?(wait = "none") let submit_ballot ?key ?wait ~proto_hash vote client = spawn_submit_ballot ?key ?wait ~proto_hash vote client |> Process.check -let spawn_originate_contract ?endpoint ?(wait = "none") ?init ?burn_cap ~alias - ~amount ~src ~prg client = +let spawn_originate_contract ?hooks ?endpoint ?(wait = "none") ?init ?burn_cap + ~alias ~amount ~src ~prg client = spawn_command + ?hooks ?endpoint client (["--wait"; wait] @@ -782,11 +785,12 @@ let convert_script_to_json ?endpoint ~script client = let convert_data_to_json ?endpoint ~data client = convert_michelson_to_json ~kind:"data" ?endpoint ~input:data client -let originate_contract ?endpoint ?wait ?init ?burn_cap ~alias ~amount ~src ~prg - client = +let originate_contract ?hooks ?endpoint ?wait ?init ?burn_cap ~alias ~amount + ~src ~prg client = let* client_output = spawn_originate_contract ?endpoint + ?hooks ?wait ?init ?burn_cap @@ -885,14 +889,15 @@ let stresstest ?endpoint ?source_aliases ?source_pkhs ?source_accounts ?seed client |> Process.check -let spawn_run_script ~src ~storage ~input client = +let spawn_run_script ?hooks ~src ~storage ~input client = spawn_command + ?hooks client ["run"; "script"; src; "on"; "storage"; storage; "and"; "input"; input] -let run_script ~src ~storage ~input client = +let run_script ?hooks ~src ~storage ~input client = let* client_output = - spawn_run_script ~src ~storage ~input client + spawn_run_script ?hooks ~src ~storage ~input client |> Process.check_and_read_stdout in match client_output =~* rex "storage\n(.*)" with diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index b86a8e501589..a96e74c045f9 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -413,6 +413,7 @@ val gen_and_show_keys : ?alias:string -> t -> Account.key Lwt.t (** Run [tezos-client transfer amount from giver to receiver]. *) val transfer : + ?hooks:Process.hooks -> ?endpoint:endpoint -> ?wait:string -> ?burn_cap:Tez.t -> @@ -429,6 +430,7 @@ val transfer : (** Same as [transfer], but do not wait for the process to exit. *) val spawn_transfer : + ?hooks:Process.hooks -> ?endpoint:endpoint -> ?wait:string -> ?burn_cap:Tez.t -> @@ -563,6 +565,7 @@ val spawn_submit_ballot : (** Run [tezos-client originate contract alias transferring amount from src running prg]. Returns the originated contract hash *) val originate_contract : + ?hooks:Process.hooks -> ?endpoint:endpoint -> ?wait:string -> ?init:string -> @@ -576,6 +579,7 @@ val originate_contract : (** Same as [originate_contract], but do not wait for the process to exit. *) val spawn_originate_contract : + ?hooks:Process.hooks -> ?endpoint:endpoint -> ?wait:string -> ?init:string -> @@ -653,11 +657,21 @@ val spawn_stresstest : Fails if the new storage cannot be extracted from the output. *) val run_script : - src:string -> storage:string -> input:string -> t -> string Lwt.t + ?hooks:Process.hooks -> + src:string -> + storage:string -> + input:string -> + t -> + string Lwt.t (** Same as [run_script] but do not wait for the process to exit. *) val spawn_run_script : - src:string -> storage:string -> input:string -> t -> Process.t + ?hooks:Process.hooks -> + src:string -> + storage:string -> + input:string -> + t -> + Process.t (** Run [tezos-client register global constant value from src]. Returns the address hash of the new constant. *) diff --git a/tezt/tests/main.ml b/tezt/tests/main.ml index 7e706555d8f4..792fd66ccb45 100644 --- a/tezt/tests/main.ml +++ b/tezt/tests/main.ml @@ -108,5 +108,6 @@ let () = Manager_operations.register ~protocols ; Replace_by_fees.register ~protocols:[Alpha] ; Sc_rollup.register ~protocols:[Alpha] ; + Views.register ~protocols:[Alpha] () ; (* Test.run () should be the last statement, don't register afterwards! *) Test.run () diff --git a/tezt/tests/views.ml b/tezt/tests/views.ml new file mode 100644 index 000000000000..96ff3770cee1 --- /dev/null +++ b/tezt/tests/views.ml @@ -0,0 +1,158 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2021 Nomadic Labs *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(* Testing + ------- + Component: Michelson + Invocation: dune exec tezt/tests/main.exe -- --file views.ml + Subject: Call smart contract views to catch performance regressions. + *) + +(* This contract registers all SOURCE addresses that ever call it. It has views + that return registered callers count and the last caller address respectively. *) +let register_callers_src = + {| +parameter unit; +storage (list address); +code { + CDR ; + SOURCE ; + CONS ; + NIL operation ; + PAIR ; + }; +view "calls_count" unit nat { CDR ; SIZE }; +view "last_caller" unit (option address) { CDR ; IF_CONS { DIP { DROP } ; SOME } { NONE address } }; +|} + +(* This script calls views on register_callers contract and verifies whether + its responses are consistent, i.e. if the view calls_count returned 0, then + last caller is None, otherwise – it's Some address. *) +let check_caller_src = + {| +parameter address ; +storage (option address) ; +code { + CAR ; + DUP ; + UNIT ; + VIEW "calls_count" nat ; + IF_NONE { UNIT ; FAILWITH } {} ; + DIP { + UNIT ; + VIEW "last_caller" (option address) ; + } ; + PUSH nat 0 ; + /* Check if the caller address is consistent with given calls count. */ + IFCMPEQ { + IF_NONE { UNIT ; FAILWITH } { IF_NONE {} { UNIT ; FAILWITH }} ; + NONE address ; + } + { + IF_NONE { UNIT ; FAILWITH } { IF_NONE { UNIT ; FAILWITH } {}} ; + SOME ; + } ; + NIL operation ; + PAIR ; + } + |} + +(* Normally "--base-dir" would appear in regression logs. However, since + it is a different dir on every run, we need to mask it in regression + logs so that it doesn't cause false differences. *) +let hooks = + let rec mask_temp_dir = function + | [] -> [] + | "--base-dir" :: _ :: rest -> "--base-dir" :: "" :: rest + | arg :: args -> arg :: mask_temp_dir args + in + { + Regression.hooks with + on_spawn = + (fun cmd args -> mask_temp_dir args |> Regression.hooks.on_spawn cmd); + } + +let register ~protocols () = + Protocol.register_regression_test + ~__FILE__ + ~title:"Run views" + ~tags:["client"; "michelson"] + ~output_file:"run_views" + ~protocols + @@ fun protocol -> + let* client = Client.init_mockup ~protocol () in + let* register_callers = + Client.originate_contract + ~hooks + ~burn_cap:Tez.one + ~alias:"register_calls" + ~amount:Tez.zero + ~src:"bootstrap1" + ~prg:register_callers_src + ~init:"{}" + client + in + let arg = Format.sprintf "\"%s\"" register_callers in + let* check_caller = + Client.originate_contract + ~hooks + ~burn_cap:Tez.one + ~alias:"check_caller" + ~amount:Tez.zero + ~src:"bootstrap1" + ~prg:check_caller_src + ~init:"None" + client + in + let* () = + Client.transfer + ~hooks + ~burn_cap:Tez.one + ~amount:Tez.one + ~giver:"bootstrap1" + ~receiver:check_caller + ~arg + client + in + let* () = + Client.transfer + ~hooks + ~burn_cap:Tez.one + ~amount:Tez.one + ~giver:"bootstrap1" + ~receiver:register_callers + client + in + let* () = + Client.transfer + ~hooks + ~burn_cap:Tez.one + ~amount:Tez.one + ~giver:"bootstrap1" + ~receiver:check_caller + ~arg + client + in + return () -- GitLab From dbe218ee7c36b001538e89997436084199e04196 Mon Sep 17 00:00:00 2001 From: Marcin Pastudzki Date: Thu, 18 Nov 2021 16:25:52 +0100 Subject: [PATCH 2/4] Proto Alpha: Make balance a step constant in Michelson interpreter. Signed-off-by: Marcin Pastudzki --- .../lib_benchmark/execution_context.ml | 34 +++++++++++++++---- .../interpreter_benchmarks.ml | 1 + src/proto_alpha/lib_plugin/plugin.ml | 24 +++++++++++-- src/proto_alpha/lib_protocol/apply.ml | 19 ++++++++++- .../lib_protocol/script_interpreter.ml | 8 +++-- .../lib_protocol/script_interpreter.mli | 1 + .../lib_protocol/script_typed_ir.ml | 1 + .../lib_protocol/script_typed_ir.mli | 1 + .../test/helpers/contract_helpers.ml | 1 + 9 files changed, 77 insertions(+), 13 deletions(-) diff --git a/src/proto_alpha/lib_benchmark/execution_context.ml b/src/proto_alpha/lib_benchmark/execution_context.ml index 725e24204db8..f9e6b1a1fd27 100644 --- a/src/proto_alpha/lib_benchmark/execution_context.ml +++ b/src/proto_alpha/lib_benchmark/execution_context.ml @@ -28,16 +28,18 @@ open Error_monad type context = Alpha_context.context * Script_interpreter.step_constants +let initial_balance = 4_000_000_000_000L + let context_init_memory ~rng_state = Context.init ~rng_state ~initial_balances: [ - 4_000_000_000_000L; - 4_000_000_000_000L; - 4_000_000_000_000L; - 4_000_000_000_000L; - 4_000_000_000_000L; + initial_balance; + initial_balance; + initial_balance; + initial_balance; + initial_balance; ] 5 >>=? fun (block, accounts) -> @@ -61,12 +63,30 @@ let make ~rng_state = let payer = bs2 in let self = bs3 in let step_constants = - {source; payer; self; amount; chain_id; now; level} + { + source; + payer; + self; + amount; + balance = Alpha_context.Tez.of_mutez_exn initial_balance; + chain_id; + now; + level; + } in return (block, step_constants) | `Disk_block (block, source) -> let step_constants = - {source; payer = source; self = source; amount; chain_id; now; level} + { + source; + payer = source; + self = source; + amount; + balance = Alpha_context.Tez.of_mutez_exn initial_balance; + chain_id; + now; + level; + } in return (block, step_constants)) >>=? fun (block, step_constants) -> diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml index b7570a634a91..3ec52df528f6 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -2899,6 +2899,7 @@ module Registration_section = struct payer = zero; self = zero; amount = Tez.zero; + balance = Tez.zero; chain_id = Chain_id.zero; now = Script_timestamp.of_zint Z.zero; level = Script_int.zero_n; diff --git a/src/proto_alpha/lib_plugin/plugin.ml b/src/proto_alpha/lib_plugin/plugin.ml index 0360e939d217..7cc34ca3d518 100644 --- a/src/proto_alpha/lib_plugin/plugin.ml +++ b/src/proto_alpha/lib_plugin/plugin.ml @@ -1967,7 +1967,16 @@ module RPC = struct in let step_constants = let open Script_interpreter in - {source; payer; self = dummy_contract; amount; chain_id; now; level} + { + source; + payer; + self = dummy_contract; + amount; + balance; + chain_id; + now; + level; + } in Script_interpreter.execute ctxt @@ -2033,7 +2042,16 @@ module RPC = struct in let step_constants = let open Script_interpreter in - {source; payer; self = dummy_contract; amount; chain_id; now; level} + { + source; + payer; + self = dummy_contract; + amount; + balance; + chain_id; + now; + level; + } in let module Unparsing_mode = struct let unparsing_mode = unparsing_mode @@ -2080,6 +2098,7 @@ module RPC = struct >>=? fun view_ty -> View_helpers.extract_view_output_type entrypoint view_ty >>?= fun ty -> + Contract.get_balance ctxt contract >>=? fun balance -> Error_monad.trace View_helpers.View_callback_origination_failed @@ originate_dummy_contract ctxt @@ -2116,6 +2135,7 @@ module RPC = struct payer; self = contract; amount = Tez.zero; + balance; chain_id; now; level; diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index f4e07926e0f3..ef57bcc9c97b 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -931,6 +931,9 @@ let apply_manager_operation_content : in (ctxt, result, []) ) | Some (script, script_ir) -> + (* Token.transfer which is being called above already loads this + value into the Irmin cache, so no need to burn gas for it. *) + Contract.get_balance ctxt destination >>=? fun balance -> let now = Script_timestamp.now ctxt in let level = (Level.current ctxt).level |> Raw_level.to_int32 @@ -938,7 +941,16 @@ let apply_manager_operation_content : in let step_constants = let open Script_interpreter in - {source; payer; self = destination; amount; chain_id; now; level} + { + source; + payer; + self = destination; + amount; + chain_id; + balance; + now; + level; + } in Script_interpreter.execute ctxt @@ -2389,6 +2401,10 @@ let apply_liquidity_baking_subsidy ctxt ~escape_vote = match script with | None -> fail (Script_tc_errors.No_such_entrypoint Entrypoint.default) | Some (script, script_ir) -> ( + (* Token.transfer which is being called above already loads this + value into the Irmin cache, so no need to burn gas for it. *) + Contract.get_balance ctxt liquidity_baking_cpmm_contract + >>=? fun balance -> let now = Script_timestamp.now ctxt in let level = (Level.current ctxt).level |> Raw_level.to_int32 @@ -2404,6 +2420,7 @@ let apply_liquidity_baking_subsidy ctxt ~escape_vote = payer = liquidity_baking_cpmm_contract; self = liquidity_baking_cpmm_contract; amount = liquidity_baking_subsidy; + balance; chain_id = Chain_id.zero; now; level; diff --git a/src/proto_alpha/lib_protocol/script_interpreter.ml b/src/proto_alpha/lib_protocol/script_interpreter.ml index 4486c4705b4f..f979279bd2b5 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter.ml @@ -95,6 +95,7 @@ type step_constants = Script_typed_ir.step_constants = { payer : Contract.t; self : Contract.t; amount : Tez.t; + balance : Tez.t; chain_id : Chain_id.t; now : Script_timestamp.t; level : Script_int.n Script_int.num; @@ -1102,6 +1103,8 @@ and step : type a s b t r f. (a, s, b, t, r, f) step_type = let kstack_ty = Item_t (output_ty, s) in let kkinfo = {kkinfo with kstack_ty} in let ks = KCons (ICons_some (kkinfo, k), ks) in + Contract.get_balance_carbonated ctxt c + >>=? fun (ctxt, balance) -> (step [@ocaml.tailcall]) ( outdated ctxt, { @@ -1109,6 +1112,7 @@ and step : type a s b t r f. (a, s, b, t, r, f) step_type = source = sc.self; self = c; amount = Tez.zero; + balance; } ) (update_local_gas_counter ctxt) kinstr @@ -1155,12 +1159,10 @@ and step : type a s b t r f. (a, s, b, t, r, f) step_type = (step [@ocaml.tailcall]) (ctxt, sc) gas k ks res stack | IBalance (_, k) -> let ctxt = update_context gas ctxt in - Contract.get_balance_carbonated ctxt sc.self - >>=? fun (ctxt, balance) -> let gas = update_local_gas_counter ctxt in let ctxt = outdated ctxt in let g = (ctxt, sc) in - (step [@ocaml.tailcall]) g gas k ks balance (accu, stack) + (step [@ocaml.tailcall]) g gas k ks sc.balance (accu, stack) | ILevel (_, k) -> (step [@ocaml.tailcall]) g gas k ks sc.level (accu, stack) | INow (_, k) -> (step [@ocaml.tailcall]) g gas k ks sc.now (accu, stack) diff --git a/src/proto_alpha/lib_protocol/script_interpreter.mli b/src/proto_alpha/lib_protocol/script_interpreter.mli index 0fce503243a4..1d03e3cb796a 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter.mli +++ b/src/proto_alpha/lib_protocol/script_interpreter.mli @@ -62,6 +62,7 @@ type step_constants = Script_typed_ir.step_constants = { payer : Contract.t; self : Contract.t; amount : Tez.t; + balance : Tez.t; chain_id : Chain_id.t; now : Script_timestamp.t; level : Script_int.n Script_int.num; diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.ml b/src/proto_alpha/lib_protocol/script_typed_ir.ml index 1b795de98d01..5d9fe73d0af7 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.ml +++ b/src/proto_alpha/lib_protocol/script_typed_ir.ml @@ -49,6 +49,7 @@ type step_constants = { - as caller in VIEW, TRANSFER_TOKENS, and CREATE_CONTRACT *) amount : Tez.t; (** The amount of the current transaction, as returned by AMOUNT. *) + balance : Tez.t; (** The balance of the contract as returned by BALANCE. *) chain_id : Chain_id.t; (** The chain id of the chain, as returned by CHAIN_ID. *) now : Script_timestamp.t; diff --git a/src/proto_alpha/lib_protocol/script_typed_ir.mli b/src/proto_alpha/lib_protocol/script_typed_ir.mli index 7c586021b632..4991feaedf3e 100644 --- a/src/proto_alpha/lib_protocol/script_typed_ir.mli +++ b/src/proto_alpha/lib_protocol/script_typed_ir.mli @@ -33,6 +33,7 @@ type step_constants = { payer : Contract.t; self : Contract.t; amount : Tez.t; + balance : Tez.t; chain_id : Chain_id.t; now : Script_timestamp.t; level : Script_int.n Script_int.num; 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 ad37f1aa039d..2570b95a18e5 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/contract_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/contract_helpers.ml @@ -73,6 +73,7 @@ let default_step_constants = payer = default_source; self = default_source; amount = Tez.zero; + balance = Tez.zero; chain_id = Chain_id.zero; now = Script_timestamp.of_zint Z.zero; level = Script_int.zero_n; -- GitLab From 56f813742587ad4cce6001b0898a4269531374da Mon Sep 17 00:00:00 2001 From: Marcin Pastudzki Date: Thu, 18 Nov 2021 16:27:21 +0100 Subject: [PATCH 3/4] Proto Alpha: Update regression tests output. Making contract balance a step constant reduced gas costs and baker fees of executing contracts which use BALANCE instruction. It also probably increased said values for contracts using VIEW instruction. Other contracts should be unaffected. Real-life effects might be different due to caching. Signed-off-by: Marcin Pastudzki --- ...ddressTransfer::test_send_self_address.out | 12 +++---- ...ef0e55c43a9a857214d8761e67b.7da5c9014e.out | 12 +++---- ...TestContractOpcodes::test_balance[0.5].out | 6 ++-- ...s.TestContractOpcodes::test_balance[0].out | 6 ++-- ...estContractOpcodes::test_balance[1000].out | 6 ++-- ...s.TestContractOpcodes::test_balance[1].out | 6 ++-- ...stContractOpcodes::test_balance[1e-06].out | 6 ++-- ...s.TestContractOpcodes::test_balance[5].out | 6 ++-- ...Opcodes::test_balance[8000000000000.0].out | 6 ++-- ...put[balance.tz-111-Unit-4000000000000].out | 6 ++-- tezt/_regressions/run_views.out | 32 +++++++++---------- 11 files changed, 52 insertions(+), 52 deletions(-) diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestSelfAddressTransfer::test_send_self_address.out b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestSelfAddressTransfer::test_send_self_address.out index a7b397372f01..67a858252965 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract.TestSelfAddressTransfer::test_send_self_address.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract.TestSelfAddressTransfer::test_send_self_address.out @@ -1,7 +1,7 @@ tests_alpha/test_contract.py::TestSelfAddressTransfer::test_send_self_address Node is bootstrapped. -Estimated gas: 5413.006 units (will add 100 for safety) +Estimated gas: 5192.990 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. Operation hash is '[BLOCK_HASH]' @@ -12,13 +12,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [CONTRACT_HASH] - Fee to the baker: ꜩ0.000846 + Fee to the baker: ꜩ0.000824 Expected counter: [EXPECTED_COUNTER] - Gas limit: 5514 + Gas limit: 5293 Storage limit: 0 bytes Balance updates: - [CONTRACT_HASH] ... -ꜩ0.000846 - payload fees(the block proposer) ....... +ꜩ0.000846 + [CONTRACT_HASH] ... -ꜩ0.000824 + payload fees(the block proposer) ....... +ꜩ0.000824 Transaction: Amount: ꜩ0 From: [CONTRACT_HASH] @@ -27,7 +27,7 @@ This sequence of operations was run: This transaction was successfully applied Updated storage: Unit Storage size: 82 bytes - Consumed gas: 3353.748 + Consumed gas: 3133.732 Internal operations: Transaction: Amount: ꜩ0 diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_slice_success[(Pair 0xe009ab79e8b84ef0e55c43a9a857214d8761e67b.7da5c9014e.out b/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_slice_success[(Pair 0xe009ab79e8b84ef0e55c43a9a857214d8761e67b.7da5c9014e.out index 4f437d5c9431..05e09c848dbf 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_slice_success[(Pair 0xe009ab79e8b84ef0e55c43a9a857214d8761e67b.7da5c9014e.out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_onchain_opcodes.TestContractOnchainOpcodes::test_slice_success[(Pair 0xe009ab79e8b84ef0e55c43a9a857214d8761e67b.7da5c9014e.out @@ -1,7 +1,7 @@ tests_alpha/test_contract_onchain_opcodes.py::TestContractOnchainOpcodes::test_slice_success[(Pair 0xe009ab79e8b84ef0e55c43a9a857214d8761e67b75ba63500a5694fb2ffe174acc2de22d01ccb7259342437f05e1987949f0ad82e9f32e9a0b79cb252d7f7b8236ad728893f4e7150742eefdbeda254970f9fcd92c6228c178e1a923e5600758eb83f2a05edd0be7625657901f2ba81eaf145d003dbef78e33f43a32a3788bdf0501000000085341554349535345 "spsig1PPUFZucuAQybs5wsqsNQ68QNgFaBnVKMFaoZZfi1BtNnuCAWnmL9wVy5HfHkR6AeodjVGxpBVVSYcJKyMURn6K1yknYLm")] Node is bootstrapped. -Estimated gas: 4184.720 units (will add 100 for safety) +Estimated gas: 3964.704 units (will add 100 for safety) Estimated storage: 257 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[BLOCK_HASH]' @@ -12,13 +12,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [CONTRACT_HASH] - Fee to the baker: ꜩ0.000936 + Fee to the baker: ꜩ0.000914 Expected counter: [EXPECTED_COUNTER] - Gas limit: 4285 + Gas limit: 4065 Storage limit: 277 bytes Balance updates: - [CONTRACT_HASH] ... -ꜩ0.000936 - payload fees(the block proposer) ....... +ꜩ0.000936 + [CONTRACT_HASH] ... -ꜩ0.000914 + payload fees(the block proposer) ....... +ꜩ0.000914 Transaction: Amount: ꜩ0 From: [CONTRACT_HASH] @@ -29,7 +29,7 @@ This sequence of operations was run: Updated storage: [OPERATION_HASH]48f709699019725ba Storage size: 578 bytes - Consumed gas: 2764.720 + Consumed gas: 2544.704 Internal operations: Transaction: Amount: ꜩ1000 diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[0.5].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[0.5].out index 49508b6ba64a..ddd26b5b18aa 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[0.5].out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[0.5].out @@ -11,11 +11,11 @@ trace [ (Pair Unit 0) ] - location: 7 (remaining gas: 1039994.938 units remaining) [ ] - - location: 8 (remaining gas: 1039774.922 units remaining) + - location: 8 (remaining gas: 1039994.938 units remaining) [ 500000 ] - - location: 9 (remaining gas: 1039774.907 units remaining) + - location: 9 (remaining gas: 1039994.923 units remaining) [ {} 500000 ] - - location: 11 (remaining gas: 1039774.892 units remaining) + - location: 11 (remaining gas: 1039994.908 units remaining) [ (Pair {} 500000) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[0].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[0].out index 5e66595481d6..c7f286bb44c4 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[0].out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[0].out @@ -11,11 +11,11 @@ trace [ (Pair Unit 0) ] - location: 7 (remaining gas: 1039994.938 units remaining) [ ] - - location: 8 (remaining gas: 1039774.922 units remaining) + - location: 8 (remaining gas: 1039994.938 units remaining) [ 0 ] - - location: 9 (remaining gas: 1039774.907 units remaining) + - location: 9 (remaining gas: 1039994.923 units remaining) [ {} 0 ] - - location: 11 (remaining gas: 1039774.892 units remaining) + - location: 11 (remaining gas: 1039994.908 units remaining) [ (Pair {} 0) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1000].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1000].out index a579be096adc..a1ed7938b6e1 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1000].out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1000].out @@ -11,11 +11,11 @@ trace [ (Pair Unit 0) ] - location: 7 (remaining gas: 1039994.938 units remaining) [ ] - - location: 8 (remaining gas: 1039774.922 units remaining) + - location: 8 (remaining gas: 1039994.938 units remaining) [ 1000000000 ] - - location: 9 (remaining gas: 1039774.907 units remaining) + - location: 9 (remaining gas: 1039994.923 units remaining) [ {} 1000000000 ] - - location: 11 (remaining gas: 1039774.892 units remaining) + - location: 11 (remaining gas: 1039994.908 units remaining) [ (Pair {} 1000000000) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1].out index bf19a152b9eb..e27ed8107fed 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1].out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1].out @@ -11,11 +11,11 @@ trace [ (Pair Unit 0) ] - location: 7 (remaining gas: 1039994.938 units remaining) [ ] - - location: 8 (remaining gas: 1039774.922 units remaining) + - location: 8 (remaining gas: 1039994.938 units remaining) [ 1000000 ] - - location: 9 (remaining gas: 1039774.907 units remaining) + - location: 9 (remaining gas: 1039994.923 units remaining) [ {} 1000000 ] - - location: 11 (remaining gas: 1039774.892 units remaining) + - location: 11 (remaining gas: 1039994.908 units remaining) [ (Pair {} 1000000) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1e-06].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1e-06].out index 9ac426c714a7..f7e51d2d2d9c 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1e-06].out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[1e-06].out @@ -11,11 +11,11 @@ trace [ (Pair Unit 0) ] - location: 7 (remaining gas: 1039994.938 units remaining) [ ] - - location: 8 (remaining gas: 1039774.922 units remaining) + - location: 8 (remaining gas: 1039994.938 units remaining) [ 1 ] - - location: 9 (remaining gas: 1039774.907 units remaining) + - location: 9 (remaining gas: 1039994.923 units remaining) [ {} 1 ] - - location: 11 (remaining gas: 1039774.892 units remaining) + - location: 11 (remaining gas: 1039994.908 units remaining) [ (Pair {} 1) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[5].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[5].out index ce8cb0601025..ee4e1500051e 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[5].out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[5].out @@ -11,11 +11,11 @@ trace [ (Pair Unit 0) ] - location: 7 (remaining gas: 1039994.938 units remaining) [ ] - - location: 8 (remaining gas: 1039774.922 units remaining) + - location: 8 (remaining gas: 1039994.938 units remaining) [ 5000000 ] - - location: 9 (remaining gas: 1039774.907 units remaining) + - location: 9 (remaining gas: 1039994.923 units remaining) [ {} 5000000 ] - - location: 11 (remaining gas: 1039774.892 units remaining) + - location: 11 (remaining gas: 1039994.908 units remaining) [ (Pair {} 5000000) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[8000000000000.0].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[8000000000000.0].out index 47b7efaaaf6e..fb69d27649c8 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[8000000000000.0].out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_balance[8000000000000.0].out @@ -11,11 +11,11 @@ trace [ (Pair Unit 0) ] - location: 7 (remaining gas: 1039994.938 units remaining) [ ] - - location: 8 (remaining gas: 1039774.922 units remaining) + - location: 8 (remaining gas: 1039994.938 units remaining) [ 8000000000000000000 ] - - location: 9 (remaining gas: 1039774.907 units remaining) + - location: 9 (remaining gas: 1039994.923 units remaining) [ {} 8000000000000000000 ] - - location: 11 (remaining gas: 1039774.892 units remaining) + - location: 11 (remaining gas: 1039994.908 units remaining) [ (Pair {} 8000000000000000000) ] diff --git a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[balance.tz-111-Unit-4000000000000].out b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[balance.tz-111-Unit-4000000000000].out index 78cc5b82534c..8bc1c350c188 100644 --- a/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[balance.tz-111-Unit-4000000000000].out +++ b/tests_python/tests_alpha/_regtest_outputs/test_contract_opcodes.TestContractOpcodes::test_contract_input_output[balance.tz-111-Unit-4000000000000].out @@ -11,11 +11,11 @@ trace [ (Pair Unit 111) ] - location: 7 (remaining gas: 1039994.938 units remaining) [ ] - - location: 8 (remaining gas: 1039774.922 units remaining) + - location: 8 (remaining gas: 1039994.938 units remaining) [ 4000000000000 ] - - location: 9 (remaining gas: 1039774.907 units remaining) + - location: 9 (remaining gas: 1039994.923 units remaining) [ {} 4000000000000 ] - - location: 11 (remaining gas: 1039774.892 units remaining) + - location: 11 (remaining gas: 1039994.908 units remaining) [ (Pair {} 4000000000000) ] diff --git a/tezt/_regressions/run_views.out b/tezt/_regressions/run_views.out index 57e07aa1869e..2f1c0b721fe6 100644 --- a/tezt/_regressions/run_views.out +++ b/tezt/_regressions/run_views.out @@ -146,24 +146,24 @@ Contract memorized as check_caller. ./tezos-client --mode mockup --base-dir '' --wait none transfer 1 from bootstrap1 to KT1EYwqeAzgkynYXJnHJ7ZxuXk5bNBBy6R6L --burn-cap 1 --arg '"KT19P9vLfrXCEwUMpiURQ5vY8Ncp5idkyKTD"' Node is bootstrapped. -Estimated gas: 4448.948 units (will add 100 for safety) +Estimated gas: 4888.980 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. -Operation hash is 'ooeWJ1x8vuNSdxzJnQPjw3Jz9XMJFqJe1Cga8quXXbWcucEujBy' +Operation hash is 'op4wu7aQT9ofgup46yvygx2td15DfJ2o8CLgamEkaZkRnqyPMvL' NOT waiting for the operation to be included. Use command - tezos-client wait for ooeWJ1x8vuNSdxzJnQPjw3Jz9XMJFqJe1Cga8quXXbWcucEujBy to be included --confirmations 1 --branch BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU + tezos-client wait for op4wu7aQT9ofgup46yvygx2td15DfJ2o8CLgamEkaZkRnqyPMvL to be included --confirmations 1 --branch BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx - Fee to the baker: ꜩ0.000751 + Fee to the baker: ꜩ0.000795 Expected counter: 3 - Gas limit: 4549 + Gas limit: 4989 Storage limit: 0 bytes Balance updates: - tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.000751 - payload fees(the block proposer) ....... +ꜩ0.000751 + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.000795 + payload fees(the block proposer) ....... +ꜩ0.000795 Transaction: Amount: ꜩ1 From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx @@ -172,7 +172,7 @@ This sequence of operations was run: This transaction was successfully applied Updated storage: None Storage size: 208 bytes - Consumed gas: 4449.746 + Consumed gas: 4889.778 Balance updates: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ1 KT1EYwqeAzgkynYXJnHJ7ZxuXk5bNBBy6R6L ... +ꜩ1 @@ -216,24 +216,24 @@ This sequence of operations was run: ./tezos-client --mode mockup --base-dir '' --wait none transfer 1 from bootstrap1 to KT1EYwqeAzgkynYXJnHJ7ZxuXk5bNBBy6R6L --burn-cap 1 --arg '"KT19P9vLfrXCEwUMpiURQ5vY8Ncp5idkyKTD"' Node is bootstrapped. -Estimated gas: 5761.955 units (will add 100 for safety) +Estimated gas: 6201.987 units (will add 100 for safety) Estimated storage: 27 bytes added (will add 20 for safety) Operation successfully injected in the node. -Operation hash is 'oohh2J6m4DnZ9e4d57NeUfNjK3eWQh5xcTxoCLGwCyktxswEYUp' +Operation hash is 'oo6wNGAK8aSyy6XkpBd1Eij4DvdV6te4V91uYzSdtZCPcRNPnAG' NOT waiting for the operation to be included. Use command - tezos-client wait for oohh2J6m4DnZ9e4d57NeUfNjK3eWQh5xcTxoCLGwCyktxswEYUp to be included --confirmations 1 --branch BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU + tezos-client wait for oo6wNGAK8aSyy6XkpBd1Eij4DvdV6te4V91uYzSdtZCPcRNPnAG to be included --confirmations 1 --branch BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx - Fee to the baker: ꜩ0.000883 + Fee to the baker: ꜩ0.000927 Expected counter: 5 - Gas limit: 5862 + Gas limit: 6302 Storage limit: 47 bytes Balance updates: - tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.000883 - payload fees(the block proposer) ....... +ꜩ0.000883 + tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.000927 + payload fees(the block proposer) ....... +ꜩ0.000927 Transaction: Amount: ꜩ1 From: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx @@ -243,7 +243,7 @@ This sequence of operations was run: Updated storage: (Some 0x000002298c03ed7d454a101eb7022bc95f7e5f41ac78) Storage size: 235 bytes Paid storage size diff: 27 bytes - Consumed gas: 5762.753 + Consumed gas: 6202.785 Balance updates: tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx ... -ꜩ0.00675 storage fees ........................... +ꜩ0.00675 -- GitLab From f6376c8e43a833e93e1195e3482017d12a8e9bca Mon Sep 17 00:00:00 2001 From: Marcin Pastudzki Date: Thu, 2 Dec 2021 16:34:22 +0100 Subject: [PATCH 4/4] Docs: Mention the new constant in changelog. Signed-off-by: Marcin Pastudzki --- docs/protocols/alpha.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 09a1d38a74cf..63d822e2411b 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -49,3 +49,13 @@ Michelson In their output encodings, the objects containing the fields ``item`` and ``annot`` are replaced with the contents of the field ``item``. (MR :gl:`!4139`) + +Internal +-------- + +The following changes are not visible to the users but reflect +improvements of the codebase. + +- ``BALANCE`` is now passed to the Michelson interpreter as a step constant + instead of being read from the context each time this instruction is + executed. (MR :gl:`!3871`) -- GitLab