Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contracts with common function names: only one of them is shown in the results #121

Closed
fabianorodrigo opened this issue Jul 21, 2022 · 1 comment

Comments

@fabianorodrigo
Copy link

Hi,

I have two contracts in my project. One of them is an upgradeable version of the other.

I have the same tests for both of them.
The tabular data presented by hardhat-gas-reporter shows in "Deployments" section both contracts
However, in the "Methods" section it's shown only the non upgradeable contract.

·------------------------------|----------------------------|-------------|-----------------------------·
|     Solc version: 0.8.9      ·  Optimizer enabled: false  ·  Runs: 200  ·  Block limit: 30000000 gas  │
·······························|····························|·············|······························
|  Methods                     ·               15 gwei/gas                ·       1554.27 eur/eth       │
·············|·················|··············|·············|·············|···············|··············
|  Contract  ·  Method         ·  Min         ·  Max        ·  Avg        ·  # calls      ·  eur (avg)  │
·············|·················|··············|·············|·············|···············|··············
|  ETHPool   ·  depositReward  ·       41318  ·      61254  ·      49140  ·           14  ·       1.15  │
·············|·················|··············|·············|·············|···············|··············
|  ETHPool   ·  grantRole      ·       51994  ·      56971  ·      54485  ·            6  ·       1.27  │
·············|·················|··············|·············|·············|···············|··············
|  ETHPool   ·  withdraw       ·       48932  ·      62512  ·      55763  ·           24  ·       1.30  │
·············|·················|··············|·············|·············|···············|··············
|  Deployments                 ·                                          ·  % of limit   ·             │
·······························|··············|·············|·············|···············|··············
|  ETHPool                     ·           -  ·          -  ·    1715286  ·        5.7 %  ·      39.99  │
·······························|··············|·············|·············|···············|··············
|  ETHPoolUpgradeable          ·           -  ·          -  ·    2754146  ·        9.2 %  ·      64.21  │
·------------------------------|--------------|-------------|-------------|---------------|-------------·

When I delete the non upgradeable contract along with its tests, then the methods of upgradeable contract is shown in "Methods" section.

·----------------------------------------|----------------------------|-------------|-----------------------------·
|          Solc version: 0.8.9           ·  Optimizer enabled: false  ·  Runs: 200  ·  Block limit: 30000000 gas  │
·········································|····························|·············|······························
|  Methods                               ·               13 gwei/gas                ·       1553.79 eur/eth       │
·······················|·················|··············|·············|·············|···············|··············
|  Contract            ·  Method         ·  Min         ·  Max        ·  Avg        ·  # calls      ·  eur (avg)  │
·······················|·················|··············|·············|·············|···············|··············
|  ETHPoolUpgradeable  ·  depositReward  ·       46232  ·      64054  ·      50997  ·            7  ·       1.03  │
·······················|·················|··············|·············|·············|···············|··············
|  ETHPoolUpgradeable  ·  grantRole      ·       56959  ·      56971  ·      56967  ·            3  ·       1.15  │
·······················|·················|··············|·············|·············|···············|··············
|  ETHPoolUpgradeable  ·  withdraw       ·       52846  ·      62512  ·      57720  ·           12  ·       1.17  │
·······················|·················|··············|·············|·············|···············|··············
|  Deployments                           ·                                          ·  % of limit   ·             │
·········································|··············|·············|·············|···············|··············
|  ETHPoolUpgradeable                    ·           -  ·          -  ·    2754146  ·        9.2 %  ·      55.63  │
·----------------------------------------|--------------|-------------|-------------|---------------|-------------·

After a couple of trials, I renamed one of the methods of the upgradeable version and then this one method with a different name is listed. I imagine that this problem is related with some kind of data structure that uses the method name as key.
Hope this helps to improve this amazing tool.

·----------------------------------------|----------------------------|-------------|-----------------------------·
|          Solc version: 0.8.9           ·  Optimizer enabled: false  ·  Runs: 200  ·  Block limit: 30000000 gas  │
·········································|····························|·············|······························
|  Methods                               ·               15 gwei/gas                ·       1550.25 eur/eth       │
·······················|·················|··············|·············|·············|···············|··············
|  Contract            ·  Method         ·  Min         ·  Max        ·  Avg        ·  # calls      ·  eur (avg)  │
·······················|·················|··············|·············|·············|···············|··············
|  ETHPool             ·  depositReward  ·       41318  ·      64032  ·      49729  ·           14  ·       1.16  │
·······················|·················|··············|·············|·············|···············|··············
|  ETHPool             ·  grantRole      ·       51994  ·      56971  ·      54485  ·            6  ·       1.27  │
·······················|·················|··············|·············|·············|···············|··············
|  ETHPool             ·  withdraw       ·       48932  ·      58599  ·      53806  ·           12  ·       1.25  │
·······················|·················|··············|·············|·············|···············|··············
|  ETHPoolUpgradeable  ·  withdrawTest   ·       52880  ·      62547  ·      57754  ·           12  ·       1.34  │
·······················|·················|··············|·············|·············|···············|··············
|  Deployments                           ·                                          ·  % of limit   ·             │
·········································|··············|·············|·············|···············|··············
|  ETHPool                               ·           -  ·          -  ·    1715286  ·        5.7 %  ·      39.89  │
·········································|··············|·············|·············|···············|··············
|  ETHPoolUpgradeable                    ·           -  ·          -  ·    2754134  ·        9.2 %  ·      64.04  │
@fabianorodrigo fabianorodrigo changed the title Project with 2 contracts, only 1 is shown Contracts with common function names: only one of them is shown in the results Jul 21, 2022
@cgewecke cgewecke mentioned this issue Jan 31, 2024
@cgewecke cgewecke mentioned this issue Feb 11, 2024
54 tasks
@cgewecke
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants