Skip to content

Task/conservation ladder#597

Open
ola196 wants to merge 3 commits into
CalloraOrg:mainfrom
ola196:task/conservation-ladder
Open

Task/conservation ladder#597
ola196 wants to merge 3 commits into
CalloraOrg:mainfrom
ola196:task/conservation-ladder

Conversation

@ola196

@ola196 ola196 commented Jun 28, 2026

Copy link
Copy Markdown

No description provided.

ola196 added 2 commits June 28, 2026 19:40
- Extract DEFAULT_MAX_DEDUCT constant and check_max_deduct() helper into
  contracts/vault/src/limits.rs for clear separation of cap logic
- Re-export from lib.rs (pub mod limits; pub use limits::{...})
- Replace inline if-checks in deduct() and batch_deduct() with check_max_deduct()
- Add focused unit tests in test_limits.rs (7 tests: default value, at/below/above
  cap, edge cases)
- Update docs/interfaces/vault.json: improve get_max_deduct description, add
  missing set_max_deduct entry with params, errors, and event docs

Closes CalloraOrg#538
Add tests/conservation_ladder.rs: 64-seed × 48-step property test
asserting that total on-ledger USDC across vault, settlement, and
revenue-pool plus all wallet balances equals INITIAL_MINT after
every operation (deposit, deduct, batch_deduct, developer withdraw,
revenue-pool batch_distribute).

Also checks settlement's internal conservation invariant:
  usdc.balance(settlement) >= global_pool.total_balance + Σ dev_balances

Uses a deterministic LCG PRNG (no external crates) for reproducibility;
any violation prints the seed and full step trace.
@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

Hey @ola196! 👋 It looks like this PR isn't linked to any issue.

If this PR is for one of the issues assigned to you as part of a Wave, please link it to ensure your contribution is tracked properly. You can do this by adding a keyword to the PR description (e.g., Closes #123), or by clicking a button below:

Issue Title
#539 Add cross-contract conservation invariant ladder Link to this issue
#541 Add per-call CPU/memory profile snapshot Link to this issue
#543 Add SECURITY.md threat model update for new entrypoints Link to this issue
#538 Add per-tx max-deduct cap Link to this issue

ℹ️ Learn more about linking PRs to issues

- vault: add TotalDeducted storage key + get_total_deducted() view
- settlement: add TotalReceived storage key + get_total_received() view
- test_cross_invariant: 64-seed x 48-step end-to-end conservation check
- docs: update vault.json and settlement.json interface summaries

Closes CalloraOrg#539
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.

1 participant