From 676a64b81f64a4c7039f07aed6729df70a7c7f33 Mon Sep 17 00:00:00 2001 From: Benjamin Canou Date: Wed, 4 Apr 2018 10:13:59 +0200 Subject: [PATCH] Michelson: rename DEFAULT_ACCOUNT to IMPLICIT_ACCOUNT --- docs/whitedoc/michelson.rst | 4 ++-- emacs/michelson-mode.el | 2 +- src/bin_client/test/contracts/accounts.tz | 4 ++-- src/bin_client/test/contracts/auction.tz | 2 +- src/bin_client/test/contracts/default_account.tz | 2 +- src/bin_client/test/contracts/king_of_tez.tz | 2 +- src/bin_client/test/contracts/take_my_money.tz | 2 +- src/bin_client/test/test_contracts.sh | 2 +- src/proto_alpha/lib_protocol/src/alpha_context.mli | 2 +- .../lib_protocol/src/michelson_v1_primitives.ml | 8 ++++---- .../lib_protocol/src/michelson_v1_primitives.mli | 2 +- .../lib_protocol/src/script_interpreter.ml | 2 +- .../lib_protocol/src/script_ir_translator.ml | 14 +++++++------- .../lib_protocol/src/script_typed_ir.ml | 2 +- .../lib_protocol/test/contracts/accounts.tz | 4 ++-- .../lib_protocol/test/contracts/auction.tz | 2 +- .../lib_protocol/test/contracts/default_account.tz | 2 +- .../lib_protocol/test/contracts/king_of_tez.tz | 2 +- .../lib_protocol/test/contracts/take_my_money.tz | 2 +- .../lib_protocol/test/test_michelson.ml | 2 +- 20 files changed, 32 insertions(+), 32 deletions(-) diff --git a/docs/whitedoc/michelson.rst b/docs/whitedoc/michelson.rst index 6ccbc8a72..8479de4f6 100644 --- a/docs/whitedoc/michelson.rst +++ b/docs/whitedoc/michelson.rst @@ -1468,7 +1468,7 @@ recursive call (the contract just fails if the boolean is true). :: 'S -> tez : 'S -- ``DEFAULT_ACCOUNT``: Return a default contract with the given +- ``IMPLICIT_ACCOUNT``: Return a default contract with the given public/private key pair. Any funds deposited in this contract can immediately be spent by the holder of the private key. This contract cannot execute Michelson code and will always exist on the @@ -2452,7 +2452,7 @@ XII - Full grammar | TRANSFER_TOKENS | CREATE_ACCOUNT | CREATE_CONTRACT - | DEFAULT_ACCOUNT + | IMPLICIT_ACCOUNT | NOW | AMOUNT | BALANCE diff --git a/emacs/michelson-mode.el b/emacs/michelson-mode.el index 473ecf004..f9ad7473f 100644 --- a/emacs/michelson-mode.el +++ b/emacs/michelson-mode.el @@ -768,7 +768,7 @@ If `DO-NOT-OVERWRITE' is non-nil, the existing contents of the buffer are mainta (michelson-suggest-reorderable '("ADD" "SUB" "MUL") 'tez 'nat) (michelson-suggest-literals "EDIV" 'tez 'nat) (michelson-suggest-literals "EDIV" 'tez 'tez) - (michelson-suggest-literals "DEFAULT_ACCOUNT" 'key) + (michelson-suggest-literals "IMPLICIT_ACCOUNT" 'key) (michelson-suggest-depth "SWAP" 2) (michelson-suggest-depth '("DROP" "H") 1) (michelson-suggest-literals "CHECK_SIGNATURE" 'key '(pair signature string)) diff --git a/src/bin_client/test/contracts/accounts.tz b/src/bin_client/test/contracts/accounts.tz index fe1a45da8..93f16946c 100644 --- a/src/bin_client/test/contracts/accounts.tz +++ b/src/bin_client/test/contracts/accounts.tz @@ -1,7 +1,7 @@ # This is a very simple accounts system. # (Left key) initializes or deposits into an account # (Right key (pair tez (signed tez))) withdraws tez amount to a -# DEFAULT_ACCOUNT created from the key if the balance is available +# IMPLICIT_ACCOUNT created from the key if the balance is available # and the key is correctly signed parameter (or key_hash (pair key (pair tez signature))); # Maps the key to the balance they have stored @@ -38,5 +38,5 @@ code { DUP; CAR; SWAP; CAR; HASH_KEY; UPDATE; SWAP; DUP; CDAR; # Execute the transfer - DIP{ CAR; HASH_KEY; DEFAULT_ACCOUNT }; UNIT; TRANSFER_TOKENS; + DIP{ CAR; HASH_KEY; IMPLICIT_ACCOUNT }; UNIT; TRANSFER_TOKENS; PAIR }}}} diff --git a/src/bin_client/test/contracts/auction.tz b/src/bin_client/test/contracts/auction.tz index 5ebbfd2f6..6d5de990a 100644 --- a/src/bin_client/test/contracts/auction.tz +++ b/src/bin_client/test/contracts/auction.tz @@ -5,5 +5,5 @@ code { DUP; CDAR; DUP; NOW; CMPGT; IF {FAIL} {}; SWAP; # Check if auction has en DUP; CAR; DIP{CDDR}; AMOUNT; PAIR; SWAP; DIP{SWAP; PAIR}; # Setup replacement storage DUP; CAR; AMOUNT; CMPLE; IF {FAIL} {}; # Check to make sure that the new amount is greater DUP; CAR; # Get amount of refund - DIP{CDR; DEFAULT_ACCOUNT}; UNIT; TRANSFER_TOKENS; # Make refund + DIP{CDR; IMPLICIT_ACCOUNT}; UNIT; TRANSFER_TOKENS; # Make refund PAIR} # Calling convention diff --git a/src/bin_client/test/contracts/default_account.tz b/src/bin_client/test/contracts/default_account.tz index 85895f358..c71564952 100644 --- a/src/bin_client/test/contracts/default_account.tz +++ b/src/bin_client/test/contracts/default_account.tz @@ -1,5 +1,5 @@ parameter key_hash; return unit; storage unit; -code {DIP{UNIT}; CAR; DEFAULT_ACCOUNT; +code {DIP{UNIT}; CAR; IMPLICIT_ACCOUNT; PUSH tez "100.00"; UNIT; TRANSFER_TOKENS; PAIR} diff --git a/src/bin_client/test/contracts/king_of_tez.tz b/src/bin_client/test/contracts/king_of_tez.tz index 899fff0cb..3f3c978ac 100644 --- a/src/bin_client/test/contracts/king_of_tez.tz +++ b/src/bin_client/test/contracts/king_of_tez.tz @@ -13,6 +13,6 @@ code { DUP; CDAR; # New storage DIP{ AMOUNT; PAIR; NOW; PUSH int 604800; ADD; PAIR }; # Pay funds to old king - DEFAULT_ACCOUNT; AMOUNT; UNIT; TRANSFER_TOKENS; DROP }}; + IMPLICIT_ACCOUNT; AMOUNT; UNIT; TRANSFER_TOKENS; DROP }}; # Cleanup UNIT; PAIR }; diff --git a/src/bin_client/test/contracts/take_my_money.tz b/src/bin_client/test/contracts/take_my_money.tz index 2b4109bc7..9ddbebf4a 100644 --- a/src/bin_client/test/contracts/take_my_money.tz +++ b/src/bin_client/test/contracts/take_my_money.tz @@ -1,7 +1,7 @@ parameter key_hash; return unit; storage unit; -code { CAR; DEFAULT_ACCOUNT; # Create an account for the recipient of the funds +code { CAR; IMPLICIT_ACCOUNT; # Create an account for the recipient of the funds DIP{UNIT}; # Push a value of the storage type below the contract PUSH tez "1.00"; # The person can have a ꜩ UNIT; # Push the contract's argument type diff --git a/src/bin_client/test/test_contracts.sh b/src/bin_client/test/test_contracts.sh index 7bd36e8c8..6c9665235 100755 --- a/src/bin_client/test/test_contracts.sh +++ b/src/bin_client/test/test_contracts.sh @@ -393,7 +393,7 @@ init_with_transfer $contract_dir/create_contract.tz $key2 \ bake_after $client transfer 0 from bootstrap1 to create_contract -arg '"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"' assert_storage_contains create_contract '"abcdefg"' -# Test DEFAULT_ACCOUNT +# Test IMPLICIT_ACCOUNT init_with_transfer $contract_dir/default_account.tz $key1 \ Unit 1,000 bootstrap1 bake_after $client transfer 0 from bootstrap1 to default_account -arg "\"$BOOTSTRAP4_IDENTITY\"" diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index 580952231..3239d9ae2 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -186,7 +186,7 @@ module Script : sig | I_CONS | I_CREATE_ACCOUNT | I_CREATE_CONTRACT - | I_DEFAULT_ACCOUNT + | I_IMPLICIT_ACCOUNT | I_DIP | I_DROP | I_DUP diff --git a/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.ml b/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.ml index cd55055d5..6f42c9b7f 100644 --- a/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.ml +++ b/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.ml @@ -41,7 +41,7 @@ type prim = | I_CONS | I_CREATE_ACCOUNT | I_CREATE_CONTRACT - | I_DEFAULT_ACCOUNT + | I_IMPLICIT_ACCOUNT | I_DIP | I_DROP | I_DUP @@ -162,7 +162,7 @@ let string_of_prim = function | I_CONS -> "CONS" | I_CREATE_ACCOUNT -> "CREATE_ACCOUNT" | I_CREATE_CONTRACT -> "CREATE_CONTRACT" - | I_DEFAULT_ACCOUNT -> "DEFAULT_ACCOUNT" + | I_IMPLICIT_ACCOUNT -> "IMPLICIT_ACCOUNT" | I_DIP -> "DIP" | I_DROP -> "DROP" | I_DUP -> "DUP" @@ -264,7 +264,7 @@ let prim_of_string = function | "CONS" -> ok I_CONS | "CREATE_ACCOUNT" -> ok I_CREATE_ACCOUNT | "CREATE_CONTRACT" -> ok I_CREATE_CONTRACT - | "DEFAULT_ACCOUNT" -> ok I_DEFAULT_ACCOUNT + | "IMPLICIT_ACCOUNT" -> ok I_IMPLICIT_ACCOUNT | "DIP" -> ok I_DIP | "DROP" -> ok I_DROP | "DUP" -> ok I_DUP @@ -410,7 +410,7 @@ let prim_encoding = ("CONS", I_CONS) ; ("CREATE_ACCOUNT", I_CREATE_ACCOUNT) ; ("CREATE_CONTRACT", I_CREATE_CONTRACT) ; - ("DEFAULT_ACCOUNT", I_DEFAULT_ACCOUNT) ; + ("IMPLICIT_ACCOUNT", I_IMPLICIT_ACCOUNT) ; ("DIP", I_DIP) ; ("DROP", I_DROP) ; ("DUP", I_DUP) ; diff --git a/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.mli b/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.mli index cca53a235..6251da4ba 100644 --- a/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.mli +++ b/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.mli @@ -39,7 +39,7 @@ type prim = | I_CONS | I_CREATE_ACCOUNT | I_CREATE_CONTRACT - | I_DEFAULT_ACCOUNT + | I_IMPLICIT_ACCOUNT | I_DIP | I_DROP | I_DUP diff --git a/src/proto_alpha/lib_protocol/src/script_interpreter.ml b/src/proto_alpha/lib_protocol/src/script_interpreter.ml index 92b5b118d..3c3ada175 100644 --- a/src/proto_alpha/lib_protocol/src/script_interpreter.ml +++ b/src/proto_alpha/lib_protocol/src/script_interpreter.ml @@ -744,7 +744,7 @@ let rec interp ?script:None ~spendable:true ~delegatable >>=? fun (ctxt, contract, origination) -> Fees.origination_burn ctxt ~source contract >>=? fun ctxt -> logged_return ~origination (Item ((Unit_t, Unit_t, contract), rest), ctxt) - | Default_account, Item (key, rest) -> + | Implicit_account, Item (key, rest) -> Lwt.return (Gas.consume ctxt Interp_costs.implicit_account) >>=? fun ctxt -> let contract = Contract.implicit_contract key in logged_return (Item ((Unit_t, Unit_t, contract), rest), ctxt) diff --git a/src/proto_alpha/lib_protocol/src/script_ir_translator.ml b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml index 72f4d4baf..6c8ac1733 100644 --- a/src/proto_alpha/lib_protocol/src/script_ir_translator.ml +++ b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml @@ -193,7 +193,7 @@ let number_of_generated_growing_types : type b a. (b, a) instr -> int = function | Manager -> 0 | Transfer_tokens _ -> 1 | Create_account -> 0 - | Default_account -> 0 + | Implicit_account -> 0 | Create_contract _ -> 1 | Create_contract_literal _ -> 1 | Now -> 0 @@ -248,7 +248,7 @@ let namespace = function | I_CONS | I_CREATE_ACCOUNT | I_CREATE_CONTRACT - | I_DEFAULT_ACCOUNT + | I_IMPLICIT_ACCOUNT | I_DIP | I_DROP | I_DUP @@ -1963,9 +1963,9 @@ and parse_instr (Tez_t, rest, _), _), _), _) -> typed ctxt loc Create_account (Item_t (Contract_t (Unit_t, Unit_t), rest, instr_annot)) - | Prim (loc, I_DEFAULT_ACCOUNT, [], instr_annot), + | Prim (loc, I_IMPLICIT_ACCOUNT, [], instr_annot), Item_t (Key_hash_t, rest, _) -> - typed ctxt loc Default_account + typed ctxt loc Implicit_account (Item_t (Contract_t (Unit_t, Unit_t), rest, instr_annot)) | Prim (loc, I_CREATE_CONTRACT, [], instr_annot), Item_t @@ -2071,7 +2071,7 @@ and parse_instr | I_LT | I_GT | I_LE | I_GE | I_MANAGER | I_TRANSFER_TOKENS | I_CREATE_ACCOUNT | I_CREATE_CONTRACT | I_NOW - | I_DEFAULT_ACCOUNT | I_AMOUNT | I_BALANCE + | I_IMPLICIT_ACCOUNT | I_AMOUNT | I_BALANCE | I_CHECK_SIGNATURE | I_HASH_KEY | I_H | I_STEPS_TO_QUOTA as name), (_ :: _ as l), _), _ -> @@ -2114,7 +2114,7 @@ and parse_instr fail (Bad_stack (loc, I_TRANSFER_TOKENS, 3, stack)) | Prim (loc, (I_DROP | I_DUP | I_CAR | I_CDR | I_SOME | I_H | I_DIP | I_IF_NONE | I_LEFT | I_RIGHT | I_IF_LEFT | I_IF - | I_LOOP | I_IF_CONS | I_MANAGER | I_DEFAULT_ACCOUNT + | I_LOOP | I_IF_CONS | I_MANAGER | I_IMPLICIT_ACCOUNT | I_NEG | I_ABS | I_INT | I_NOT | I_EQ | I_NEQ | I_LT | I_GT | I_LE | I_GE as name), _, _), stack -> @@ -2141,7 +2141,7 @@ and parse_instr I_LT ; I_GT ; I_LE ; I_GE ; I_MANAGER ; I_TRANSFER_TOKENS ; I_CREATE_ACCOUNT ; I_CREATE_CONTRACT ; I_NOW ; I_AMOUNT ; I_BALANCE ; - I_DEFAULT_ACCOUNT ; I_CHECK_SIGNATURE ; I_H ; I_HASH_KEY ; + I_IMPLICIT_ACCOUNT ; I_CHECK_SIGNATURE ; I_H ; I_HASH_KEY ; I_STEPS_TO_QUOTA ; I_PUSH ; I_NONE ; I_LEFT ; I_RIGHT ; I_NIL ; I_EMPTY_SET ; I_DIP ; I_LOOP ; diff --git a/src/proto_alpha/lib_protocol/src/script_typed_ir.ml b/src/proto_alpha/lib_protocol/src/script_typed_ir.ml index c54271567..9e8dbb583 100644 --- a/src/proto_alpha/lib_protocol/src/script_typed_ir.ml +++ b/src/proto_alpha/lib_protocol/src/script_typed_ir.ml @@ -322,7 +322,7 @@ and ('bef, 'aft) instr = | Create_account : (public_key_hash * (public_key_hash option * (bool * (Tez.t * 'rest))), (unit, unit) typed_contract * 'rest) instr - | Default_account : + | Implicit_account : (public_key_hash * 'rest, (unit, unit) typed_contract * 'rest) instr | Create_contract : 'g ty * 'p ty * 'r ty -> (public_key_hash * (public_key_hash option * (bool * (bool * (Tez.t * diff --git a/src/proto_alpha/lib_protocol/test/contracts/accounts.tz b/src/proto_alpha/lib_protocol/test/contracts/accounts.tz index fe1a45da8..93f16946c 100644 --- a/src/proto_alpha/lib_protocol/test/contracts/accounts.tz +++ b/src/proto_alpha/lib_protocol/test/contracts/accounts.tz @@ -1,7 +1,7 @@ # This is a very simple accounts system. # (Left key) initializes or deposits into an account # (Right key (pair tez (signed tez))) withdraws tez amount to a -# DEFAULT_ACCOUNT created from the key if the balance is available +# IMPLICIT_ACCOUNT created from the key if the balance is available # and the key is correctly signed parameter (or key_hash (pair key (pair tez signature))); # Maps the key to the balance they have stored @@ -38,5 +38,5 @@ code { DUP; CAR; SWAP; CAR; HASH_KEY; UPDATE; SWAP; DUP; CDAR; # Execute the transfer - DIP{ CAR; HASH_KEY; DEFAULT_ACCOUNT }; UNIT; TRANSFER_TOKENS; + DIP{ CAR; HASH_KEY; IMPLICIT_ACCOUNT }; UNIT; TRANSFER_TOKENS; PAIR }}}} diff --git a/src/proto_alpha/lib_protocol/test/contracts/auction.tz b/src/proto_alpha/lib_protocol/test/contracts/auction.tz index 5ebbfd2f6..6d5de990a 100644 --- a/src/proto_alpha/lib_protocol/test/contracts/auction.tz +++ b/src/proto_alpha/lib_protocol/test/contracts/auction.tz @@ -5,5 +5,5 @@ code { DUP; CDAR; DUP; NOW; CMPGT; IF {FAIL} {}; SWAP; # Check if auction has en DUP; CAR; DIP{CDDR}; AMOUNT; PAIR; SWAP; DIP{SWAP; PAIR}; # Setup replacement storage DUP; CAR; AMOUNT; CMPLE; IF {FAIL} {}; # Check to make sure that the new amount is greater DUP; CAR; # Get amount of refund - DIP{CDR; DEFAULT_ACCOUNT}; UNIT; TRANSFER_TOKENS; # Make refund + DIP{CDR; IMPLICIT_ACCOUNT}; UNIT; TRANSFER_TOKENS; # Make refund PAIR} # Calling convention diff --git a/src/proto_alpha/lib_protocol/test/contracts/default_account.tz b/src/proto_alpha/lib_protocol/test/contracts/default_account.tz index 85895f358..c71564952 100644 --- a/src/proto_alpha/lib_protocol/test/contracts/default_account.tz +++ b/src/proto_alpha/lib_protocol/test/contracts/default_account.tz @@ -1,5 +1,5 @@ parameter key_hash; return unit; storage unit; -code {DIP{UNIT}; CAR; DEFAULT_ACCOUNT; +code {DIP{UNIT}; CAR; IMPLICIT_ACCOUNT; PUSH tez "100.00"; UNIT; TRANSFER_TOKENS; PAIR} diff --git a/src/proto_alpha/lib_protocol/test/contracts/king_of_tez.tz b/src/proto_alpha/lib_protocol/test/contracts/king_of_tez.tz index 899fff0cb..3f3c978ac 100644 --- a/src/proto_alpha/lib_protocol/test/contracts/king_of_tez.tz +++ b/src/proto_alpha/lib_protocol/test/contracts/king_of_tez.tz @@ -13,6 +13,6 @@ code { DUP; CDAR; # New storage DIP{ AMOUNT; PAIR; NOW; PUSH int 604800; ADD; PAIR }; # Pay funds to old king - DEFAULT_ACCOUNT; AMOUNT; UNIT; TRANSFER_TOKENS; DROP }}; + IMPLICIT_ACCOUNT; AMOUNT; UNIT; TRANSFER_TOKENS; DROP }}; # Cleanup UNIT; PAIR }; diff --git a/src/proto_alpha/lib_protocol/test/contracts/take_my_money.tz b/src/proto_alpha/lib_protocol/test/contracts/take_my_money.tz index 2b4109bc7..9ddbebf4a 100644 --- a/src/proto_alpha/lib_protocol/test/contracts/take_my_money.tz +++ b/src/proto_alpha/lib_protocol/test/contracts/take_my_money.tz @@ -1,7 +1,7 @@ parameter key_hash; return unit; storage unit; -code { CAR; DEFAULT_ACCOUNT; # Create an account for the recipient of the funds +code { CAR; IMPLICIT_ACCOUNT; # Create an account for the recipient of the funds DIP{UNIT}; # Push a value of the storage type below the contract PUSH tez "1.00"; # The person can have a ꜩ UNIT; # Push the contract's argument type diff --git a/src/proto_alpha/lib_protocol/test/test_michelson.ml b/src/proto_alpha/lib_protocol/test/test_michelson.ml index 6c38e4eb4..030eeb242 100644 --- a/src/proto_alpha/lib_protocol/test/test_michelson.ml +++ b/src/proto_alpha/lib_protocol/test/test_michelson.ml @@ -439,7 +439,7 @@ let test_example () = Script.execute_code_pred ~tc sb script (parse_param "\"abc\"") >>=?? fun (_, ret, _, _, _) -> Assert.equal_string ~msg: __LOC__ "\"abc\"" @@ string_of_canon ret ; - (* Test DEFAULT_ACCOUNT *) + (* Test IMPLICIT_ACCOUNT *) let account = Account.new_account () in let b_str = quote @@ Signature.Public_key_hash.to_b58check account.hpub in test_contract ~tc "default_account" "Unit" b_str >>=? fun (_cs, tc) ->