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

Add option to report view & pure method gas usage #92

Closed
cgewecke opened this issue Feb 4, 2022 · 7 comments
Closed

Add option to report view & pure method gas usage #92

cgewecke opened this issue Feb 4, 2022 · 7 comments

Comments

@cgewecke
Copy link
Owner

cgewecke commented Feb 4, 2022

We should be able to use estimateGas for these.

It impairs test speeds but this data is important for libraries.

(See prb-math 70)

@cameel
Copy link

cameel commented Feb 4, 2022

For the cases where speed is important you could add a toggle in the config to disable it (I think it should be enabled by default though).

@cgewecke
Copy link
Owner Author

cgewecke commented Feb 4, 2022

@cameel Do you think so?

I am inclined the other way because I've seen estimateGas really slow things down on Hardhat (by more than 2X which is what I would expect) and test suites make so many calls.

Definitely worth benchmarking on a large project.

@cameel
Copy link

cameel commented Feb 4, 2022

Ah, that's way more than I expected. If it really slows things down that much then yeah, it might make sense to keep if off by default.

BTW, let me know if you need help benchmarking it on some real-life projects. We have a nice setup in Solidity where we run a bunch of them (13+ mid to large projects, including OpenZeppelin, Uniswap v3, Gnosis, etc) in CI to test the compiler. As a part of this we can see a breakdown of how long each one took to run the whole test suite: https://app.circleci.com/pipelines/github/ethereum/solidity/22003/workflows/92d7ef3e-f94a-448c-9db1-16cc18d19e9a (all the t_native_test_ext_... jobs are such projects). The time includes compilation, dependency installation, etc. but on the upside it would also show how relevant the slowdown is compared to other factors.

@cgewecke
Copy link
Owner Author

cgewecke commented Feb 4, 2022

Oh fantastic, thank you @cameel

@sebastiantf
Copy link

Would be cool to have this!

@ItsNickBarry
Copy link

This would be very useful for SolidState.

@cgewecke cgewecke mentioned this issue Jan 11, 2024
@cgewecke cgewecke mentioned this issue Feb 11, 2024
54 tasks
@cgewecke
Copy link
Owner Author

This has been added in the latest release (2.0). The relevant options look like this

gasReporter: {
  // This option executes an additional `eth_estimateGas` for every `eth_call`
  // detected by the reporter. If you have 1000's of tests setting it to true has a
  // noticeable performance impact
  reportPureAndViewMethods: true,

  // This option can add several seconds to test startup time if you have
  // 100's of contracts in your project. (It parses all the sources in your dependency tree
  // to identify state variable declarations)
  excludeAutoGeneratedGetters: true,
}

https://github.com/cgewecke/hardhat-gas-reporter/releases/tag/v2.0.0

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

No branches or pull requests

4 participants