fix: correct same-tx CAS idiom in spend_vault docs and example - #455
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesCAS-guarded change_budget update
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant Owner
participant DirectDelegation
participant SpendVault
Owner->>DirectDelegation: change_budget(expected, new_budget, ...)
DirectDelegation->>SpendVault: set_allowance(cap_id, option::some(expected), new_budget, ...)
SpendVault-->>SpendVault: compare expected vs current remaining
alt expected matches
SpendVault-->>DirectDelegation: allowance updated
else stale expected
SpendVault-->>DirectDelegation: abort EUnexpectedAllowance
end
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #455 +/- ##
==========================================
+ Coverage 96.62% 96.68% +0.05%
==========================================
Files 34 34
Lines 3405 3405
Branches 793 794 +1
==========================================
+ Hits 3290 3292 +2
Misses 70 70
+ Partials 45 43 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Review — allowance
|
A same-tx
allowance<T>()read cannot serve as a CAS guard, the shared Vault is locked for the whole tx, so the read trivially matches andEUnexpectedAllowancenever fires on a mismatch.expectedfrom an earlier (off-chain / prior-tx) read,direct_delegation::change_budgettakesexpected: u64from the caller instead of self-reading,Library code unchanged (comment-only); 177/177 tests pass.
Summary by CodeRabbit
Bug Fixes
Documentation
set_allowanceCAS “Lifecycle” behavior, including how same-transaction and cross-transaction check-then-act scenarios can fail safely.Examples & Tests