Skip to content

test: per-call profile snapshot#674

Open
ola196 wants to merge 1 commit into
CalloraOrg:mainfrom
ola196:task/profile-snapshot
Open

test: per-call profile snapshot#674
ola196 wants to merge 1 commit into
CalloraOrg:mainfrom
ola196:task/profile-snapshot

Conversation

@ola196

@ola196 ola196 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Implement per-call CPU/memory profile snapshot for budget regression detection in callora-vault.

  • Add contracts/vault/tests/snap_profile.rs with a ProfileSnapshot struct that captures cpu (instructions) and mem (read_bytes + write_bytes) via env.cost_estimate().resources() immediately after each entrypoint call.
  • Add assert_within_budget() helper: emits a machine-readable JSON line compatible with scripts/gas-regression.sh and asserts both dimensions stay within 2x the .gas-baseline.json baseline.
  • Add assert_no_regression() helper: validates relative growth between two snapshots with a configurable percentage threshold.
  • Cover 11 entrypoints: init, deposit, deduct, batch_deduct, pause, unpause, set_max_deduct, get_meta, balance, is_paused, get_max_deduct.
  • Add relative regression tests: deduct second-call overhead and batch_deduct single-item vs plain deduct.
  • Add sanity tests: nonzero snapshot after real call, boundary comparisons.

Closes #541

Implement per-call CPU/memory profile snapshot for budget regression
detection in callora-vault.

- Add contracts/vault/tests/snap_profile.rs with a ProfileSnapshot struct
  that captures cpu (instructions) and mem (read_bytes + write_bytes) via
  env.cost_estimate().resources() immediately after each entrypoint call.
- Add assert_within_budget() helper: emits a machine-readable JSON line
  compatible with scripts/gas-regression.sh and asserts both dimensions
  stay within 2x the .gas-baseline.json baseline.
- Add assert_no_regression() helper: validates relative growth between two
  snapshots with a configurable percentage threshold.
- Cover 11 entrypoints: init, deposit, deduct, batch_deduct, pause, unpause,
  set_max_deduct, get_meta, balance, is_paused, get_max_deduct.
- Add relative regression tests: deduct second-call overhead and
  batch_deduct single-item vs plain deduct.
- Add sanity tests: nonzero snapshot after real call, boundary comparisons.

Closes CalloraOrg#541
@drips-wave

drips-wave Bot commented Jul 23, 2026

Copy link
Copy Markdown

@ola196 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.

Add per-call CPU/memory profile snapshot

1 participant