Skip to content

Missing share price cause unexpected unlock_fund failure #3459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
NingLin-P opened this issue Mar 26, 2025 · 1 comment · May be fixed by #3480
Open

Missing share price cause unexpected unlock_fund failure #3459

NingLin-P opened this issue Mar 26, 2025 · 1 comment · May be fixed by #3480
Assignees
Labels
bug Something isn't working execution Subspace execution phase-2

Comments

@NingLin-P
Copy link
Member

NingLin-P commented Mar 26, 2025

The share price of a given operator pool is an important component in our staking protocol, we use the share price to convert balance to share during deposit/withdraw/unlock.

The share price is added to the state during epoch transition except for a few cases:

  • The operator is pending slash or slashed, or deregistered
  • The operator has no new deposit/withdraw/reward in the epoch

And we make an assumption that if it is not the above cases and the share price is not available then we assume the epoch is not ending yet.

Issue

Unfortunately, there are edge cases that make the assumption broken, where we have insufficient checks to the withdraw/deposit amount and the user can successfully request withdraw/deposit 0 amount of funds, and during epoch transition, the share price won't be added for this operator.

This causes issues with withdrawal. The zero-withdrawal will create a WithdrawalInShares item and when the next non-zero withdraw comes, since we can't find the share price and thus can't convert the WithdrawalInShares to WithdrawalInBalance we assume the epoch is not ending yet and merge the non-zero withdraw to the previous WithdrawalInShares item even they are initiated in different epoch. Moreover the WithdrawalInShares refers to an epoch whose share price doesn't exist so even if the unlocking period is passed, the unlock_fund will still fail with MissingWithdrawal error.

For deposit, it has a similar situation where the share price is missing and merging deposits from different epochs, but when it merging deposits it uses the current epoch as the effective_domain_epoch instead of the zero-deposit epoch which doesn't have the share price.

Solution

  1. Add check to withdraw and deposit to reject zero amount request
  2. Explicitly check the share price existence when converting the previous epoch deposit/withdraw, and return error if the share price is unavailable while the epoch it refers to has already ended.

Migration on Taurus

In Taurus, a zero-withdrawal happens in block #1,434,952, in order to fix the issue we may need to manually insert share price in migration of the new runtime upgrade.

The missing share price is Operator 1, domainEpoch: [0, 8146], currentTotalShares: 186,504,781,826,675,866,347,230 / currentTotalStake: 186,505,937,012,273,200,789,523

cc @vedhavyas @teor2345

@NingLin-P NingLin-P added the bug Something isn't working label Mar 26, 2025
@teor2345 teor2345 added execution Subspace execution audit-P2 Medium audit priority labels Mar 26, 2025
@vedhavyas vedhavyas removed the audit-P2 Medium audit priority label Mar 27, 2025
@NingLin-P NingLin-P self-assigned this Apr 9, 2025
@pc9821nb-uuliao
Copy link

MY address:subm2BoKZaJRGsHRPymDp8JWFB2nXDYMy55JQW6JPwEp5HFyC
Operator 69
The same issue as operator 1. Hope to solve it together

Image

@NingLin-P NingLin-P linked a pull request Apr 11, 2025 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working execution Subspace execution phase-2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants