Skip to content

Commit

Permalink
Automatically merged updates to draft EIP(s) 663 (#2038)
Browse files Browse the repository at this point in the history
Hi, I'm a bot! This change was automatically merged because:

 - It only modifies existing Draft or Last Call EIP(s)
 - The PR was approved or written by at least one author of each modified EIP
 - The build is passing
  • Loading branch information
axic authored and eip-automerger committed May 17, 2019
1 parent 90d9ce6 commit 0ec6181
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion EIPS/eip-663.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ created: 2017-07-03

## Abstract

`SWAP` and `DUP` instructions are limited to a stack depth of 16. Introduce two new instructions, `SWAPn` and `DUPn`, which lift this limitation and allow accessing the stack up to its full depth of 1024 items.
Currently, `SWAP` and `DUP` instructions are limited to a stack depth of 16. Introduce two new instructions, `SWAPn` and `DUPn`, which lift this limitation and allow accessing the stack up to its full depth of 1024 items.

## Motivation

Expand All @@ -22,9 +22,12 @@ Introducing `SWAPn` and `DUPn` will provide an option to compilers to simplify a

## Specification

### Option A

Instructions `DUPn` (`0xb0`) and `SWAPn` (`0xb1`) are introduced, which take the top item from stack (referred to as `n`).

If `n` exceeds 1024 or 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.

Otherwise
- for `DUPn` the stack item at depth `n` is duplicated at the top of the stack
Expand All @@ -34,6 +37,20 @@ The gas cost for both instructions is set at 3. In reality the cost for such an

Since both of these instructions require the top stack item to contain the position, it is still only possible to reach more than 16 stack items if there is at least one free stack slot.

This option has no effect no static analyzers, given no immediate value is introduced.

### Option B

The difference to Option A is that `DUPn` and `SWAPn` do not take the value of `n` from the top stack item, but instead encode it as a 16-bit big endian immediate value following the opcode.

This results in wasting a byte in the cases of only referring to the top 255 stack items.

### Option C

This option extends Option A with two new instructions, `DUPSn` and `SWAPSn`, where the value of `n` is encoded as an 8-bit immediate value following the opcode.

The value `n` has a range of 0 to 255, but otherwise the same rules apply as in Option A.

## Rationale

TBA
Expand Down

0 comments on commit 0ec6181

Please sign in to comment.