fix(rewards): ChangeSchedule checks net amount instead of total - #348
fix(rewards): ChangeSchedule checks net amount instead of total#348g0spel wants to merge 1 commit into
Conversation
Fixes KiiChain#338. The ChangeSchedule function in the rewards module was checking funds availability against the full TotalAmount, ignoring already-released tokens. This prevented governance from updating a schedule after partial release, even when the pool held sufficient funds to cover the remaining balance. Change: pass TotalAmount - ReleasedAmount to fundsAvailable instead of TotalAmount, so only the unreleased portion is reserved. Closes: KiiChain#338
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe Estimated code review effort: 1 (Trivial) | ~3 minutes Sequence Diagram(s)sequenceDiagram
participant MsgServer
participant Schedule
participant FundsAvailable
MsgServer->>Schedule: Read TotalAmount, ReleasedAmount
MsgServer->>MsgServer: Compute netAmount = TotalAmount - ReleasedAmount
MsgServer->>FundsAvailable: Check funds against netAmount
FundsAvailable-->>MsgServer: sufficient or insufficient funds result
Related issues: Related PRs: None identified. Suggested labels: bug, rewards Suggested reviewers: None specified. 🐰 A schedule once demanded its whole, 🚥 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❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Description
Fixes #338 - Broken ChangeSchedule function.
The
ChangeSchedulefunction in thex/rewardsmodule was checking funds availability against the fullTotalAmount, ignoring already-released tokens. This prevented governance from updating a schedule after partial release, even when the pool held sufficient funds to cover the remaining balance.The Bug
If
TotalAmount=1000andReleasedAmount=900, the function required1000in the pool even though only100remained to be paid.The Fix
Now only the unreleased portion is checked against the community pool.
Validation
ReleasedAmount ≤ TotalAmountis already enforced byvalidateSchedule()on line 91-94Sub()operation is safe because of these pre-conditionsRelated
TestRewardsChangeScheduleOverStrictFundsCheckE2E