-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unlimited SWAP and DUP instructions #663
Conversation
76b75a1
to
1a2ce5f
Compare
Alternatively to ease verification, the parameter to
|
To clarify, the "immediate value" option would mean an encoding |
Sorry haven't seen the issue #174 which proposes the same. |
I still think that if #615 is accepted this will be unnecessary. |
EIPS/draft_unlimited_swapdup.md
Outdated
|
||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a stack underflow exception is issued, what should happen to the contract execution? Would it be equivalent to REVERT
with a certain output?
Does it ever happen that the stack depth is still at the limit after popping n
?
EIPS/draft_unlimited_swapdup.md
Outdated
- for `DUPn` the stack item at depth `n` is duplicated at the top of the stack | ||
- for `SWAPn` the top stack item is swapped with the item at depth `n` | ||
|
||
The gas cost for both instructions is set at 3. In reality the cost for such an operation is 6 including the required `PUSH`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cost can be smaller than 6 per operation. In fact the cost can be very close to 3. For example,
PUSH1 0
PUSH1 0
DUPn
DUPn
DUPn
DUPn
DUPn
DUPn
DUPn
...
This is a courtesy notice to let you know that the format for EIPs has been modified slightly. If you want your draft merged, you will need to make some small changes to how your EIP is formatted:
If your PR is editing an existing EIP rather than creating a new one, this has already been done for you, and you need only rebase your PR. In addition, a continuous build has been setup, which will check your PR against the rules for EIP formatting automatically once you update your PR. This build ensures all required headers are present, as well as performing a number of other checks. Please rebase your PR against the latest master, and edit your PR to use the above format for frontmatter. For convenience, here's a sample header you can copy and adapt:
|
Updated to satisfy draft requirements. |
It seems a lot easier to do stack analysis if the would be arguments inlined in the code, rather than taken off the stack. That would also play better with #615 . |
This option was also proposed, see #663 (comment) and #663 (comment). Changed the EIP to explicitly list both options (in #2038). |
Added discussion URL: https://ethereum-magicians.org/t/eip-663-unlimited-swap-and-dup-instructions/3346 |
No description provided.