Fix unshieldedtreasury deposits, add tests, improve doc - #762
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe treasury now uses ChangesUnshielded Treasury behavior
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@contracts/src/multisig/test/mocks/MockUnshieldedTreasury.compact`:
- Around line 99-110: The self-send mock is correct; update the related warning
and live test instead. In contracts/src/multisig/UnshieldedTreasury.compact
lines 94-98, remove the contradictory self-send warning without changing
MockUnshieldedTreasury.compact lines 99-110. In
contracts/src/multisig/test/UnshieldedTreasury.test.ts lines 274-290, make the
live-only test assert sent.kind === 'rejected' and remove post-send funds
probing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c36a4350-3340-4224-868b-8bc27d876694
📒 Files selected for processing (4)
contracts/src/multisig/UnshieldedTreasury.compactcontracts/src/multisig/test/UnshieldedTreasury.test.tscontracts/src/multisig/test/mocks/MockUnshieldedTreasury.compactcontracts/src/multisig/test/simulators/UnshieldedTreasurySimulator.ts
Fix:
UnshieldedTreasury._depositreverted on every call. Its overflow guard passedUINT128_MAX - amount (≈2¹²⁸)tounshieldedBalanceLte, which fails at runtime with failed to decode for built-in type u64 despite the built-in's declaredUint<128>parameter. Both guards now check the module's own_balanceswith in-circuit arithmetic instead of the protocol balanceThat also fixes two latent bugs: the protocol balance is a start-of-execution snapshot, so it couldn't see a credit or debit made earlier in the same transaction. It rejected a legitimate receive-then-spend, and let an intra-transaction overspend through to fail as an opaque range fault instead of the named assert
Add: test and sim (dry and live). Covers protocol claims in the module's docs, including a regression guard that pins the
unshieldedBalanceLteoperand limit so the fix can't be quietly revertedDocs: warnings for unspendable recipients (accepted, funds provably removed, not a sanctioned burn) and self-sends (zeroes the tracked balance while funds stay spendable), plus a note that zero-amount ops are value-preserving no-ops
Summary by CodeRabbit
Documentation
Tests