-
Notifications
You must be signed in to change notification settings - Fork 134
/
zeppelin-erc20-spec.ini
261 lines (237 loc) · 17 KB
/
zeppelin-erc20-spec.ini
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
; ERC20-EVM Specification Template Parameters
; For more details, refer to README.md.
[root]
k: #execute => #halt
schedule: CONSTANTINOPLE
gas: #gas(INITGAS, 0, 0) => _
[totalSupply]
statusCode: _ => EVMC_SUCCESS
output: _ => #buf(32, TOTAL)
callData: #abiCallData("totalSupply", .TypedArgs)
log: _
refund: _
storage: M
origStorage: _
requires:
andBool select(M, #hashedLocation({COMPILER}, {_TOTALSUPPLY}, .IntList)) ==Int TOTAL
andBool 0 <=Int TOTAL andBool TOTAL <Int (2 ^Int 256)
ensures:
[balanceOf]
statusCode: _ => EVMC_SUCCESS
output: _ => #buf(32, BAL)
callData: #abiCallData("balanceOf", #address(OWNER))
log: _
refund: _
storage: M
origStorage: _
requires:
andBool select(M, #hashedLocation({COMPILER}, {_BALANCES}, OWNER)) ==Int BAL
andBool 0 <=Int OWNER andBool OWNER <Int (2 ^Int 160)
andBool 0 <=Int BAL andBool BAL <Int (2 ^Int 256)
ensures:
[allowance]
statusCode: _ => EVMC_SUCCESS
output: _ => #buf(32, ALLOWANCE)
callData: #abiCallData("allowance", #address(OWNER), #address(SPENDER))
log: _
refund: _
storage: M
origStorage: _
requires:
andBool select(M, #hashedLocation({COMPILER}, {_ALLOWANCES}, OWNER SPENDER)) ==Int ALLOWANCE
andBool 0 <=Int OWNER andBool OWNER <Int (2 ^Int 160)
andBool 0 <=Int SPENDER andBool SPENDER <Int (2 ^Int 160)
andBool 0 <=Int ALLOWANCE andBool ALLOWANCE <Int (2 ^Int 256)
ensures:
[approve]
statusCode: _ => EVMC_SUCCESS
output: _ => #buf(32, 1)
callData: #abiCallData("approve", #address(SPENDER), #uint256(VALUE))
log: _:List ( .List => ListItem(#abiEventLog(ACCT_ID, "Approval", #indexed(#address(CALLER_ID)), #indexed(#address(SPENDER)), #uint256(VALUE))) )
refund: _ => _
storage: M1 => M2
origStorage:
M1
requires:
andBool 0 <=Int SPENDER andBool SPENDER <Int (2 ^Int 160)
andBool 0 <=Int VALUE andBool VALUE <Int (2 ^Int 256)
ensures:
ensures select(M2, #hashedLocation({COMPILER}, {_ALLOWANCES}, CALLER_ID SPENDER)) ==Int VALUE
andBool M1 ==IMap M2 except
(SetItem(#hashedLocation({COMPILER}, {_ALLOWANCES}, CALLER_ID SPENDER)) .Set)
[transfer]
callData: #abiCallData("transfer", #address(TO_ID), #uint256(VALUE))
refund: _ => _
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)
[transfer-success]
statusCode: _ => EVMC_SUCCESS
output: _ => #buf(32, 1)
log: _:List ( .List => ListItem(#abiEventLog(ACCT_ID, "Transfer", #indexed(#address(CALLER_ID)), #indexed(#address(TO_ID)), #uint256(VALUE))) )
[transfer-success-1]
storage: M1 => M2
origStorage: M1
+requires:
andBool select(M1, #hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID)) ==Int BAL_FROM
andBool select(M1, #hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) ==Int BAL_TO
andBool CALLER_ID =/=Int TO_ID
andBool VALUE <=Int BAL_FROM
andBool BAL_TO +Int VALUE <Int (2 ^Int 256)
andBool TO_ID =/=Int 0
ensures:
ensures select(M2, #hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID)) ==Int BAL_FROM -Int VALUE
andBool select(M2, #hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) ==Int BAL_TO +Int VALUE
andBool M1 ==IMap M2 except
(SetItem(#hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID))
SetItem(#hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) .Set)
[transfer-success-2]
storage: M
origStorage:
M
+requires:
andBool select(M, #hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID)) ==Int BAL_FROM
andBool CALLER_ID ==Int TO_ID
andBool VALUE <=Int BAL_FROM
andBool TO_ID =/=Int 0
ensures:
[transfer-failure]
output: _ => _
log: _
[transfer-failure-1]
storage: M1 => M2
origStorage:
M1
+requires:
andBool select(M1, #hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID)) ==Int BAL_FROM
andBool select(M1, #hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) ==Int BAL_TO
[transfer-failure-1-a]
statusCode: _ => EVMC_REVERT
+requires:
andBool CALLER_ID =/=Int TO_ID
andBool ( VALUE >Int BAL_FROM
orBool TO_ID ==Int 0 )
ensures:
ensures M2 ==IMap M1
[transfer-failure-1-b]
statusCode: _ => EVMC_INVALID_INSTRUCTION
+requires:
andBool CALLER_ID =/=Int TO_ID
andBool VALUE <=Int BAL_FROM
andBool TO_ID =/=Int 0
andBool BAL_TO +Int VALUE >=Int (2 ^Int 256)
ensures:
ensures M2 ==IMap M1
except (SetItem(#hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID)) .Set)
[transfer-failure-2]
statusCode: _ => EVMC_REVERT
storage: M
origStorage: _
+requires:
andBool select(M, #hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID)) ==Int BAL_FROM
andBool CALLER_ID ==Int TO_ID
andBool ( VALUE >Int BAL_FROM
orBool TO_ID ==Int 0 )
ensures:
[transferFrom]
callData: #abiCallData("transferFrom", #address(FROM_ID), #address(TO_ID), #uint256(VALUE))
refund: _ => _
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)
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 ALLOW andBool ALLOW <Int (2 ^Int 256)
[transferFrom-success]
statusCode: _ => EVMC_SUCCESS
output: _ => #buf(32, 1)
log: _:List ( .List => ListItem(#abiEventLog(ACCT_ID, "Transfer", #indexed(#address(FROM_ID)), #indexed(#address(TO_ID)), #uint256(VALUE))))
[transferFrom-success-1]
storage: M1 => M2
origStorage:
M1
+requires:
andBool select(M1, #hashedLocation({COMPILER}, {_BALANCES}, FROM_ID)) ==Int BAL_FROM
andBool select(M1, #hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) ==Int BAL_TO
andBool select(M1, #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID)) ==Int ALLOW
andBool FROM_ID =/=Int TO_ID
andBool VALUE <=Int BAL_FROM
andBool BAL_TO +Int VALUE <Int (2 ^Int 256)
andBool VALUE <=Int ALLOW
andBool TO_ID =/=Int 0
andBool #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID) =/=Int #hashedLocation({COMPILER}, {_BALANCES}, TO_ID)
andBool #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID) =/=Int #hashedLocation({COMPILER}, {_BALANCES}, FROM_ID)
ensures:
ensures select(M2, #hashedLocation({COMPILER}, {_BALANCES}, FROM_ID)) ==Int BAL_FROM -Int VALUE
andBool select(M2, #hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) ==Int BAL_TO +Int VALUE
andBool select(M2, #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID)) ==Int ALLOW -Int VALUE
andBool M1 ==IMap M2 except
(SetItem(#hashedLocation({COMPILER}, {_BALANCES}, FROM_ID))
SetItem(#hashedLocation({COMPILER}, {_BALANCES}, TO_ID))
SetItem(#hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID)) .Set)
[transferFrom-success-2]
storage: M1 => M2
origStorage: M1
+requires:
andBool select(M1, #hashedLocation({COMPILER}, {_BALANCES}, FROM_ID)) ==Int BAL_FROM
andBool select(M1, #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID)) ==Int ALLOW
andBool FROM_ID ==Int TO_ID
andBool VALUE <=Int BAL_FROM
andBool VALUE <=Int ALLOW
andBool TO_ID =/=Int 0
ensures:
ensures select(M2, #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID)) ==Int ALLOW -Int VALUE
andBool M1 ==IMap M2 except
(SetItem(#hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID)) .Set)
[transferFrom-failure]
output: _ => _
log: _
[transferFrom-failure-1]
storage: M1 => M2
origStorage: M1
+requires:
andBool select(M1, #hashedLocation({COMPILER}, {_BALANCES}, FROM_ID)) ==Int BAL_FROM
andBool select(M1, #hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) ==Int BAL_TO
andBool select(M1, #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID)) ==Int ALLOW
[transferFrom-failure-1-a]
statusCode: _ => EVMC_REVERT
+requires:
andBool FROM_ID =/=Int TO_ID
andBool ( VALUE >Int BAL_FROM
orBool VALUE >Int ALLOW
orBool TO_ID ==Int 0 )
ensures:
ensures M2 ==IMap M1
[transferFrom-failure-1-b]
statusCode: _ => EVMC_INVALID_INSTRUCTION
+requires:
andBool FROM_ID =/=Int TO_ID
andBool VALUE <=Int BAL_FROM
andBool VALUE <=Int ALLOW
andBool TO_ID =/=Int 0
andBool BAL_TO +Int VALUE >=Int (2 ^Int 256)
ensures:
ensures M2 ==IMap M1 except
(SetItem(#hashedLocation({COMPILER}, {_BALANCES}, FROM_ID))
SetItem(#hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) .Set)
[transferFrom-failure-2]
statusCode: _ => EVMC_REVERT
storage: M
origStorage: _
+requires:
andBool select(M, #hashedLocation({COMPILER}, {_BALANCES}, FROM_ID)) ==Int BAL_FROM
andBool select(M, #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID)) ==Int ALLOW
andBool FROM_ID ==Int TO_ID
andBool ( VALUE >Int BAL_FROM
orBool VALUE >Int ALLOW
orBool TO_ID ==Int 0 )
ensures:
[pgm]
compiler: "Solidity"
_balances: 0
_totalSupply: 1
_allowances: 2
code: "0x60606040526004361061008e576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461009357806318160ddd146100ed57806323b872dd14610116578063661884631461018f57806370a08231146101e9578063a9059cbb14610236578063d73dd62314610290578063dd62ed3e146102ea575b600080fd5b341561009e57600080fd5b6100d3600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610356565b604051808215151515815260200191505060405180910390f35b34156100f857600080fd5b610100610448565b6040518082815260200191505060405180910390f35b341561012157600080fd5b610175600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610452565b604051808215151515815260200191505060405180910390f35b341561019a57600080fd5b6101cf600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061080c565b604051808215151515815260200191505060405180910390f35b34156101f457600080fd5b610220600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a9d565b6040518082815260200191505060405180910390f35b341561024157600080fd5b610276600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ae5565b604051808215151515815260200191505060405180910390f35b341561029b57600080fd5b6102d0600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610d04565b604051808215151515815260200191505060405180910390f35b34156102f557600080fd5b610340600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610f00565b6040518082815260200191505060405180910390f35b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b6000600154905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415151561048f57600080fd5b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111515156104dc57600080fd5b600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561056757600080fd5b6105b8826000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f8790919063ffffffff16565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061064b826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fa090919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061071c82600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f8790919063ffffffff16565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600080600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508083111561091d576000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506109b1565b6109308382610f8790919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610b2257600080fd5b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610b6f57600080fd5b610bc0826000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f8790919063ffffffff16565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610c53826000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fa090919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b6000610d9582600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610fa090919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000828211151515610f9557fe5b818303905092915050565b6000808284019050838110151515610fb457fe5b80915050929150505600a165627a7a7230582058550344abe30ea80d7004da1407b11319bd56cc09cfbbc9ca9a7c80adacd5a30029"