@@ -12,9 +12,9 @@ We define the following Ethereum data types:
1212- ` u256 ` : a 256 bit number, represented as a 32 bytes long little endian unsigned integer in memory
1313
1414We 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.
1818
1919# API
2020
@@ -30,6 +30,10 @@ Subtracts an amount to the gas counter
3030
3131* nothing*
3232
33+ ** Trap conditions**
34+
35+ - ` amount ` is negative.
36+
3337## getAddress
3438
3539Gets address of currently executing account and stores it in memory at the given
@@ -45,6 +49,7 @@ offset.
4549
4650** Trap conditions**
4751
52+ - ` resultOffset ` is negative,
4853- store to memory at ` resultOffset ` results in out of bounds access.
4954
5055## getExternalBalance
@@ -63,7 +68,9 @@ offset.
6368
6469** Trap conditions**
6570
71+ - ` addressOffset ` is negative,
6672- load from memory at ` addressOffset ` results in out of bounds access,
73+ - ` resultOffset ` is negative,
6774- store to memory at ` resultOffset ` results in out of bounds access.
6875
6976## getBlockHash
@@ -83,6 +90,8 @@ Gets the hash of one of the 256 most recent complete blocks.
8390
8491** Trap conditions**
8592
93+ - ` number ` is negative,
94+ - ` resultOffset ` is negative,
8695- store to memory at ` resultOffset ` results in out of bounds access (also checked on failure).
8796
8897## call
@@ -103,8 +112,13 @@ Sends a message with arbitrary data to a given address path
103112
104113** Trap conditions**
105114
115+ - ` gas ` is negative,
116+ - ` addressOffset ` is negative,
106117- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
118+ - ` valueOffset ` is negative,
107119- load ` u128 ` from memory at ` valueOffset ` results in out of bounds access,
120+ - ` dataLength ` is negative,
121+ - ` dataOffset ` is negative,
108122- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
109123
110124## callDataCopy
@@ -124,7 +138,10 @@ the input data passed with the message call instruction or transaction.
124138
125139** Trap conditions**
126140
141+ - ` length ` is negative,
142+ - ` dataOffset ` is negative,
127143- load ` length ` number of bytes from input data buffer at ` dataOffset ` results in out of bounds access,
144+ - ` resultOffset ` is negative,
128145- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
129146
130147## getCallDataSize
@@ -158,8 +175,13 @@ data passed with the message call instruction or transaction.
158175
159176** Trap conditions**
160177
178+ - ` gas ` is negative,
179+ - ` addressOffset ` is negative,
161180- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
181+ - ` valueOffset ` is negative,
162182- load ` u128 ` from memory at ` valueOffset ` results in out of bounds access,
183+ - ` dataLength ` is negative,
184+ - ` dataOffset ` is negative,
163185- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
164186
165187## callDelegate
@@ -180,7 +202,11 @@ persisting the current values for sender and value.
180202
181203** Trap conditions**
182204
205+ - ` gas ` is negative,
206+ - ` addressOffset ` is negative,
183207- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
208+ - ` dataLength ` is negative,
209+ - ` dataOffset ` is negative,
184210- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
185211
186212## callStatic
@@ -202,7 +228,11 @@ value.
202228
203229** Trap conditions**
204230
231+ - ` gas ` is negative,
232+ - ` addressOffset ` is negative,
205233- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
234+ - ` dataLength ` is negative,
235+ - ` dataOffset ` is negative,
206236- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
207237
208238## storageStore
@@ -220,7 +250,9 @@ Store 256-bit a value in memory to persistent storage
220250
221251** Trap conditions**
222252
253+ - ` pathOffset ` is negative,
223254- load ` bytes32 ` from memory at ` pathOffset ` results in out of bounds access,
255+ - ` valueOffset ` is negative,
224256- load ` bytes32 ` from memory at ` valueOffset ` results in out of bounds access.
225257
226258## storageLoad
@@ -238,7 +270,9 @@ Loads a 256-bit a value to memory from persistent storage
238270
239271** Trap conditions**
240272
273+ - ` pathOffset ` is negative,
241274- load ` bytes32 ` from memory at ` pathOffset ` results in out of bounds access,
275+ - ` resultOffset ` is negative,
242276- store ` bytes32 ` to memory at ` resultOffset ` results in out of bounds access.
243277
244278## getCaller
@@ -256,6 +290,7 @@ the address of the account that is directly responsible for this execution.
256290
257291** Trap conditions**
258292
293+ - ` resultOffset ` is negative,
259294- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
260295
261296## getCallValue
@@ -273,6 +308,7 @@ this execution and loads it into memory at the given location.
273308
274309** Trap conditions**
275310
311+ - ` resultOffset ` is negative,
276312- store ` u128 ` to memory at ` resultOffset ` results in out of bounds access.
277313
278314## codeCopy
@@ -291,7 +327,10 @@ Copies the code running in current environment to memory.
291327
292328** Trap conditions**
293329
330+ - ` length ` is negative,
331+ - ` codeOffset ` is negative,
294332- load ` length ` number of bytes from the current code buffer at ` codeOffset ` results in out of bounds access,
333+ - ` resultOffset ` is negative,
295334- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
296335
297336## getCodeSize
@@ -320,6 +359,7 @@ Gets the block’s beneficiary address and loads into memory.
320359
321360** Trap conditions**
322361
362+ - ` resultOffset ` is negative,
323363- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
324364
325365## create
@@ -341,8 +381,12 @@ Creates a new contract with a given value.
341381
342382** Trap conditions**
343383
384+ - ` valueOffset ` is negative,
344385- load ` u128 ` from memory at ` valueOffset ` results in out of bounds access,
386+ - ` dataLength ` is negative,
387+ - ` dataOffset ` is negative,
345388- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
389+ - ` resultOffset ` is negative,
346390- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
347391
348392## getBlockDifficulty
@@ -359,6 +403,7 @@ Get the block’s difficulty.
359403
360404** Trap conditions**
361405
406+ - ` resultOffset ` is negative,
362407- store ` u256 ` to memory at ` resultOffset ` results in out of bounds access.
363408
364409## externalCodeCopy
@@ -378,8 +423,12 @@ Copies the code of an account to memory.
378423
379424** Trap conditions**
380425
426+ - ` addressOffset ` is negative,
381427- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
428+ - ` length ` is negative,
429+ - ` codeOffset ` is negative,
382430- load ` length ` number of bytes from the account code buffer at ` codeOffset ` results in out of bounds access,
431+ - ` resultOffset ` is negative,
383432- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
384433
385434## getExternalCodeSize
@@ -396,6 +445,7 @@ Get size of an account’s code.
396445
397446** Trap conditions**
398447
448+ - ` addressOffset ` is negative,
399449- load ` address ` from memory at ` addressOffset ` results in out of bounds access.
400450
401451## getGasLeft
@@ -436,6 +486,7 @@ Gets price of gas in current environment.
436486
437487** Trap conditions**
438488
489+ - ` resultOffset ` is negative,
439490- store ` u128 ` to memory at ` resultOffset ` results in out of bounds access.
440491
441492## log
@@ -458,11 +509,17 @@ Creates a new log in the current environment
458509
459510** Trap conditions**
460511
512+ - ` dataLength ` is negative,
513+ - ` dataOffset ` is negative,
461514- 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,
463517- load ` bytes32 ` from memory at ` topic1 ` results in out of bounds access,
518+ - ` topic2 ` is negative,
464519- load ` bytes32 ` from memory at ` topic2 ` results in out of bounds access,
520+ - ` topic3 ` is negative,
465521- load ` bytes32 ` from memory at ` topic3 ` results in out of bounds access,
522+ - ` topic4 ` is negative,
466523- load ` bytes32 ` from memory at ` topic4 ` results in out of bounds access.
467524
468525## getBlockNumber
@@ -493,6 +550,7 @@ account with non-empty associated code.
493550
494551** Trap conditions**
495552
553+ - ` resultOffset ` is negative,
496554- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
497555
498556## finish
@@ -510,6 +568,8 @@ Set the returning output data for the execution. This will cause a trap and the
510568
511569** Trap conditions**
512570
571+ - ` dataLength ` is negative,
572+ - ` dataOffset ` is negative,
513573- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
514574
515575## revert
@@ -527,6 +587,8 @@ Set the returning output data for the execution. This will cause a trap and the
527587
528588** Trap conditions**
529589
590+ - ` dataLength ` is negative,
591+ - ` dataOffset ` is negative,
530592- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
531593
532594## getReturnDataSize
@@ -561,7 +623,10 @@ from last executed `call`, `callCode`, `callDelegate`, `callStatic` or `create`.
561623
562624** Trap conditions**
563625
626+ - ` length ` is negative,
627+ - ` dataOffset ` is negative,
564628- load ` length ` number of bytes from input data buffer at ` dataOffset ` results in out of bounds access,
629+ - ` resultOffset ` is negative,
565630- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
566631
567632* nothing*
@@ -581,6 +646,7 @@ beneficiary address. This will cause a trap and the execution will be aborted im
581646
582647** Trap conditions**
583648
649+ - ` addressOffset ` is negative,
584650- load ` address ` from memory at ` addressOffset ` results in out of bounds access.
585651
586652## getBlockTimestamp
0 commit comments