Skip to content

Commit

Permalink
Rewrite the specification of EIP-663
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Nov 28, 2022
1 parent 0d650fc commit 3ca9eaf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions EIPS/eip-663.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ 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`:
- 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 (1024), a stack overflow exception is issued.
- Otherwise the stack item at depth `n` is duplicated at the top of the stack.

Otherwise
3. For `SWAPN`:
- If the current stack depth is less than `n + 1`, then a stack underflow exception is ussed.
- Otherwise the stack item at depth `n + 1` is swapped with the item at depth `1` (i.e. the top item).

- 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`
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 3ca9eaf

Please sign in to comment.