fix(config): bound cooldown_slots above to prevent permanent withdrawal lock (closes #121) - #132
Conversation
…al lock (closes dcccrypto#121) validate_cooldown_slots only rejected 0. An admin could set cooldown_slots = u64::MAX via InitPool or UpdateConfig; process_withdraw's saturating_add then yields a deadline clock.slot can never reach, permanently freezing all withdrawals. Add an upper bound (~1 year of slots ≈ 78.84M) — long enough for any realistic cooldown, finite enough to rule out a permanent lock. Enforced on both the InitPool (L288) and UpdateConfig (L1192) paths, which both call validate_cooldown_slots. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 49 minutes and 52 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ✨ 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 |
Closes #121.
validate_cooldown_slots(src/processor.rs) only rejectedcooldown_slots == 0. An admin could setcooldown_slots = u64::MAXviaInitPoolorUpdateConfig; inprocess_withdraw,deposit.last_deposit_slot.saturating_add(pool.cooldown_slots)then yieldsu64::MAX, a deadlineclock.slotcan never reach — permanently freezing all withdrawals.This adds an upper bound
MAX_COOLDOWN_SLOTS = 78_840_000(~1 year at ~2.5 slots/sec) — long enough for any realistic withdrawal cooldown, but finite so a permanent lock is impossible. It's enforced on both paths that set the value (process_init_poolandprocess_update_configboth callvalidate_cooldown_slots).cargo checkpasses. (The exact cap is easy to adjust if you prefer a different ceiling.)