dapptools icon indicating copy to clipboard operation
dapptools copied to clipboard

Gas snapshotting

Open transmissions11 opened this issue 4 years ago • 3 comments

Writing this down so I don't forget. Could implement this hardhat gas snapshotting pattern pretty easily by:

  • Adding a dapp snapshot command that runs dapp test and searches through the output for (gas: XXXXX), then stores the results in a .dappshots file (unless overriden via an env var/flag) with each test's gas usage tied to its name

  • Adding a dapp check-snapshot command that runs dapp snapshot (but outputs to a temp file instead of .dappshots) and compares it with .dappshots. If they don't match the command exits with an error.

transmissions11 avatar Sep 05 '21 02:09 transmissions11

ideally don't run non-concrete tests (tests prefixed with prove/invariant and standard test prefixed functions with arguments) during dapp snapshot or else things could take a while

transmissions11 avatar Oct 01 '21 20:10 transmissions11

i feel like it could make sense to add a flag for doing a "quick" run in the general case, that skips the above specified longer running tests, that we could then leverage here...wdyt

jennypollack avatar Oct 01 '21 21:10 jennypollack

would be epic.

this is some wishlist shit but would love an env var like DAPP_TEST_MODE that could be set to 1 or 2 (0/unset would just trigger the current behavior). In mode 1 it runs all prove tests as fuzz tests for people to quickly run their whole suite and make sure there's no low hanging fruit. In mode 2 it would do what we discussed above and ignore all non-concrete tests entirely.

transmissions11 avatar Oct 01 '21 21:10 transmissions11