cgewecke / hardhat-gas-reporter

Gas Usage Analytics for Hardhat
MIT License
409 stars 56 forks source link

Contracts with similar ABIs are meshed together in report #154

Closed sebastiantf closed 5 months ago

sebastiantf commented 1 year ago

I have two contracts Campaigns, CampaignsNativeGaslessClaim which have almost similar ABIs. The gas report only have separate functions which have different ABIs. The counts for the functions with same ABIs seem to suggest that they're being meshed together instead of staying separate.

I have confirmed that all methods are being called on both contracts. Particularly the following methods are not reported for CampaignsNativeGaslessClaim:

createCampaign has different ABIs on both contracts, so that seem to be reported separately correctly

Screenshot 2023-07-03 at 4 42 14 PM
cgewecke commented 7 months ago

Apologies for the very late response here - do you remember if this problem was in the context of using OZ's upgradeable contracts? (Have tentatively labeled it that way)

sebastiantf commented 7 months ago

Yes. I was using OZ's upgradeable contract

CWhits commented 7 months ago

Similar experience. I am testing two smart contracts, one a regular ERC721 and another one that is OZ's upgradeable. They are almost identical and the contract name displayed is just the regular ERC721 although every test is being completed.

cgewecke commented 7 months ago

@CWhits Yes, when a proxy sits in front of a target contract the gas-reporter has to fall back on function selectors alone to figure out what's being called. If there are method name collisions the contract attributions can be incorrect.

In the original version of this plugin (eth-gas-reporter) there was an option to help the reporter navigate proxies but no one used it AFAIK.

Am going to add explicit support for OZ upgradeable in the next major version since it's become much more of an issue. Working on this this month however it will probably not be published in beta before March.

cgewecke commented 5 months ago

This has been fixed in the latest version (2.0). If you're using OZ's upgrades plugin the reporter will automatically resolve proxied contracts.

Closing but just ping if you continue to have problems with this.