Closed elfedy closed 4 months ago
Hey @elfedy, thank you for the extensive summary. It is a known issue and we're investigating how to resolve it. The only way is probably parsing the AST and extracting imports from there. We'll try that.
Will be released in v1.5.2!
π Feature Request
π Description
When compiling a source file and finding an import that is not provided as input,
solc
will try to resolve the source via an import callback. If resolved successfully, the source will be compiled and be part of the output. This is not something that zksolc apparently expects, as it fails with this error. You can reproduce the behavior by following these examples. Ideallyzksolc
would be able to work just fine when it finds compiled outputs fromsolc
that come from sources that are not part of the initial input. At least an attempt to reproduce the deafultHost Filesystem Loader
that tries to get the file from the path derived from the source unit name would probably fit lots of use cases. If this is not possible or not planned to be supported, it would be nice to either usesolc
internally with--no-import-callback
or give a clearer error explaining the user what happened a bit better (solc produced an output from a resolved import vs from a source provided on compiler input and this is not supported).π€ Rationale
Benefits from the feature would be:
solc
will add an already provided input but with a different name as a result of import resolution (It may havehome/user/Contract.sol
and./Contract.sol
as different source units), in which casezksolc
will fail when looking to thesources
map withSource code for path not found
even though a source code matching that path was provided as input.π Additional Context
This request comes as a result of investigating an issue in foundry: https://github.com/matter-labs/foundry-zksync/issues/411
After patching forge with an issue that did not add the correct
allow_paths
, usingforge build --zksync
on the provided example will result in the issue described in.3
on the Rationale, where solc will resolve an import of an already provided source with a different source unit name, and then zksolc won't find the source by the path string of solc's output in the input provided by foundry.