Check stateful annotations #560

Merged
zxq9 merged 8 commits from PT-162578475-stateful into master 2019-05-15 22:44:38 +09:00
zxq9 commented 2019-05-14 17:08:15 +09:00 (Migrated from gitlab.com)

Created by: UlfNorell

cc https://github.com/aeternity/protocol/pull/352

Functions must be annotated as stateful in order to

  • Update the contract state (using put)
  • Call Chain.spend or other primitive functions that cost tokens
  • Call an Oracle or AENS function that requires a signature
  • Make a remote call with a non-zero value
  • Construct a lambda calling a stateful function. We get away with checking statefulness at the construction site rather than the call site since lambdas cannot outlive a contract call (no passing/receiving lambdas to/from other contracts, no storing lambdas in the state).

It does not need to be stateful to

  • Read the contract state
  • Call another contract with value=0, even when the remote function is stateful

There is a separate check for init that it neither reads nor writes the state. It can be stateful in the other senses though.

*Created by: UlfNorell* - `stateful` [PT-162578475](https://www.pivotaltracker.com/story/show/162578475) - `init` [PT-160750930](https://www.pivotaltracker.com/story/show/160750930) cc https://github.com/aeternity/protocol/pull/352 Functions must be annotated as `stateful` in order to - Update the contract state (using `put`) - Call `Chain.spend` or other primitive functions that cost tokens - Call an Oracle or AENS function that requires a signature - Make a remote call with a non-zero value - Construct a lambda calling a stateful function. We get away with checking statefulness at the construction site rather than the call site since lambdas cannot outlive a contract call (no passing/receiving lambdas to/from other contracts, no storing lambdas in the state). It does not need to be stateful to - Read the contract state - Call another contract with value=0, even when the remote function is stateful There is a separate check for `init` that it neither reads nor writes the state. It can be stateful in the other senses though.
zxq9 commented 2019-05-14 18:31:21 +09:00 (Migrated from gitlab.com)

Created by: hanssv

Review: Approved

*Created by: hanssv* **Review:** Approved
zxq9 commented 2019-05-15 20:29:04 +09:00 (Migrated from gitlab.com)

Created by: ThomasArts

does this really work? Attribute must then contain {stateful, true}, I guess. I'm concerned about proplists:get_value in the bottom instead of prop_lists:is_defined.

*Created by: ThomasArts* does this really work? Attribute must then contain {stateful, true}, I guess. I'm concerned about proplists:get_value in the bottom instead of prop_lists:is_defined.
zxq9 commented 2019-05-15 20:33:55 +09:00 (Migrated from gitlab.com)

Created by: ThomasArts

Review: Approved

*Created by: ThomasArts* **Review:** Approved
zxq9 commented 2019-05-15 22:43:41 +09:00 (Migrated from gitlab.com)

Created by: UlfNorell

1> proplists:get_value(foo, [foo]).                                                                       
true
*Created by: UlfNorell* ```erlang 1> proplists:get_value(foo, [foo]). true ```
zxq9 commented 2019-05-15 22:44:38 +09:00 (Migrated from gitlab.com)

Merged by: UlfNorell at 2019-05-15 13:44:38 UTC

*Merged by: UlfNorell at 2019-05-15 13:44:38 UTC*
Sign in to join this conversation.
No description provided.