truffle doesn't use solidity's remappings

Created on 31 Aug 2019  路  7Comments  路  Source: trufflesuite/truffle

  • [x] I've asked for help in the Truffle Gitter before filing this issue.
  • [x] I've asked for help on Twitter

Issue

When compiling contracts that import other contracts, truffle behaves differently to sol-compiler and solc. The reason is that solidity's "remappings" are not put in the metadata object, as they should. See the docs on Layout of a Solidity Source File or this StackExchange thread for more info.

Steps to Reproduce

Make sure to have truffle and sol-compiler globally installed and check out my sol-compiler-truffle-mismatch repo.

1. git clone [email protected]:PaulRBerg/sol-compiler-truffle-mismatch.git
2. cd sol-compiler-truffle-mismatch
3. yarn install
4. ./compare.sh

The last instruction should print "Artifacts are NOT equal".

Expected Behavior

The artifacts should be the same, even if they are compiled with two different tools.

Actual Results

The resulted artifacts have different metadata, because truffle doesn't put solidity's remappings in there, while sol-compiler does. It follows that the bytecode of the contracts gets to be different, since the bytes at the end include the hash of the metadata (see the solidity docs on Contract Metadata).

Environment

  • Operating System: macOS v10.14.6
  • Ethereum client: ganache-cli v6.5.1
  • Truffle version (truffle version): v5.0.33
  • node version (node --version): v10.15.3
  • npm version (npm --version): v6.10.2
Compiler bug help wanted needs investigated

Most helpful comment

@PaulRBerg This is now out in the wild with version 5.0.35!

All 7 comments

Ok so looks like we just need to whitelist a remapping property for compilers.solc.settings in truffle-config.js. Then people should be able to specify remappings there. Thanks for such a detailed report @PaulRBerg!

No worries. Thanks for the quick fix!

I guess I can use this fix only if I build truffle from scratch. How does the release process work? Do you wait for other major features on your roadmap to get done before bumping the version?

Hi @PaulRBerg we do weekly releases, so you should see this in the newest release sometime later today. Thanks!

Legend, thanks @fainashalts!

@PaulRBerg This is now out in the wild with version 5.0.35!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rstormsf picture rstormsf  路  3Comments

mezrin picture mezrin  路  3Comments

tcurdt picture tcurdt  路  3Comments

Katsu1991 picture Katsu1991  路  3Comments

ferittuncer picture ferittuncer  路  3Comments