-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Empty amount delegation stored after unbonding/redelegation #10216
Comments
This is because the shares are non-zero. Recall, shares are an approximation. // remove the delegation
if delegation.Shares.IsZero() {
err = k.RemoveDelegation(ctx, delegation)
} else {
k.SetDelegation(ctx, delegation)
// call the after delegation modification hook
err = k.AfterDelegationModified(ctx, delegatorAddress, delegation.GetValidatorAddr())
} |
Yeah that's what I figured out. Does it make sense to have this stored on the state though? Wouldn't it make more sense to delete the delegation entry when the amount is zero even if shares are not zero? If the amount is zero, even a slashing wouldn't affect it so what's the point on leaving it there? |
That's a great question! I think we can remove it if amount is zero. We just need to double check some edge cases like how distribution rewards work, e.g. do they work based on shares or amount. Thoughts @ValarDragon |
These shares should definitely be removed if amount is 0 imo. Great catch! (Also somewhat concerning for state blowup atm) The distribution rewards should work based on shares |
Should we make a new issue tracking clearing these at upgrade time? (Its not a blocker for anything, but good to track / maybe help lower state size) |
I already implemented a live upgrade handler to clear these. Unless you're referring to apps that still rely on export/import, in that case we do not cover this. |
oh perfect, I misunderstood. |
Hi @RiccardoM ! I know it's been a while, we've been looking into the issue and we believe it might be resolved. We tried the following scenarios (All scenarios were tested with unbond and redelegate):
In each of the scenarios, it was ensured that there were no remaining shares, meaning that every time the amount was 0, the shares were also 0. If you continue experiencing the same issue, please provide an example of the amount you are delegating and the amount you are unbonding so we can look into it more closely. Just in case, if you want test it. Script to configure the node
And simulate one situation
|
@RiccardoM were you able to see lucas's answer? |
@RiccardoM any update with this one? |
@lucaslopezf @educlerici-zondax Thanks for fixing this! |
We close the Issue because it is already fixed |
Summary of Bug
If you unbond or redelegate all your tokens from a validator, it might happen that a delegation entry is persisted on chain with amount equals to zero.
Version
v0.44
Steps to Reproduce
Sometimes, it might happen that the chain stores a delegation entry with
amount
equals to0
but with a non-emptyshares
amount. This results in the following happening:For Admin Use
The text was updated successfully, but these errors were encountered: