-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
vm.snapshot / vm.revertTo non deterministic #5118
Comments
Yup this looks quite weird, will prio taking a look at this tomorrow, it should've been fixed already. |
resolves an issue with foundry-rs/foundry#5118
resolves an issue with foundry-rs/foundry#5118
Hello, So what we roughly do is:
To mitigate we noticed that when creating another snapshot within |
Thanks @sakulstra — I'll take a look soon |
Hey @sakulstra — so i took a bit of a dive into this, and this is actually expected behavior:
The trick is essentially to "regen" the snapshot after being used (e.g on a loop on the OG post). You can't revert to a snapshot more than once. |
@Evalir oh wow. Somehow didn't stumble over this. Do you think that's desired behavior, though? |
Hmm yeah, I think maybe we could have something like a "persistent" snapshot which is not deleted after usage, or some flag on the wdyt @mds1 and @mattsse ? I haven't dug deep enough to see technical limitations in implementing this, but I doubt there'd be any. I'm just leaning towards a new cheatcode to maintain parity with hardhat/ganache's behavior with the standard one. |
Does anyone rely on the existing behavior? I can't imagine so, and making snapshots persistent so you can always revert to them doesn't feel like a breaking change, and it also feels strictly better to make them persistent. Though I don't know what the motivation for making them one-time-use was (e.g. technical, footgun, etc). Might be some info in the PRs that implemented the feature |
Yeah AFAIK now the current behavior is to mimic hardhat/ganache's behavior, but I'm happy to make that change as IMHO snapshots being persistent is better, albeit the departure from the previous behavior is notable and i wanna be mindful of it. |
resolves an issue with foundry-rs/foundry#5118
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (08a629a 2023-06-03T00:04:22.625130135Z)
What command(s) is the bug in?
vm.snapshot
Operating System
Linux
Describe the bug
There seems to be an issue with nested snapshots and reverts.
I don't really have an explanation of what is happening exactly.
I have a testsuite iterating over a list of assets and performing some tasks, including deposit some link on aave.
Now the interesting thing is, when i create a single snapshot in the beginning and revert to it after testing each asset at some point LINK will exceed supply cap, although i'm always depositing the same amount and reverting to the previous state.
I assume that somehow:
These
revertTo
: https://github.com/bgd-labs/aave-helpers/blob/master/src/ProtocolV3TestBase.sol#L147Seem to mess with this
revertTo
: https://github.com/bgd-labs/aave-helpers/blob/master/src/ProtocolV3TestBase.sol#L115This code fails:
This code works:
Analysing the code the behavior should be the same as it shouldn't matter if i:
So there seems to be an issue with creating snapshots / reverting to a snapshot.
As a reproduction you can run:
forge test --match-contract ProtocolV3TestE2ETestAll -vv
and change the snapshot accordingly.The text was updated successfully, but these errors were encountered: