Block update_split while a mutable split holds escrow balance - #1
Merged
Conversation
A controller could accept a deposit under one routing table and pay it out under another by calling update_split between deposit and distribute, redirecting escrowed funds to arbitrary recipients. update_split now refuses to run while held_tokens(id) is non-empty, forcing distribute first. Immutable splits (controller: None) were never affected since their routing table can't change. Documents the trust model in SECURITY.md and clarifies deposit()/ update_split() docs on whether escrow can be redirected.
📝 WalkthroughWalkthroughChangesMutable split routing
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Contract coverage: tributary-splitter
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes tributary-protocol#253
A split's controller could call
update_splitbetweendepositanddistribute, replacing recipients and shares and redirecting an already-escrowed deposit to arbitrary recipients. Immutable splits (controller: None) were never affected since their routing table can't change.Fix:
update_splitnow rejects (Error::SplitHasBalance) whileheld_tokens(id)is non-empty for the split, forcing the controller todistributeevery held token first before changing recipients or shares.contracts/splitter/src/lib.rs: guard added toupdate_split, doc comments onError::SplitHasBalance,update_split, anddepositclarifying the trust modelcontracts/splitter/src/test.rs:update_split_rejects_while_balance_outstanding— deposits, attempts an update (rejected), distributes, then confirms the update succeeds afterwards and the new recipient never sees funds that were already paid outSECURITY.md: new "Trust model: escrow and mutable splits" section documenting the guarantee and its limitsdocs/api-reference.md,docs/architecture.md,CHANGELOG.md: updated to reflect the new error case and behaviorTest plan
cargo testincontracts/splitter— 42 passed, including the new regression testcargo clippy --all-targets— cleanSummary by CodeRabbit
New Features
SplitHasBalanceerror for blocked updates.Bug Fixes
Documentation