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