-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Foundry crashes with arithmetic operation overflow
#3596
Comments
arithmetic operation overflow
after forge-std dependency update
I think this is a U256 overflow, @mds1 were there any changes re balance or similar? |
@benesjan I believe it's the deal cheatcode that overflows here https://github.com/AztecProtocol/aztec-connect-bridges/blob/f8ef3f8dc5a3c21046d20fa235de6271586cb1a1/src/test/bridges/erc4626/ERC4626.t.sol#L108 or rather somewhere in that test |
There's no changes in forge-std that I can think of that would cause. Though it seems to me like this is a forge error, not a forge-std error. From lines 87-89 of the linked CI job:
If this was a solidity/EVM overflow it wouldn't panic |
nvm it's somewhere else I'm almost certain this is the call that's causing this couldn't find the actual implementation of this, could you please provide the link to the function impl? |
arithmetic operation overflow
after forge-std dependency updatearithmetic operation overflow
after forge-std dependency update
maybe related to the uint96 value fuzzing |
@benesjan have you narrowed down the cause of this, i.e. are you sure it's the forge-std update as mentioned in the original description vs. a certain forge release that introduced this? |
I've narrowed this down to these lines at least if I comment out the entire
|
@mds1 it's not caused by the update but it seems the update makes it more frequent. I think that the tests are simply failing with the overflow error and for some reason it causes forge to crash. Sometimes forge doesn't crash and I see that the tests fail with the overflow error. I tried compiling an older forge version (from October 17) and the issue occurs there as well. |
the randomness of this is likely related to the fuzz test function's inputs. Me guess at this point is, that the state changes inside the prank are picked up by the fuzzer (which looks at state) and perhaps the uint96 strategy has a problem with those values. |
arithmetic operation overflow
after forge-std dependency updatearithmetic operation overflow
when overflow occurs within contract code execution
Hello, this bug is still occurring. I have a new example. I introduced a bug in test in this commit which caused overflow in the tested smart contract. This overflow caused |
is it still the same test? |
No, it's a different test. Previously it was an ERC4626 bridge test and now it is a TroveBridge test. They are unrelated and don't share basically any code. |
sorry, I meant test function |
It's a different test function. I run locally the following command and it fails: It is on this PR's branch. Thanks |
thanks, no fuzz test this time, makes it easier to debug, will have a closer look. |
@mattsse Thanks a ton! This was haunting us for a while |
pushed two related fixes today, If you could narrow this down to the failing test, I'd be happy to give it another try. |
Hello @mattsse, while trying to reproduce the bug I've stumbled upon another one: After dealing 5 ETH to an address owner's balance suddenly drops to 1 wei. This is how you should be able to reproduce it: Checkout the I just executed foundryup so I am using the newest version. |
arithmetic operation overflow
when overflow occurs within contract code executionarithmetic operation overflow
yes please, ty! |
@sprw121 does your code make use of |
No cheat code. Yes I can try to put up a repro repo. Let me know if you want me to delete / clean up the comments in this thread. |
Hello @mattsse, our CI is now passing without any crashes so you can probably close this issue. Thank you for fixing this 👍 |
Hi @mattsse — wanted to share that I'm unfortunately running into a similar issue. As far as I can tell, if a test combines the following, it leads to intermittent crashing of foundry:
When I get a chance, I will try to create a small repro example! |
@benesjan, I'm curious if you had to do anything specific to resolve the issue in your code? |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (70f4fb5 2022-11-02T00:05:06.592613Z)
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
Hello, after updating
forge-std
dependency foundry started crashing witharithmetic operation overflow
error. The issue is occuring locally on my M1 Macbook as well as in a linux docker container in CI. Here is the code and here is the log of a failing CI pipeline.Update
The bug is not related to
forge-std
(theforge-std
update simply made it occur more frequently). The bug is caused by overflow in smart contract execution.The text was updated successfully, but these errors were encountered: