Skip to content
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

VIP: Use REVERT opcode for assert statement #478

Closed
jacqueswww opened this issue Nov 17, 2017 · 2 comments
Closed

VIP: Use REVERT opcode for assert statement #478

jacqueswww opened this issue Nov 17, 2017 · 2 comments
Labels
VIP: Approved VIP Approved

Comments

@jacqueswww
Copy link
Contributor

jacqueswww commented Nov 17, 2017

This is the suggested template for new VIPs.

Preamble

VIP: 478
Title:  REVERT for assert
Author: Jacques Wagener
Type: Standard Track
Status: Draft
Created: 2017-11-17

Simple Summary

The assert statement should be converted to use REVERT opcode.

Abstract

Suggests changing the assert statement to using REVERT opcode underlying, allowing gas to be remaining gas be returned.

Motivation

Most scenarios one would prefer remaing gas to be sent back, and not completely absorbed. Currently the assert statement in Viper produces a an invalid jump, draining all gas.

Specification

Syntax wise assert statys exactly the same:

def test(x: num) -> bool:                                                                                                                                           
    assert x > 0                                                                                                                                                    
    return True 

Backwards Compatibility

Previous Dapps or contracts that assumed gas will completely spent after a failed assert, will now receive gas back. It doesn't effect compatibility much, as viper isn't used in production yet.

References

ethereum/EIPs#140

Copyright

Copyright and related rights waived via CC0

@jacqueswww
Copy link
Contributor Author

jacqueswww commented Nov 17, 2017

Whether a secondary keyword for 0xfd (INVALID) asserts are necessary, should be discussed - however I much prefer only having assert, having multiple require/assert/require keywords tends to just be confusing. And I don't really see the need for a throw/assert keyword that drains all gas ?

@fubuloubu
Copy link
Member

fubuloubu commented Nov 17, 2017

Yeah, I agree. I don't think there is a need to use the opcode that drains all gas. Perhaps this INVALID opcode might not be as useful as originally intended? Unless it is there as a means to punish abuse of the system, like in overflows, recursion issues, loop issues, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VIP: Approved VIP Approved
Projects
None yet
Development

No branches or pull requests

3 participants