@@ -12,9 +12,9 @@ We define the following Ethereum data types:
12
12
- ` u256 ` : a 256 bit number, represented as a 32 bytes long little endian unsigned integer in memory
13
13
14
14
We also define the following WebAssembly data types:
15
- - ` i32 ` : same as ` i32 ` in WebAssembly
16
- - ` i32ptr ` : same as ` i32 ` in WebAssembly, but treated as a pointer to a WebAssembly memory offset
17
- - ` i64 ` : same as ` i64 ` in WebAssembly
15
+ - ` i32 ` : the 32-bit signed integer type mapped to ` i32 ` in WebAssembly,
16
+ - ` i32ptr ` : the 32-bit signed integer treated as an offset to the WebAssembly memory, mapped to ` i32 ` in WebAssembly,
17
+ - ` i64 ` : the 64-bit signed integer type mapped to ` i64 ` in WebAssembly.
18
18
19
19
# API
20
20
@@ -30,6 +30,10 @@ Subtracts an amount to the gas counter
30
30
31
31
* nothing*
32
32
33
+ ** Trap conditions**
34
+
35
+ - ` amount ` is negative.
36
+
33
37
## getAddress
34
38
35
39
Gets address of currently executing account and stores it in memory at the given
@@ -45,6 +49,7 @@ offset.
45
49
46
50
** Trap conditions**
47
51
52
+ - ` resultOffset ` is negative,
48
53
- store to memory at ` resultOffset ` results in out of bounds access.
49
54
50
55
## getExternalBalance
@@ -63,7 +68,9 @@ offset.
63
68
64
69
** Trap conditions**
65
70
71
+ - ` addressOffset ` is negative,
66
72
- load from memory at ` addressOffset ` results in out of bounds access,
73
+ - ` resultOffset ` is negative,
67
74
- store to memory at ` resultOffset ` results in out of bounds access.
68
75
69
76
## getBlockHash
@@ -83,6 +90,8 @@ Gets the hash of one of the 256 most recent complete blocks.
83
90
84
91
** Trap conditions**
85
92
93
+ - ` number ` is negative,
94
+ - ` resultOffset ` is negative,
86
95
- store to memory at ` resultOffset ` results in out of bounds access (also checked on failure).
87
96
88
97
## call
@@ -103,8 +112,13 @@ Sends a message with arbitrary data to a given address path
103
112
104
113
** Trap conditions**
105
114
115
+ - ` gas ` is negative,
116
+ - ` addressOffset ` is negative,
106
117
- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
118
+ - ` valueOffset ` is negative,
107
119
- load ` u128 ` from memory at ` valueOffset ` results in out of bounds access,
120
+ - ` dataLength ` is negative,
121
+ - ` dataOffset ` is negative,
108
122
- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
109
123
110
124
## callDataCopy
@@ -124,7 +138,10 @@ the input data passed with the message call instruction or transaction.
124
138
125
139
** Trap conditions**
126
140
141
+ - ` length ` is negative,
142
+ - ` dataOffset ` is negative,
127
143
- load ` length ` number of bytes from input data buffer at ` dataOffset ` results in out of bounds access,
144
+ - ` resultOffset ` is negative,
128
145
- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
129
146
130
147
## getCallDataSize
@@ -158,8 +175,13 @@ data passed with the message call instruction or transaction.
158
175
159
176
** Trap conditions**
160
177
178
+ - ` gas ` is negative,
179
+ - ` addressOffset ` is negative,
161
180
- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
181
+ - ` valueOffset ` is negative,
162
182
- load ` u128 ` from memory at ` valueOffset ` results in out of bounds access,
183
+ - ` dataLength ` is negative,
184
+ - ` dataOffset ` is negative,
163
185
- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
164
186
165
187
## callDelegate
@@ -180,7 +202,11 @@ persisting the current values for sender and value.
180
202
181
203
** Trap conditions**
182
204
205
+ - ` gas ` is negative,
206
+ - ` addressOffset ` is negative,
183
207
- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
208
+ - ` dataLength ` is negative,
209
+ - ` dataOffset ` is negative,
184
210
- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
185
211
186
212
## callStatic
@@ -202,7 +228,11 @@ value.
202
228
203
229
** Trap conditions**
204
230
231
+ - ` gas ` is negative,
232
+ - ` addressOffset ` is negative,
205
233
- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
234
+ - ` dataLength ` is negative,
235
+ - ` dataOffset ` is negative,
206
236
- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
207
237
208
238
## storageStore
@@ -220,7 +250,9 @@ Store 256-bit a value in memory to persistent storage
220
250
221
251
** Trap conditions**
222
252
253
+ - ` pathOffset ` is negative,
223
254
- load ` bytes32 ` from memory at ` pathOffset ` results in out of bounds access,
255
+ - ` valueOffset ` is negative,
224
256
- load ` bytes32 ` from memory at ` valueOffset ` results in out of bounds access.
225
257
226
258
## storageLoad
@@ -238,7 +270,9 @@ Loads a 256-bit a value to memory from persistent storage
238
270
239
271
** Trap conditions**
240
272
273
+ - ` pathOffset ` is negative,
241
274
- load ` bytes32 ` from memory at ` pathOffset ` results in out of bounds access,
275
+ - ` resultOffset ` is negative,
242
276
- store ` bytes32 ` to memory at ` resultOffset ` results in out of bounds access.
243
277
244
278
## getCaller
@@ -256,6 +290,7 @@ the address of the account that is directly responsible for this execution.
256
290
257
291
** Trap conditions**
258
292
293
+ - ` resultOffset ` is negative,
259
294
- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
260
295
261
296
## getCallValue
@@ -273,6 +308,7 @@ this execution and loads it into memory at the given location.
273
308
274
309
** Trap conditions**
275
310
311
+ - ` resultOffset ` is negative,
276
312
- store ` u128 ` to memory at ` resultOffset ` results in out of bounds access.
277
313
278
314
## codeCopy
@@ -291,7 +327,10 @@ Copies the code running in current environment to memory.
291
327
292
328
** Trap conditions**
293
329
330
+ - ` length ` is negative,
331
+ - ` codeOffset ` is negative,
294
332
- load ` length ` number of bytes from the current code buffer at ` codeOffset ` results in out of bounds access,
333
+ - ` resultOffset ` is negative,
295
334
- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
296
335
297
336
## getCodeSize
@@ -320,6 +359,7 @@ Gets the block’s beneficiary address and loads into memory.
320
359
321
360
** Trap conditions**
322
361
362
+ - ` resultOffset ` is negative,
323
363
- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
324
364
325
365
## create
@@ -341,8 +381,12 @@ Creates a new contract with a given value.
341
381
342
382
** Trap conditions**
343
383
384
+ - ` valueOffset ` is negative,
344
385
- load ` u128 ` from memory at ` valueOffset ` results in out of bounds access,
386
+ - ` dataLength ` is negative,
387
+ - ` dataOffset ` is negative,
345
388
- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
389
+ - ` resultOffset ` is negative,
346
390
- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
347
391
348
392
## getBlockDifficulty
@@ -359,6 +403,7 @@ Get the block’s difficulty.
359
403
360
404
** Trap conditions**
361
405
406
+ - ` resultOffset ` is negative,
362
407
- store ` u256 ` to memory at ` resultOffset ` results in out of bounds access.
363
408
364
409
## externalCodeCopy
@@ -378,8 +423,12 @@ Copies the code of an account to memory.
378
423
379
424
** Trap conditions**
380
425
426
+ - ` addressOffset ` is negative,
381
427
- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
428
+ - ` length ` is negative,
429
+ - ` codeOffset ` is negative,
382
430
- load ` length ` number of bytes from the account code buffer at ` codeOffset ` results in out of bounds access,
431
+ - ` resultOffset ` is negative,
383
432
- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
384
433
385
434
## getExternalCodeSize
@@ -396,6 +445,7 @@ Get size of an account’s code.
396
445
397
446
** Trap conditions**
398
447
448
+ - ` addressOffset ` is negative,
399
449
- load ` address ` from memory at ` addressOffset ` results in out of bounds access.
400
450
401
451
## getGasLeft
@@ -436,6 +486,7 @@ Gets price of gas in current environment.
436
486
437
487
** Trap conditions**
438
488
489
+ - ` resultOffset ` is negative,
439
490
- store ` u128 ` to memory at ` resultOffset ` results in out of bounds access.
440
491
441
492
## log
@@ -458,11 +509,17 @@ Creates a new log in the current environment
458
509
459
510
** Trap conditions**
460
511
512
+ - ` dataLength ` is negative,
513
+ - ` dataOffset ` is negative,
461
514
- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access,
462
- - ` numberOfTopics ` is greater than 4,
515
+ - ` numberOfTopics ` is negative or greater than 4,
516
+ - ` topic1 ` is negative,
463
517
- load ` bytes32 ` from memory at ` topic1 ` results in out of bounds access,
518
+ - ` topic2 ` is negative,
464
519
- load ` bytes32 ` from memory at ` topic2 ` results in out of bounds access,
520
+ - ` topic3 ` is negative,
465
521
- load ` bytes32 ` from memory at ` topic3 ` results in out of bounds access,
522
+ - ` topic4 ` is negative,
466
523
- load ` bytes32 ` from memory at ` topic4 ` results in out of bounds access.
467
524
468
525
## getBlockNumber
@@ -493,6 +550,7 @@ account with non-empty associated code.
493
550
494
551
** Trap conditions**
495
552
553
+ - ` resultOffset ` is negative,
496
554
- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
497
555
498
556
## finish
@@ -510,6 +568,8 @@ Set the returning output data for the execution. This will cause a trap and the
510
568
511
569
** Trap conditions**
512
570
571
+ - ` dataLength ` is negative,
572
+ - ` dataOffset ` is negative,
513
573
- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
514
574
515
575
## revert
@@ -527,6 +587,8 @@ Set the returning output data for the execution. This will cause a trap and the
527
587
528
588
** Trap conditions**
529
589
590
+ - ` dataLength ` is negative,
591
+ - ` dataOffset ` is negative,
530
592
- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
531
593
532
594
## getReturnDataSize
@@ -561,7 +623,10 @@ from last executed `call`, `callCode`, `callDelegate`, `callStatic` or `create`.
561
623
562
624
** Trap conditions**
563
625
626
+ - ` length ` is negative,
627
+ - ` dataOffset ` is negative,
564
628
- load ` length ` number of bytes from input data buffer at ` dataOffset ` results in out of bounds access,
629
+ - ` resultOffset ` is negative,
565
630
- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
566
631
567
632
* nothing*
@@ -581,6 +646,7 @@ beneficiary address. This will cause a trap and the execution will be aborted im
581
646
582
647
** Trap conditions**
583
648
649
+ - ` addressOffset ` is negative,
584
650
- load ` address ` from memory at ` addressOffset ` results in out of bounds access.
585
651
586
652
## getBlockTimestamp
0 commit comments