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

Brownie does not generate proper compilation artifacts for interfaces #941

Open
montyly opened this issue Jan 27, 2021 · 9 comments
Open
Labels
bug Something isn't working

Comments

@montyly
Copy link

montyly commented Jan 27, 2021

Hi,

It looks like the interfaces compilation artifacts generated in build/interfaces are not generated with the same compiler call that build/contracts. So some references ID in the interfaces AST do not match the references from build/contracts.

For example, in the AST generated, the src field is composed of three elements start:length:fileID. When solc generates the compilation artifact fileID will be unique per filename. Because build/interfaces is not generated at the same time that build/contracts, the fileID can collide, breaking integration with third-party tools (such as slither)

For example, if the codebase has two files:

$ cat interfaces/interface.sol 
pragma solidity 0.7.2;

interface I{

}
$ cat contracts/implementation.sol 
pragma solidity 0.7.2;
import "../../interfaces/interface.sol";

contract Imp is I{

}

Running $ solc contracts/implementation.sol --ast-compact-json --allow-paths . will lead the src fields in the AST to be

  • x:y:0 for contracts/implementation.sol elements and
  • x:y:1 for interfaces/interface.sol elements.

However, running brownie compile will lead all the src to be in the form x:y:0, making it difficult to distinguish if the source maps contracts/implementation.sol or interfaces/interface.sol.

I am not too familiar with how brownie generates build/interfaces, but would it be possible to either:

  • Add the compilation artifacts for the interfaces directly into build/contracts (so both in build/contracts for consistency and in build/interfaces for other usages)
  • Or have an option to force build/interfaces to be generated with the same call to solc that for build/contracts

This issue is similar to #772.

@montyly
Copy link
Author

montyly commented Apr 22, 2021

Hi, is there any update on this issue? It prevents our users from running Slither on brownie's codebases

@iamdefinitelyahuman
Copy link
Member

Sorry just haven't found the bandwidth to address yet 😬

@princearoragithub
Copy link

Hi @iamdefinitelyahuman , is there any update on this?

@rohitgoyal
Copy link

+1, Waiting for this to resolve for a long time.

@PatrickAlphaC
Copy link
Contributor

We might need to bounty this bad larry

@rohitgoyal
Copy link

Has there been any change to this?

@PatrickAlphaC
Copy link
Contributor

@iamdefinitelyahuman can we put out a gitcoin grant perhaps?

@rohitgoyal
Copy link

@iamdefinitelyahuman can we put out a gitcoin grant perhaps?

+1

@seventh-dawn
Copy link

seventh-dawn commented Nov 10, 2022

I know how to solve it, but my solution is fairly bootleg and can be refined.
The correct artifacts are actually volontarily filtered by brownie during the contract compilation.
I have solved it on a local fork and managed to run slither on our codebase which has all kind of flavors of contracts, without any issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants