Description
Soroban has per-operation gas costs that affect user fees. Currently there are no benchmarks measuring gas consumption for each entrypoint. A gas cost regression would let developers see if a PR increases user costs. This is critical for maintaining affordable contract interaction.
Requirements and context
- Security: Standard security review required for state-mutating changes
- Testing: Full test suite must pass; new tests for changed behavior
- Documentation: Update doc comments and README if user-facing
Suggested execution
Branch: fix/feat/test-gas-benchmarks
Implement changes
- Create a benches/contract_bench.rs file using Soroban's test infrastructure
- Add benchmark functions for: init (1 and 10 milestones), lock_funds, submit_work, approve_and_release, raise_dispute, resolve_dispute
- Print gas costs in a machine-parseable format (JSON) for CI comparison
- Add a CI step that compares gas costs against the baseline and warns on >10% increase
Test and commit
Run benchmarks and record baseline gas costs. Verify the benchmark output is parseable. Make a small change and verify the diff is detected.
Example commit message
feat(test): add Soroban gas cost benchmarks for all 8 contract entrypoints
Guidelines
- Open a PR against
master
- Keep PR focused on this single concern
- Run
cargo test or npm test before review
- Ensure no lint or typecheck warnings
Description
Soroban has per-operation gas costs that affect user fees. Currently there are no benchmarks measuring gas consumption for each entrypoint. A gas cost regression would let developers see if a PR increases user costs. This is critical for maintaining affordable contract interaction.
Requirements and context
Suggested execution
Branch:
fix/feat/test-gas-benchmarksImplement changes
Test and commit
Run benchmarks and record baseline gas costs. Verify the benchmark output is parseable. Make a small change and verify the diff is detected.
Example commit message
Guidelines
mastercargo testornpm testbefore review