2

I got my smart contracts ready over Hardhat and once I'm running hh test all the tests are passing successfully but while running hh coverage I'm getting the below error.

Any idea why the regular tests are working but the coverage isn't?

How can this be solved?

Version
=======
> solidity-coverage: v0.7.20

Instrumenting for coverage...
=============================

> MyContract1.sol
> MyContract2.sol
> MyContract3.sol


Compilation:
============

Compiling 35 files with 0.8.6
CompilerError: Stack too deep when compiling inline assembly: Variable headStart is 1 slot(s) too deep inside the stack.


Error in plugin solidity-coverage: HardhatError: HH600: Compilation failed 
3
  • 1
    Stack too deep often appears when function is taking too may variables, or some structure has enormous amount of variables inside of it)
    – Sky
    Jun 5, 2022 at 9:05
  • Thanks you. I still think there's more to it since regular tests are working well while coverage fails
    – forhas
    Jun 6, 2022 at 10:19
  • 1
    Yeah, that is strange. You might report that issue to the team behind HardHat. (I think you can go to their GitHub to do that.)
    – Sky
    Jun 6, 2022 at 11:25

1 Answer 1

4

Add .solcover.js at the root of your project folder with the following option:

module.exports = {
  configureYulOptimizer: true
};

Take a look at these related threads:

https://github.com/ethereum/solidity/issues/11638#issuecomment-1101524130 https://github.com/sc-forks/solidity-coverage/blob/master/HARDHAT_README.md#configuration

1
  • Enabling yul in hardhat.config.js with details: {yul: true} worked for me but I have no idea what it does. Can you provide any explanations?
    – MehmedB
    Apr 11 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.