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: Support for ERC 1066 aka FISSION codes aka "Revert with Reason" #1345

Open
fubuloubu opened this Issue Mar 11, 2019 · 7 comments

Comments

Projects
None yet
4 participants
@fubuloubu
Copy link
Member

fubuloubu commented Mar 11, 2019

Simple Summary

Fission Codes follow an HTTP Status Code-like syntax to allow smart contracts to describe exceptional conditions to other smart contracts and wider tooling in a machine- and human-readable format, that is easily localized to different spoken languages for better UX.

Abstract

See https://fission.codes/fission-codes/motivation/

Motivation

This will allow us to enable functionality for broader support of better UX and DX flows for smart contracts and dapps developed via the Vyper compiler.

Specification

This proposal would add a new type reason (derived from bytes[1]) which would be a valid return type for any function, and an event Reason(_code: reason) which could only be used in the following context (pending support of #1342):

@public
@constant
def check_authorization_status() -> reasonCode:
    if self.isAuthorized[msg.sender]:
        return 0x11
        # OR
        return Reason(permission.ALLOWED)  # in this case, just a byte
    return 0x10
    # OR
    return Reason(permission.DISALLOWED)  # in this case, just a byte

@public
def make_changes(_delegate: address):
    if not self.isAuthorized[msg.sender]:
        # reverts and emits `Reason` event
        raise 0x10
        # OR
        raise Reason(permission.DISALLOWED)
    self.isAuthorized[_delegate] = True

It would be nice if we could think about enum support for this

Backwards Compatibility

This would change the current semantics of "revert with reason string" to allow a Fission Code to be used in it's stead.

Dependencies

Relevant to #1342, not dependant

Copyright

Copyright and related rights waived via CC0

@fubuloubu

This comment has been minimized.

Copy link
Member Author

fubuloubu commented Mar 11, 2019

cc @bmann @expede

Hit me with your best shot!

@charles-cooper

This comment has been minimized.

@charles-cooper

This comment has been minimized.

Copy link
Contributor

charles-cooper commented Mar 11, 2019

As an alternative to EIP1444, we could add the human readable strings to the ABI.

@jacqueswww

This comment has been minimized.

Copy link
Contributor

jacqueswww commented Mar 11, 2019

I like this, gets my 👍

@jacqueswww

This comment has been minimized.

Copy link
Contributor

jacqueswww commented Mar 11, 2019

@fubuloubu I think we can perhaps have a dependent VIP that make the vyper clamps emit 0x26 Above Range or Overflow ?

On the implementation side one could have static scratch pad that would work as a lookup table, that grows as one uses Reason, the compiler would grow it larger than 32bytes if needed - but in most cases it will only be one 32byte word.
Mostly because REVERT uses memory and we can't just push the constant byte on the stack.

@fubuloubu

This comment has been minimized.

Copy link
Member Author

fubuloubu commented Mar 11, 2019

I think we can perhaps have a dependent VIP that make the vyper clamps emit 0x26 Above Range or Overflow?

I like this suggestion! Good way to first integrate it and play around with it

@bmann

This comment has been minimized.

Copy link

bmann commented Mar 13, 2019

Heya! Thanks @fubuloubu -- totally interested to follow this. @expede is traveling and can jump in to participate soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.