Description
QuickLendX exposes dozens of #[contractimpl] entrypoints in src/lib.rs (e.g. store_invoice, place_bid, accept_bid_and_fund, process_partial_payment, settle_invoice, distribute_revenue). Today there is no per-entrypoint Soroban CPU-instruction baseline checked into the repo, so silent gas regressions can slip through. This issue introduces a baseline table of (entrypoint, scenario) -> max_instructions/read_bytes/write_bytes captured via env.cost_estimate() / BudgetSnapshot, persisted in scripts/gas-baseline.toml, and enforced by a CI test that fails when any scenario exceeds the baseline by more than a configurable tolerance (default 3%).
Requirements and context
- Secure: ensure budget probes do not change protocol behaviour or skip
require_auth.
- Tested: at least one baseline scenario per entrypoint listed in
lib.rs #[contractimpl].
- Documented:
docs/gas-baselines.md explaining how to refresh baselines and review diffs.
- Reference modules:
src/lib.rs, src/escrow.rs, src/settlement.rs, src/bid.rs, src/profits.rs.
Suggested execution
git checkout -b feature/gas-regression-baselines
- Add
src/bench.rs helper exposing measure(env, label, || { ... }) that records Budget deltas.
- Modify
src/lib.rs only via #[cfg(test)] instrumentation (no behaviour change).
- Persist baselines in
scripts/gas-baseline.toml; add scripts/update-gas-baseline.sh.
- Tests in
tests/gas_regression.rs iterate scenarios and assert deltas within tolerance.
- Docs:
docs/gas-baselines.md with run/update workflow.
- Use Rust doc
/// NatSpec-style comments on the bench helpers.
- Validate that the bench harness cannot bypass
require_auth or pause checks.
Test and commit
Run cargo test --test gas_regression -- --nocapture and capture output. Cover edge cases: paused-state rejection paths, error paths, and the largest realistic invoice. Include a security note that baselines are non-load-bearing for correctness.
Example commit message
test(gas): add per-entrypoint Soroban instruction-budget regression baselines
Guidelines
- Minimum 95% test coverage
- Clear documentation in
docs/gas-baselines.md
- Timeframe: 96 hours
Description
QuickLendX exposes dozens of
#[contractimpl]entrypoints insrc/lib.rs(e.g.store_invoice,place_bid,accept_bid_and_fund,process_partial_payment,settle_invoice,distribute_revenue). Today there is no per-entrypoint Soroban CPU-instruction baseline checked into the repo, so silent gas regressions can slip through. This issue introduces a baseline table of(entrypoint, scenario) -> max_instructions/read_bytes/write_bytescaptured viaenv.cost_estimate()/BudgetSnapshot, persisted inscripts/gas-baseline.toml, and enforced by a CI test that fails when any scenario exceeds the baseline by more than a configurable tolerance (default 3%).Requirements and context
require_auth.lib.rs#[contractimpl].docs/gas-baselines.mdexplaining how to refresh baselines and review diffs.src/lib.rs,src/escrow.rs,src/settlement.rs,src/bid.rs,src/profits.rs.Suggested execution
git checkout -b feature/gas-regression-baselinessrc/bench.rshelper exposingmeasure(env, label, || { ... })that recordsBudgetdeltas.src/lib.rsonly via#[cfg(test)]instrumentation (no behaviour change).scripts/gas-baseline.toml; addscripts/update-gas-baseline.sh.tests/gas_regression.rsiterate scenarios and assert deltas within tolerance.docs/gas-baselines.mdwith run/update workflow.///NatSpec-style comments on the bench helpers.require_author pause checks.Test and commit
Run
cargo test --test gas_regression -- --nocaptureand capture output. Cover edge cases: paused-state rejection paths, error paths, and the largest realistic invoice. Include a security note that baselines are non-load-bearing for correctness.Example commit message
test(gas): add per-entrypoint Soroban instruction-budget regression baselinesGuidelines
docs/gas-baselines.md