-
Notifications
You must be signed in to change notification settings - Fork 0
/
footer.txt
executable file
·329 lines (294 loc) · 14.4 KB
/
footer.txt
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
eD09375DC6B20050d242d1611af97eE4A6E93CAd:
balance: '100000000000'
nonce: ''
storage: {}
code: |
(module
(import "ethereum" "storageStore" (func $storageStore (param i32 i32)))
(import "ethereum" "call" (func $call (param i64 i32 i32 i32 i32) (result i32)))
(import "ethereum" "getReturnDataSize" (func $getReturnDataSize (result i32)))
(import "ethereum" "returnDataCopy" (func $returnDataCopy (param i32 i32 i32)))
(import "debug" "printMemHex" (func $printMemHex (param i32 i32)))
(import "debug" "print32" (func $print32 (param i32)))
(memory 1)
;; first command: query balance of 0xeD09375DC6B20050d242d1611af97eE4A6E93CAd
(data (i32.const 0) "\99\93\02\1a\ed\09\37\5d\c6\b2\00\50\d2\42\d1\61\1a\f9\7e\e4\a6\e9\3c\ad")
;; second command: Transfer 500000 to 0xe929CF2544363bdCEE4a976515d5F97758Ef476c
(data (i32.const 32) "\5d\35\9f\bd\e9\29\CF\25\44\36\3b\dC\EE\4a\97\65\15\d5\F9\77\58\Ef\47\6c\00\00\00\00\00\07\a1\20")
;; third command: Query balance of 0xeD09375DC6B20050d242d1611af97eE4A6E93CAd
;;(data (i32.const 64) "\99\93\02\1a\de\ad\be\ef\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
(data (i32.const 64) "\99\93\02\1a\ed\09\37\5d\c6\b2\00\50\d2\42\d1\61\1a\f9\7e\e4\a6\e9\3c\ad")
;; fourth command: Query balance of 0xe929CF2544363bdCEE4a976515d5F97758Ef476c
;;(data (i32.const 96) "\99\93\02\1a\6c\47\ef\58\77\f9\d5\15\65\97\4a\ee\dc\3b\36\44\25\cf\29\e9")
(data (i32.const 96) "\99\93\02\1a\e9\29\CF\25\44\36\3b\dC\EE\4a\97\65\15\d5\F9\77\58\Ef\47\6c")
;; contract address
(data (i32.const 128) "\a0\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
;; storage keys
(data (i32.const 160) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\01") ;; 01
(data (i32.const 192) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02") ;; 02
(data (i32.const 224) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\03") ;; 03
(data (i32.const 256) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\04") ;; 04
(data (i32.const 512) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\05") ;; 05
(data (i32.const 544) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\06") ;; 06
(data (i32.const 576) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\07") ;; 07
(data (i32.const 608) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\08") ;; 08
(export "memory" (memory 0))
(export "main" (func $main))
(func $main
;; locals
(local $memOffset i32)
(local $ptrAddress i32)
(local $ptrValueZero i32)
(local $ptrCommand1 i32)
(local $ptrCommand2 i32)
(local $ptrCommand3 i32)
(local $ptrCommand4 i32)
(local $lenCommand1 i32)
(local $lenCommand2 i32)
(local $lenCommand3 i32)
(local $lenCommand4 i32)
(local $ptrCallResult1 i32)
(local $ptrCallResult2 i32)
(local $ptrCallResult3 i32)
(local $ptrCallResult4 i32)
(local $ptrStorageKey1 i32)
(local $ptrStorageKey2 i32)
(local $ptrStorageKey3 i32)
(local $ptrStorageKey4 i32)
(local $ptrStorageKey5 i32)
(local $ptrStorageKey6 i32)
(local $ptrStorageKey7 i32)
(local $ptrStorageKey8 i32)
(local $ptrReturnData1 i32)
(local $ptrReturnData2 i32)
(local $ptrReturnData3 i32)
(local $ptrReturnData4 i32)
;; init data pointers
(set_local $ptrCommand1 (i32.const 0))
(set_local $ptrCommand2 (i32.const 32))
(set_local $ptrCommand3 (i32.const 64))
(set_local $ptrCommand4 (i32.const 96))
(set_local $ptrAddress (i32.const 128))
(set_local $lenCommand1 (i32.const 24))
(set_local $lenCommand2 (i32.const 32))
(set_local $lenCommand3 (i32.const 24))
(set_local $lenCommand4 (i32.const 24))
;; memory layout and pointers
(set_local $memOffset (i32.const 160))
(set_local $ptrStorageKey1 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 0)))) ;; 160
(set_local $ptrStorageKey2 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 1)))) ;; 192
(set_local $ptrStorageKey3 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 2)))) ;; 224
(set_local $ptrStorageKey4 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 3)))) ;; 256
(set_local $ptrValueZero (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 4)))) ;; 288
(set_local $ptrReturnData1 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 5)))) ;; 320
(set_local $ptrReturnData2 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 6)))) ;; 352
(set_local $ptrCallResult1 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 7)))) ;; 384
(set_local $ptrCallResult2 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 8)))) ;; 416
(set_local $ptrCallResult3 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 9)))) ;; 448
(set_local $ptrCallResult4 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 10)))) ;; 480
(set_local $ptrStorageKey5 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 11)))) ;; 512
(set_local $ptrStorageKey6 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 12)))) ;; 544
(set_local $ptrStorageKey7 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 13)))) ;; 576
(set_local $ptrStorageKey8 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 14)))) ;; 608
(set_local $ptrReturnData3 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 15)))) ;; 640
(set_local $ptrReturnData4 (i32.add (get_local $memOffset) (i32.mul (i32.const 32) (i32.const 16)))) ;; 672
(call $printMemHex (get_local $ptrCommand1) (get_local $lenCommand1))
;; send data 99 93 2 1a de ad be ef 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
;; first command: Query balance of 0xeD09375DC6B20050d242d1611af97eE4A6E93CAd
;; and save result
(i32.store
(get_local $ptrCallResult1)
(call $call
;; gas
(i64.const 100000)
;; address offset
(get_local $ptrAddress)
;; value offset
(get_local $ptrValueZero)
;; data offset
(get_local $ptrCommand1)
;; data length
(get_local $lenCommand1)
)
)
;; [ 1 ] call exit code =======================================
;; receives 0 = success, stored in key 1
;; store it
(call $print32 (i32.const 1))
(call $printMemHex (get_local $ptrCallResult1) (i32.const 32))
(call $storageStore (get_local $ptrStorageKey1) (get_local $ptrCallResult1))
;; read return val
(call $returnDataCopy
;; resultOffset
(get_local $ptrReturnData1)
;; dataOffset
(i32.const 0)
;; length
(call $getReturnDataSize)
)
;; [ 2 ] call result ===========================================
;; receives balance, stored in key 2
;; store it
(call $print32 (i32.const 2))
(call $printMemHex (get_local $ptrReturnData1) (i32.const 32))
(call $storageStore (get_local $ptrStorageKey2) (get_local $ptrReturnData1))
(call $printMemHex (get_local $ptrCommand2) (get_local $lenCommand2))
;; second command: Transfer 500000 to 0xe929CF2544363bdCEE4a976515d5F97758Ef476c
;; and save result
(i32.store
(get_local $ptrCallResult2)
(call $call
;; gas
(i64.const 1000000)
;; address offset
(get_local $ptrAddress)
;; value offset
(get_local $ptrValueZero)
;; data offset
(get_local $ptrCommand2)
;; data length
(get_local $lenCommand2)
)
)
;; [ 3 ] 2nd call exit code ====================================================
;; store it
(call $print32 (i32.const 3))
(call $printMemHex (get_local $ptrCallResult2) (i32.const 32))
(call $storageStore (get_local $ptrStorageKey3) (get_local $ptrCallResult2))
;; read return val
(call $returnDataCopy
;; resultOffset
(get_local $ptrReturnData2)
;; dataOffset
(i32.const 0)
;; length
(call $getReturnDataSize)
)
;; [ 4 ] 2nd call no output ===================================================
;; store it
(call $print32 (i32.const 4))
(call $printMemHex (get_local $ptrReturnData2) (i32.const 32))
(call $storageStore (get_local $ptrStorageKey4) (get_local $ptrReturnData2))
(call $printMemHex (get_local $ptrCommand3) (get_local $lenCommand3))
;; third command: Query balance of 0xeD09375DC6B20050d242d1611af97eE4A6E93CAd
;; and save result
(i32.store
(get_local $ptrCallResult3)
(call $call
;; gas
(i64.const 100000)
;; address offset
(get_local $ptrAddress)
;; value offset
(get_local $ptrValueZero)
;; data offset
(get_local $ptrCommand3)
;; data length
(get_local $lenCommand3)
)
)
;; [ 5 ] 3rd call exit code ================================================
;; store it
(call $print32 (i32.const 5))
(call $printMemHex (get_local $ptrCallResult3) (i32.const 32))
(call $storageStore (get_local $ptrStorageKey5) (get_local $ptrCallResult3))
;; read return val
(call $returnDataCopy
;; resultOffset
(get_local $ptrReturnData3)
;; dataOffset
(i32.const 0)
;; length
(call $getReturnDataSize)
)
;; [ 6 ] 3rd call result ====================================================
;; store it
(call $print32 (i32.const 6))
(call $printMemHex (get_local $ptrReturnData3) (i32.const 32))
(call $storageStore (get_local $ptrStorageKey6) (get_local $ptrReturnData3))
;; fourth command: Query balance of 0xe929CF2544363bdCEE4a976515d5F97758Ef476c
;; and save result
(call $printMemHex (get_local $ptrCommand4) (get_local $lenCommand4))
(i32.store
(get_local $ptrCallResult4)
(call $call
;; gas
(i64.const 100000)
;; address offset
(get_local $ptrAddress)
;; value offset
(get_local $ptrValueZero)
;; data offset
(get_local $ptrCommand4)
;; data length
(get_local $lenCommand4)
)
)
;; [ 7 ] 4th call exit code ================================================
;; store it
(call $print32 (i32.const 7))
(call $printMemHex (get_local $ptrCallResult4) (i32.const 32))
(call $storageStore (get_local $ptrStorageKey7) (get_local $ptrCallResult4))
;; read return val
(call $returnDataCopy
;; resultOffset
(get_local $ptrReturnData4)
;; dataOffset
(i32.const 0)
;; length
(call $getReturnDataSize)
)
;; [ 8 ] 4th call result ===================================================
;; store it
(call $print32 (i32.const 8))
(call $printMemHex (get_local $ptrReturnData4) (i32.const 32))
(call $storageStore (get_local $ptrStorageKey8) (get_local $ptrReturnData4))
)
)
expect:
- indexes:
data: !!int -1
gas: !!int -1
value: !!int -1
network:
- ALL
result:
#a94f5374fce5edbc8e2a8697c15331677e6ebf0b:
#balance: '99999853295'
eD09375DC6B20050d242d1611af97eE4A6E93CAd:
storage: {
# First call should be success
# $memPointerStorageKey1 = 1
1: 0,
# first return data: expect to get balance 1000000 that we set above in pre
2: 1000000,
# Second call should be success
3: 0,
# No output expected from second call
4: '',
# Third call should be success
5: 0,
# Third call should return new balance
6: 500000,
# Fourth call should be success
7: 0,
# Fourth call should return new balance
#8: 500000,
}
a000000000000000000000000000000000000000:
storage: {
# Token balances
0xeD09375DC6B20050d242d1611af97eE4A6E93CAd: 500000,
0xe929cf2544363bdcee4a976515d5f97758ef476c: 500000
}
transaction:
data:
- '0x'
gasLimit:
- '0x5500000'
gasPrice: '0x01'
nonce: '0x04'
secretKey: "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8"
to: 'eD09375DC6B20050d242d1611af97eE4A6E93CAd'
value:
- '0'