fix(stake): #200 delete dead flush_available + #194 discriminator guard + #195 ATA owner check - #208
Conversation
#195 ATA owner check #200 — Remove math::flush_available(): dead code (no production callers) that was buggy (omitted total_returned + saturating arithmetic). The live FlushToInsurance path already computes capacity via total_pool_value() (#202, i128/returned/RL-aware). Also removes its 4 inline math tests + the 2 tests/kani.rs proofs that proved the dead fn (live-path safety is covered by total_pool_value()'s #169 proofs). #194 — Validate the StakeDeposit discriminator on already-initialized records (process_deposit, process_deposit_junior, process_withdraw). Previously only the zero→init transition set it; an already-init record was trusted on is_initialized alone. Defense-in-depth (currently unreachable via PDA-derivation + owner checks). #195 — Verify user_ata is SPL-Token-program-owned before reading its raw account layout (deposit, withdraw, deposit_junior). Prevents a non-token account with crafted mint/owner bytes from satisfying the field checks (the SPL CPI would later revert; this fails fast with a clear error). build-sbf clean; full suite (22 binaries) green. Closes #200, #194, #195. Credit @v1ktorrr0x. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughRemoves the ChangesRemoval of
Processor account validation hardening
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Possibly related PRs
Poem
✨ 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 |
Three verified findings (credit @v1ktorrr0x):
math::flush_available()(no prod callers; live path usestotal_pool_value()per fix(stake): compute FlushToInsurance available via total_pool_value to stop false-overflow brick #202). Removes its inline tests + the 2 kani proofs of the dead fn.build-sbf clean, 22 test suites green. Closes #200, #194, #195.
Summary by CodeRabbit
Bug Fixes
Security
Tests