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

Annotation for specifying reverts #104

Open
suhabe opened this issue Oct 17, 2019 · 1 comment
Open

Annotation for specifying reverts #104

suhabe opened this issue Oct 17, 2019 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@suhabe
Copy link

suhabe commented Oct 17, 2019

How can I write solc-verify annotations for the following function to specify that the function reverts when a>=10?

contract test {
    function add(uint256 a) public pure returns (uint256) {
        require(a < 10);
    }
}
@suhabe suhabe changed the title Specify that a transaction reverts Annotation for specifying reverts Oct 17, 2019
@dddejan dddejan added enhancement New feature or request question Further information is requested labels Oct 17, 2019
@dddejan
Copy link
Member

dddejan commented Oct 17, 2019

This is an interesting question/featue.

First to clarify what's going on. The current approach we take is verification modulo successfully completed transactions. So, e.g, for a function postcondition, we try to prove that for any inputs where the function terminates "as expected", the postcondition holds. Simplifying a bit, we treat "as expected" to be "no assertion failures". Reverts are treated as expected failures used for things like specifying inputs requirements. This means we use assume to model require in our logic.

In your example the require statement in essence is the specification that the function reverts when a >= 10. But, since it is in code, it doesn't really look like a spec and it cannot be used to reason modularly at call sites of the function. Also require can be written anywhere in code.

For internal functions, one can specify a function precondition that guarantees "as expected" termination (see example), but this is not exactly what's needed.

To be able to specify and reason about revert/assert failures we would need to model them with more operational detail. So yes, needs work and is probably a useful feature. We will need this eventually to be able to handle try/catch that will show in 0.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants