diff --git a/eth_interface.md b/eth_interface.md index a03f997c..5bb17596 100644 --- a/eth_interface.md +++ b/eth_interface.md @@ -11,9 +11,9 @@ We define the following Ethereum data types: - `u256`: a 256 bit number, represented as a 32 bytes long little endian unsigned integer in memory We also define the following WebAssembly data types: -- `i32`: same as `i32` in WebAssembly -- `i32ptr`: same as `i32` in WebAssembly, but treated as a pointer to a WebAssembly memory offset -- `i64`: same as `i64` in WebAssembly +- `i32`: the 32-bit signed integer type mapped to `i32` in WebAssembly, +- `i32ptr`: the 32-bit signed integer treated as an offset to the WebAssembly memory, mapped to `i32` in WebAssembly, +- `i64`: the 64-bit signed integer type mapped to `i64` in WebAssembly. # API @@ -29,6 +29,10 @@ Subtracts an amount to the gas counter *nothing* +**Trap conditions** + +- `amount` is negative. + ## getAddress Gets address of currently executing account and stores it in memory at the given @@ -44,6 +48,7 @@ offset. **Trap conditions** +- `resultOffset` is negative, - store to memory at `resultOffset` results in out of bounds access. ## getExternalBalance @@ -62,7 +67,9 @@ offset. **Trap conditions** +- `addressOffset` is negative, - load from memory at `addressOffset` results in out of bounds access, +- `resultOffset` is negative, - store to memory at `resultOffset` results in out of bounds access. ## getBlockHash @@ -82,6 +89,8 @@ Gets the hash of one of the 256 most recent complete blocks. **Trap conditions** +- `number` is negative, +- `resultOffset` is negative, - store to memory at `resultOffset` results in out of bounds access (also checked on failure). ## call @@ -102,8 +111,13 @@ Sends a message with arbitrary data to a given address path **Trap conditions** +- `gas` is negative, +- `addressOffset` is negative, - load `address` from memory at `addressOffset` results in out of bounds access, +- `valueOffset` is negative, - load `u128` from memory at `valueOffset` results in out of bounds access, +- `dataLength` is negative, +- `dataOffset` is negative, - load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access. ## callDataCopy @@ -123,7 +137,10 @@ the input data passed with the message call instruction or transaction. **Trap conditions** +- `length` is negative, +- `dataOffset` is negative, - load `length` number of bytes from input data buffer at `dataOffset` results in out of bounds access, +- `resultOffset` is negative, - store `length` number of bytes to memory at `resultOffset` results in out of bounds access. ## getCallDataSize @@ -157,8 +174,13 @@ data passed with the message call instruction or transaction. **Trap conditions** +- `gas` is negative, +- `addressOffset` is negative, - load `address` from memory at `addressOffset` results in out of bounds access, +- `valueOffset` is negative, - load `u128` from memory at `valueOffset` results in out of bounds access, +- `dataLength` is negative, +- `dataOffset` is negative, - load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access. ## callDelegate @@ -179,7 +201,11 @@ persisting the current values for sender and value. **Trap conditions** +- `gas` is negative, +- `addressOffset` is negative, - load `address` from memory at `addressOffset` results in out of bounds access, +- `dataLength` is negative, +- `dataOffset` is negative, - load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access. ## callStatic @@ -201,7 +227,11 @@ value. **Trap conditions** +- `gas` is negative, +- `addressOffset` is negative, - load `address` from memory at `addressOffset` results in out of bounds access, +- `dataLength` is negative, +- `dataOffset` is negative, - load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access. ## storageStore @@ -219,7 +249,9 @@ Store 256-bit a value in memory to persistent storage **Trap conditions** +- `pathOffset` is negative, - load `u256` from memory at `pathOffset` results in out of bounds access, +- `valueOffset` is negative, - load `u256` from memory at `valueOffset` results in out of bounds access. ## storageLoad @@ -237,7 +269,9 @@ Loads a 256-bit a value to memory from persistent storage **Trap conditions** +- `pathOffset` is negative, - load `u256` from memory at `pathOffset` results in out of bounds access, +- `resultOffset` is negative, - store `u256` to memory at `resultOffset` results in out of bounds access. ## getCaller @@ -255,6 +289,7 @@ the address of the account that is directly responsible for this execution. **Trap conditions** +- `resultOffset` is negative, - store `address` to memory at `resultOffset` results in out of bounds access. ## getCallValue @@ -272,6 +307,7 @@ this execution and loads it into memory at the given location. **Trap conditions** +- `resultOffset` is negative, - store `u128` to memory at `resultOffset` results in out of bounds access. ## codeCopy @@ -290,7 +326,10 @@ Copies the code running in current environment to memory. **Trap conditions** +- `length` is negative, +- `codeOffset` is negative, - load `length` number of bytes from the current code buffer at `codeOffset` results in out of bounds access, +- `resultOffset` is negative, - store `length` number of bytes to memory at `resultOffset` results in out of bounds access. ## getCodeSize @@ -319,6 +358,7 @@ Gets the block’s beneficiary address and loads into memory. **Trap conditions** +- `resultOffset` is negative, - store `address` to memory at `resultOffset` results in out of bounds access. ## create @@ -340,8 +380,12 @@ Creates a new contract with a given value. **Trap conditions** +- `valueOffset` is negative, - load `u128` from memory at `valueOffset` results in out of bounds access, +- `dataLength` is negative, +- `dataOffset` is negative, - load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access. +- `resultOffset` is negative, - store `address` to memory at `resultOffset` results in out of bounds access. ## getBlockDifficulty @@ -358,6 +402,7 @@ Get the block’s difficulty. **Trap conditions** +- `resultOffset` is negative, - store `u256` to memory at `resultOffset` results in out of bounds access. ## externalCodeCopy @@ -377,8 +422,12 @@ Copies the code of an account to memory. **Trap conditions** +- `addressOffset` is negative, - load `address` from memory at `addressOffset` results in out of bounds access, +- `length` is negative, +- `codeOffset` is negative, - load `length` number of bytes from the account code buffer at `codeOffset` results in out of bounds access, +- `resultOffset` is negative, - store `length` number of bytes to memory at `resultOffset` results in out of bounds access. ## getExternalCodeSize @@ -395,6 +444,7 @@ Get size of an account’s code. **Trap conditions** +- `addressOffset` is negative, - load `address` from memory at `addressOffset` results in out of bounds access. ## getGasLeft @@ -435,6 +485,7 @@ Gets price of gas in current environment. **Trap conditions** +- `resultOffset` is negative, - store `u128` to memory at `resultOffset` results in out of bounds access. ## log @@ -457,11 +508,17 @@ Creates a new log in the current environment **Trap conditions** +- `dataLength` is negative, +- `dataOffset` is negative, - load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access, -- `numberOfTopics` is greater than 4, +- `numberOfTopics` is negative or greater than 4, +- `topic1` is negative, - load `u256` from memory at `topic1` results in out of bounds access, +- `topic2` is negative, - load `u256` from memory at `topic2` results in out of bounds access, +- `topic3` is negative, - load `u256` from memory at `topic3` results in out of bounds access, +- `topic4` is negative, - load `u256` from memory at `topic4` results in out of bounds access. ## getBlockNumber @@ -492,6 +549,7 @@ account with non-empty associated code. **Trap conditions** +- `resultOffset` is negative, - store `address` to memory at `resultOffset` results in out of bounds access. ## finish @@ -509,6 +567,8 @@ Set the returning output data for the execution. This will cause a trap and the **Trap conditions** +- `dataLength` is negative, +- `dataOffset` is negative, - load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access. ## revert @@ -526,6 +586,8 @@ Set the returning output data for the execution. This will cause a trap and the **Trap conditions** +- `dataLength` is negative, +- `dataOffset` is negative, - load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access. ## getReturnDataSize @@ -560,7 +622,10 @@ from last executed `call`, `callCode`, `callDelegate`, `callStatic` or `create`. **Trap conditions** +- `length` is negative, +- `dataOffset` is negative, - load `length` number of bytes from input data buffer at `dataOffset` results in out of bounds access, +- `resultOffset` is negative, - store `length` number of bytes to memory at `resultOffset` results in out of bounds access. *nothing* @@ -580,6 +645,7 @@ beneficiary address. This will cause a trap and the execution will be aborted im **Trap conditions** +- `addressOffset` is negative, - load `address` from memory at `addressOffset` results in out of bounds access. ## getBlockTimestamp