trufflesuite / truffle-compile

Compiler helper and artifact manager
22 stars 46 forks source link

Modifying a base contract doesn't trigger recompilation of derived contracts. #47

Closed wbt closed 6 years ago

wbt commented 6 years ago

(Moved from https://github.com/trufflesuite/truffle/issues/839)


Issue

Modifying a base contract doesn't trigger recompilation of derived contracts.

Steps to Reproduce

  1. Copy Alpha.sol and Beta.sol from https://github.com/ethereum/solidity/issues/3675 to a new Truffle project's contracts directory.

  2. In the project directory, truffle compile.

  3. To Alpha.sol, add the following before the final closing curly brace:

    function newFunctionInBaseContract(uint newValue) public {
        secondField = newValue;
    }
  4. In the project directory, truffle compile again, as many times as you want.

  5. Inspect ABI of Beta in build/contracts/Beta.json.

Expected Behavior

The output from truffle compile should be:

Compiling .\contracts\Alpha.sol... Compiling .\contracts\Beta.sol... Writing artifacts to .\build\contracts

ABIs in Alpha.json and Beta.json should both contain newFunctionInBaseContract.

Actual Results

The output from truffle compile is:

Compiling .\contracts\Alpha.sol... Writing artifacts to .\build\contracts

and while Alpha.json contains the ABI including newFunctionInBaseContract, Beta does not.

Environment

wbt commented 6 years ago

I suspect the issue is in profiler.js in required_sources or dependency_graph. The updated files are added to the list in line 149 based just on file update time. This is returned to index.js:299, then passed as options.paths to compile.with_dependencies which at line 325 bounces it back to Profiler.required_sources.
I don't have time to dive deeper at the moment but hope this helps.

gnidan commented 6 years ago

This is a known issue, there's WIP to address this in #41

cgewecke commented 6 years ago

This is fixed as of 4.1.5. Thanks @wbt.