feat: add gas benchmarks to CI#170
Conversation
- Generated with forge snapshot - 158 test gas measurements - Baseline for tracking gas regressions
- make gas-snapshot: generate new snapshot - make gas-check: verify against baseline
- Runs after tests in contracts-unit-invariant job - Fails CI if gas usage increases significantly - Addresses #164
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Greptile SummaryThis PR adds a
Confidence Score: 5/5Safe to merge — the change is purely additive monitoring with no contract or production logic touched. The PR only adds a committed gas baseline, two Makefile targets, and a CI step that reads that baseline. No contract code, deployment scripts, or critical configuration is modified. The unrelated file removals (.nvmrc, pnpm-workspace.yaml) are safe: the lockfile has a single root importer with no workspace-protocol dependencies, and Node version management is already handled by .mise.toml. No files require special attention. The known non-determinism concern in contracts/.gas-snapshot (fuzz test mean varying across seeds) and the missing trailing newline were both raised in prior review threads. Important Files Changed
Sequence DiagramsequenceDiagram
participant CI as GitHub Actions
participant FT as forge test -vv
participant PL as make test-production-lock
participant GC as make gas-check
participant SN as .gas-snapshot
CI->>FT: Run deterministic test suite (all tests)
FT-->>CI: Pass / Fail
CI->>PL: Run production lock invariants
PL-->>CI: Pass / Fail
CI->>GC: "forge snapshot --check --snap .gas-snapshot --tolerance 2 --nmp test/{invariant,integration}/**"
GC->>SN: Read baseline measurements
SN-->>GC: 148 gas entries
GC->>GC: Re-run unit/e2e tests, measure gas
GC->>GC: Compare each test within 2% tolerance
GC-->>CI: Pass (within tolerance) / Fail (regression detected)
Reviews (4): Last reviewed commit: "docs: update CONTRIBUTING.md for mise-on..." | Re-trigger Greptile |
Gas usage varies slightly between local and CI environments. 300 gas difference (~0.06%) is acceptable variance. Increased tolerance from 1% to 2% to prevent false failures.
Invariant tests have non-deterministic gas usage due to fuzzing, causing CI failures. Exclude them from gas snapshots to track only deterministic unit/e2e test gas usage. - Update Makefile to use --nmp flag for invariant/integration exclusion - Regenerate .gas-snapshot with 147 measurements (was 159) - Gas check now stable across CI runs
- Remove .nvmrc: mise (.mise.toml) manages Node version - Remove pnpm-workspace.yaml: single-package project doesn't need it - Node version pinned to 22 in .mise.toml
…172) - Fix: Remove outdated .nvmrc reference in README (now using mise) - Fix: Update PoseidonT3.sol Solidity version from ^0.8.24 to ^0.8.25 - Docs: Update CHANGELOG with recent merged PRs (#170, #169, #168, #163) - Refactor: Move documentation to docs/ directory for better organization - Update README links to reflect new docs/ structure
…#173) * chore: fix typo, bug, update docs, and reorganize project structure - Fix: Remove outdated .nvmrc reference in README (now using mise) - Fix: Update PoseidonT3.sol Solidity version from ^0.8.24 to ^0.8.25 - Docs: Update CHANGELOG with recent merged PRs (#170, #169, #168, #163) - Refactor: Move documentation to docs/ directory for better organization - CONTRIBUTING.md -> docs/CONTRIBUTING.md - BRANCHING.md -> docs/BRANCHING.md - DEPLOYMENT.md -> docs/DEPLOYMENT.md - TROUBLESHOOTING.md -> docs/TROUBLESHOOTING.md - Copy THREAT_MODEL.md, KNOWN_ISSUES.md, ARCHITECTURE.md to docs/ - Update README links to reflect new docs/ structure * chore(contracts): set EVM version to paris for OP Stack compatibility - Add evm_version = "paris" to foundry.toml - Ensures bytecode compatibility with Optimism Superchain - Paris is the EVM version used by OP Mainnet and OP Sepolia - All 148 tests pass with Paris EVM * chore: update gas snapshot for paris EVM version Gas costs increased by ~3-5% after switching to paris EVM target. This is expected behavior for OP Stack compatibility.
…174) * chore: fix typo, bug, update docs, and reorganize project structure - Fix: Remove outdated .nvmrc reference in README (now using mise) - Fix: Update PoseidonT3.sol Solidity version from ^0.8.24 to ^0.8.25 - Docs: Update CHANGELOG with recent merged PRs (#170, #169, #168, #163) - Refactor: Move documentation to docs/ directory for better organization - CONTRIBUTING.md -> docs/CONTRIBUTING.md - BRANCHING.md -> docs/BRANCHING.md - DEPLOYMENT.md -> docs/DEPLOYMENT.md - TROUBLESHOOTING.md -> docs/TROUBLESHOOTING.md - Copy THREAT_MODEL.md, KNOWN_ISSUES.md, ARCHITECTURE.md to docs/ - Update README links to reflect new docs/ structure * chore(contracts): set EVM version to paris for OP Stack compatibility - Add evm_version = "paris" to foundry.toml - Ensures bytecode compatibility with Optimism Superchain - Paris is the EVM version used by OP Mainnet and OP Sepolia - All 148 tests pass with Paris EVM * refactor(deps): replace createx with direct openzeppelin dependency - Install OpenZeppelin v5.1.0 as direct git submodule - Remove createx dependency (only used for nested OZ) - Remove unused DeployUtils.sol library - Update remappings: @openzeppelin/=lib/openzeppelin-contracts/ - Consolidate all remappings to foundry.toml - Remove root remappings.txt to avoid conflicts - Add forge-std/ remapping for completeness - Clean forge cache and verify build Benefits: - Smaller dependency tree (3 deps instead of 4) - Direct control over OpenZeppelin version - No nested dependencies - Single source of truth for remappings Verified: - forge build: success - forge test: 159 tests passed * fix(docs): use consistent MAINNET_RPC variable in deployment guide Address CodeRabbit feedback: line 488 used generic $RPC instead of $MAINNET_RPC. Since this is in the Mainnet Deployment section and the previous line uses $MAINNET_RPC, update for consistency.
* feat: add initial gas snapshot baseline - Generated with forge snapshot - 158 test gas measurements - Baseline for tracking gas regressions * feat: add gas snapshot targets to Makefile - make gas-snapshot: generate new snapshot - make gas-check: verify against baseline * ci: add gas snapshot check to workflow - Runs after tests in contracts-unit-invariant job - Fails CI if gas usage increases significantly - Addresses #164 * fix: increase gas check tolerance to 2% Gas usage varies slightly between local and CI environments. 300 gas difference (~0.06%) is acceptable variance. Increased tolerance from 1% to 2% to prevent false failures. * fix: exclude invariant tests from gas snapshots Invariant tests have non-deterministic gas usage due to fuzzing, causing CI failures. Exclude them from gas snapshots to track only deterministic unit/e2e test gas usage. - Update Makefile to use --nmp flag for invariant/integration exclusion - Regenerate .gas-snapshot with 147 measurements (was 159) - Gas check now stable across CI runs * chore: remove .nvmrc and pnpm-workspace.yaml - Remove .nvmrc: mise (.mise.toml) manages Node version - Remove pnpm-workspace.yaml: single-package project doesn't need it - Node version pinned to 22 in .mise.toml * docs: update CONTRIBUTING.md for mise-only setup
…172) - Fix: Remove outdated .nvmrc reference in README (now using mise) - Fix: Update PoseidonT3.sol Solidity version from ^0.8.24 to ^0.8.25 - Docs: Update CHANGELOG with recent merged PRs (#170, #169, #168, #163) - Refactor: Move documentation to docs/ directory for better organization - Update README links to reflect new docs/ structure
…#173) * chore: fix typo, bug, update docs, and reorganize project structure - Fix: Remove outdated .nvmrc reference in README (now using mise) - Fix: Update PoseidonT3.sol Solidity version from ^0.8.24 to ^0.8.25 - Docs: Update CHANGELOG with recent merged PRs (#170, #169, #168, #163) - Refactor: Move documentation to docs/ directory for better organization - CONTRIBUTING.md -> docs/CONTRIBUTING.md - BRANCHING.md -> docs/BRANCHING.md - DEPLOYMENT.md -> docs/DEPLOYMENT.md - TROUBLESHOOTING.md -> docs/TROUBLESHOOTING.md - Copy THREAT_MODEL.md, KNOWN_ISSUES.md, ARCHITECTURE.md to docs/ - Update README links to reflect new docs/ structure * chore(contracts): set EVM version to paris for OP Stack compatibility - Add evm_version = "paris" to foundry.toml - Ensures bytecode compatibility with Optimism Superchain - Paris is the EVM version used by OP Mainnet and OP Sepolia - All 148 tests pass with Paris EVM * chore: update gas snapshot for paris EVM version Gas costs increased by ~3-5% after switching to paris EVM target. This is expected behavior for OP Stack compatibility.
…174) * chore: fix typo, bug, update docs, and reorganize project structure - Fix: Remove outdated .nvmrc reference in README (now using mise) - Fix: Update PoseidonT3.sol Solidity version from ^0.8.24 to ^0.8.25 - Docs: Update CHANGELOG with recent merged PRs (#170, #169, #168, #163) - Refactor: Move documentation to docs/ directory for better organization - CONTRIBUTING.md -> docs/CONTRIBUTING.md - BRANCHING.md -> docs/BRANCHING.md - DEPLOYMENT.md -> docs/DEPLOYMENT.md - TROUBLESHOOTING.md -> docs/TROUBLESHOOTING.md - Copy THREAT_MODEL.md, KNOWN_ISSUES.md, ARCHITECTURE.md to docs/ - Update README links to reflect new docs/ structure * chore(contracts): set EVM version to paris for OP Stack compatibility - Add evm_version = "paris" to foundry.toml - Ensures bytecode compatibility with Optimism Superchain - Paris is the EVM version used by OP Mainnet and OP Sepolia - All 148 tests pass with Paris EVM * refactor(deps): replace createx with direct openzeppelin dependency - Install OpenZeppelin v5.1.0 as direct git submodule - Remove createx dependency (only used for nested OZ) - Remove unused DeployUtils.sol library - Update remappings: @openzeppelin/=lib/openzeppelin-contracts/ - Consolidate all remappings to foundry.toml - Remove root remappings.txt to avoid conflicts - Add forge-std/ remapping for completeness - Clean forge cache and verify build Benefits: - Smaller dependency tree (3 deps instead of 4) - Direct control over OpenZeppelin version - No nested dependencies - Single source of truth for remappings Verified: - forge build: success - forge test: 159 tests passed * fix(docs): use consistent MAINNET_RPC variable in deployment guide Address CodeRabbit feedback: line 488 used generic $RPC instead of $MAINNET_RPC. Since this is in the Mainnet Deployment section and the previous line uses $MAINNET_RPC, update for consistency.
Summary
Adds gas snapshot tracking to catch gas regressions early.
Changes
make gas-snapshot: generate new snapshotmake gas-check: verify against baselineBenefits
Verification
Risk
Low - adds monitoring only, no code changes.
Related