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

Use file-relative paths instead of project-relative #10202

Open
adraffy opened this issue Apr 18, 2024 · 6 comments
Open

Use file-relative paths instead of project-relative #10202

adraffy opened this issue Apr 18, 2024 · 6 comments
Labels
C-customer-issue Category: An issue encountered by customers integrating with Optimism

Comments

@adraffy
Copy link

adraffy commented Apr 18, 2024

Is your feature request related to a problem? Please describe.

These project relative paths:

import { Types } from "src/libraries/Types.sol";

Describe the solution you'd like

Should be changed to file relative paths:

import { Types } from "./Types.sol";

Additional context

For example, these files cannot be used in Remix as the npm imports cannot disambiguate "src/"

This also causes issues with Foundry, where the same file is imported twice causing T != T errors.

@tynes
Copy link
Contributor

tynes commented Apr 18, 2024

Can you give a reproducible case that shows this error? Imports using this style are part of our style guide. They make refactoring much easier internally to the project. Perhaps we could raise this as an issue with remix?

@adraffy
Copy link
Author

adraffy commented Apr 18, 2024

Yeah, I can submit a foundry repo and a remix project example.

IMO, that's a weird style guide recommendation, as the file is only refactored once. Every importer pays the price of translating project-relative includes.

For example, all OpenZeppelin and forge-std includes are file-relative.

@adraffy adraffy changed the title Use Relative Paths for src/ Use fille-relative paths instead of project-relative Apr 18, 2024
@adraffy adraffy changed the title Use fille-relative paths instead of project-relative Use file-relative paths instead of project-relative Apr 18, 2024
@adraffy
Copy link
Author

adraffy commented Apr 21, 2024

https://github.com/adraffy/optimism-project-relative-issue/blob/main/src/Contract.sol

  1. foundryup
  2. forge build

Compiler run failed:
Error (9553): Invalid type for argument in function call. Invalid implicit conversion from struct Types.OutputRootProof memory to struct Types.OutputRootProof memory requested.

@tynes
Copy link
Contributor

tynes commented Apr 23, 2024

Thank you for the repro case

@adraffy
Copy link
Author

adraffy commented Apr 23, 2024

You can use the following one-liner to repro in Remix:

import "@eth-optimism/contracts-bedrock/src/libraries/Encoding.sol";

This will correctly import via NPM then fail with with: Error: not found src/libraries/rlp/RLPWriter.sol

@smartcontracts smartcontracts added the C-customer-issue Category: An issue encountered by customers integrating with Optimism label Apr 23, 2024
@tynes
Copy link
Contributor

tynes commented Apr 24, 2024

I see, so relative paths are going to be more portable. I am curious if the following comment helps for the foundry case: foundry-rs/foundry#3440 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-customer-issue Category: An issue encountered by customers integrating with Optimism
Projects
None yet
Development

No branches or pull requests

3 participants