hardhat-gas-reporter icon indicating copy to clipboard operation
hardhat-gas-reporter copied to clipboard

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

Open fabianorodrigo opened this issue 1 year ago • 0 comments

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 avatar Jul 21 '22 22:07 fabianorodrigo