-
Notifications
You must be signed in to change notification settings - Fork 333
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
feat: gas reports and snapshots #12724
Conversation
allow tolerance in snapshot check.
6c6fe5c
to
7385dab
Compare
l1-contracts/test/MultiProof.t.sol
Outdated
@@ -90,6 +89,11 @@ contract MultiProofTest is RollupBase { | |||
) | |||
) | |||
); | |||
// skip blob check if forge gas report is true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the rollup.t.sol are both pulling from the rollup base. We could instead have a value that is written in the constructor or so to set it up neatly across all of them and not having multiple places needing to go look for env vars? Could also mean that this value is just set in that one place and not even needed in the others which seems nice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An extra reason for this is that it would be inherited 👀 so we would avoid an issue as just encountered hehe where the ignition ones are using the blobs so it fails because not updated.
l1-contracts/README.md
Outdated
|
||
When your PR is ready for review, run `./bootstrap.sh snapshot` to update the snapshot, then `./bootstrap.sh test` to make sure you're good. | ||
|
||
You can also run `./bootstrap.sh gas_report` to get a gas report for the current state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think it would be fine to mention the FORGE_GAS_REPORT
here. Also we should just have a general note that a bunch of the blob logic is skipped in the gas reports so they are not exact
l1-contracts/README.md
Outdated
@@ -31,6 +32,16 @@ We use `forge fmt` to format. But follow a few general guidelines beyond the sta | |||
- Do `function transfer(address _to, uint256 _amount);` | |||
- use `_` prefix for `internal` and `private` functions. | |||
|
|||
## Gas snapshots and CI | |||
|
|||
CI will run `forge snapshot --check`. This means that as you develop, you should run `./bootstrap.sh snapshot --diff` to make sure you understand the gas cost of your changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure how much I would care about the gas spent on tests, but more the gas spent on the functions in the contracts. e.g., a test spending 15M gas is not super important for me, but if it is a function that we use that is spending 15M gas that is something that is important
l1-contracts/bootstrap.sh
Outdated
echo "$hash cd l1-contracts && forge test --no-match-contract UniswapPortalTest" | ||
# Test the things that fail with --gas-report (due to forge issues) separately | ||
# need to chain these together, otherwise we get a "bus error (core dumped)" occasionally. | ||
echo "$hash cd l1-contracts && forge test --match-test \"(testInvalidBlobHash)|(testInvalidBlobProof)\" && forge test --match-contract \"(FeeRollupTest)|(MinimalFeeModelTest)\" && ./bootstrap.sh gas_report check" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this way of doing it is too convoluted and easy to mess up such that we are not running a bunch of tests.
Also we know that gas-report and test don't behave the same so i would not tempt fate.
Can you run test and then afterwards doing the gas report instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the gas report should also run with isolate and force a rebuild to make sure that you got the matching things, otherwise I would expect the diff to mess you up sometimes (it does in this pr actually)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but we then need to pull it out of here and not run through the parallelize
edit: nevermind- I misunderstood your rebuild comment.
l1-contracts/foundry.toml
Outdated
|
||
[fuzz] | ||
seed = "0000000000000000000000000000000000000000000000000000000000000042" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we would generally do that, was thinking only for the gas reporting to not have the checks and such be messed up.
Generally think it is nice for tests and such that seed is not static, sometimes new things come up because of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I didn't see that you could specify --fuzz-seed. Yes for sure. This made me nervous too.
@@ -204,7 +204,14 @@ contract RollupBase is DecoderBase { | |||
blobHash := mload(add(blobInputs, 0x21)) | |||
} | |||
blobHashes[0] = blobHash; | |||
vm.blobhashes(blobHashes); | |||
// https://github.com/foundry-rs/foundry/issues/10074 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🫡
88401df
to
f7cf45b
Compare
6901067
to
a3d5df5
Compare
a3d5df5
to
c3e5e47
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid stuff 🫡
* master: fix: filter for empty attestations when pulling from block (#12740) feat: one-way noir sync (#12592) feat(avm): Address derivation gadget (#12721) chore(ci): add workflow dispatch to masternet (#12739) feat: add default accounts (#12734) feat: gas reports and snapshots (#12724) fix(avm): fix vm1 fake proof size (#12733) feat(bb): extend_edges optimization for zero values past end_index (#12703) fix: remove hard coding of constructor for account manager (#12678) git subrepo push --branch=master noir-projects/aztec-nr git_subrepo.sh: Fix parent in .gitrepo file. [skip ci] chore: replace relative paths to noir-protocol-circuits git subrepo push --branch=master barretenberg fix: verify_honk_proof inputs generation in bootstrap (#12457) fix: Patches to cycle_group and cycle_group fuzzer (#12385)
Skips the uniswap test in ci again as we deleted that part by mistake in #12724
Gas Reports
You can run
./bootstrap.sh gas_report
to generate a detailed gas report for the current state and update the gas_report.md file.When running CI or tests with
./bootstrap.sh test
, the script will automatically check if gas usage has changed by running./bootstrap.sh gas_report check
. If gas usage has changed, the test will fail and show a diff of the changes.If the changes in gas usage are expected and desired:
./bootstrap.sh gas_report
to update the gas report fileNOTE: Our gas reporting excludes certain tests due to Forge limitations:
This is related to this Foundry issue.
This means that we don't report gas for blob validation (currently 50k gas per blob, and we use 3 blobs per propose in production).
If you want to run gas reports directly with
forge
, you must use the environment variableFORGE_GAS_REPORT=true
instead of the--gas-report
flag. The./bootstrap.sh gas_report
command does this for you automatically.