Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrupted compilation artifacts in case of contracts name collision #2843

Closed
2 tasks done
montyly opened this issue Aug 19, 2022 · 4 comments · Fixed by gakonst/ethers-rs#1621
Closed
2 tasks done
Assignees
Labels
C-forge Command: forge Cmd-forge-build Command: forge build T-bug Type: bug

Comments

@montyly
Copy link

montyly commented Aug 19, 2022

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (6b3db2a 2022-08-19T00:24:19.967244Z)

What command(s) is the bug in?

forge build

Operating System

No response

Describe the bug

If two contracts are in files that share the same filename/contract name, foundry will generate corrupted compilation artifacts (one of the contract overwrites the other).

I was the impression that it was solved when #1488 was fixed, but I am still experimenting the issue with the latest forge.

I created a repo to show the issue https://github.com/montyly/foundry-collision

% forge --version
forge 0.2.0 (6b3db2a 2022-08-19T00:24:19.967244Z)

This issue is a major blocker for many slither/echidna users, so it would be great if we could have a fix.

@mattsse
Copy link
Member

mattsse commented Aug 19, 2022

so the first run succeeds where you get a.sol/A.json and inner/a.sol/A.json

but on partial recompile there's a conflict.

fixing

@montyly
Copy link
Author

montyly commented Aug 20, 2022

Great, thanks for the quick fix @mattsse

@montyly
Copy link
Author

montyly commented Aug 20, 2022

Actually there are still collision possible. For example, if two files have the same name without the case sensitivy, but different with:

Then the collision still occur. In the repo out/src/A.sol https://github.com/montyly/foundry-collision/blob/7fe6e6550bc9ad19e6623c56b5a9b66426c7a099/out/a.sol/A.json#L3-L9 (src/a.sol compilation artifacts are overridden by src/inner/A.sol)

Tested with the latest forge:

forge --version
forge 0.2.0 (29ff0b0 2022-08-20T00:05:53.843766Z)

I haven't tested if a.sol and A.sol are both within the same directory, but I am assuming the issue will be the same (only for case sensitive system)

@mattsse
Copy link
Member

mattsse commented Aug 20, 2022

right, forgot about case-sesnistivity...

but this is now a simple fix.

thanks for flagging again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-build Command: forge build T-bug Type: bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants