-
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
Strange block.timestamp / warp interactions with via-ir #3806
Comments
oh also note that setting via_ir = false fixes the issue. Removing the warp also fixes the issue |
seems compiler is seeing my block.timestamp + 100 pre-warp and autoresolving my block.timestamp + 100 post-warp to the same value |
Can close i suppose but this is super strange behavior :( |
Any way we could remove whatever optimizerStep that does this clobbering for test/ contracts? |
@marktoda did you find any workaround, after all? I just enabled Did you, by chance, override the |
Hey @PaulRBerg ! Honestly my solution was just to redesign the test suite to get around this issue. In our case, changing some constants around to re-evaluate block.timestamp in different expressions allowed the value to change properly, i.e.
I did tinker around with optimizerSteps, but couldn't isolate the correct step easily and gave up to do the hacky way out :D |
Thanks for the tips, @marktoda. I will probably end up doing the same, i.e. introduce a few new constants to go around this whacky behavior of |
…imizing out vm.roll See: foundry-rs/foundry#3806 and linked
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (f6361e6 2022-12-01T15:11:38.140433224Z)
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
Block.timestamp and warp seem to have very strange behavior under via-ir. Minimal repro:
foundry.toml:
Expected output:
Actual output:
Super strange - I have no idea why the addition would not apply to block.timestamp
Another repro showing that stack variables get clobbered
Expected output:
Actual output:
The text was updated successfully, but these errors were encountered: