forked from runtimeverification/verified-smart-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hkg-erc20-spec.ini
217 lines (196 loc) · 11.9 KB
/
hkg-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
; ERC20-EVM Specification Template Parameters
; For more details, refer to README.md.
[root]
k: #execute => #halt
schedule: CONSTANTINOPLE
gas: #gas({GASCAP}, 0, 0) => _
ensures:
[totalSupply]
statusCode: _ => EVMC_REVERT
output: _ => _
callData: #abiCallData("totalSupply", .TypedArgs)
log: _
refund: _
storage: _:Map
origStorage: _
requires:
[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)
[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)
[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 VALUE >Int 0
ensures:
ensures select(M2, #hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID)) ==Int BAL_FROM -Int VALUE
; WARNING: Overflow is not checked
andBool select(M2, #hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) ==Int BAL_TO +Word 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 VALUE >Int 0
[transfer-failure]
statusCode: _ => EVMC_SUCCESS
output: _ => #buf(32, 0)
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
andBool CALLER_ID =/=Int TO_ID
andBool ( VALUE >Int BAL_FROM
orBool VALUE <=Int 0 )
ensures:
ensures M1 ==IMap M2 except
(SetItem(#hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID)) .Set)
[transfer-failure-2]
storage: M1
origStorage: _
+requires:
andBool select(M1, #hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID)) ==Int BAL_FROM
andBool CALLER_ID ==Int TO_ID
andBool ( VALUE >Int BAL_FROM
orBool VALUE <=Int 0 )
[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 VALUE <=Int ALLOW
andBool VALUE >Int 0
ensures:
ensures select(M2, #hashedLocation({COMPILER}, {_BALANCES}, FROM_ID)) ==Int BAL_FROM -Int VALUE
; WARNING: Overflow is not checked
andBool select(M2, #hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) ==Int BAL_TO +Word 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 VALUE >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]
statusCode: _ => EVMC_SUCCESS
output: _ => #buf(32, 0)
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
andBool FROM_ID =/=Int TO_ID
andBool ( VALUE >Int BAL_FROM orBool VALUE >Int ALLOW orBool VALUE <=Int 0 )
ensures:
ensures M1 ==IMap M2 except
(SetItem(#hashedLocation({COMPILER}, {_BALANCES}, FROM_ID))
SetItem(#hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) .Set)
[transferFrom-failure-2]
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 VALUE <=Int 0 )
[pgm]
compiler: "Solidity"
_totalSupply: 0
_balances: 1
_allowances: 2
code: "0x60606040526004361061006d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063095ea7b31461007257806323b872dd146100cc57806370a0823114610145578063a9059cbb14610192578063dd62ed3e146101ec575b600080fd5b341561007d57600080fd5b6100b2600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610258565b604051808215151515815260200191505060405180910390f35b34156100d757600080fd5b61012b600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061034a565b604051808215151515815260200191505060405180910390f35b341561015057600080fd5b61017c600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506105c6565b6040518082815260200191505060405180910390f35b341561019d57600080fd5b6101d2600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803590602001909190505061060f565b604051808215151515815260200191505060405180910390f35b34156101f757600080fd5b610242600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610778565b6040518082815260200191505060405180910390f35b600081600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b600081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410158015610417575081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b80156104235750600082115b156105ba5781600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190506105bf565b600090505b9392505050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b600081600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101580156106605750600082115b1561076d5781600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a360019050610772565b600090505b92915050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050929150505600a165627a7a723058206cb5284e8795f7d1c570318732bc1cb8add2222946156c0ba28c946531c4a2f50029"
gasCap: 100000