@@ -11,9 +11,9 @@ We define the following Ethereum data types:
1111- ` u256 ` : a 256 bit number, represented as a 32 bytes long little endian unsigned integer in memory
1212
1313We 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.
1717
1818# API
1919
@@ -29,6 +29,10 @@ Subtracts an amount to the gas counter
2929
3030* nothing*
3131
32+ ** Trap conditions**
33+
34+ - ` amount ` is negative.
35+
3236## getAddress
3337
3438Gets address of currently executing account and stores it in memory at the given
@@ -44,6 +48,7 @@ offset.
4448
4549** Trap conditions**
4650
51+ - ` resultOffset ` is negative,
4752- store to memory at ` resultOffset ` results in out of bounds access.
4853
4954## getExternalBalance
@@ -62,7 +67,9 @@ offset.
6267
6368** Trap conditions**
6469
70+ - ` addressOffset ` is negative,
6571- load from memory at ` addressOffset ` results in out of bounds access,
72+ - ` resultOffset ` is negative,
6673- store to memory at ` resultOffset ` results in out of bounds access.
6774
6875## getBlockHash
@@ -82,6 +89,8 @@ Gets the hash of one of the 256 most recent complete blocks.
8289
8390** Trap conditions**
8491
92+ - ` number ` is negative,
93+ - ` resultOffset ` is negative,
8594- store to memory at ` resultOffset ` results in out of bounds access (also checked on failure).
8695
8796## call
@@ -102,8 +111,13 @@ Sends a message with arbitrary data to a given address path
102111
103112** Trap conditions**
104113
114+ - ` gas ` is negative,
115+ - ` addressOffset ` is negative,
105116- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
117+ - ` valueOffset ` is negative,
106118- load ` u128 ` from memory at ` valueOffset ` results in out of bounds access,
119+ - ` dataLength ` is negative,
120+ - ` dataOffset ` is negative,
107121- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
108122
109123## callDataCopy
@@ -123,7 +137,10 @@ the input data passed with the message call instruction or transaction.
123137
124138** Trap conditions**
125139
140+ - ` length ` is negative,
141+ - ` dataOffset ` is negative,
126142- load ` length ` number of bytes from input data buffer at ` dataOffset ` results in out of bounds access,
143+ - ` resultOffset ` is negative,
127144- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
128145
129146## getCallDataSize
@@ -157,8 +174,13 @@ data passed with the message call instruction or transaction.
157174
158175** Trap conditions**
159176
177+ - ` gas ` is negative,
178+ - ` addressOffset ` is negative,
160179- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
180+ - ` valueOffset ` is negative,
161181- load ` u128 ` from memory at ` valueOffset ` results in out of bounds access,
182+ - ` dataLength ` is negative,
183+ - ` dataOffset ` is negative,
162184- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
163185
164186## callDelegate
@@ -179,7 +201,11 @@ persisting the current values for sender and value.
179201
180202** Trap conditions**
181203
204+ - ` gas ` is negative,
205+ - ` addressOffset ` is negative,
182206- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
207+ - ` dataLength ` is negative,
208+ - ` dataOffset ` is negative,
183209- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
184210
185211## callStatic
@@ -201,7 +227,11 @@ value.
201227
202228** Trap conditions**
203229
230+ - ` gas ` is negative,
231+ - ` addressOffset ` is negative,
204232- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
233+ - ` dataLength ` is negative,
234+ - ` dataOffset ` is negative,
205235- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
206236
207237## storageStore
@@ -219,7 +249,9 @@ Store 256-bit a value in memory to persistent storage
219249
220250** Trap conditions**
221251
252+ - ` pathOffset ` is negative,
222253- load ` u256 ` from memory at ` pathOffset ` results in out of bounds access,
254+ - ` valueOffset ` is negative,
223255- load ` u256 ` from memory at ` valueOffset ` results in out of bounds access.
224256
225257## storageLoad
@@ -237,7 +269,9 @@ Loads a 256-bit a value to memory from persistent storage
237269
238270** Trap conditions**
239271
272+ - ` pathOffset ` is negative,
240273- load ` u256 ` from memory at ` pathOffset ` results in out of bounds access,
274+ - ` resultOffset ` is negative,
241275- store ` u256 ` to memory at ` resultOffset ` results in out of bounds access.
242276
243277## getCaller
@@ -255,6 +289,7 @@ the address of the account that is directly responsible for this execution.
255289
256290** Trap conditions**
257291
292+ - ` resultOffset ` is negative,
258293- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
259294
260295## getCallValue
@@ -272,6 +307,7 @@ this execution and loads it into memory at the given location.
272307
273308** Trap conditions**
274309
310+ - ` resultOffset ` is negative,
275311- store ` u128 ` to memory at ` resultOffset ` results in out of bounds access.
276312
277313## codeCopy
@@ -290,7 +326,10 @@ Copies the code running in current environment to memory.
290326
291327** Trap conditions**
292328
329+ - ` length ` is negative,
330+ - ` codeOffset ` is negative,
293331- load ` length ` number of bytes from the current code buffer at ` codeOffset ` results in out of bounds access,
332+ - ` resultOffset ` is negative,
294333- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
295334
296335## getCodeSize
@@ -319,6 +358,7 @@ Gets the block’s beneficiary address and loads into memory.
319358
320359** Trap conditions**
321360
361+ - ` resultOffset ` is negative,
322362- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
323363
324364## create
@@ -340,8 +380,12 @@ Creates a new contract with a given value.
340380
341381** Trap conditions**
342382
383+ - ` valueOffset ` is negative,
343384- load ` u128 ` from memory at ` valueOffset ` results in out of bounds access,
385+ - ` dataLength ` is negative,
386+ - ` dataOffset ` is negative,
344387- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
388+ - ` resultOffset ` is negative,
345389- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
346390
347391## getBlockDifficulty
@@ -358,6 +402,7 @@ Get the block’s difficulty.
358402
359403** Trap conditions**
360404
405+ - ` resultOffset ` is negative,
361406- store ` u256 ` to memory at ` resultOffset ` results in out of bounds access.
362407
363408## externalCodeCopy
@@ -377,8 +422,12 @@ Copies the code of an account to memory.
377422
378423** Trap conditions**
379424
425+ - ` addressOffset ` is negative,
380426- load ` address ` from memory at ` addressOffset ` results in out of bounds access,
427+ - ` length ` is negative,
428+ - ` codeOffset ` is negative,
381429- load ` length ` number of bytes from the account code buffer at ` codeOffset ` results in out of bounds access,
430+ - ` resultOffset ` is negative,
382431- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
383432
384433## getExternalCodeSize
@@ -395,6 +444,7 @@ Get size of an account’s code.
395444
396445** Trap conditions**
397446
447+ - ` addressOffset ` is negative,
398448- load ` address ` from memory at ` addressOffset ` results in out of bounds access.
399449
400450## getGasLeft
@@ -435,6 +485,7 @@ Gets price of gas in current environment.
435485
436486** Trap conditions**
437487
488+ - ` resultOffset ` is negative,
438489- store ` u128 ` to memory at ` resultOffset ` results in out of bounds access.
439490
440491## log
@@ -457,11 +508,17 @@ Creates a new log in the current environment
457508
458509** Trap conditions**
459510
511+ - ` dataLength ` is negative,
512+ - ` dataOffset ` is negative,
460513- 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,
462516- load ` u256 ` from memory at ` topic1 ` results in out of bounds access,
517+ - ` topic2 ` is negative,
463518- load ` u256 ` from memory at ` topic2 ` results in out of bounds access,
519+ - ` topic3 ` is negative,
464520- load ` u256 ` from memory at ` topic3 ` results in out of bounds access,
521+ - ` topic4 ` is negative,
465522- load ` u256 ` from memory at ` topic4 ` results in out of bounds access.
466523
467524## getBlockNumber
@@ -492,6 +549,7 @@ account with non-empty associated code.
492549
493550** Trap conditions**
494551
552+ - ` resultOffset ` is negative,
495553- store ` address ` to memory at ` resultOffset ` results in out of bounds access.
496554
497555## finish
@@ -509,6 +567,8 @@ Set the returning output data for the execution. This will cause a trap and the
509567
510568** Trap conditions**
511569
570+ - ` dataLength ` is negative,
571+ - ` dataOffset ` is negative,
512572- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
513573
514574## revert
@@ -526,6 +586,8 @@ Set the returning output data for the execution. This will cause a trap and the
526586
527587** Trap conditions**
528588
589+ - ` dataLength ` is negative,
590+ - ` dataOffset ` is negative,
529591- load ` dataLength ` number of bytes from memory at ` dataOffset ` results in out of bounds access.
530592
531593## getReturnDataSize
@@ -560,7 +622,10 @@ from last executed `call`, `callCode`, `callDelegate`, `callStatic` or `create`.
560622
561623** Trap conditions**
562624
625+ - ` length ` is negative,
626+ - ` dataOffset ` is negative,
563627- load ` length ` number of bytes from input data buffer at ` dataOffset ` results in out of bounds access,
628+ - ` resultOffset ` is negative,
564629- store ` length ` number of bytes to memory at ` resultOffset ` results in out of bounds access.
565630
566631* nothing*
@@ -580,6 +645,7 @@ beneficiary address. This will cause a trap and the execution will be aborted im
580645
581646** Trap conditions**
582647
648+ - ` addressOffset ` is negative,
583649- load ` address ` from memory at ` addressOffset ` results in out of bounds access.
584650
585651## getBlockTimestamp
0 commit comments