forked from runtimeverification/verified-smart-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spec-diff.patch
239 lines (223 loc) · 7.47 KB
/
spec-diff.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
[totalSupply]
k: #execute => (RETURN RET_ADDR:Int 32 ~> _)
@@ -9,7 +9,7 @@ gas: {GASCAP} => _
log: _
refund: _
storage:
- #hashedLocation({COMPILER}, {_TOTALSUPPLY}, .IntList) |-> TOTAL
+ #hashedLocation({COMPILER}, {_SUPPLY}, .IntList) |-> TOTAL
_:Map
requires:
andBool 0 <=Int TOTAL andBool TOTAL <Int (2 ^Int 256)
@@ -44,36 +44,53 @@ requires:
andBool 0 <=Int ALLOWANCE andBool ALLOWANCE <Int (2 ^Int 256)
[approve]
-k: #execute => (RETURN RET_ADDR:Int 32 ~> _)
callData: #abiCallData("approve", #address(SPENDER), #uint256(VALUE))
-localMem: .Map => ( .Map[ RET_ADDR := #asByteStackInWidth(1, 32) ] _:Map )
gas: {GASCAP} => _
-log: _:List ( .List => ListItem(#abiEventLog(ACCT_ID, "Approval", #indexed(#address(CALLER_ID)), #indexed(#address(SPENDER)), #uint256(VALUE))) )
+log: _ => _
refund: _ => _
storage:
- #hashedLocation({COMPILER}, {_ALLOWANCES}, CALLER_ID SPENDER) |-> (_:Int => VALUE)
+ #hashedLocation({COMPILER}, {_STOPPED}, .IntList) |-> STOPPED
_:Map
requires:
andBool 0 <=Int SPENDER andBool SPENDER <Int (2 ^Int 160)
andBool 0 <=Int VALUE andBool VALUE <Int (2 ^Int 256)
+ andBool 0 <=Int STOPPED andBool STOPPED <Int (2 ^Int 256)
+
+
+[approve-success]
+k: #execute => (RETURN RET_ADDR:Int 32 ~> _)
+localMem: .Map => ( .Map[ RET_ADDR := #asByteStackInWidth(1, 32) ] _:Map )
++storage:
+ #hashedLocation({COMPILER}, {_ALLOWANCES}, CALLER_ID SPENDER) |-> (_:Int => VALUE)
++requires:
+ andBool STOPPED ==Int 0
+
+[approve-failure]
+k: #execute => #exception
+localMem: .Map => _:Map
++requires:
+ andBool STOPPED ==Int 1 <<Int (20 *Int 8)
[transfer]
callData: #abiCallData("transfer", #address(TO_ID), #uint256(VALUE))
+log: _ => _
gas: {GASCAP} => _
refund: _ => _
+storage:
+ #hashedLocation({COMPILER}, {_STOPPED}, .IntList) |-> STOPPED
requires:
andBool 0 <=Int TO_ID andBool TO_ID <Int (2 ^Int 160)
andBool 0 <=Int VALUE andBool VALUE <Int (2 ^Int 256)
andBool 0 <=Int BAL_FROM andBool BAL_FROM <Int (2 ^Int 256)
andBool 0 <=Int BAL_TO andBool BAL_TO <Int (2 ^Int 256)
+ andBool 0 <=Int STOPPED andBool STOPPED <Int (2 ^Int 256)
[transfer-success]
k: #execute => (RETURN RET_ADDR:Int 32 ~> _)
localMem: .Map => ( .Map[ RET_ADDR := #asByteStackInWidth(1, 32) ] _:Map )
-log: _:List ( .List => ListItem(#abiEventLog(ACCT_ID, "Transfer", #indexed(#address(CALLER_ID)), #indexed(#address(TO_ID)), #uint256(VALUE))) )
[transfer-success-1]
-storage:
++storage:
#hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID) |-> (BAL_FROM => BAL_FROM -Int VALUE)
#hashedLocation({COMPILER}, {_BALANCES}, TO_ID) |-> (BAL_TO => BAL_TO +Int VALUE)
_:Map
@@ -81,42 +98,65 @@ storage:
andBool CALLER_ID =/=Int TO_ID
andBool VALUE <=Int BAL_FROM
andBool BAL_TO +Int VALUE <Int (2 ^Int 256)
+ andBool STOPPED ==Int 0
[transfer-success-2]
-storage:
++storage:
#hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID) |-> BAL_FROM
_:Map
+requires:
andBool CALLER_ID ==Int TO_ID
andBool VALUE <=Int BAL_FROM
+ andBool STOPPED ==Int 0
[transfer-failure]
k: #execute => #exception
localMem: .Map => _:Map
-log: _
[transfer-failure-1]
-storage:
++storage:
#hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID) |-> (BAL_FROM => _)
#hashedLocation({COMPILER}, {_BALANCES}, TO_ID) |-> BAL_TO
_:Map
+requires:
andBool CALLER_ID =/=Int TO_ID
- andBool ( VALUE >Int BAL_FROM
- orBool BAL_TO +Int VALUE >=Int (2 ^Int 256) )
+
+
+[transfer-failure-1-a]
++requires:
+ andBool VALUE >Int BAL_FROM
+
+
+[transfer-failure-1-b]
++requires:
+ andBool BAL_TO +Int VALUE >=Int (2 ^Int 256)
+
+[transfer-failure-1-c]
++requires:
+ andBool STOPPED ==Int 1 <<Int (20 *Int 8)
[transfer-failure-2]
-storage:
++storage:
#hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID) |-> BAL_FROM
_:Map
+requires:
andBool CALLER_ID ==Int TO_ID
+
+[transfer-failure-2-a]
++requires:
andBool VALUE >Int BAL_FROM
+[transfer-failure-2-b]
++requires:
+ andBool STOPPED ==Int 1 <<Int (20 *Int 8)
+
+
[transferFrom]
callData: #abiCallData("transferFrom", #address(FROM_ID), #address(TO_ID), #uint256(VALUE))
gas: {GASCAP} => _
refund: _ => _
+storage:
+ #hashedLocation({COMPILER}, {_STOPPED}, .IntList) |-> STOPPED
requires:
andBool 0 <=Int FROM_ID andBool FROM_ID <Int (2 ^Int 160)
andBool 0 <=Int TO_ID andBool TO_ID <Int (2 ^Int 160)
@@ -124,14 +164,15 @@ requires:
andBool 0 <=Int BAL_FROM andBool BAL_FROM <Int (2 ^Int 256)
andBool 0 <=Int BAL_TO andBool BAL_TO <Int (2 ^Int 256)
andBool 0 <=Int ALLOW andBool ALLOW <Int (2 ^Int 256)
+ andBool 0 <=Int STOPPED andBool STOPPED <Int (2 ^Int 256)
[transferFrom-success]
k: #execute => (RETURN RET_ADDR:Int 32 ~> _)
localMem: .Map => ( .Map[ RET_ADDR := #asByteStackInWidth(1, 32) ] _:Map )
-log: _:List ( .List => ListItem(#abiEventLog(ACCT_ID, "Transfer", #indexed(#address(FROM_ID)), #indexed(#address(TO_ID)), #uint256(VALUE))) )
+log: _ => _
[transferFrom-success-1]
-storage:
++storage:
#hashedLocation({COMPILER}, {_BALANCES}, FROM_ID) |-> (BAL_FROM => BAL_FROM -Int VALUE)
#hashedLocation({COMPILER}, {_BALANCES}, TO_ID) |-> (BAL_TO => BAL_TO +Int VALUE)
#hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID) |-> (ALLOW => ALLOW -Int VALUE)
@@ -141,9 +182,10 @@ storage:
andBool VALUE <=Int BAL_FROM
andBool BAL_TO +Int VALUE <Int (2 ^Int 256)
andBool VALUE <=Int ALLOW
+ andBool STOPPED ==Int 0
[transferFrom-success-2]
-storage:
++storage:
#hashedLocation({COMPILER}, {_BALANCES}, FROM_ID) |-> BAL_FROM
#hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID) |-> (ALLOW => ALLOW -Int VALUE)
_:Map
@@ -151,38 +193,64 @@ storage:
andBool FROM_ID ==Int TO_ID
andBool VALUE <=Int BAL_FROM
andBool VALUE <=Int ALLOW
+ andBool STOPPED ==Int 0
[transferFrom-failure]
k: #execute => #exception
localMem: .Map => _:Map
-log: _
+log: _ => _
[transferFrom-failure-1]
-storage:
++storage:
#hashedLocation({COMPILER}, {_BALANCES}, FROM_ID) |-> (BAL_FROM => _) // BAL_FROM
#hashedLocation({COMPILER}, {_BALANCES}, TO_ID) |-> (BAL_TO => _) // BAL_TO
- #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID) |-> ALLOW
+ #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID) |-> (ALLOW => _)
_:Map
+requires:
andBool FROM_ID =/=Int TO_ID
- andBool ( VALUE >Int BAL_FROM
- orBool BAL_TO +Int VALUE >=Int (2 ^Int 256)
- orBool VALUE >Int ALLOW )
+
+[transferFrom-failure-1-a]
++requires:
+ andBool VALUE >Int BAL_FROM
+
+
+[transferFrom-failure-1-b]
++requires:
+ andBool BAL_TO +Int VALUE >=Int (2 ^Int 256)
+
+[transferFrom-failure-1-c]
++requires:
+ andBool VALUE >Int ALLOW
+
+[transferFrom-failure-1-d]
++requires:
+ andBool STOPPED ==Int 1 <<Int (20 *Int 8)
[transferFrom-failure-2]
-storage:
++storage:
#hashedLocation({COMPILER}, {_BALANCES}, FROM_ID) |-> BAL_FROM
#hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID) |-> ALLOW
_:Map
+requires:
andBool FROM_ID ==Int TO_ID
- andBool ( VALUE >Int BAL_FROM
- orBool VALUE >Int ALLOW )
+
+[transferFrom-failure-2-a]
++requires:
+ andBool VALUE >Int BAL_FROM
+
+[transferFrom-failure-2-b]
++requires:
+ andBool VALUE >Int ALLOW
+
+[transferFrom-failure-2-c]
++requires:
+ andBool STOPPED ==Int 1 <<Int (20 *Int 8)