Skip to content

0% coverage when using hardhat-foundry & foundry.toml is present #853

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

Closed
jd1900 opened this issue Feb 7, 2024 · 15 comments
Closed

0% coverage when using hardhat-foundry & foundry.toml is present #853

jd1900 opened this issue Feb 7, 2024 · 15 comments

Comments

@jd1900
Copy link

jd1900 commented Feb 7, 2024

After checking the new FAQ options on https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#running-out-of-stack I'm still having the same issue.
With Work-arounds #1 and #2 it compiles, but only the interfaces are covered. The rest at 0%.
With Work-around #3 I'm getting this error:

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

[
  {
    version: '0.8.24',
    settings: {
      evmVersion: 'shanghai',
      optimizer: [Object],
      viaIR: true,
      outputSelection: [Object]
    }
  }
]
YulException: Cannot swap Variable var_data_8820_length with Variable var_dataIndex: too deep in the stack by 3 slots in [ var_data_8820_length expr_11 expr_10 var_data_offset expr var_data_8820_length var_valueIndex var_myVar1_length var_myVar1_offset zero_uint256 var_i RET var_myVar2_length var_myVar2_offset var_j var_currentValue expr_10 var_data_offset _8 var_dataIndex ]
No memoryguard was present. Consider using memory-safe assembly only and annotating it via 'assembly ("memory-safe") { ... }'.


Error in plugin solidity-coverage: HardhatError: HH600: Compilation failed

@cgewecke
Copy link
Member

cgewecke commented Feb 7, 2024

@jd1900 Am actively working on a patch that will let you use viaIR without any special config. If it works (fingers crossed) will ping this issue shortly (within next 2 days) to ask you to trial a beta of it.

@cgewecke cgewecke added the viaIR label Feb 7, 2024
@jd1900
Copy link
Author

jd1900 commented Feb 8, 2024

@jd1900 Am actively working on a patch that will let you use viaIR without any special config. If it works (fingers crossed) will ping this issue shortly (within next 2 days) to ask you to trial a beta of it.

Thank you @cgewecke !

@cgewecke
Copy link
Member

cgewecke commented Feb 9, 2024

@jd1900 The patch is published at the viaIR tag.

npm install --save-dev solidity-coverage@viaIR

You should remove all the .solcover.js compiler config stuff from the workarounds and just have viaIR: true in your hardhat.config.ts compiler settings. LMK if it works, or doesn't, thanks for trying it out.

@jd1900
Copy link
Author

jd1900 commented Feb 9, 2024

I've just tried it. It doesn't crash or complains about the stack too deep.
Unfortunately I got the same result, interfaces 100 and non interface contracts 0.

@cgewecke
Copy link
Member

cgewecke commented Feb 9, 2024

@jd1900 I ran it against 1inch's solidity-utilities locally and it worked.

Could you try running npx hardhat clean to double-check that's not the problem?

Also ... to make sure you've installed the correct version, you can check the version info at the top of your coverage run:

Screen Shot 2024-02-09 at 8 16 16 AM

Am happy to debug this if you can provide a public repo link or invite me to private repo.

@jd1900
Copy link
Author

jd1900 commented Feb 9, 2024

Unfortunately, same thing:
image

image image

@cgewecke
Copy link
Member

cgewecke commented Feb 9, 2024

@jd1900 I've just opened a PR showing how I installed and ran on a fork of 1inch/solidity-utils here:

cgewecke/solidity-utils#1

It's passing and its coverage is identical to their master branch using 0.8.6. Could you compare what you are doing locally to this repo and find the relevant difference?

@jd1900
Copy link
Author

jd1900 commented Feb 9, 2024

@jd1900 I've just opened a PR showing how I installed and ran on a fork of 1inch/solidity-utils here:

cgewecke/solidity-utils#1

It's passing and its coverage is identical to their master branch using 0.8.6. Could you compare what you are doing locally to this repo and find the relevant difference?

That's what I did, the instructions you gave. But it just doesn't work, as shown above.

@cgewecke
Copy link
Member

cgewecke commented Feb 9, 2024

@jd1900 Why is it working in solidity-utils and not in your project?

Could you compare what you are doing locally to this repo and find the relevant difference?

@cgewecke
Copy link
Member

Closing via #854 because just published 0.8.7. If you can provide me with a reproduction case very happy to look into it though.

@cgewecke
Copy link
Member

@jd1900 Let's continue this discussion in this issue ... I don't want the other thread to become a chat for people who are unfamiliar with how github / providing reproduction cases work - sorry. Am going to delete that conversation so other people can quickly report what they see.

You need to provide a simple of WAY OF REPRODUCING THE PROBLEM. A working repository with clear steps to reproduce the bug you're reporting. Otherwise it's impossible to debug.

@cgewecke cgewecke reopened this Feb 10, 2024
@jd1900
Copy link
Author

jd1900 commented Feb 14, 2024

I've finally found the issue @cgewecke . When using foundry plugin and a "foundry.toml" exists, it leaves all as uncovered except for the interfaces.
https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-foundry

After removing this, it worked.

@cgewecke
Copy link
Member

@jd1900 Oh!! Very interesting, thanks so much for debugging this. (Am going to edit your issue title to reflect this discovery)

@cgewecke cgewecke changed the title Running out of stack v.0.8.6 0% coverage when using hardhat-foundry & foundry.toml is present Feb 14, 2024
@cgewecke
Copy link
Member

This has been patched via #866 and should be fixed in v0.8.8.

@jd1900
Copy link
Author

jd1900 commented Feb 22, 2024

Great, I can confirm it's working now on my end.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants