-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Component
Forge
Describe the feature you would like
Problem:
Currently, changes in .snapshot
do not necessarily reflect gas changes a developer cares about. Snapshots directly reflect the gas use of the test functions, and only indirectly reflect the gas used by the contract being tested.
If a developer changes a test and the contract being tested in the same diff, they lose signal in the .snapshot
as to the gas effect of their changes.
We see many developers solve this by creating super minimal tests with names like testXGas
so that they always have some indication of exclusively the changing gas use in the contract being tested.
In fact, for me personally, I generally only care about the snapshot of these functions. The gas snapshot of all the other functions is mostly just noise.
Proposed solution
A very useful tool is forge test --gas-report
it shows the gas use of each function in each contract! This is great, and could be super powered by (1) enabling writing this gas report to the snapshot (2) enabling passing arguments as to which contracts we exclusively want gas reports for.
The command might look something like
forge snapshot --gas-report --contracts MyContract
This command could run existing snapshot functionality and additionally write the gas report of the specified contracts to the end of the snapshot. Though, for me personally, if writing the gas-report to snapshot existed, I could do without the existing snapshot functionality entirely, I think. Possibly still nice for quickly checking gas of something, though.
Additional context
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status