Price data missing from report
See original GitHub issueI just finished integrating hardhat-gas-reporter
into a new Advanced Sample Project that can be generated by the project initialization feature of the hardhat
command-line interface. See https://github.com/nomiclabs/hardhat/pull/1632
However, I could not get the price data to show in the output. Re-posting from a comment on that PR:
- Running with eth gas reporter doesnโt show anything in the USD column. Why does this happen? Maybe some missing config? Can we maybe remove it / use ETH?
I spent an hour trying to figure this out. I couldnโt get it to work.
I tried removing the currency from the config, and that made it default to EUR, but it still didnโt have any price data. I also tried changing the config to
currency: "ETH"
, but that didnโt result in any meaningful data either. I also tried getting a CoinMarketCap API key and plugging it into the config, but that didnโt help either.
I even went in and debugged
eth-gas-station
, adding aconsole.log()
statements to just before the call to coinmarketcap and just after. The one just before showed that the URL it was hitting was just fine (I pulled the url viacurl
and the data looks fine/legit to me (no error conditions or anything, and expected object fields seem fine)), but theconsole.log()
statement just after the CMC call never gets executed, and I gave up on trying to figure out why.
For easy reference:
- the config in use: https://github.com/nomiclabs/hardhat/blob/master/packages/hardhat-core/sample-projects/advanced/hardhat.config.js#L36
- results from the CI run: https://github.com/nomiclabs/hardhat/runs/3313026188#step:6:831
And hereโs a paste of the output Iโm seeing:
ยท----------------------------|----------------------------|-------------|-----------------------------ยท
| Solc version: 0.8.4 ยท Optimizer enabled: false ยท Runs: 200 ยท Block limit: 30000000 gas โ
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Methods โ
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Contract ยท Method ยท Min ยท Max ยท Avg ยท # calls ยท usd (avg) โ
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Greeter ยท setGreeting ยท - ยท - ยท 35426 ยท 2 ยท - โ
ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Deployments ยท ยท % of limit ยท โ
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท|ยทยทยทยทยทยทยทยทยทยทยทยทยทยท
| Greeter ยท - ยท - ยท 497002 ยท 1.7 % ยท - โ
ยท----------------------------|--------------|-------------|-------------|---------------|-------------ยท
Reproducing would be easy if you checked out and built the hardhat monorepo and then in an empty folder did yarn init --yes && yarn add --file:/path/to/monorepo/packages/hardhat-core && yarn hardhat
and selected โadvanced projectโ and then did REPORT_GAS=true yarn hardhat test
. And it would be even easier than that if you were to wait until this functionality is officially released.
Please let me know if this is my error or if Iโm having the wrong expectations.
Thank you!
Issue Analytics
- State:
- Created 2 years ago
- Comments:24 (10 by maintainers)
Top GitHub Comments
@kazazor I think youโll need to get your own free-tier coinmarketcap api key, here and set the option in your config:
The limit on the shared key is not per plugin user but rather for all users of the plugin. Itโs rate limited almost instantly now that the package is widely used โฆ you have to have your own credentials for price reporting to work unfortunately.
Just lmk if doing that doesnโt work and I will re-open this issue and investigate.
@feuGeneA
I think you could get price data by introducing a small delay in your โinternalโ hh test here.
But ultimately the problem is a race-condition in eth-gas-reporter and the sync-ness of mochaโs third-party reporter api. This race-condition shouldnโt affect most people though - their test suites typically run longer than the latency of the CMC request.
To fix I will need to fetch the price in
TASK_TEST_RUN_MOCHA_TESTS
here (where async is supported) and create a configuration option at eth-gas-reporter for this data.Sorry about thisโฆIโm sure it was annoying to debug ๐