Skip to content

Commit

Permalink
Clarifications to EIP-663 (#6055)
Browse files Browse the repository at this point in the history
* Rewrite the specification of EIP-663

* Some wording improvements

Co-authored-by: Paweł Bylica <chfast@gmail.com>

* Linter 😳

Co-authored-by: Paweł Bylica <chfast@gmail.com>
  • Loading branch information
axic and chfast authored Nov 30, 2022
1 parent 70de94a commit f2db669
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions EIPS/eip-663.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,20 @@ If the code is legacy bytecode, both of these instructions result in an *excepti

If the code is valid EOF1, the following execution rules apply:

These instructions are followed by an 8-bit immediate value, which we call `imm`, and can have a value of 0 to 255. We introduce the variable `n` which equals to `imm + 1`.
1. These instructions are followed by an 8-bit immediate value, which we call `imm`, and can have a value of 0 to 255. We introduce the variable `n` which equals to `imm + 1`.

If the current stack depth is less than `n`, then a stack underflow exception is issued. If the current stack depth is at the limit, a stack overflow exception is issued. In both of these cases the EVM stops and all gas is consumed.
2. For `DUPN`:

Otherwise
- If the current stack height is less than `n`, then a stack underflow exception is issued.
- If the current stack height is at the limit (1024), a stack overflow exception is issued.
- Otherwise the `n`'th stack item is duplicated at the top of the stack. (*Note: We use 1-based indexing here.*)

- for `DUPN` the stack item at depth `n - 1` is duplicated at the top of the stack
- for `SWAPN` the top stack item is swapped with the item at depth `n`
3. For `SWAPN`:

- If the current stack height is less than `n + 1`, then a stack underflow exception is issued.
- Otherwise the `n + 1`th stack item is swapped with the top stack item.

Clarification: the "stack underflow/overflow exception" means the EVM execution is halted and all gas is consumed.

The gas cost for both instructions is set at 3.

Expand Down

0 comments on commit f2db669

Please sign in to comment.