This directory stores gas benchmark baselines per branch. Baselines are used to detect gas regressions in pull requests before deployment.
Baseline files follow the naming convention:
{branch}-gas-baseline.json
Examples:
main-gas-baseline.json— Gas benchmark baseline for main branchdevelop-gas-baseline.json— Gas benchmark baseline for develop branch
- Gas benchmarks run
- Results are saved as baseline for the current branch
- Baseline is committed and pushed to the repository
- Gas benchmarks run against the PR code
- Results are compared against the baseline from the target branch (usually
main) - If any benchmark regresses by more than the threshold (default 10%), the check fails
- A benchmark report is posted to the PR with details
Default threshold: 10%
Benchmarks tracked:
- Single Winner (Max Outcomes) — Gas estimate for resolving with 1 winner at max outcomes
- Max Push Winners (Max Outcomes) — Gas estimate for resolving with MAX_PUSH_PAYOUT_WINNERS winners
- Pull Mode Triggered — Gas estimate when pull mode is triggered (>MAX_PUSH_PAYOUT_WINNERS winners)
To manually update baselines for a branch:
cd contracts/predict-iq
node scripts/compare-gas-benchmarks.js --save-baseline --branch mainThis will save all current gas estimates as baselines for the specified branch.
To compare results against a different branch's baseline:
cd contracts/predict-iq
node scripts/compare-gas-benchmarks.js --branch develop --threshold 15This compares against the develop branch baseline with a 15% threshold.
Baseline files are JSON snapshots of gas estimates and include:
- Gas estimates for each benchmark
- Branch name
- Timestamp of when the baseline was created
They are committed to the repository to ensure consistent regression detection across CI runs.
The gas estimate for payout operations follows this formula:
gas_estimate = 100_000 + (winner_count * 50_000)
Where:
100_000is the base costwinner_countis the number of winners50_000is the per-winner cost
- 1 winner: 100,000 + (1 × 50,000) = 150,000 instructions
- 10 winners: 100,000 + (10 × 50,000) = 600,000 instructions
- 50 winners (MAX_PUSH_PAYOUT_WINNERS): 100,000 + (50 × 50,000) = 2,600,000 instructions
Gas benchmarks are run on every PR and compared against the main branch baseline. If a regression is detected:
- The CI check fails
- A detailed report is posted to the PR comment
- The PR cannot be merged until the regression is resolved
This ensures gas efficiency is maintained across all contract changes.