Skip to content

Gas snapshotting wishlist #137

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
6 of 8 tasks
transmissions11 opened this issue Nov 17, 2021 · 9 comments
Closed
6 of 8 tasks

Gas snapshotting wishlist #137

transmissions11 opened this issue Nov 17, 2021 · 9 comments
Labels
A-gas-snapshots Area: gas snapshotting/reporting C-forge Command: forge T-feature Type: feature

Comments

@transmissions11
Copy link
Contributor

transmissions11 commented Nov 17, 2021

  • Account for gas refunds! OG tools does not right now.

  • Don't include test call overhead in gas snapshots. OG tools includes some of the overhead rn:

Screen Shot 2021-11-16 at 4 42 42 PM

Screen Shot 2021-11-16 at 4 42 21 PM

  • - --diff flag that shows how much gas usage changed from the last snapshot

    • Summarizes % change of aggregated gas usage across all test funcs
    • Leaderboard for which tests' gas usage changed the most (by %).
      • Show gas units diff and % diff
  • - Gas snapshots for fuzz tests

    • Median & mean
    • Gas usage per range of inputs like:
testAddThatExitsEarlyOnLargeNumbers(100-500) = ~5000 gas
testAddThatExitsEarlyOnLargeNumbers(500+) = ~100 gas
  • Breakdown of not only gas usage of tests but gas usage of functions the tests call like hardhat-gas-reporter

image

related: dapphub/dapptools#761

  • flamegraphs like tenderly

image

@transmissions11 transmissions11 changed the title Gas snapshotting Gas snapshotting wishlist Nov 17, 2021
@lucas-manuel
Copy link

Whats left on this? Table formatting?

@wilsoncusack
Copy link
Contributor

I don't think any of this is done except gas for fuzzed tests?

@mds1
Copy link
Collaborator

mds1 commented Dec 27, 2021

Breakdown of not only gas usage of tests but gas usage of functions the tests call like hardhat-gas-reporter

This one is arguably implemented as you can see gas usage by function in traces, as in #192 (comment), but a report/snapshots showing this would be nice to have

Also I think flamegraphs should be added to this list, below is Tenderly's for reference

image

@transmissions11 might be worth adding some checkboxes and editing it to link out to PRs once implemented. Mean and median gas on fuzz tests was added in #236

@transmissions11
Copy link
Contributor Author

@transmissions11 might be worth adding some checkboxes and editing it to link out to PRs once implemented. Mean and median gas on fuzz tests was added in #236

good idea, done. also added flamegraphs

@onbjerg onbjerg added T-feature Type: feature C-forge Command: forge A-gas-snapshots Area: gas snapshotting/reporting labels Jan 19, 2022
@onbjerg onbjerg added this to Foundry Apr 17, 2022
@onbjerg onbjerg moved this to Todo in Foundry Apr 17, 2022
@onbjerg
Copy link
Collaborator

onbjerg commented Jun 21, 2022

Backref #1795

@OliverNChalk
Copy link
Contributor

Just wanted to sanity check the forge snapshot --diff feature. Here is what I currently use, it's:

forge snapshot && git diff --word-diff .gas-snapshot
image

Here's what forge snapshot --diff produces:
image

It looks like the gas diff per case is computed as: case_change / total_gas_previous which seems off, I would have expected it to be: case_change / case_previous.

I would also argue that showing before, after, delta is helpful but that may just be personal preference

@wdv4758h
Copy link

wdv4758h commented Jul 1, 2022

Is there a place to show Deployment Cost diff right now?
Not sure if this is in the snapshot scope, but I will be happy if it's in snapshot diff.
I've been working to cut the contract size, tracking the size in snapshot helps.

@lucas-manuel
Copy link

Close-able? @mds1

@mds1
Copy link
Collaborator

mds1 commented May 18, 2023

Closing in favor of #2056

@mds1 mds1 closed this as completed May 18, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry May 18, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-gas-snapshots Area: gas snapshotting/reporting C-forge Command: forge T-feature Type: feature
Projects
Archived in project
Development

No branches or pull requests

8 participants