cgewecke / eth-gas-reporter

Gas usage per unit test. Average gas usage per method. A mocha reporter.
MIT License
603 stars 94 forks source link

Not reporting on contracts created with truffle's external compile step #107

Closed BlinkyStitt closed 5 years ago

BlinkyStitt commented 5 years ago

My contract is written in solidity 0.5. It depends on a contract written by someone else in solidity 0.4. I've managed to get migrations and tests working for the external contract by using an external compile step (https://github.com/trufflesuite/truffle/issues/1607#issuecomment-452159899).

The problem is that eth-gas-reporter doesn't show anything for the 0.4 contracts. I'm guessing this is because there are keys needed for the truffle contract to parse correctly, but I'm not sure. The json generated by the external compile step doesn't have as many keys as the normal files: https://gist.github.com/WyseNynja/e54064191465abc3c662b3b2df1e4280

What do I need to do to get gas reports for my external contracts? Is it simply keys missing from my JSON, or is there something bigger I have to do?

BlinkyStitt commented 5 years ago

I've made some changes to how I generate the artifacts for old versions of solidity (I'm now using sol-compiler for everything), but eth-gas-reporter still doesn't detect gas costs for any of my calls. It does show the overall use for the tests though.

I'm guessing something is not working right in stats.mapMethodsToContracts(artifacts, config.src)

BlinkyStitt commented 5 years ago

I tried setting src: 'contracts-sol-compiler' since my contracts aren't in the main contracts directory, but that didn't make any difference.

cgewecke commented 5 years ago

@WyseNynja Apologies for neglecting this for so long - do you have a way I can reproduce this and try get it working?

cgewecke commented 5 years ago

With 0.2.2 you should be able to configure the reporter for any artifact format, contract source folder location, etc. There's more info about this in the advanced use section of the docs.