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

Build-info file's solc output has contracts with absolute paths #7878

Closed
2 tasks done
ericglau opened this issue May 6, 2024 · 4 comments · Fixed by foundry-rs/compilers#121 or #7883
Closed
2 tasks done

Build-info file's solc output has contracts with absolute paths #7878

ericglau opened this issue May 6, 2024 · 4 comments · Fixed by foundry-rs/compilers#121 or #7883
Assignees
Labels
T-bug Type: bug

Comments

@ericglau
Copy link

ericglau commented May 6, 2024

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 (2e3c197 2024-05-06T16:01:48.856025000Z)

What command(s) is the bug in?

forge build --build-info

Operating System

macOS (Apple Silicon)

Describe the bug

Recent versions of forge causes solc output's contracts paths to use absolute paths, whereas previously they were paths relative to the project root.

For example, run:

forge init
forge build --build-info

In out/build-info/<file>.json, the input section has sources with paths relative to the project root, e.g.:

  "input": {
    "language": "Solidity",
    "sources": {
      "lib/forge-std/src/Base.sol": {
...

However in the output section, contracts have absolute paths.

  "output": {
    "contracts": {
      "/Users/MyUser/foundryproject/lib/forge-std/src/Base.sol": {

This causes a problem for any tooling which tries to match output contracts with their corresponding source inputs.

@ericglau ericglau added the T-bug Type: bug label May 6, 2024
@ualtinok
Copy link
Contributor

ualtinok commented May 7, 2024

I've encountered this problem while trying to use openzeppelin-foundry-upgrades. It causes to fail with:

[FAIL. Reason: setup failed: revert: Failed to run upgrade safety validation: /...../node_modules/@openzeppelin/upgrades-core/dist/validate/run.js:152
        const content = solcInput.sources[source].content;
                                                  ^

TypeError: Cannot read properties of undefined (reading 'content')

@mattsse
Copy link
Member

mattsse commented May 7, 2024

thanks for flagging

@klkvr perhaps this was caused by recent changes in compilers

@0xalpharush
Copy link
Contributor

0xalpharush commented May 7, 2024

From crytic/slither-action#84 (comment)

If you have the option, installing an older Foundry release seems to work around the problem: foundryup -v nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9

Maybe something related to the addition of SparseOutputFileFilter or the conflict_free_output_file in foundry-compilers that was pulled in by #7822

@mattsse
Copy link
Member

mattsse commented May 7, 2024

mattsse pushed a commit to foundry-rs/compilers that referenced this issue May 7, 2024
Closes foundry-rs/foundry#7878

Removes paths stripping logic from solc implementation, instead we now
use `CompilerInput::strip_prefix` and `CompilerOutput::join_all`
directly in `compile_*` functions, and only join output paths after
writing build info.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
None yet
5 participants