-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Unreachable revert path in invariant test #7268
Comments
@nican0r there is an initial check that does not count as fuzz run where we assert the invariant in its initial state, and if it fails we exit early. So I am pretty sure the check went through OK (and printing the first sequence of logs), while first run resulted in revert, I think you could try reproducing by using sequence extracted from counterexample you posted above
|
Hi @grandizzy, thanks for the response, I should've clarified that I actually had created a unit test with the call sequence that resulted in the broken invariant to try and figure out where the revert was (that's what's in the pic of the call trace) and was unable to reproduce it. This was the main thing I was trying to highlight as I had tried this with many other call sequences that supposedly reverted and were identified by the fuzzer but none were reproducible so the corresponding unit tests provided no insight into where it might be reverting. I've pushed the unit test to this repo and you can find it in the ActorManager.t.sol contract. Running it with |
Awesome, thank you, please link the other example if you can find it. Re unit test there's also the possibility of vm.prank missing and influencing scenario (but not likely to be the issue here). Is there a way I could reproduce the problem by running an invariant test on the repo you linked above? Please provide instruction if so, would really like to debug it |
@nican0r I also see in the image you attached the vm.warp call which in invariant test was not preserved between calls until #7219 This will be the default soon but until then there's a new setting |
Awesome, the |
No worries, it will be the default behaviour soon 👍 |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (551bcb5 2024-02-28T07:40:04.170939000Z)
What command(s) is the bug in?
forge test
Operating System
macOS (Intel)
Describe the bug
When running a invariant test with
fail_on_revert = true
I get a call sequence which causes an arithmetic error:Looking at the second call trace with -vvv where the revert is supposed to be, there is no error:
I've added logging statements to the called
borrow
function that log different points in the function execution, including when the function call is complete and from the logs can see that both calls made by the fuzzer reach the end of their execution:It seems like the revert is due to an extra function call made by the fuzzer that isn't included in the call sequence which makes it impossible to reproduce with a unit test.
To rule out the possibility of a revert in the invariant I used the following invariant definition:
The text was updated successfully, but these errors were encountered: