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

Name collision for interfaces in Compound finance contracts prevents brownie from compiling #729

Closed
Pet3ris opened this issue Aug 21, 2020 · 7 comments · Fixed by #734
Closed

Comments

@Pet3ris
Copy link

Pet3ris commented Aug 21, 2020

Environment information

  • brownie Version: 1.10.6
  • ganache-cli Version: n/a
  • solc Version: 0.5.16
  • Python Version: 3.7
  • OS: osx

What was wrong?

I ran:

git clone https://github.com/compound-finance/compound-protocol.git

Then in a separate directory, I first initialised brownie:

poetry run brownie init

After that, I simlinked the contracts folder:

ln -s ../compound-protocol/contracts ./contracts

And tried to compile:

poetry run brownie compile

Getting the following error:

  File "brownie/_cli/__main__.py", line 60, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/compile.py", line 37, in main
    project.load()
  File "brownie/project/main.py", line 656, in load
    return Project(name, project_path)
  File "brownie/project/main.py", line 160, in __init__
    self.load()
  File "brownie/project/main.py", line 170, in load
    self._sources = Sources(contract_sources, interface_sources)
  File "brownie/project/sources.py", line 53, in __init__
    + "\n  ".join(f"{k}: {', '.join(sorted(v))}" for k, v in collisions.items())
NamespaceCollision: Multiple contracts or interfaces with the same name
  PotLike: contracts/CDaiDelegate.sol, contracts/DAIInterestRateModelV3.sol

How can it be fixed?

It seems like brownie doesn't support contracts with the same names, I wonder if it should be more permissive, perhaps namespacing contracts that appear in different files by prefixing with the filename (certainly for interfaces). In the compound example, these interfaces actually have different source code and are meant to be deployed as part of another contract.

@iamdefinitelyahuman
Copy link
Member

This is a high priority for v2.0.0, but unfortunately the current design makes it difficult to solve prior to a large scale refactor :(

@Pet3ris
Copy link
Author

Pet3ris commented Aug 25, 2020

No problem @iamdefinitelyahuman - that makes sense and thanks for clarifying!

@Pet3ris
Copy link
Author

Pet3ris commented Aug 25, 2020

Do you know if there is any viable work-around, perhaps a way to select a subset of contracts for compilation?

@iamdefinitelyahuman
Copy link
Member

Looking at the compound repo, it seems the collision is between an interface and an abstract contract. I think - might be able to apply a workaround without a major release, where collisions are OK so long as neither thing is a compilable contract. I'll try to give it some bandwidth tomorrow, I have a new minor release almost ready anyway so can try to get this in as well.

In the mean time, it's quick and dirty but you could just rename PotLike in one of the contracts. Or if you only need certain aspects of compound, try grabbing the verified, flattened sources from etherscan.

@Pet3ris
Copy link
Author

Pet3ris commented Aug 25, 2020

Fingers crossed that does it, I'll try and confirm if this would work tomorrow with the rename.

@Pet3ris
Copy link
Author

Pet3ris commented Aug 28, 2020

@iamdefinitelyahuman thanks and confirming that this update solves it for me ✅.

@iamdefinitelyahuman
Copy link
Member

Glad to hear! Sorry it took me so long.

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

Successfully merging a pull request may close this issue.

2 participants