-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix(coverage): add new option "--ir-minimum" to resolve the "stack too deep" error #5349
fix(coverage): add new option "--ir-minimum" to resolve the "stack too deep" error #5349
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this—but we might want to add a CLI warning that adding this flag overrides several configuration options and should probably only be used as a workaround for stack too deep, and link to the relevant issue.
wdyt @mattsse ?
should be unblocked now |
p_println!(!self.opts.silent => "{}", | ||
Paint::yellow( | ||
concat!( | ||
"Warning! \"--ir-minimum\" flag enables viaIR with minimum optimization, which can result in inaccurate source mappings.\n", | ||
"Only use this flag as a workaround if you are experiencing \"stack too deep\" errors.\n", | ||
"Note that \"viaIR\" is only available in Solidity 0.8.13 and above.\n", | ||
"See more:\n", | ||
"https://github.com/foundry-rs/foundry/issues/3357\n" | ||
))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Evalir CLI warning added
// TODO: How to detect solc version if the user does not specify a solc version in | ||
// config case1: specify local installed solc ? | ||
// case2: mutliple solc versions used and auto_detect_solc == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vir-ir
and ir-minimum
will only work in solidity 0.8.13 and above.
I don't find a better way to reject the unsatisfied compilers.
74de551
to
ce860a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good now! thanks!
if let Some(SolcReq::Version(version)) = &config.solc { | ||
if *version < Version::new(0, 8, 13) { | ||
return Err(eyre::eyre!( | ||
"viaIR with minimum optimization is only available in Solidity 0.8.13 and above." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tysm for this
// TODO: How to detect solc version if the user does not specify a solc version in | ||
// config case1: specify local installed solc ? | ||
// case2: mutliple solc versions used and auto_detect_solc == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can ignore this this,
all options are sanitized in ethers-solc depending on version, meaning unsupported options are removed before calling solc
Hey guys! I have I seem to have found a bug with Any ideas on what to do here to get coverage to show 100%? I have posted a bug report issue for this here FYI: #6156 |
Motivation
Partially fix #3357.
More and more people (including myself) are using the magical
via-ir
to solve the "stack too deep" issue. However, this would cause problems in test coverage as all the optimizations are disabled in test coverage.The solidity team suggests working around this issue by enabling "via-ir" with a "minimum amount of optimization."
And this workaround is also recommended in the FAQ of solcoverage.
Solution
In this pr, a new "--ir-minimum" option is added to the coverage subcommand, which enables "via-ir" with a minimum amount of optimization.
test case
The contract
Deep
indeep.sol
will not compile without any optimizations due to the "stack too deep" error:And the test script is as follows:
When you run test coverage without "--ir-minimum", you will see the "stack too deep" error:
When you run test coverage with "--ir-minimum", the "stack too deep" error is gone: