You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running forge coverage with the --via-ir flag, the compilation fails with a "stack too deep" error. Trying the --ir-minimum flag as a workaround, as suggested in the documentation, results in additional errors related to unsupported VM versions and instructions, even when using the latest Solidity compiler.
[profile.default]
src = "src"out = "out"libs = ["lib"]
remappings = [
"@account-abstraction/=lib/account-abstraction/contracts",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts",
"@foundry-era-contracts/=lib/foundry-era-contracts/src/system-contracts/contracts",
]
# i've tried comment and uncomment to rely solely on the --via-ir CLI command. The error persists in both scenarios.# via-ir = true# optimizer = true# optimizer_runs = 2000
Run forge coverage --via-ir.
Observe the following error:
Error: Compiler run failed:
Error: Compiler error (/solidity/libyul/backends/evm/AsmCodeGen.cpp:63):
CompilerError: Stack too deep. Try compiling with `--via-ir` (cli) or the equivalent
`viaIR: true` (standard JSON) while enabling the optimizer. Otherwise, try removing local variables.
Run forge coverage --ir-minimum as a workaround.
Observe the following errors:
Warning (3420): Source file does not specify required compiler version! Consider adding "pragma solidity ^0.8.28;"
--> test/zkSync/ZkMinimalAccount.t.sol
Error (5921): "basefee" is not supported by the VM version.
--> lib/account-abstraction/contracts/core/UserOperationLib.sol:46:61:
|
46 |return min(maxFeePerGas, maxPriorityFeePerGas + block.basefee);| ^^^^^^^^^^^^^
Error (5921): "basefee" is not supported by the VM version.
--> lib/account-abstraction/contracts/core/EntryPoint.sol:664:61:
|
664 |return min(maxFeePerGas, maxPriorityFeePerGas + block.basefee);| ^^^^^^^^^^^^^
Error (7755): The "mcopy" instruction is only available for Cancun-compatible VMs (you are currently compiling for"istanbul").
--> lib/openzeppelin-contracts/contracts/utils/Bytes.sol:96:13:
|
96 | mcopy(add(result, 0x20), add(buffer, add(start, 0x20)), sub(end, start))
| ^^^^^
Test with forge test --via-ir to confirm that it works without issues.
As for forge coverage --via-ir, see my response in the other issue: #13972 (comment). Tl;dr is that this is not a simple bug we can fix right now. Our current Yul->EVM transform is just still not good enough to overcome the inherent EVM limitation of having only 16 slots available at a time. Which is being worked on but may also eventually become irrelevant due to EOF.
As such, I'd be inclined to close this, because there's nothing we can do specifically for forge coverage and there are already many reports of such StackToDeep cases.
Trying the --ir-minimum flag as a workaround, as suggested in the documentation, results in additional errors related to unsupported VM versions and instructions, even when using the latest Solidity compiler.
This could be a problem with project configuration or a bug in forge. These errors are the expected result when you're compiling Cancun code and request code generation for a pre-Cancun EVM. The question is why an older EVM is being selected - but that does not look like a problem with solc itself.
--via-ir in forge coverage is a noop, and it now issues a warning. The errors you encounter with --ir-minimum are due to unspecified solc version in your config, fixed in foundry-rs/foundry#9768.
Description
When running
forge coverage
with the--via-ir
flag, the compilation fails with a "stack too deep" error. Trying the--ir-minimum
flag as a workaround, as suggested in the documentation, results in additional errors related to unsupported VM versions and instructions, even when using the latest Solidity compiler.Environment
0.8.28
IR
default
Foundry
default
Fedora
Steps to Reproduce
Add the following configuration to
foundry.toml
:Run
forge coverage --via-ir
.Observe the following error:
Run
forge coverage --ir-minimum
as a workaround.Observe the following errors:
forge test --via-ir
to confirm that it works without issues.The text was updated successfully, but these errors were encountered: