Open Uhan19 opened 1 month ago
Hi! Thanks for the report; can you confirm if it works locally or if you see the same error there? e.g.
git clone --recursive https://github.com/Ammalgam-Protocol/peripheral-v1
cd peripheral-v1
forge install --quiet
forge build --build-info --skip */test/** */script/** --force
slither . --ignore-compile --config-file=slither.config.json --fail-low
Hi @elopez - I had to adjust to use this build command forge build --build-info --skip test/** /script/** --force
but running slither . --ignore-compile --config-file=slither.config.json --fail-low
generated the same error on local.
crytic_compile.platform.exceptions.InvalidCompilation: Unknown file: contracts/interfaces/callbacks/ITransferValidator.sol
Alright, so this is not an issue on the action then, but on either crytic-compile or Foundry's artifact generation. Out of curiosity, can you try again without the skip flags and report back? i.e. do a plain forge build --force
@elopez - that makes sense.
so running: forge build --force
and then slither . --ignore-compile --config-file=slither.config.json --fail-low
generates this error:
Error in .
Traceback (most recent call last):
File "/Library/Python/3.9/site-packages/slither_analyzer-0.9.2-py3.9.egg/slither/__main__.py", line 834, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/Library/Python/3.9/site-packages/slither_analyzer-0.9.2-py3.9.egg/slither/__main__.py", line 87, in process_all
compilations = compile_all(target, **vars(args))
File "/Library/Python/3.9/site-packages/crytic_compile-0.3.0-py3.9.egg/crytic_compile/crytic_compile.py", line 620, in compile_all
compilations.append(CryticCompile(target, **kwargs))
File "/Library/Python/3.9/site-packages/crytic_compile-0.3.0-py3.9.egg/crytic_compile/crytic_compile.py", line 110, in __init__
self._compile(**kwargs)
File "/Library/Python/3.9/site-packages/crytic_compile-0.3.0-py3.9.egg/crytic_compile/crytic_compile.py", line 530, in _compile
self._platform.compile(self, **kwargs)
File "/Library/Python/3.9/site-packages/crytic_compile-0.3.0-py3.9.egg/crytic_compile/platform/foundry.py", line 90, in compile
hardhat_like_parsing(crytic_compile, self._target, build_directory, self._target)
File "/Library/Python/3.9/site-packages/crytic_compile-0.3.0-py3.9.egg/crytic_compile/platform/hardhat.py", line 66, in hardhat_like_parsing
targets_json = loaded_json["output"]
KeyError: 'output'
@Uhan19 can you upgrade your slither and crytic-compile and see if that still happens? I see you're using quite old versions (0.9.2, 0.3.0 respectively)
@elopez - I have just upgraded to 0.10.4
and 0.3.7
, but unfortunately the error is still occuring. Trying to look into the build artifact and see if I can figure out where the issue is. Althought I do see the ITransferValidator.sol
in the out/
directory.
Also running a simple forge build
still generates the KeyError: output
error when running:
slither . --ignore-compile --config-file=slither.config.json --fail-low
It's possible the artifacts don't reflect the correct path of the file, does contracts/interfaces/callbacks/ITransferValidator.sol
exist in that path? or is it in some other location? What do the artifacts mentioning contracts/interfaces/callbacks/ITransferValidator.sol
say?
In the meantime I'll move this issue to the crytic-compile repo to keep things organized.
It's possible the artifacts don't reflect the correct path of the file, does
contracts/interfaces/callbacks/ITransferValidator.sol
exist in that path? or is it in some other location? What do the artifacts mentioningcontracts/interfaces/callbacks/ITransferValidator.sol
say?
so contracts/interfaces/callbacks/ITransferValidator.sol
is the path for the file in the core-v1
repo, which is a submodule of peripheral-v1
. In the peripheral-v1
the path should be lib/core-v1/contracts/interfaces/callbacks/ITransferValidator.sol
I just tooked at the the build-info
json that was generated and I see that under sources
:
{ "sources": { ..., "contracts/interfaces/callbacks/ITransferValidator.sol": { "id": 2, "ast": {} }, ..., "lib/core-v1/contracts/interfaces/callbacks/ITransferValidator.sol": { "id": 9, "ast": {...} }, ... } }
The second source with the correct path, has the ast
fully populated with data. So I think this could potentially be the issue, since that first path is incorrect.
I wonder if this could be related to https://github.com/foundry-rs/foundry/issues/7591
@0xalpharush have you seen this issue with the paths in the Foundry artifacts before?
@elopez - yea that looks very familiar to my issue:
what's interesting is that some files are duped, but not all of them. For example:
cat $(find out/build-info/*.json) | jq '.output.sources | keys' | grep 'ITransferValidator.sol'
"contracts/interfaces/callbacks/ITransferValidator.sol", "lib/core-v1/contracts/interfaces/callbacks/ITransferValidator.sol",
cat $(find out/build-info/*.json) | jq '.output.sources | keys' | grep 'IAmmalgamCallee.sol'
"lib/core-v1/contracts/interfaces/callbacks/IAmmalgamCallee.sol",
It could also be an instance of https://github.com/gakonst/ethers-rs/issues/2609 as it seems like the remappings may not be preserving the leading path prefix.
Would you mind reporting this on the foundry repo so it gets looked at by them?
sure will do,
I just checked in the core-v1
repo build-info and it looks like there's no dupe there, so I am not running into the same issue:
❯ cat $(find out/build-info/*.json) | jq '.output.sources | keys' | grep 'ITransferValidator.sol'
"contracts/interfaces/callbacks/ITransferValidator.sol",
Hi team,
running into some issues when I am reusing a slither workflow from one of my solidity repos (core-v1) in another repo (peripheral-v1). Core-v1 repo is submodule in the Peripheral-v1,
lib/core-v1
. The slither analysis passes in CI on the core-v1 repo, however it fails when the workflow is being called by the peripheral CI workflow. Here is the error:ITransferValidator.sol is a file in the core-v1 repo, and it is not used or imported in the peripheral-v1 repo, so I am not sure why slither is trying to compile this file.
here is my slither.yml in core-v1:
and this is the calling workflow CI.yml in the Peripheral-v1 repo:
I also have added
slither.config.json
in both repos:I had thought that perhaps I needed to define the targets for slither to run and perhaps it was running in the run context or root level, but after adding a step to list the directories, I could see that the file structure is as I expected. I also commented out the cache restore and build the contracts as part of the slither workflow, however this did not resolve the issue either. Would love some input in terms of why the compiler is reading a file in the submodule when it should've been filtered out. Please let me know if I can provide any additional information. Thanks.