Closed ilguardianodelblocco closed 6 months ago
Please upgrade to the latest slither version and see if this improves the foundry compilation
The same issue is with me. And the issue still exsits in slither v0.10.0
and crytic-compile v0.3.5
. The content of remappings.txt
file is as follows:
hardhat/=node_modules/hardhat/
xdeployer/=node_modules/xdeployer/
forge-std/=contracts/lib/forge-std/src/
@openzeppelin/=node_modules/@openzeppelin/
ds-test/=contracts/lib/forge-std/lib/ds-test/src/
@erc6900/reference-implementation/=contracts/lib/reference-implementation/src/
@eth-infinitism/account-abstraction/=contracts/lib/account-abstraction/contracts/
when I ran slither
in root dir of my project, I got an error below:
'npx hardhat clean' running (wd: /Users/ivan/Dev/gitlab/myprojects/erc6900-plugins)
'npx hardhat clean --global' running (wd: /Users/ivan/Dev/gitlab/myprojects/erc6900-plugins)
Problem deserializing hardhat configuration, using defaults: Expecting value: line 1 column 1 (char 0)
'npx hardhat compile --force' running (wd: /Users/ivan/Dev/gitlab/myprojects/erc6900-plugins)
Traceback (most recent call last):
File "/opt/homebrew/bin/slither", line 8, in <module>
sys.exit(main())
^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/slither/__main__.py", line 727, in main
main_impl(all_detector_classes=detectors, all_printer_classes=printers)
File "/opt/homebrew/lib/python3.11/site-packages/slither/__main__.py", line 833, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/slither/__main__.py", line 96, in process_all
compilations = compile_all(target, **vars(args))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 718, in compile_all
compilations.append(CryticCompile(target, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 207, in __init__
self._compile(**kwargs)
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 629, in _compile
self._platform.compile(self, **kwargs)
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/platform/hardhat.py", line 183, in compile
hardhat_like_parsing(crytic_compile, self._target, build_directory, hardhat_working_dir)
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/platform/hardhat.py", line 97, in hardhat_like_parsing
path = convert_filename(
^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/utils/naming.py", line 169, in convert_filename
filename = _verify_filename_existence(filename, cwd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/utils/naming.py", line 119, in _verify_filename_existence
raise InvalidCompilation(f"Unknown file: {filename}")
crytic_compile.platform.exceptions.InvalidCompilation: Unknown file: @erc6900/reference-implementation/interfaces/IPlugin.sol
It seems like crytic-compile
checks only from contracts
and node_modules
, instead from remappings.txt
which redirects the path to the actually path.
Hi @TheStarBoys, you seem to be using hardhat in your case and not foundry. The compilation tool takes care of the remappings and not Slither in this case. If you intended to use foundry; do you have a foundry.toml
file in /Users/ivan/Dev/gitlab/myprojects/erc6900-plugins
?
Hi @TheStarBoys, you seem to be using hardhat in your case and not foundry. The compilation tool takes care of the remappings and not Slither in this case. If you intended to use foundry; do you have a
foundry.toml
file in/Users/ivan/Dev/gitlab/myprojects/erc6900-plugins
?
Yeah,it's a project using foundry and hardhat. It's both OK for compiling using forge build
and npx hardhat compile
individually.
crytic-compile
allows to forcibly use compile tools, either hardhat Or foundry. But It is both not working for using crytic-compile
. And there's the same issue mentioned above.
Would you be able to share the codebase? Generally if it builds but isn't working, there is something we need to debug with the underlying compilation framework e.g. it is providing a file path that does not exist.
I use the slither by python API. If the contract use a mappings, Slither will go wrong. The reason is also "file not found, Searched the following locations: "". The contract address is 0x51bdbfcd7656e2c25ad1bc8037f70572b7142ecc. In the Router.sol file,
import {Math} from "openzeppelin-math/Math.sol";
But the openzeppelin-math/Math.sol is remapped to lib/openzeppelin-contracts/contracts/utils/math/Math.sol I use etherscan API to download the contract source code, the file system is like https://etherscan.deth.net/address/0x51bdbfcd7656e2c25ad1bc8037f70572b7142ecc My python3 code is
from slither.slither import Slither
ctsl = Slither(file)
How to solve this remappings problem in slither API?
Describe the issue:
When I try to run slither on cmd prompt I have this issue
This is the remappings.txt file:
this is the foundry.toml file:
Code example to reproduce the issue:
slither ./src/auction/Auction.sol
Version:
0.8.3
Relevant log output: