Skip to content

feat(#149): add resource ceiling assertions to bench harnesses - #453

Open
Keengfk wants to merge 1 commit into
stellar-vortex-protocol:mainfrom
Keengfk:feat/149-resource-ceiling-assertions
Open

Keengfk wants to merge 1 commit into
stellar-vortex-protocol:mainfrom
Keengfk:feat/149-resource-ceiling-assertions

Conversation

@Keengfk

@Keengfk Keengfk commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

feat(#149): add resource ceiling assertions to bench harnesses

Summary

Adds hard CPU and memory budget ceilings to every public entrypoint in
intent_settlement and solver_registry. A test fails immediately in CI whenever
a code change causes an entrypoint to exceed its ceiling, making silent
resource regressions impossible.

What changed

intent_settlement/src/bench.rs (rewritten)

  • Ceiling constants (CPU_CEIL_* / MEM_CEIL_*) for all 12 single-call
    entrypoints: submit_intent, accept_intent, fill_intent (full + partial),
    cancel_intent, expire_intent, slash_solver, request_extension, register_solver
    (first + top-up), withdraw_bond, deregister_solver
  • Worst-case batch ceilings for batch_submit_intent, batch_accept_intent,
    batch_fill_intent, batch_cancel_intent at MAX_BATCH_SIZE = 20
  • One bench_ceiling_* test per entrypoint using an assert_within_ceiling helper
  • Existing resource_cost_report and resource_cost_is_reproducible tests
    retained unchanged

solver_registry/src/bench.rs (new file)

  • Full bench harness matching the intent_settlement pattern
  • Ceiling assertions for all 22 public entrypoints: initialize, set_writer,
    set_tier_threshold, register_solver, stake, unstake, deregister_solver,
    record_fill, record_failure, slash, get_tier, tier_for, get_reputation_score,
    get_solver, get_solver_count, get_tier_table, get_fill_window_bonus_pct,
    get_slash_bps, get_fee_rebate_bps, get_admin, get_bond_token,
    compute_reputation_score
  • resource_cost_report and resource_cost_is_reproducible smoke tests included

solver_registry/src/lib.rs

  • Added #[cfg(test)] mod bench; module declaration

Methodology

Ceilings are set at baseline + 10% (rounded up to the nearest 1 000). Baselines
for intent_settlement come from the existing
docs/149-resource-cost-per-entrypoint.md snapshot (soroban-sdk 21.7.7).
Baselines for solver_registry are first-capture values at the same SDK version.

To update ceilings after a deliberate cost change:

  1. Run cargo test --features testutils bench::resource_cost_report --
    --nocapture to get new measured values
  2. Set CPU_CEIL_* / MEM_CEIL_* to new_value * 110 / 100
  3. Update docs/149-*.md with the new baseline

Out of scope

Cost optimisation is tracked separately. This PR only adds the guard rails.
closes #423

… bench harnesses

Add worst-case CPU/memory ceiling assertions (10% headroom) for every
public entrypoint in intent_settlement and solver_registry.

intent_settlement/src/bench.rs:
- Ceiling constants for all 12 single entrypoints (submit, accept,
  fill full/partial, cancel, expire, slash, request_extension,
  register_solver x2, withdraw_bond, deregister_solver)
- Worst-case batch ceilings for batch_submit/accept/fill/cancel at
  MAX_BATCH_SIZE=20
- bench_ceiling_* test per entrypoint; assert_within_ceiling helper
- Existing resource_cost_report and resource_cost_is_reproducible
  tests retained unchanged

solver_registry/src/bench.rs (new):
- Full bench harness mirroring intent_settlement pattern
- Ceiling assertions for all 22 public entrypoints: initialize,
  set_writer, set_tier_threshold, register_solver, stake, unstake,
  deregister_solver, record_fill, record_failure, slash, get_tier,
  tier_for, get_reputation_score, get_solver, get_solver_count,
  get_tier_table, get_fill_window_bonus_pct, get_slash_bps,
  get_fee_rebate_bps, get_admin, get_bond_token,
  compute_reputation_score
- resource_cost_report and resource_cost_is_reproducible smoke tests

solver_registry/src/lib.rs:
- Add `#[cfg(test)] mod bench;` declaration

Ceilings are set at baseline + 10% (rounded up to nearest 1000).
Regenerate baselines with:
  cargo test --features testutils bench::resource_cost_report -- --nocapture

Closes stellar-vortex-protocol#149
@drips-wave

drips-wave Bot commented Sep 30, 2026

Copy link
Copy Markdown

@Keengfk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[High] Enforce per-entrypoint resource ceilings as unit tests for every contract

1 participant