scribble icon indicating copy to clipboard operation
scribble copied to clipboard

Invariant can cause infinite recursion stack overflow

Open NeverFearTomorrow opened this issue 2 years ago • 3 comments

If an invariant calls a function that makes an external call, then the invariant winds up triggering itself, which leads to infinite recursion. This could be considered user error, but it's very hard to detect the source of the problem, because stack overflow leads to an unhelpful error message on revert. I think it would be good if scribble would explicitly detect and disallow the use of a function that makes external calls in an invariant. Or maybe there's some other way to warn the user against doing this, or preventing this from happening. The user may not realize right away that a simple view function is technically crossing a contract boundary when they use that function to acquire some basic info for use in their invariant, so anything to help ward the user off of this is helpful.

NeverFearTomorrow avatar Nov 07 '22 18:11 NeverFearTomorrow