-
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
bug(forge coverage
): stack too deep when using --ir-minimum
#3357
Comments
AFAIK Unfortunately for now to use coverage you'll need to refactor such that you can compile with the optimizer off / without via-IR |
Understood, thanks! Is this issue thus nullified? Would it be possible to have more information on where the Stack Too Deep error occurs in the source code pls? |
I think this is a question for @uranium93? But yes I'd say this is a known issue/limitation so we can close this
Unfortunately not, as solc does not provide this information since it's complex to retrieve. You can read more here: ethereum/solidity#11638 (comment) |
Thank you! |
I understand the reasoning for compiling without the optimizer – but I will note that this means currently any project that imports Seaport contracts directly cannot use forge coverage, as some assembly results in stack-too-deep errors. There's probably not much to do at the moment – but we'd love if we could encourage new projects to build on top of Seaport with Foundry (including coverage) in the future. |
Hey @Rubilmax , for me the only fix that was possible and fast is to re-write the affected tests with hardhat |
@uranium93 structs are a neat way to solve Stack Too Deep. |
Hi Matt, is this issue still unresolved? I would be happy to work on it. |
This is still the case, however this is not easy to resolve in forge due to the current coverage limitations (which themselves are due to solc limitations). The easiest solution is to update your code to avoid stack too deep issues |
Sorry, this is not a well-informed idea (I do not really know foundry internals tbh) but maybe a quick fix for this issue could be to add an optional flag to raise stack limit only when computing coverage? |
@PaulRBerg @mds1 The issue is not about For everyone, the fix I applied was to combine both foundry and hardhat (use hardhat instead of foundry for whatever tests causing coverage to fail with this error), a bit more work but it works if you need to report the code coverage |
I managed to reliably reproduce by running The issue in the solidity compiler is being tracked here ethereum/solidity#11638 |
Looks like there will be a remedy when solidity 0.8.21 comes out: ethereum/solidity#13972 |
For future readers: This workaround is better than |
In my case
The solution that @aviggiano linked is for some specific blockchain as far as I can tell? Could be wrong. Overall, I think we should reopen the issue as it's not solved yet. |
hi, @mattsse @spockP
|
Hey! Same issue for me. I think the issue should be re-opened,
|
|
vouching for reopening this issue |
This should definitely be reopened as its not really brought into light anywhere in the docs, don't need to resolve it. Just something for developers to have a heads up about before going with foundry for coverage. |
Would this be resolved if there was a version of Solidity and/or EVM (that the tests run on) which does not have the stack access limitation? Is that possible? |
I am also facing this issue. I have a big account abstraction foundry project . 1.) running forge coverage gives me this error Error: 2.) running forge coverage --ir-minimum gives me this error forge coverage --ir-minimum Analysing contracts... library AxirStorage { This is a bug. Consider reporting it at https://github.com/foundry-rs/foundry ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering. |
forge coverage
): stack too deep when using --ir-minimum
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (ddaf100 2022-09-24T00:05:44.382307Z)
What command(s) is the bug in?
forge coverage
Operating System
macOS (Apple Silicon)
Describe the bug
on executing
forge coverage
i am getting the below errorbut
forge test
andforge build
are working fine.NOTE: I noticed also that
forge build
andforge test
are considering the cache butforge coverage
is trying to re-compile even though I have a cached successful buildThe text was updated successfully, but these errors were encountered: