-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
auth: v0.43 migration breaks all slashed vesting accounts #10712
Comments
TBH I really don't know how to go about fixing this in either the migration logic or for existing chains that already have migrated. Will need to marinate on this for a bit... |
Are there any updates on this? |
What is the reason it breaks? |
What do you mean? I've detailed out everything inside the issue description. Do you need something else? |
@RiccardoM is this issue still present? |
Yes, it is. |
Thank you. @alexanderbez I see you assigned yourself, do you still want to lead this? |
Yeah I'm happy to take lead on this but I just can't think of a solution TBH, at least not without really complicating the migration logic. |
I am upgrading chain from v42 to v44 and came across this issue. Steps to replicate :
All vesting account created for PersistenceCore-1 had v42 vesting account bug. |
Hey @arhamchordia I already commented above ^ (#10712 (comment)). There isn't a migration solution, at least not one that I think is practical. Honestly, I think the best bet is for chains to identify all affected vesting account(s) and manually fix their balances in a chain upgrade. We can probably write a guide on this or something...not sure, but we should consider closing this issue perhaps. Just my two cents. |
Is anyone here willing to put a deep look if it's possible to fix the vesting account migration? Or can someone else also confirm that it's not possible? |
Now discussing about it: it seams that the solution is to require that the x/auth migration is the last one. |
No, it is not the solution. Please read again the issue description, I've included a detailed explanation of what is happening and why. |
I don't think it's that simple @robert-zaremba. The crux of the problem is that the migration logic needs to know delegation amounts at specific heights/points in time, making the migration logic essentially require being executed on archive nodes making any sort of solution unrealistic. Correct me if I'm wrong @RiccardoM. Hence, my proposal is that chains just deal with these accounts manually. |
You're not wrong. To fix this there's the need to know the entire history of delegations and unbonding delegations for all vesting accounts since when they were created, so that the tracking functions can be called and the on-chain state can relfect the truth. |
@alexanderbez how about migration logic, that directly writes delegated token amount to delegated vesting amount in auth vesting account? |
I think you need to first (1) identify all affected vesting accounts, and (2) iterate over those accounts manually setting the fields to the correct values. How to do this is probably not trivial. @RiccardoM how did you end up solving this (assuming you didi)? |
@alexanderbez , do you suggest a genesis.json manual migration? We stop the chain at upgrade height, export genesis.json, change the vesting accounts delegated vesting/ delegated free entries. match them with the current delegation/ undelegation state? Current delegations will show the -tokens delegated, shares(not required) do this for all vesting accounts ( affected or not ), I think the state should come out the same? I do not understand why we need an archival node for this? is there something I am missing out on? Please correct me if I am wrong, |
closing this for now, if you are running into this issue please reach out to the team. 0.43 is no longer supported |
Summary of Bug
When a
VestedAccount
is slashed for a large amount of the delegated tokens, they won't be able to perform any operation later if they undergo thev0.43
x/auth
migrationVersion
v0.44.5
Steps to Reproduce
VestedAccount
with10000000000uatom
(10.000 ATOM)length: 0
amount: 10000000uatom
(10 ATOM)This will make sure that you have most of the tokens vesting and some of them free when the chain starts
x/auth
storage by using theMigrateAccount
methodpanic
caused by theSub
method ofsdk.Coin
Explanation
VestedAccount
gets slashed, theirOriginalVesting
andVestingPeriod
amounts are not slashed.MigrateAccount
method, theDelegatedVesting
amounts are retrieved from thex/staking
module which returns the slashed amountsThis causes a problem during the handling of every transaction that includes a fee because, while trying to pay for the fee, the following calls are made:
Now, the
subUnlockedCoins
method is written as follows:The main focus here should be the following:
LockedCoins
method is called, to get the amount of vesting coins that are not delegatedlockedCoins
is subtracted from the currentbalance
of the accountParticularly, the
lockedCoins
amount are computed as follows:The problem with all this flow is that, if the account was slashed, we will have the follow:
OriginalVesting
is never changed, soVestingCoins
will return the amount not considering the slashIn our example
10.000 - 10 = 9.990 ATOM
LockedCoins
will return the amount considering the slashedDelegatedVesting
In our example
9.990 - (9.998 - 5%) = 491,9 ATOM
Balance
will continue to be equals toInitialBalance - Delegated
In our example
10.000 - 9.998 = 2 ATOM
So,
lockedCoins
will be larger than thebalance
and thus the following line insidesubUnlockedCoins
will throw a panic with error"negative coin amount"
:Since this method is called every time a fee needs to be deducted from the account, it will always error making it impossible for the owner of such account to perform any operation whatsoever.
Side note
Due to the above computation between the
balance
and thelockedCoins
amounts, I believe that this bug will only raise for those accounts who have delegated almost entirely their vesting coins. If the account leaves enough vesting coins free, thebalance
will result higher than thelockedCoins
amount and thus the problem will not be raised initially.For Admin Use
The text was updated successfully, but these errors were encountered: