foundry icon indicating copy to clipboard operation
foundry copied to clipboard

bug(`forge`): `verify-contract` doesn't support remappings

Open adraffy opened this issue 1 month ago • 4 comments

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 of LibMem use 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.

adraffy avatar Nov 26 '25 22:11 adraffy

thanks, will check, most probably similar withhttps://github.com/foundry-rs/foundry/issues/12659 need to see where the regression

grandizzy avatar Nov 27 '25 03:11 grandizzy

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

grandizzy avatar Dec 04 '25 14:12 grandizzy

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?

adraffy avatar Dec 05 '25 23:12 adraffy

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: \"\"."

adraffy avatar Dec 06 '25 22:12 adraffy