Skip to content

fix: reward callback failure unlock#211

Open
dongcool wants to merge 1 commit into
mainfrom
fix/reward-callback-failure-unlock
Open

fix: reward callback failure unlock#211
dongcool wants to merge 1 commit into
mainfrom
fix/reward-callback-failure-unlock

Conversation

@dongcool
Copy link
Copy Markdown
Collaborator

@dongcool dongcool commented May 8, 2026

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 into executing state before calling the external staking pool. The callback previously used #[callback], which panics
before 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 in executing = true and block future operations for that
validator.

Fix

Change validator_get_balance_callback to 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:

  • test
  • clippy and fmt

@linguists linguists changed the title fix reward callback failure unlock fix: reward callback failure unlock May 11, 2026
@linguists
Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Warning

Rate limit exceeded

@linguists has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 7 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a34d50d0-7b34-4964-b9cd-605a23c3c2d2

📥 Commits

Reviewing files that changed from the base of the PR and between 7620e4e and a759814.

📒 Files selected for processing (3)
  • contracts/linear/src/epoch_actions.rs
  • contracts/linear/src/validator_pool.rs
  • tests/__tests__/linear/epoch-action-failure.ava.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/reward-callback-failure-unlock

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

&mut self,
validator_id: AccountId,
#[callback] total_balance: U128,
#[callback_result] result: Result<U128, PromiseError>,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping the callback_result approach here since it handles failed promise results directly and releases the validator lock for retry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants