trufflesuite / truffle

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
14.02k stars 2.32k forks source link

Artifacts are from different compiler runs | Contracts compiling more than once #3521

Open ghost opened 4 years ago

ghost commented 4 years ago

Issue

1- I have Artifacts are from different compiler runs when trying to migrate my contracts. When I try to compile all the contracts I see: 2- some contracts are double-compiling and 3- some of OZ imports are double-compiling and their paths are messed up with slashed and backslashes 4- when I run truffle compile, it compiles all my contracts (not OZ) again, even when there are no changes there

Compiling @openzeppelin/contracts-ethereum-package/contracts/GSN/Context.sol
Compiling @openzeppelin/contracts-ethereum-package/contracts/Initializable.sol
Compiling @openzeppelin/contracts-ethereum-package/contracts/access/AccessControl.sol
Compiling @openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol
Compiling @openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol
Compiling @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol
Compiling @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Burnable.sol
Compiling @openzeppelin/contracts-ethereum-package/contracts/token/ERC20/SafeERC20.sol
Compiling @openzeppelin/contracts-ethereum-package/contracts/utils/ReentrancyGuard.sol
Compiling @openzeppelin\contracts-ethereum-package\contracts\GSN\Context.sol
Compiling @openzeppelin\contracts-ethereum-package\contracts\Initializable.sol
Compiling @openzeppelin\contracts-ethereum-package\contracts\math\SafeMath.sol
Compiling @openzeppelin\contracts-ethereum-package\contracts\token\ERC20\ERC20.sol
Compiling @openzeppelin\contracts-ethereum-package\contracts\token\ERC20\IERC20.sol
Compiling @openzeppelin\contracts-ethereum-package\contracts\utils\Address.sol
Compiling @openzeppelin\contracts-ethereum-package\contracts\utils\EnumerableSet.sol
Compiling .\contracts\Migrations.sol
Compiling .\contracts\Modules\AddressProvider.sol
Compiling .\contracts\Modules\SchoolModule.sol
Compiling .\contracts\Modules\OracleModule.sol
Compiling .\contracts\Modules\ClassModule.sol
Compiling .\contracts\City\City.sol
Compiling .\contracts\inc\Base.sol
Compiling .\contracts\inc\CoreLibrary.sol
Compiling .\contracts\Modules\AddressProvider.sol
Compiling .\contracts\Modules\SchoolModule.sol
Compiling .\contracts\Modules\OracleModule.sol
Compiling .\contracts\Modules\ClassModule.sol
Compiling .\contracts\City\City.sol
Compiling .\contracts\inc\Base.sol
Compiling .\contracts\inc\CoreLibrary.sol

Environment

haltman-at commented 4 years ago

Hi, thanks for the report! Do you have an example repo we could check out that would allow us to reproduce this, or other instructions we could follow to create a reproduction example? Thank you!

ghost commented 4 years ago

Hi, @haltman-at will try to upload a testing repo to try it.

ghost commented 4 years ago

@haltman-at I uploaded this sample https://github.com/drbullock/TruffleTest

I have added now Interfaces to my original project now and it looks like it is partially fixed, but it is still recompiling the Interfaces.

In the meantime, from the test repo (only for compiling) here are the logs:

Fresh compile:

Compiling your contracts...
===========================
> Compiling @openzeppelin/contracts-upgradeable/token/ERC20/ERC20BurnableUpgradeable.sol
> Compiling @openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\GSN\ContextUpgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\math\SafeMathUpgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\proxy\Initializable.sol
> Compiling @openzeppelin\contracts-upgradeable\token\ERC20\ERC20Upgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\token\ERC20\IERC20Upgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\utils\AddressUpgradeable.sol
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\inc\Base.sol
> Compiling .\contracts\interfaces\IToken.sol
> Compiling .\contracts\tokens\AToken.sol
> Compiling .\contracts\tokens\BToken.sol
> Compiling .\contracts\inc\Base.sol
> Compiling .\contracts\interfaces\IToken.sol
> Artifacts written to C:\TruffleTest\build\contracts
> Compiled successfully using:
   - solc: 0.7.4+commit.3f05b770.Emscripten.clang

Next compiles:

Compiling your contracts...
===========================
> Compiling .\contracts\inc\Base.sol
> Compiling .\contracts\interfaces\IToken.sol
> Artifacts written to C:\TruffleTest\build\contracts
> Compiled successfully using:
   - solc: 0.7.4+commit.3f05b770.Emscripten.clang

Truffle Version:

Truffle v5.1.53 (core: 5.1.53)
Solidity - 0.7.4 (solc-js)
Node v12.18.4
Web3.js v1.2.9
eggplantzzz commented 3 years ago

@drbullock Thanks very much for the report and the repro repo! We'll dig into this and see if we can see what's going on here.