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

Suggestion: use remappings instead of relative paths for external dependencies #435

Closed
0xJem opened this issue Jan 20, 2025 · 3 comments
Closed

Comments

@0xJem
Copy link

0xJem commented Jan 20, 2025

IMetaMorpho.sol contains the following imports from OZ and Morpho Blue:

import {IMorpho, Id, MarketParams} from "../../lib/morpho-blue/src/interfaces/IMorpho.sol";
import {IERC4626} from "../../lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol";
import {IERC20Permit} from "../../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol";

If the integrator does not have the dependencies at these exact locations, it's not possible to compile a contract integrating with the IMetaMorpho interface.

Scenarios where this would break:

  • Integrator has the dependencies with a version string (e.g. lib/morpho-blue-1.0.0/)
  • Integrator is using soldeer to manage dependencies (e.g. dependencies/morpho-blue-1.0.0/)

It does also not appear to be possible to add a relative path into the remappings.txt file to force forge/solc to remap the relative path. i.e. this does not work ../../lib/morpho-blue/src/=dependencies/morpho-blue-1.0.0/src/

@Rubilmax
Copy link
Contributor

If the integrator does not have the dependencies at these exact locations

In which case is this possible? Aren't you installing this repository as a forge dependency (git submodule under-the-hood)?

Relative dependencies are safer than remappings because the versions of contracts are exact (whereas remappings can map OUR dependency import to YOURS - possibly breaking)

@MathisGD
Copy link
Contributor

The reason why we don't use remapping it precisely to make sure that our dependancies are used (instead of other ones, whatever they are). Remappings can create dangerous bugs.

As @Rubilmax said, it's best to use our repos as git submodule (to recursively have the dependancies).

I'm not familiar with soldeer, but can't it fetch all the dependancies recursively?

@0xJem
Copy link
Author

0xJem commented Jan 22, 2025

In which case is this possible? Aren't you installing this repository as a forge dependency (git submodule under-the-hood)?

A dependency can be added at a custom location when using forge install. Soldeer also uses a different directory structure.

The reason why we don't use remapping it precisely to make sure that our dependancies are used

Right, this makes sense! I can probably add it to our setup script to set up the metamorpho dependencies. Thanks for the tip and explanation.

@0xJem 0xJem closed this as not planned Won't fix, can't repro, duplicate, stale Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants