Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Truffle should warn you if you have two contracts with the same name in different folders #387

Closed
1 task
LogvinovLeon opened this issue Apr 3, 2017 · 14 comments · Fixed by #3021
Closed
1 task
Labels
Artifacts error better issue indicates improvement to error messaging priority4 📋

Comments

@LogvinovLeon
Copy link
Contributor


Issue

I just spent a couple of hours trying to understand, why didn't the functions of my contract appear in an ABI after compilation.
The reason was - that I had two contracts with the same name in different folders.

Steps to Reproduce

Create two different contracts with the same name in different folders

Expected Behavior

Truffle would give you an error during compilation

Actual Results

Compilation was successful and it just overrided the json artifacts of the previous contract

Environment

  • Operating System: OSX
  • Truffle version: 3.2.1
  • Ethereum client: N/A
  • node version: v7.7.2
  • npm version: N/A
@stale
Copy link

stale bot commented Nov 8, 2018

Thank you for raising this issue! It has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you would like to keep this issue open, please respond with information about the current state of this problem.

@stale stale bot added the stale label Nov 8, 2018
@LogvinovLeon
Copy link
Contributor Author

I think it's still valid

@stale
Copy link

stale bot commented Nov 8, 2018

Thanks for your response! This issue is no longer considered stale and someone from the Truffle team will try to respond as soon as they can.

@stale stale bot removed the stale label Nov 8, 2018
@stale
Copy link

stale bot commented Jan 7, 2019

Thank you for raising this issue! It has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you would like to keep this issue open, please respond with information about the current state of this problem.

@stale stale bot added the stale label Jan 7, 2019
@eggplantzzz
Copy link
Contributor

Not stale again.

@stale
Copy link

stale bot commented Jan 7, 2019

Thanks for your response! This issue is no longer considered stale and someone from the Truffle team will try to respond as soon as they can.

@montyly
Copy link

montyly commented Apr 15, 2020

Task Description

Add a warning on the console output of truffle compile if the codebase has multiple contracts with the same name.

Acceptance criteria

  • Running truffle compile on a codebase with the issue produces a warning
  • The warning shows the paths of the contracts

Required skills

  • Experience with Javascript
  • Experience with Typescript

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 200.0 DAI (200.0 USD @ $1.0/DAI) attached to it.

@montyly
Copy link

montyly commented Apr 20, 2020

Note: the bounty is funded by Trail of Bits

@gitcoinbot
Copy link

gitcoinbot commented Apr 20, 2020

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 2 weeks, 5 days from now.
Please review their action plans below:

1) jeremigendron has applied to start work (Funders only: approve worker | reject worker).

Figure out where contract compilation occurs, log the output from that and check to see if contracts with the same name aren't processed specially (which they should be, in this case with a warning to the console).
2) antodp has applied to start work (Funders only: approve worker | reject worker).

I've encountered this problem myself working with the Truffle Suite.
I will search in the source code to find the moving parts and act as required.
3) evgeniuz has applied to start work (Funders only: approve worker | reject worker).

Worked previously on Truffle project, this one should be an easy fix. Will add necessary changes.
4) kichjang has been approved to start work.

There are a couple of places where we can check for contract name duplicity:

  1. In compile-solidity. In the callback supplied to findContracts, we perform a duplicity check on the files parameter array.
  2. In contract-sources. Accept an additional parameter or config option that indicates whether or not to fail upon detecting multiple files of the same name.
  3. In workflow-compile. Under Contracts.compileSources, check the contracts variable and throw an error upon seeing two or more contracts with the same name.

One additional complexity here that needs to be solved is the limited "view" of the compilation targets under a compile.necessary run -- we may not have the visibility to see all contracts that needs to be compiled during a run, and so it may not raise an error on duplicate contract names because of its "blindness" to unnecessary files.
5) thecydonian has applied to start work (Funders only: approve worker | reject worker).

Check list of contracts during compilation. If multiple exist exist with same name, throw error.
6) bobface has applied to start work (Funders only: approve worker | reject worker).

I will make Truffle check for contracts with the same name during compilation and fail with an error if there are any. I will also add a flag to disable this check.

Learn more on the Gitcoin Issue Details page.

tpscrpt added a commit to tpscrpt/truffle that referenced this issue Apr 20, 2020
…ntracts

Also, included changes to the logging of warnings for cleaner output;
and extra support in the test/ folder so you can check it out

cd packages/workflow-compile && yarn test

 > Compilation warnings encountered:
      Detected duplicate contracts: SimpleStorage
@gitcoinbot
Copy link

@KiChjang Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@KiChjang
Copy link
Contributor

@gitcoinbot Working on it, problem now is to write effective tests that can show that the bug is fixed by my changes.

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 200.0 DAI (200.0 USD @ $1.0/DAI) has been submitted by:

  1. @kichjang

@ceresstation please take a look at the submitted work:


@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 200.0 DAI (200.0 USD @ $1.0/DAI) attached to this issue has been approved & issued to @KiChjang.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Artifacts error better issue indicates improvement to error messaging priority4 📋
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants