-
Notifications
You must be signed in to change notification settings - Fork 66
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
Incosistent Gas Report Per Test. Caching? #77
Comments
@simondlr I think something is cacheing but if you're deploying within the Are you using Are you using any other plugins like hardhat-deploy? If so I think hh-deploy is smart about using deployed contracts when possible ... could be happening there. |
Hey @cgewecke! using evm_snapshot & custom deploy.
I believe that the revert is causing all kinds of problems. I did some more tests. beforeAll is only used to create a snapshot. In the following report, the snapshot is not saved. And then, if you are not doing revert in beforeEach, then all tests produce the same gas report.
But. If you add in a snapshot in beforeAll.
and then add the revert in beforeEach back in again, it throws the wonky gas reports.
Not sure where is the best next step to do more debugging. It doesn't make sense why the first test would be different here either. |
Ah ok, thanks. Will take a look and see if I can reproduce. |
There might be a simpler test here that replicates the issues, but it's not a big problem atm for me, so not prioritisting it. Let me know however if you need more samples or configurations. :) |
Hey. Trying to figure out why gas-report is showing inconsistent gas reporting per unit test. The averages box seems correct, but the gas reported per test seems off/wrong?
I'm using a hardhat node. 2.6.1
And secondly, using gas-reporter 1.0.4.
Example of quirk. This test uses 17m gas because it's deploying two contracts + doing some individual transactions.
✓ S: test claim by transferring OG id to another account after claimed. (17735020 gas)
If you copy the test, the second test shows a much smaller gas usage number.
✓ S: test claim by transferring OG id to another account after claimed. (17735008 gas)
✓ S: test claim by transferring OG id to another account after claimed. (24608 gas)
Here's the test. It mints an NFT and then allows an original holder to claim an NFT of a new project.
The only indication I can gather here is that because I'm reverting to a clean snapshot in between each test, that the contracts that end up being deployed have the same addresses.
So, maybe this revert process is tripping up gas reporting? Is it the hardhat node doing optimizations automatically (no idea what it could be), or is the gas reporter? It's not urgent since I'm more interested in the average numbers of function calls vs gas per test, which seems to be reporting appropriately.
Any thoughts?
The text was updated successfully, but these errors were encountered: