Skip to content

Commit 13973a2

Browse files
authored
Merge pull request #44 from ethereum/eei
EEI: update all undefined parts
2 parents 3300b06 + 1081aae commit 13973a2

File tree

1 file changed

+69
-80
lines changed

1 file changed

+69
-80
lines changed

eth_interface.md

Lines changed: 69 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,19 @@
1-
# Ethereum Environment Interface (EEI) Specification (*Revision 1*)
1+
# Ethereum Environment Interface (EEI) Specification (*Revision 2*)
22

33
The Ethereum Environment Interface exposes the core Ethereum API to the eWASM environment. The Ethereum [module](https://github.com/WebAssembly/design/blob/master/Modules.md) will be implemented in the Ethereum client's native language. All parameters and returns are restricted to 32 or 64 bit integers. Floats are disallowed.
44

5-
## Environment
6-
7-
The Ethereum Environment Interface exposes the following information.
8-
9-
* gasCount - the current amount of gas used
10-
* gas - The totally amount of gas that the contract instance has to use
11-
* gasPrice - The price in wei paid for gas
12-
* gasLimit - The max amount of gas that maybe expended
13-
* address - The contract's address
14-
* origin - The origin address of the message that caused this contract to run
15-
* coinbase - The current block's coinbase
16-
* difficulty - The current block's difficulty
17-
* caller - The address that directly messaged this contract
18-
* callValue - The value in wei of that the message has
19-
* callData - The message's data
20-
* code - The code of the current running contract
21-
* logs - All the logs that the contract emitted
22-
* state - Ethereum's state as stored in the state trie
23-
24-
Further more we define the following caps on the environmental variables
25-
26-
* `codesize` is capped to a 64 bit integer
27-
* `calldata` size is capped to 64 bits
28-
* `balances` are represented as a 128 bit little endian unsigned integer
29-
* `gasPrice` is represented as a 64 bit little endian unsigned integer
30-
* `gas` is represented as a 64 bit little endian unsigned integer
5+
# Data types
6+
7+
We define the following Ethereum data types:
8+
- `bytes`: an array of bytes with unrestricted length
9+
- `address`: a 160 bit number, represented as a 20 bytes long little endian unsigned integer in memory
10+
- `u128`: a 128 bit number, represented as a 16 bytes long little endian unsigned integer in memory
11+
- `u256`: a 256 bit number, represented as a 32 bytes long little endian unsigned integer in memory
12+
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
3117

3218
# API
3319

@@ -37,7 +23,7 @@ Subtracts an amount to the gas counter
3723

3824
**Parameters**
3925

40-
- `amount` **integer** the amount to subtract to the gas counter
26+
- `amount` **i64** the amount to subtract to the gas counter
4127

4228
**Returns**
4329

@@ -50,7 +36,7 @@ the given offset.
5036

5137
**Parameters**
5238

53-
- `resultOffset` **i32** the memory offset to load the address into
39+
- `resultOffset` **i32ptr** the memory offset to load the address into (`address`)
5440

5541
**Returns**
5642

@@ -63,8 +49,8 @@ offset.
6349

6450
**Parameters**
6551

66-
- `addressOffset` **i32** the memory offset to load the address from
67-
- `resultOffset` **i32** the memory offset to load the balance into
52+
- `addressOffset` **i32ptr** the memory offset to load the address from (`address`)
53+
- `resultOffset` **i32ptr** the memory offset to load the balance into (`u128`)
6854

6955
**Returns**
7056

@@ -76,8 +62,8 @@ Gets the hash of one of the 256 most recent complete blocks.
7662

7763
**Parameters**
7864

79-
- `number` **integer** which block to load
80-
- `resultOffset` **i32** the memory offset to load the hash into
65+
- `number` **i64** which block to load
66+
- `resultOffset` **i32ptr** the memory offset to load the hash into (`u256`)
8167

8268
**Returns**
8369

@@ -89,12 +75,12 @@ Sends a message with arbitrary date to a given address path
8975

9076
**Parameters**
9177

92-
- `gas` **integer** the gas limit
93-
- `addressOffset` **i32** the memory offset to load the address from
94-
- `valueOffset` **i32** the memory offset to load the value from
95-
- `dataOffset` **i32** the memory offset to load data from
78+
- `gas` **i64** the gas limit
79+
- `addressOffset` **i32ptr** the memory offset to load the address from (`address`)
80+
- `valueOffset` **i32ptr** the memory offset to load the value from (`u128`)
81+
- `dataOffset` **i32ptr** the memory offset to load data from (`bytes`)
9682
- `dataLength` **i32** the length of data
97-
- `resultOffset` **i32** the memory offset to store the result data at
83+
- `resultOffset` **i32ptr** the memory offset to store the result data at (`bytes`)
9884
- `resultLength` **i32** the maximal length of result data
9985

10086
**Returns**
@@ -108,7 +94,7 @@ the input data passed with the message call instruction or transaction.
10894

10995
**Parameters**
11096

111-
- `resultOffset` **i32** the memory offset to load data into
97+
- `resultOffset` **i32ptr** the memory offset to load data into (`bytes`)
11298
- `dataOffset` **i32** the offset in the input data
11399
- `length` **i32** the length of data to copy
114100

@@ -127,20 +113,20 @@ data passed with the message call instruction or transaction.
127113

128114
**Returns**
129115

130-
`callDataSize` **integer**
116+
`callDataSize` **i32**
131117

132118
## callCode
133119

134120
Message-call into this account with an alternative account's code.
135121

136122
**Parameters**
137123

138-
- `gas` **integer** the gas limit
139-
- `addressOffset` **i32** the memory offset to load the address from
140-
- `valueOffset` **i32** the memory offset to load the value from
141-
- `dataOffset` **i32** the memory offset to load data from
124+
- `gas` **i64** the gas limit
125+
- `addressOffset` **i32ptr** the memory offset to load the address from (`address`)
126+
- `valueOffset` **i32ptr** the memory offset to load the value from (`u128`)
127+
- `dataOffset` **i32ptr** the memory offset to load data from (`bytes`)
142128
- `dataLength` **i32** the length of data
143-
- `resultOffset` **i32** the memory offset to store the result data at
129+
- `resultOffset` **i32ptr** the memory offset to store the result data at (`bytes`)
144130
- `resultLength` **i32** the maximal length of result data
145131

146132
**Returns**
@@ -154,36 +140,38 @@ persisting the current values for sender and value.
154140

155141
**Parameters**
156142

157-
- `gas` **integer** the gas limit
158-
- `addressOffset` **i32** the memory offset to load the address from
159-
- `dataOffset` **i32** the memory offset to load data from
143+
- `gas` **i64** the gas limit
144+
- `addressOffset` **i32ptr** the memory offset to load the address from (`address`)
145+
- `dataOffset` **i32ptr** the memory offset to load data from (`bytes`)
160146
- `dataLength` **i32** the length of data
161-
- `resultOffset` **i32** the memory offset to store the result data at
147+
- `resultOffset` **i32ptr** the memory offset to store the result data at (`bytes`)
162148
- `resultLength` **i32** the maximal length of result data
163149

164150
**Returns**
165151

166152
`result` **i32** Returns 1 or 0 depending on if the VM trapped on the message or not
167153

168154
## storageStore
155+
169156
Store 256-bit a value in memory to persistent storage
170157

171158
**Parameters**
172159

173-
- `pathOffest` **i32** the memory offset to load the path from
174-
- `valueOffset` **i32** the memory offset to load the value from
160+
- `pathOffest` **i32ptr** the memory offset to load the path from (`u256`)
161+
- `valueOffset` **i32ptr** the memory offset to load the value from (`u256`)
175162

176163
**Returns**
177164

178165
*nothing*
179166

180167
## storageLoad
168+
181169
Loads a 256-bit a value to memory from persistent storage
182170

183171
**Parameters**
184172

185-
- `pathOffest` **i32** the memory offset to load the path from
186-
- `resultOffset` **i32** the memory offset to store the result at
173+
- `pathOffest` **i32ptr** the memory offset to load the path from (`u256`)
174+
- `resultOffset` **i32ptr** the memory offset to store the result at (`u256`)
187175

188176
**Returns**
189177

@@ -196,7 +184,7 @@ the address of the account that is directly responsible for this execution.
196184

197185
**Parameters**
198186

199-
- `resultOffset` **i32** the memory offset to load the address into
187+
- `resultOffset` **i32ptr** the memory offset to load the address into (`address`)
200188

201189
**Returns**
202190

@@ -209,7 +197,7 @@ this execution and loads it into memory at the given location.
209197

210198
**Parameters**
211199

212-
- `resultOffset` **i32** the memory offset to load the value into
200+
- `resultOffset` **i32ptr** the memory offset to load the value into (`u128`)
213201

214202
**Returns**
215203

@@ -221,7 +209,7 @@ Copies the code running in current environment to memory.
221209

222210
**Parameters**
223211

224-
- `resultOffset` **i32** the memory offset to load the result into
212+
- `resultOffset` **i32ptr** the memory offset to load the result into (`bytes`)
225213
- `codeOffset` **i32** the offset within the code
226214
- `length` **i32** the length of code to copy
227215

@@ -247,7 +235,7 @@ Gets the block’s beneficiary address and loads into memory.
247235

248236
**Parameters**
249237

250-
- `resultOffset` **i32** the memory offset to load the coinbase address into
238+
- `resultOffset` **i32ptr** the memory offset to load the coinbase address into (`address`)
251239

252240
**Returns**
253241

@@ -259,34 +247,35 @@ Creates a new contract with a given value.
259247

260248
**Parameters**
261249

262-
- `valueOffset` **i32** the memory offset to load the value from
263-
- `dataOffset` **i32** the memory offset to load the code for the new contract from
250+
- `valueOffset` **i32ptr** the memory offset to load the value from (`u128`)
251+
- `dataOffset` **i32ptr** the memory offset to load the code for the new contract from (`bytes`)
264252
- `length` **i32** the data length
253+
- `resultOffset` **i32ptr** the memory offset to write the new contract address to (`address`)
265254

266255
**Returns**
267256

268-
*nothing*
257+
`result` **i32** Returns 1 or 0 depending on if the VM trapped on the message or not
269258

270259
## getBlockDifficulty
271260

272261
Get the block’s difficulty.
273262

274263
**Parameters**
275264

276-
*none*
265+
- `offset` **i32ptr** the memory offset to load the difficulty into (`u256`)
277266

278267
**Returns**
279268

280-
`difficulty` **integer**
269+
*nothing*
281270

282271
## externalCodeCopy
283272

284273
Copies the code of an account to memory.
285274

286275
**Parameters**
287276

288-
- `addressOffset` **i32** the memory offset to load the address from
289-
- `resultOffset` **i32** the memory offset to load the result into
277+
- `addressOffset` **i32ptr** the memory offset to load the address from (`address`)
278+
- `resultOffset` **i32ptr** the memory offset to load the result into (`bytes`)
290279
- `codeOffset` **i32** the offset within the code
291280
- `length` **i32** the length of code to copy
292281

@@ -300,7 +289,7 @@ Get size of an account’s code.
300289

301290
**Parameters**
302291

303-
- `addressOffset` **i32** the memory offset to load the address from
292+
- `addressOffset` **i32ptr** the memory offset to load the address from (`address`)
304293

305294
**Returns**
306295

@@ -316,7 +305,7 @@ Returns the current gasCounter
316305

317306
**Returns**
318307

319-
`gasLeft` **integer**
308+
`gasLeft` **i64**
320309

321310
## getBlockGasLimit
322311

@@ -328,33 +317,33 @@ Get the block’s gas limit.
328317

329318
**Returns**
330319

331-
`blockGasLimit` **integer**
320+
`blockGasLimit` **i64**
332321

333322
## getTxGasPrice
334323

335324
Gets price of gas in current environment.
336325

337326
**Parameters**
338327

339-
*none*
328+
- `valueOffset` **i32ptr** the memory offset to write the value to (`u128`)
340329

341330
**Returns**
342331

343-
`gasPrice` **integer**
332+
*nothing*
344333

345334
## log
346335

347336
Creates a new log in the current environment
348337

349338
**Parameters**
350339

351-
- `dataOffset` **i32** the memory offset to load data from
340+
- `dataOffset` **i32ptr** the memory offset to load data from (`bytes`)
352341
- `length` **i32** the data length
353-
- `topic1` **integer**
354-
- `topic2` **integer**
355-
- `topic3` **integer**
356-
- `topic4` **integer**
357-
- `topic5` **integer**
342+
- `numberOfTopics` **i32** the number of topics following (0 to 4)
343+
- `topic1` **i32ptr** the memory offset to load topic1 from (`u256`)
344+
- `topic2` **i32ptr** the memory offset to load topic2 from (`u256`)
345+
- `topic3` **i32ptr** the memory offset to load topic3 from (`u256`)
346+
- `topic4` **i32ptr** the memory offset to load topic4 from (`u256`)
358347

359348
**Returns**
360349

@@ -370,7 +359,7 @@ Get the block’s number.
370359

371360
**Returns**
372361

373-
`blockNumber` **integer**
362+
`blockNumber` **i64**
374363

375364
## getTxOrigin
376365

@@ -380,7 +369,7 @@ account with non-empty associated code.
380369

381370
**Parameters**
382371

383-
- `resultOffset` **i32** the memory offset to load the origin address from
372+
- `resultOffset` **i32ptr** the memory offset to load the origin address from (`address`)
384373

385374
**Returns**
386375

@@ -392,7 +381,7 @@ Halt execution returning output data.
392381

393382
**Parameters**
394383

395-
- `dataOffset` **i32** the memory offset of the output data
384+
- `dataOffset` **i32ptr** the memory offset of the output data (`bytes`)
396385
- `length` **i32** the length of the output data
397386

398387
**Returns**
@@ -406,7 +395,7 @@ balance to an address path
406395

407396
**Parameters**
408397

409-
- `addressOffset` **i32** the memory offset to load the address from
398+
- `addressOffset` **i32ptr** the memory offset to load the address from (`address`)
410399

411400
**Returns**
412401

@@ -422,4 +411,4 @@ Get the block’s timestamp.
422411

423412
**Returns**
424413

425-
`blockTimestamp` **integer**
414+
`blockTimestamp` **i64**

0 commit comments

Comments
 (0)