bug(`forge`): `verify-contract` doesn't support remappings
Component
Forge
Have you ensured that all of these are up to date?
- [x] Foundry
- [x] Foundryup
What version of Foundry are you on?
1.5.0-stable
What version of Foundryup are you on?
1.4.0
What command(s) is the bug in?
forge verify-contract
Operating System
Linux
Describe the bug
I'm deploying RegistryFinder.sol in ensdomains/namechain.
It has a dependency LibMem.sol in ensdomains/ens-contracts that is included by NameCoder.sol which is imported in RegistryFinder.sol.
The ensdomains/namechain repo uses a remappings.txt which maps LibMem.sol to the local LibMem.sol. This mapping is confirmed by a test.
tl;dr: In
ensdomains/namechain, imports ofLibMemuse the local version.
Here is a deployment of RegistryFinder.sol: 0xf930e563C2DF027B1c46b33b942bE0619FBfc039
Here is the cli command:
forge verify-contract \
0xf930e563C2DF027B1c46b33b942bE0619FBfc039 \
src/universalResolver/RegistryFinder.sol:RegistryFinder \
--chain 11155111 \
--constructor-args 0x0000000000000000000000000f3eb298470639a96bd548cea4a648bc80b2cee2000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000050365746800000000000000000000000000000000000000000000000000000000
It fails with:
Fail - Unable to verify. Solidity Compilation Error: Source "src/common/utils/LibMem.sol" not found: File not found. Searched the following locations: ""."
When I inspect the output of --show-standard-json-input, I notice that it doesn't have the remapped file even though it lists the correct remappings. It includes a source key for "lib/ens-contracts/contracts/utils/LibMem/LibMem.sol" (the file that is mapped) and does not include "src/common/utils/LibMem.sol" (the remapped file).
If I make the above edits to the json, it verifies correctly.
thanks, will check, most probably similar withhttps://github.com/foundry-rs/foundry/issues/12659 need to see where the regression
could be an issue with the order of remappings and how we load them, this fixed a problem that looks similar for Uniswap https://github.com/Uniswap/contracts/pull/122/commits/61adab891effab02ef1ba00c043b8d25d25a49d9
I'm not sure I understand the context of that fix.
In ensdomains/namechain, I want to replace lib/ens-contracts/contracts/utils/LibMem.sol with src/common/utils/LibMem.sol for all imports (which is local and @ens/)
And I'm using:
@ens/contracts/=lib/ens-contracts/contracts/
@ens/contracts/utils/LibMem/=src/common/utils/
lib/ens-contracts/contracts/utils/LibMem/=src/common/utils/
Which works correctly for forge build, test, and coverage but not verify-contract.
Are you saying I should try other permutations of this ordering?
This also seems to fail with a different error on a different contract (ETHTLDResolver), which I think is related to the same problem: Fail - Unable to verify. Solidity Compilation Error: Source \"lib/openzeppelin-contracts-v4/contracts/token/ERC721/IERC721.sol\" not found: File not found. Searched the following locations: \"\"."