Skip to content

ci: add gas report workflow with baseline comparison#518

Open
jonaprieto wants to merge 1 commit into
mainfrom
jonaprieto/gas-artifacts
Open

ci: add gas report workflow with baseline comparison#518
jonaprieto wants to merge 1 commit into
mainfrom
jonaprieto/gas-artifacts

Conversation

@jonaprieto
Copy link
Copy Markdown
Contributor

@jonaprieto jonaprieto commented Apr 14, 2026

Move gas reporting into a dedicated gas-report.yml workflow, keeping the contracts CI lean. The new workflow provides gas snapshot, per-function gas report, contract sizes (with EVM 24KB limit warnings), and a baseline diff vs. main on every PR. The baseline is cached on each main merge and PRs automatically compare against it, surfacing regressions with delta and percentage inline in a sticky PR comment.

@jonaprieto jonaprieto added the ci CI/CD pipeline changes label Apr 14, 2026
@jonaprieto jonaprieto self-assigned this Apr 14, 2026
@jonaprieto jonaprieto force-pushed the jonaprieto/gas-artifacts branch 2 times, most recently from 7c08ac4 to 74ed534 Compare April 14, 2026 02:12
@jonaprieto
Copy link
Copy Markdown
Contributor Author

CI is green and artifacts are live. Here's the first run producing them:

https://github.com/anoma/pa-evm/actions/runs/24377241026

The gas-report artifact contains both a .gas-snapshot (per-test gas costs) and a gas-report.txt (per-function breakdown for all Benchmark contracts). Artifacts are retained for 30 days and labeled with the branch and commit SHA for easy comparison across PRs.

@jonaprieto jonaprieto requested a review from heueristik April 14, 2026 03:03
@jonaprieto jonaprieto force-pushed the jonaprieto/gas-artifacts branch from 74ed534 to 7dc6525 Compare April 14, 2026 03:15
@jonaprieto jonaprieto marked this pull request as ready for review April 14, 2026 16:06
@jonaprieto jonaprieto force-pushed the jonaprieto/gas-artifacts branch from 7dc6525 to 377f645 Compare April 15, 2026 16:43
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 15, 2026

Gas Report

Total benchmark gas: 202,096,997 — no baseline yet, diff available after first merge to main

Gas Snapshot — per-test gas consumption
Test Gas
Benchmark:test_aggregated_proof_gas_cost_is_fixed 32,870,549
Benchmark:test_empty_transaction_gas_cost_is_fixed 33,460
Benchmark:test_execute_00 20,116
Benchmark:test_execute_01_01_agg 694,584
Benchmark:test_execute_01_01_reg 1,185,130
Benchmark:test_execute_02_02_agg 1,662,585
Benchmark:test_execute_02_02_reg 4,361,352
Benchmark:test_execute_05_01_agg 1,991,226
Benchmark:test_execute_05_01_reg 5,424,650
Benchmark:test_execute_10_01_agg 3,636,485
Benchmark:test_execute_10_01_reg 10,709,124
Benchmark:test_execute_15_01_agg 5,343,708
Benchmark:test_execute_15_01_reg 15,974,733
Benchmark:test_execute_20_01_agg 7,217,976
Benchmark:test_execute_20_01_reg 21,276,208
Benchmark:test_print_calldata_agg 8,257,151
Benchmark:test_print_calldata_reg 11,436,231
Benchmark:test_regular_proof_gas_cost_is_bound 70,001,729
Gas Report — per-function statistics
╭--------------------------------------------------+-----------------+---------+---------+----------+---------╮
| src/ProtocolAdapter.sol:ProtocolAdapter Contract |                 |         |         |          |         |
+=============================================================================================================+
| Deployment Cost                                  | Deployment Size |         |         |          |         |
|--------------------------------------------------+-----------------+---------+---------+----------+---------|
| 10327775                                         | 21324           |         |         |          |         |
|--------------------------------------------------+-----------------+---------+---------+----------+---------|
|                                                  |                 |         |         |          |         |
|--------------------------------------------------+-----------------+---------+---------+----------+---------|
| Function Name                                    | Min             | Avg     | Median  | Max      | # Calls |
|--------------------------------------------------+-----------------+---------+---------+----------+---------|
| execute                                          | 29815           | 4873847 | 3483778 | 17879605 | 13      |
|--------------------------------------------------+-----------------+---------+---------+----------+---------|
| simulateExecute                                  | 29878           | 3347417 | 2110267 | 17879673 | 26      |
╰--------------------------------------------------+-----------------+---------+---------+----------+---------╯
Contract Sizes — EVM bytecode size (24,576 B limit)
Contract Runtime (B) Initcode (B) Margin (B)
BlockTimeForwarder 531 557 24,045
CommitmentTree 521 1,068 24,055
ControlID 213 241 24,363
Groth16Verifier 1,728 1,754 22,848
NullifierSet 347 373 24,229
ProtocolAdapter 20,137 21,228 4,439
RiscZeroGroth16Verifier 5,300 8,607 19,276
RiscZeroVerifierEmergencyStop 2,364 2,642 22,212
RiscZeroVerifierRouter 2,778 2,996 21,798
SHA256 119 147 24,457
VersioningLibExternal 123 147 24,453

Generated by CI — commit 8398d0e — 2026-04-15 20:06 UTC

Copy link
Copy Markdown
Collaborator

@heueristik heueristik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very cool! Can we add it into a separate workflow so that the complexity and runtime of the contracts test workflow is not increased?

@jonaprieto jonaprieto force-pushed the jonaprieto/gas-artifacts branch from 377f645 to b06fae8 Compare April 15, 2026 17:36
@jonaprieto jonaprieto changed the title ci: add gas consumption artifacts ci: add gas report workflow with baseline comparison Apr 15, 2026
heueristik
heueristik previously approved these changes Apr 15, 2026
Move gas reporting into a dedicated gas-report.yml workflow, keeping the
contracts CI lean. The new workflow provides:

- Gas snapshot and per-function gas report
- Contract sizes with EVM 24KB limit margin
- Baseline caching on main push via actions/cache
- Automatic diff vs. main on every PR (delta + percentage)
- Sticky PR comment updated on each push
- Artifacts uploaded with 30-day retention

On the first merge to main the baseline is seeded. Every subsequent PR
compares against it and surfaces regressions inline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI/CD pipeline changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants