Lambda types forget stateful constraint #217

Open
opened 2020-02-08 01:00:30 +09:00 by zxq9 · 0 comments
zxq9 commented 2020-02-08 01:00:30 +09:00 (Migrated from gitlab.com)

Created by: radrow

Consider the following contract:

contract Bum =
  type state = (int * (int => unit))
  entrypoint init() = (0, (x) => ())

  stateful entrypoint setX(x : int) = switch(state)
    (_, f) => put((x, f))

  entrypoint getX() = switch(state)
    (x, _) => x

  stateful entrypoint hack() = switch(state)
    (s, f) => put((s, (x) => setX(x)))

  entrypoint bum(x : int) = switch(state)
    (_, f) => f(x)

If the user calls hack they can start to freely modify the state from non-stateful entrypoint bum:

AESO> :dep bum.aes as bum
bum : Bum was successfully deployed
AESO> bum.getX()
0
AESO> bum.hack()
()
AESO> bum.bum(2137)
()
AESO> bum.getX()   
2137

This bug is sponsored by Sophia REPL

*Created by: radrow* Consider the following contract: ```ocaml contract Bum = type state = (int * (int => unit)) entrypoint init() = (0, (x) => ()) stateful entrypoint setX(x : int) = switch(state) (_, f) => put((x, f)) entrypoint getX() = switch(state) (x, _) => x stateful entrypoint hack() = switch(state) (s, f) => put((s, (x) => setX(x))) entrypoint bum(x : int) = switch(state) (_, f) => f(x) ``` If the user calls `hack` they can start to freely modify the state from non-stateful entrypoint `bum`: ``` AESO> :dep bum.aes as bum bum : Bum was successfully deployed AESO> bum.getX() 0 AESO> bum.hack() () AESO> bum.bum(2137) () AESO> bum.getX() 2137 ``` <sup> <sup> This bug is sponsored by Sophia REPL </sup> </sup>
Sign in to join this conversation.
No Milestone
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: QPQ-AG/sophia#217
No description provided.