Vyper: VIP: Support for ERC 1066 aka FISSION codes aka "Revert with Reason"

Created on 11 Mar 2019  路  7Comments  路  Source: vyperlang/vyper

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://docs.fission.codes/fission-codes/

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() -> Reason:
    if self.isAuthorized[msg.sender]:
        return Reason(permission.ALLOWED)  # in this case, just a byte (0x11)
    return Reason(permission.DISALLOWED)  # in this case, just a byte (0x10)

@public
def make_changes(_delegate: address):
    if not self.isAuthorized[msg.sender]:
        # reverts and emits `Reason` event
        raise Reason(permission.DISALLOWED)  # Reason 0x10
    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

Approved

All 7 comments

cc @bmann @expede

Hit me with your best shot!

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

I like this, gets my :+1:

@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.

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nrryuya picture nrryuya  路  3Comments

denis-bogdanas picture denis-bogdanas  路  3Comments

lsaether picture lsaether  路  4Comments

haydenadams picture haydenadams  路  3Comments

robinsierra picture robinsierra  路  3Comments