Preamble
VIP: <to be assigned>
Title: assertions that should never-ever fail
Author: Yoichi Hirai <yoichi@ethereum.org>
Type: Standard Track
Status: Draft
Created: 2018-03-21
Simple Summary
Add a special type of assertion that should never ever fail. When a static analyzer can fire it, the program surely has a bug.
Abstract
Static analyzers can detect bugs, but only when the desired properties are specified. The easiest way is to insert a "never-to-fail" assertions in the program.
Motivation
Mythril has a feature to detect when 0xfe is somehow reachable. KEVM can soon do that.
assert in vyper is expected to fail sometimes, and it is compiled to REVERT. REVERT might indicate a mistake of the caller, a mistake of the programmer, or a mistake of the compiler. So, static analyzers cannot shout "this is a bug".
Instead, if Vyper has a never-to-fail assertion that translates to INVALID (0xfe), static analyzers can confidently shout "this is a bug. See, this execution reaches INVALID".
Alternatives are specially formatted comments like ACSL or JML, but they are hard to learn.
Specification
Add a additional custom constant to the assert statement:
assert amount != 0, UNREACHABLE
as well as
Backwards Compatibility
A program containing a name assure will cause compillation errors.
Copyright
Copyright and related rights waived via CC0
Preamble
Simple Summary
Add a special type of assertion that should never ever fail. When a static analyzer can fire it, the program surely has a bug.
Abstract
Static analyzers can detect bugs, but only when the desired properties are specified. The easiest way is to insert a "never-to-fail" assertions in the program.
Motivation
Mythril has a feature to detect when 0xfe is somehow reachable. KEVM can soon do that.
assertin vyper is expected to fail sometimes, and it is compiled toREVERT.REVERTmight indicate a mistake of the caller, a mistake of the programmer, or a mistake of the compiler. So, static analyzers cannot shout "this is a bug".Instead, if Vyper has a never-to-fail assertion that translates to
INVALID (0xfe), static analyzers can confidently shout "this is a bug. See, this execution reachesINVALID".Alternatives are specially formatted comments like ACSL or JML, but they are hard to learn.
Specification
Add a additional custom constant to the
assertstatement:as well as
Backwards Compatibility
A program containing a name
assurewill cause compillation errors.Copyright
Copyright and related rights waived via CC0