0xProject / 0x-monorepo

0x protocol monorepo - includes our smart contracts and many developer tools
Other
1.41k stars 466 forks source link

sol-compiler: not working with truffle and solidity ^0.5.10 #2114

Closed PaulRBerg closed 5 years ago

PaulRBerg commented 5 years ago

Expected Behavior

Sol-compiler's artifact bytecode should match truffle's artifacts' bytecode.

Current Behavior

They are not.

Possible Solution

Identify what's changed with solidity 0.5.10 (since prior versions work, re dev-tools-truffle-example) and truffle ^5.0.33.

Steps to Reproduce (for bugs)

1. `git clone git@github.com:sablierhq/sablier.git`
2. `yarn install` and `yarn build`
3. start ganache-cli in a new terminal window
4. `cd packages/protocol` and `yarn coverage`

Context

It started with these warnings printed while doing coverage:

Unable to find matching bytecode for contract creation 0x6080604052348015...7469616c697a6564, please check your artifacts. Ignoring...

I have many contracts, but I selected only one for comparison. The said contract imports several other contracts from @openzeppelin/contracts-ethereum-package.

I ran both truffle and sol-compiler and I inspected the bytecode. It's almost the same, but the last 32 bytes before the least 57 bytes are the issue:

truffle: ccaccfa0af901c4280201ed107dd9b58538533030e041a78a5c97b390e6626f5
sol-compiler: 31d6ca3958853066a75e61371d764ceee92a1ebbfb8aadee3c805769e0561c26

Furthermore:

• I checked on StackExchange and this is not related to the Swarm hash. That's the ending 32 bytes.

• What's weird is that if I use truffle-flattener to get a single file for the contract (copy-pasting the imports inside), then the artifacts finally match, but only ONCE.

Your Environment

Package Version
sol-compiler 3.1.13
solidity 0.5.10
truffle 5.0.33
PaulRBerg commented 5 years ago

Cc-ing @gnidan in case you happen to know what's the deal with those 32 bytes?

PaulRBerg commented 5 years ago

Closing this because the issue was actually with truffle.

https://github.com/trufflesuite/truffle/issues/2355