Skip to content
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-Candidate]: Running Slither with --compile-force-framework hardhat flag doesn't works while contract compiles with Hardhat #570

Open
ds-rgangavasi opened this issue Aug 6, 2024 · 5 comments

Comments

@ds-rgangavasi
Copy link

ds-rgangavasi commented Aug 6, 2024

Describe the issue:

Repo: Steadefi

  • The repository includes two framework files: Hardhat and Foundry.

  • Goal: My goal is to always compile such repositories using Hardhat and provide the artifacts to Slither, making it mandatory for slither to use Hardhat artifacts exclusively.

  • Where I need Help?: When running slither with --compile-force-framework hardhat slither runs into error, but with default Foundry (no flag provided) works flawlessly. I need to run it using HH artifacts.

  • The project compiles with hardhat: npx hardhat compile --force. | forge build also works.
    image

  • Used tool: Slither

  • command try 1: slither . --ignore-compile --filter-paths \.t\.sol$,\.s\.sol$ --compile-force-framework hardhat | fails with error: ERROR:Slither:Unable to compile all targets.

  • command try 2: slither . --filter-paths \.t\.sol$,\.s\.sol$ --compile-force-framework hardhat | fails with error: ERROR:Slither:Unable to compile all targets.

  • command try 3: slither . --filter-paths \.t\.sol$,\.s\.sol$ | works with foundry as default.
    image

  • command try 4: slither . --filter-paths \.t\.sol$,\.s\.sol$ --compile-force-framework hardhat --exclude-dependencies | fails with error: ERROR:Slither:Unable to compile all targets.
    image

  • command try 5: slither . --filter-paths \.t\.sol$,\.s\.sol$ --hardhat-artifacts-directory ./artifacts --exclude-dependencies --ignore-compile | fails with error: ERROR:Slither:Unable to compile all targets.

Code example to reproduce the issue:

Repo: Steadefi

Version:

python --version
node --version
npm --version
yarn --version
npx hardhat --version
forge --version
slither --version

Python 3.11.7
v20.15.1
10.7.0
1.22.22
2.18.2
forge 0.2.0 (fe2acca 2024-07-22T00:20:15.468269927Z)
0.10.3

Relevant log output:

ERROR:Slither:Unable to compile all targets.
@elopez
Copy link
Member

elopez commented Aug 6, 2024

Hi, thanks for the report! Can you confirm what happens if you run the following?

slither . --compile-force-framework hardhat

@ds-rgangavasi
Copy link
Author

Hi, thanks for the report! Can you confirm what happens if you run the following?

slither . --compile-force-framework hardhat

image

  • It starts compiling using hardhat
  • then while running tool, fails with error: ERROR:Slither:Unable to compile all targets.

@elopez
Copy link
Member

elopez commented Aug 6, 2024

Does crytic-compile . print any different error?

@ds-rgangavasi
Copy link
Author

crytic-compile .

  • crytic-compile . --compile-force-framework hardhat gives following error:
    ERROR:CryticCompile:Unknown file: forge-std/console.sol
    image

crytic-compile --version
0.3.3

@elopez
Copy link
Member

elopez commented Aug 6, 2024

I had a look locally, the paths generated on the Hardhat artifacts seem to be a bit odd, in particular the ones for forge-std/console.sol. You can work around the issue meanwhile by running the following from the repo root ln -s ../lib/forge-std/src node_modules/forge-std (or by using Foundry, which you noted works fine)

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