Skip to content

Commit 12ed4b7

Browse files
chfastaxic
authored andcommitted
EEI: Specify trap conditions
1 parent ed86850 commit 12ed4b7

File tree

1 file changed

+126
-5
lines changed

1 file changed

+126
-5
lines changed

Diff for: eth_interface.md

+126-5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ offset.
4242

4343
*nothing*
4444

45+
**Trap conditions**
46+
47+
- store to memory at `resultOffset` results in out of bounds access.
48+
4549
## getExternalBalance
4650

4751
Gets balance of the given account and loads it into memory at the given
@@ -56,6 +60,11 @@ offset.
5660

5761
*nothing*
5862

63+
**Trap conditions**
64+
65+
- load from memory at `addressOffset` results in out of bounds access,
66+
- store to memory at `resultOffset` results in out of bounds access.
67+
5968
## getBlockHash
6069

6170
Gets the hash of one of the 256 most recent complete blocks.
@@ -71,6 +80,10 @@ Gets the hash of one of the 256 most recent complete blocks.
7180

7281
*Note:* in case of failure, the output memory pointed by `resultOffset` is unchanged.
7382

83+
**Trap conditions**
84+
85+
- store to memory at `resultOffset` results in out of bounds access (also checked on failure).
86+
7487
## call
7588

7689
Sends a message with arbitrary data to a given address path
@@ -87,6 +100,12 @@ Sends a message with arbitrary data to a given address path
87100

88101
`result` **i32** Returns 0 on success, 1 on failure and 2 on `revert`
89102

103+
**Trap conditions**
104+
105+
- load `address` from memory at `addressOffset` results in out of bounds access,
106+
- load `u128` from memory at `valueOffset` results in out of bounds access,
107+
- load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access.
108+
90109
## callDataCopy
91110

92111
Copies the input data in current environment to memory. This pertains to
@@ -102,6 +121,11 @@ the input data passed with the message call instruction or transaction.
102121

103122
*nothing*
104123

124+
**Trap conditions**
125+
126+
- load `length` number of bytes from input data buffer at `dataOffset` results in out of bounds access,
127+
- store `length` number of bytes to memory at `resultOffset` results in out of bounds access.
128+
105129
## getCallDataSize
106130

107131
Get size of input data in current environment. This pertains to the input
@@ -131,6 +155,12 @@ data passed with the message call instruction or transaction.
131155

132156
`result` **i32** Returns 0 on success, 1 on failure and 2 on `revert`
133157

158+
**Trap conditions**
159+
160+
- load `address` from memory at `addressOffset` results in out of bounds access,
161+
- load `u128` from memory at `valueOffset` results in out of bounds access,
162+
- load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access.
163+
134164
## callDelegate
135165

136166
Message-call into this account with an alternative account’s code, but
@@ -147,6 +177,11 @@ persisting the current values for sender and value.
147177

148178
`result` **i32** Returns 0 on success, 1 on failure and 2 on `revert`
149179

180+
**Trap conditions**
181+
182+
- load `address` from memory at `addressOffset` results in out of bounds access,
183+
- load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access.
184+
150185
## callStatic
151186

152187
Sends a message with arbitrary data to a given address path, but disallow state
@@ -164,6 +199,11 @@ value.
164199

165200
`result` **i32** Returns 0 on success, 1 on failure and 2 on `revert`
166201

202+
**Trap conditions**
203+
204+
- load `address` from memory at `addressOffset` results in out of bounds access,
205+
- load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access.
206+
167207
## storageStore
168208

169209
Store 256-bit a value in memory to persistent storage
@@ -177,6 +217,11 @@ Store 256-bit a value in memory to persistent storage
177217

178218
*nothing*
179219

220+
**Trap conditions**
221+
222+
- load `u256` from memory at `pathOffset` results in out of bounds access,
223+
- load `u256` from memory at `valueOffset` results in out of bounds access.
224+
180225
## storageLoad
181226

182227
Loads a 256-bit a value to memory from persistent storage
@@ -190,6 +235,11 @@ Loads a 256-bit a value to memory from persistent storage
190235

191236
*nothing*
192237

238+
**Trap conditions**
239+
240+
- load `u256` from memory at `pathOffset` results in out of bounds access,
241+
- store `u256` to memory at `resultOffset` results in out of bounds access.
242+
193243
## getCaller
194244

195245
Gets caller address and loads it into memory at the given offset. This is
@@ -203,6 +253,10 @@ the address of the account that is directly responsible for this execution.
203253

204254
*nothing*
205255

256+
**Trap conditions**
257+
258+
- store `address` to memory at `resultOffset` results in out of bounds access.
259+
206260
## getCallValue
207261

208262
Gets the deposited value by the instruction/transaction responsible for
@@ -216,6 +270,10 @@ this execution and loads it into memory at the given location.
216270

217271
*nothing*
218272

273+
**Trap conditions**
274+
275+
- store `u128` to memory at `resultOffset` results in out of bounds access.
276+
219277
## codeCopy
220278

221279
Copies the code running in current environment to memory.
@@ -230,6 +288,11 @@ Copies the code running in current environment to memory.
230288

231289
*nothing*
232290

291+
**Trap conditions**
292+
293+
- load `length` number of bytes from the current code buffer at `codeOffset` results in out of bounds access,
294+
- store `length` number of bytes to memory at `resultOffset` results in out of bounds access.
295+
233296
## getCodeSize
234297

235298
Gets the size of code running in current environment.
@@ -254,6 +317,10 @@ Gets the block’s beneficiary address and loads into memory.
254317

255318
*nothing*
256319

320+
**Trap conditions**
321+
322+
- store `address` to memory at `resultOffset` results in out of bounds access.
323+
257324
## create
258325

259326
Creates a new contract with a given value.
@@ -262,7 +329,7 @@ Creates a new contract with a given value.
262329

263330
- `valueOffset` **i32ptr** the memory offset to load the value from (`u128`)
264331
- `dataOffset` **i32ptr** the memory offset to load the code for the new contract from (`bytes`)
265-
- `length` **i32** the data length
332+
- `dataLength` **i32** the data length
266333
- `resultOffset` **i32ptr** the memory offset to write the new contract address to (`address`)
267334

268335
*Note*: `create` will clear the return buffer in case of success or may fill it with data coming from `revert`.
@@ -271,6 +338,12 @@ Creates a new contract with a given value.
271338

272339
`result` **i32** Returns 0 on success, 1 on failure and 2 on `revert`
273340

341+
**Trap conditions**
342+
343+
- load `u128` from memory at `valueOffset` results in out of bounds access,
344+
- load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access.
345+
- store `address` to memory at `resultOffset` results in out of bounds access.
346+
274347
## getBlockDifficulty
275348

276349
Get the block’s difficulty.
@@ -283,6 +356,10 @@ Get the block’s difficulty.
283356

284357
*nothing*
285358

359+
**Trap conditions**
360+
361+
- store `u256` to memory at `resultOffset` results in out of bounds access.
362+
286363
## externalCodeCopy
287364

288365
Copies the code of an account to memory.
@@ -298,6 +375,12 @@ Copies the code of an account to memory.
298375

299376
*nothing*
300377

378+
**Trap conditions**
379+
380+
- load `address` from memory at `addressOffset` results in out of bounds access,
381+
- load `length` number of bytes from the account code buffer at `codeOffset` results in out of bounds access,
382+
- store `length` number of bytes to memory at `resultOffset` results in out of bounds access.
383+
301384
## getExternalCodeSize
302385

303386
Get size of an account’s code.
@@ -310,6 +393,10 @@ Get size of an account’s code.
310393

311394
`extCodeSize` **i32**
312395

396+
**Trap conditions**
397+
398+
- load `address` from memory at `addressOffset` results in out of bounds access.
399+
313400
## getGasLeft
314401

315402
Returns the current gasCounter
@@ -340,20 +427,24 @@ Gets price of gas in current environment.
340427

341428
**Parameters**
342429

343-
- `valueOffset` **i32ptr** the memory offset to write the value to (`u128`)
430+
- `resultOffset` **i32ptr** the memory offset to write the value to (`u128`)
344431

345432
**Returns**
346433

347434
*nothing*
348435

436+
**Trap conditions**
437+
438+
- store `u128` to memory at `resultOffset` results in out of bounds access.
439+
349440
## log
350441

351442
Creates a new log in the current environment
352443

353444
**Parameters**
354445

355446
- `dataOffset` **i32ptr** the memory offset to load data from (`bytes`)
356-
- `length` **i32** the data length
447+
- `dataLength` **i32** the data length
357448
- `numberOfTopics` **i32** the number of topics following (0 to 4)
358449
- `topic1` **i32ptr** the memory offset to load topic1 from (`u256`)
359450
- `topic2` **i32ptr** the memory offset to load topic2 from (`u256`)
@@ -364,6 +455,15 @@ Creates a new log in the current environment
364455

365456
*nothing*
366457

458+
**Trap conditions**
459+
460+
- load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access,
461+
- `numberOfTopics` is greater than 4,
462+
- load `u256` from memory at `topic1` results in out of bounds access,
463+
- load `u256` from memory at `topic2` results in out of bounds access,
464+
- load `u256` from memory at `topic3` results in out of bounds access,
465+
- load `u256` from memory at `topic4` results in out of bounds access.
466+
367467
## getBlockNumber
368468

369469
Get the block’s number.
@@ -390,32 +490,44 @@ account with non-empty associated code.
390490

391491
*nothing*
392492

493+
**Trap conditions**
494+
495+
- store `address` to memory at `resultOffset` results in out of bounds access.
496+
393497
## finish
394498

395499
Set the returning output data for the execution. This will cause a trap and the execution will be aborted immediately.
396500

397501
**Parameters**
398502

399503
- `dataOffset` **i32ptr** the memory offset of the output data (`bytes`)
400-
- `length` **i32** the length of the output data
504+
- `dataLength` **i32** the length of the output data
401505

402506
**Returns**
403507

404508
*doesn't return*
405509

510+
**Trap conditions**
511+
512+
- load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access.
513+
406514
## revert
407515

408516
Set the returning output data for the execution. This will cause a trap and the execution will be aborted immediately.
409517

410518
**Parameters**
411519

412520
- `dataOffset` **i32ptr** the memory offset of the output data (`bytes`)
413-
- `length` **i32** the length of the output data
521+
- `dataLength` **i32** the length of the output data
414522

415523
**Returns**
416524

417525
*doesn't return*
418526

527+
**Trap conditions**
528+
529+
- load `dataLength` number of bytes from memory at `dataOffset` results in out of bounds access.
530+
419531
## getReturnDataSize
420532

421533
Get size of current return data buffer to memory. This contains the return data
@@ -446,6 +558,11 @@ from last executed `call`, `callCode`, `callDelegate`, `callStatic` or `create`.
446558

447559
**Returns**
448560

561+
**Trap conditions**
562+
563+
- load `length` number of bytes from input data buffer at `dataOffset` results in out of bounds access,
564+
- store `length` number of bytes to memory at `resultOffset` results in out of bounds access.
565+
449566
*nothing*
450567

451568
## selfDestruct
@@ -461,6 +578,10 @@ beneficiary address. This will cause a trap and the execution will be aborted im
461578

462579
*doesn't return*
463580

581+
**Trap conditions**
582+
583+
- load `address` from memory at `addressOffset` results in out of bounds access.
584+
464585
## getBlockTimestamp
465586

466587
Get the block’s timestamp.

0 commit comments

Comments
 (0)