-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
New opcode: REVERT ("cheap throw") #140
Comments
@nmushegian the reason we haven't pushed ewasm/design#43 to an EIP yet is because it involves a lot more than just including a new opcode. |
What specifically? I understand that proposal has additional functionality, but I don't understand why just this request is a lot more than adding a new opcode for a simple version of "deliberate invalid jump". I edited OP to clarify that getting return data out (ie doing anything but invoking the existing exception mechanism) is a nice-to-have, likely out of scope for evm 1.x |
I'd support this; I also don't see why we can't just reuse the existing call return data mechanism for exception return data. It's only a 2 line of code change once the opcode exists (at least in pyethereum). |
@nmushegian: I'm getting a bit confused. Are you proposing an opcode which stops execution, returns a reason, doesn't revert state and doesn't drain gas? Or something that behaves like the current exceptions and reverts state? |
Not return a reason, since that would require much more significant VM changes. Simply revert state (and put a 0 instead of a 1 on the caller's stack) like the current exception mechanism, but don't drain all the gas. |
@nmushegian thanks! Can you please update the original description with this? I would propose the name |
Done, REVERT is better |
+1 - love this idea |
I didn't realize the standard exception mechanism doesn't roll back suicides! This is very not intuitive! https://www.reddit.com/r/ethereum/comments/5hiy29/solidity_throw_after_selfdestruct_why_does_the/ Maybe REVERT could use the behavior we expect? edit: Turns out that was just an error in just one of the implementations |
If we assume That way complex error reporting could be implemented. Additionally, if |
I agree with @axic in that this is a good time to integrate error reporting. I initially thought this could be done informally by simply leaving values on the stack at throw, but this only allows debugger inspection of error codes, and also makes propagating errors difficult. If revert allows return data, we can properly report error codes to callers. |
Created an actual draft out of this, see #206. |
Fulu named as next consensus layer upgrade and Fusaka (Fulu + Osaka) for combined upgrade at ACDC ethereum#140. https://ethereum-magicians.org/t/all-core-devs-consensus-acdc-140-august-22-2024/20768
I tried to find an existing EIP for this and couldn't. This surprises me! Please help find existing discussion.
Abstract
Right now rolling back state requires manually triggering an EVM exception (eg invalid jump), which drains all gas for the subcall. I prefer throw-oriented error handling despite all the drawbacks (no error details, drains gas) because reverting all state when something unexpected happens feels much safer.
The REVERT opcode would let you throw an exception without draining all the gas that the caller allocated to you.
Related issues:
#62
ewasm/design#43
Details
Extra things to consider
The text was updated successfully, but these errors were encountered: