fix: reward callback failure unlock#211
Conversation
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ 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 |
| &mut self, | ||
| validator_id: AccountId, | ||
| #[callback] total_balance: U128, | ||
| #[callback_result] result: Result<U128, PromiseError>, |
There was a problem hiding this comment.
Most of the functions in the current codebase use the is_promise_success() function to check callback success/failure. The current approach in the PR also works.
There was a problem hiding this comment.
Keeping the callback_result approach here since it handles failed promise results directly and releases the validator lock for retry
Summary
This PR prevents a validator from remaining locked if the reward balance refresh callback receives a failed external promise.
Problem
epoch_update_rewards()sets the validator intoexecutingstate before calling the external staking pool. The callback previously used#[callback], which panicsbefore entering the function body if the external call fails.
In that failure case, the validator never reaches the normal
post_execution()path, so it can remain stuck inexecuting = trueand block future operations for thatvalidator.
Fix
Change
validator_get_balance_callbackto use#[callback_result].On success, the existing reward update logic is unchanged. On failure, the callback clears the validator execution flag and returns without updating rewards.
Testing
CI passed:
testclippy and fmt