Skip to content

test: enforce strict soroban compute budget assertions - #88

Merged
Robotron2 merged 1 commit into
Padi-Pay:mainfrom
thegreatfeez:ci/budget-limits
Jul 24, 2026
Merged

test: enforce strict soroban compute budget assertions#88
Robotron2 merged 1 commit into
Padi-Pay:mainfrom
thegreatfeez:ci/budget-limits

Conversation

@thegreatfeez

Copy link
Copy Markdown
Contributor

Description

Adds explicit Soroban compute budget assertions so the test suite fails aggressively if any contract entry point's CPU instructions or memory usage regresses past a safe, calibrated threshold — long before it could hit Mainnet's transaction resource limits.

Every state-changing entry point (create_escrow, lock_funds, release_funds, refund, resolve_dispute) is measured with env.cost_estimate().budget(), prints its metered cost via budget().print() so usage is visible in CI logs/PR reviews, and asserts it stays under a ceiling calibrated with ~2-2.5x headroom over measured usage (still far below Mainnet's 600M instruction / ~42MB memory limits).

A standalone dummy contract with a deliberately heavy hashing loop is included to prove the assertion mechanism actually fails when usage exceeds the ceiling, rather than trivially passing.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Testing

  1. cargo test — all 65 existing tests + 6 new budget tests pass
  2. cargo fmt --all -- --check and cargo clippy --all-targets --all-features -- -D warnings — clean
  3. cargo build --target wasm32v1-none --release — builds successfully
  4. cargo test --test budget in isolation confirms test_budget_assertion_catches_heavy_loop (#[should_panic]) proves the ceiling assertion actually fires on a resource-heavy workload

Closes #72

Checklist

  • Code follows style guidelines (cargo fmt run)
  • Tests added/updated and cargo test passes
  • Documentation updated

Add explicit CPU instruction and memory ceilings for every state-changing
entry point (create_escrow, lock_funds, release_funds, refund,
resolve_dispute) using env.cost_estimate().budget(). Each test prints the
metered cost via budget().print() and fails if usage regresses past a
calibrated threshold, well before the transaction-level Mainnet limits
would be hit.

Includes a dummy contract with a deliberately heavy loop to prove the
assertion mechanism actually fails when resource usage exceeds the ceiling.

Closes Padi-Pay#72
@Robotron2
Robotron2 merged commit 0d9ec7d into Padi-Pay:main Jul 24, 2026
1 check passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jul 24, 2026
3 tasks
@thegreatfeez
thegreatfeez deleted the ci/budget-limits branch July 24, 2026 12:18
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.

Enforce Strict Soroban Budget Limits

2 participants