-
Notifications
You must be signed in to change notification settings - Fork 134
/
vyper-erc20-spec.ini
222 lines (202 loc) · 11.4 KB
/
vyper-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
; 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)
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
ensures:
[transfer-failure]
statusCode: _ => EVMC_REVERT
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
andBool CALLER_ID =/=Int TO_ID
andBool ( VALUE >Int BAL_FROM
orBool BAL_TO +Int VALUE >=Int (2 ^Int 256) )
ensures:
ensures M1 ==IMap M2
except (SetItem(#hashedLocation({COMPILER}, {_BALANCES}, CALLER_ID)) .Set)
[transfer-failure-2]
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
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 #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID) =/=Int #hashedLocation({COMPILER}, {_BALANCES}, FROM_ID)
andBool #hashedLocation({COMPILER}, {_ALLOWANCES}, FROM_ID CALLER_ID) =/=Int #hashedLocation({COMPILER}, {_BALANCES}, TO_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
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_REVERT
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
andBool FROM_ID =/=Int TO_ID
andBool ( VALUE >Int BAL_FROM
orBool BAL_TO +Int VALUE >=Int (2 ^Int 256)
orBool VALUE >Int ALLOW )
ensures:
ensures M2 ==IMap M1 except
(SetItem(#hashedLocation({COMPILER}, {_BALANCES}, FROM_ID))
SetItem(#hashedLocation({COMPILER}, {_BALANCES}, TO_ID)) .Set)
[transferFrom-failure-2]
storage: M
origStorage: M
+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 )
ensures:
[pgm]
compiler: "Vyper"
_balances: 0
_allowances: 1
_totalSupply: 2
code: "0x600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a05263d0e30db06000511415610168573460008112585761014052336101605261016051600060c052602060c02001546101405161016051600060c052602060c020015401116101405115176100e657600080fd5b6101405161016051600060c052602060c02001540161016051600060c052602060c020015560025461014051600254011161014051151761012657600080fd5b610140516002540160025561014051610180526101605160007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6020610180a3005b632e1a7d4d6000511415610260576020600461014037341561018957600080fd5b33610160526101405161016051600060c052602060c020015410156101ad57600080fd5b6101405161016051600060c052602060c02001540361016051600060c052602060c02001556101405160025410156101e457600080fd5b61014051600254036002556000600060006000600160605161014051806040519013585780919012585702610160516000f161021f57600080fd5b61014051610180526000610160517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6020610180a3600160005260206000f3005b6318160ddd600051141561028657341561027957600080fd5b60025460005260206000f3005b6370a0823160005114156102cd57602060046101403734156102a757600080fd5b60043560205181101558575061014051600060c052602060c020015460005260206000f3005b63a9059cbb60005114156103e057604060046101403734156102ee57600080fd5b60043560205181101558575033610180526101605161018051600060c052602060c0200154101561031e57600080fd5b6101605161018051600060c052602060c02001540361018051600060c052602060c020015561014051600060c052602060c02001546101605161014051600060c052602060c0200154011161016051151761037857600080fd5b6101605161014051600060c052602060c02001540161014051600060c052602060c0200155610160516101a05261014051610180517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206101a0a3600160005260206000f3005b6323b872dd6000511415610559576060600461014037341561040157600080fd5b600435602051811015585750602435602051811015585750336101a0526101a05161014051600160c052602060c0200160c052602060c02001546101c0526101805161014051600060c052602060c0200154101561045e57600080fd5b6101805161014051600060c052602060c02001540361014051600060c052602060c020015561016051600060c052602060c02001546101805161016051600060c052602060c020015401116101805115176104b857600080fd5b6101805161016051600060c052602060c02001540161016051600060c052602060c0200155610180516101c05110156104f057600080fd5b610180516101c051036101a05161014051600160c052602060c0200160c052602060c0200155610180516101e05261016051610140517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206101e0a3600160005260206000f3005b63095ea7b360005114156105ef576040600461014037341561057a57600080fd5b6004356020518110155857503361018052610160516101405161018051600160c052602060c0200160c052602060c0200155610160516101a05261014051610180517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560206101a0a3600160005260206000f3005b63dd62ed3e600051141561064f576040600461014037341561061057600080fd5b6004356020518110155857506024356020518110155857506101605161014051600160c052602060c0200160c052602060c020015460005260206000f3005b"