Skip to content
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

BUG: XCM transfer, that would slash account leads to total asset loss. #3050

Closed
2 tasks done
dudo50 opened this issue Jan 24, 2024 · 32 comments
Closed
2 tasks done

BUG: XCM transfer, that would slash account leads to total asset loss. #3050

dudo50 opened this issue Jan 24, 2024 · 32 comments
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.

Comments

@dudo50
Copy link
Contributor

dudo50 commented Jan 24, 2024

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

There is huge bug, where, when account tries to transfer XCM Message that will also slash dust (cause to go below existential deposit) their account, the account will suffer total asset loss and XCM message will not get sent. This only occurs on Kusama Asset Hub, Polkadot works fine, because it does not have latest runtime.

Steps to reproduce

Transfer amount that will result in less than existential deposit on Kusama Asset Hub (Kusama untested as I have verified identity there and do not want to loose it).

Or try any Kusama DEX and try transfer MAX option. (Kusama Asset Hub -> Kusama)
Screenshot 2024-01-24 at 16 34 47

Other XCM transfers work as expected. Please, fix this bug as it could lead to huge asset losses if released on Polkadot also.

@dudo50 dudo50 added I10-unconfirmed Issue might be valid, but it's not yet known. I2-bug The node fails to follow expected behavior. labels Jan 24, 2024
@KiChjang
Copy link
Contributor

Which functionality did you use to transfer assets? Was it a teleport, or did you create your own XCM program? If it's the latter, can you show us your XCM program?

@dudo50
Copy link
Contributor Author

dudo50 commented Jan 24, 2024

Which functionality did you use to transfer assets? Was it a teleport, or did you create your own XCM program? If it's the latter, can you show us your XCM program?

Hey @KiChjang , we used native PolkadotXCM and limited teleport function.
Screenshot 2024-01-24 at 16 34 26

Here is how the message was formatted (other messages that are formatted the same but would not slash account (amount remaining in the account after XCM is more than existential deposit) work just fine)

@ggwpez
Copy link
Member

ggwpez commented Jan 24, 2024

Apparently its this block: https://assethub-kusama.subscan.io/block/6284878?tab=event
And this state diff: diff.html.txt

@kianenigma
Copy link
Contributor

I tried to emulate this issue using Chopsticks and at first attempt couldn't. Are you claiming that any teleport that leaves the sender below existential deposit on the kusama relay chain will cause a trap? I moved 5 KSM To Charlie, teleported 4.999999 to Charlie on AH and the teleport failed with a reasonable outcome, without any traps or loss of funds.

@dudo50
Copy link
Contributor Author

dudo50 commented Jan 25, 2024

@kianenigma If I understand you correctly, you tried Kusama -> AssetHub transfer. We encountered the issue on AssetHub->Kusama transfer.

@NachoPal
Copy link
Contributor

NachoPal commented Jan 26, 2024

I tried a limitedTeleport from AssetHubKusama to Kusama with Chopsticks and it worked.

Some edge case should be triggering the issue for your case.

Sorry, I read again the issue, I see what's the edge case

@NachoPal
Copy link
Contributor

Can you share what was your balance when you tried to do the teleport and how much KSM you tried to teleport?

Not sure if I understand the issue, I am not able to reproduce it. I tried to teleport all my balance and it failed because a fee has to be paid beforehand. However, the sending account does not lose all its balance, just the mentioned fee.

@dudo50
Copy link
Contributor Author

dudo50 commented Jan 26, 2024

Can you share what was your balance when you tried to do the teleport and how much KSM you tried to teleport?

Not sure if I understand the issue, I am not able to reproduce it. I tried to teleport all my balance and it failed because a fee has to be paid beforehand. However, the sending account does not lose all its balance, just the mentioned fee.

What was the call you used and how much was your balance/you tried to send? We are always sending amount-xcmfee*1.5. Not the entire amount because then it would fail as expected with inability to pay for fees.

@dudo50
Copy link
Contributor Author

dudo50 commented Jan 26, 2024

If you go to any dex, for eg Karura or Basilisk and go to cross-chain section and hit transfer max button for transferring KSM from KusamaAssetHub->Kusama you should be able to replicate. Be sure to not have lots of coins though.

@dudo50
Copy link
Contributor Author

dudo50 commented Jan 26, 2024

You can find my approximate balance here:
Around 0.04ksm. https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fkusama-asset-hub-rpc.polkadot.io#/extrinsics/decode/0x8d02840084fc49ce30071ea611731838cc7736113c1ec68fbc47119be8a0805066df9b2b01988575310511e1dc64f6a1d041d9ca0be73beaf8c90c04f5949d89cbdefaf2768990d1c4853db0f4492eac27410aba4f7b2a87d46b918c49267086dc3402278b04018800001f09030100030001010084fc49ce30071ea611731838cc7736113c1ec68fbc47119be8a0805066df9b2b030400010000075ab2966e0b0000000000

I meant what was the balance in your account, not the amount you tried to teleport

I am unable to give you certain number as as I mentioned it was approximately same as was sent. This is the condition to catch the bug: balance-(amount+xcmfee×1.5)>0 && < ED.

@dudo50
Copy link
Contributor Author

dudo50 commented Jan 27, 2024

Here is a demonstration of the bug in the video.
And you can try any dex not just Karura dex..

So now you know how to replicate it I believe, because I really have no other way to show you now. I've tried my best.

Bug.report.for.Parity.mov

@NachoPal
Copy link
Contributor

NachoPal commented Jan 29, 2024

Thanks for the video, much clear now. I had to use exactly the same amounts to be able to reproduce the case.

Your account does not go to 0 KSM. I checked and your balance after trying the teleport was: 96,375,486. It is an UI issue because of not having enough decimals.

I think the issue was introduced in #1234

As per the Important Note states in the PR, the UI should have taken into consideration the new delivery fee, disallowing you from doing the teleport.

Initially you have enough balance to pay for the transaction fee + the first WithdrawAsset (amount to teleport). However, after the first withdrawal, when trying to send the message, it tries to take the fee, subsequently failing when trying to withdraw again as the holding registry does not have enough funds anymore.

I think this issue is solved by #2388 and #1222

Let me confirm it and see if we can patch it.

@dudo50
Copy link
Contributor Author

dudo50 commented Jan 29, 2024

Perfect! Thanks for the great explanation! Much clearer on my end now too!

@rageruun
Copy link

can anyone help? Tokens stuck in parachain bridge when transmitted from the Kusama network to the Moonriver (xcKSM)
image
hash https://kusama.subscan.io/extrinsic/0x37b705c316c4b4b8d552964a130a552e06bad1f55171fca693e4b4e1917dd336?tab=event

@KiChjang
Copy link
Contributor

KiChjang commented Jan 30, 2024

The tokens are not stuck in the bridge, but rather in the sovereign account of parachain 2023: https://kusama.subscan.io/account/F7fq1jSB3w59f8vMShxvP5eSu3wCJbL5Am5MQ6vP6VzYLWD.

Easiest way to recover this is to contact support on parachain 2023 and show them this exact extrinsic (or this issue), and tell them that you have a failed teleport, and now some assets are stuck in their sovereign account, and that you want to retrieve them. EDIT: This is a reserve asset transfer failure however, which is not the same as the problem encountered by the issue author.

For reserve asset transfers, please wait until the patches #3050 and #3070 is landed on the relay chain and AH runtimes for it to be fixed.

For teleports, please refrain from using the send MAX functionality of all XCM UIs, since it appears that none of them took account of the delivery fees, leading to this bug. Instead, send most of your KSM and leave behind maybe 1 KSM to pay for delivery fees -- this should avoid non-payment of fees.

@acatangiu
Copy link
Contributor

acatangiu commented Jan 30, 2024

runtimes patch release fixing this #3050 and #3070 is in the works

a fix for this issue has been backported to a patch release branch, next:

@rageruun
Copy link

rageruun commented Jan 30, 2024 via email

@KiChjang
Copy link
Contributor

@acatangiu Not quite, this issue uses teleport, whereas the fixes we have resolve reserve asset transfers.

@KiChjang
Copy link
Contributor

KiChjang commented Jan 31, 2024

Sorry, it looks like @rageruun here is talking about a reserve asset transfer, which is not exactly related to what the original post is about. For teleports, what I've written above still stands.

@rageruun
Copy link

@acatangiu
Copy link
Contributor

@acatangiu Not quite, this issue uses teleport, whereas the fixes we have resolve reserve asset transfers.

I believe XCM transactional processing also fixes/mitigates this issue.

@acatangiu
Copy link
Contributor

This should be fixed in runtimes patch release https://github.com/polkadot-fellows/runtimes/releases/tag/v1.1.2

@Pescador1551
Copy link

Pescador1551 commented Feb 2, 2024

Hi @KiChjang @kianenigma @NachoPal @rageruun @dudo50 @acatangiu, I encountered the same issue with a transfer of KSM during a Kusama to AssetHub transport https://kusama.subscan.io/extrinsic/21678807-20 and lost 76 KSM.
@KiChjang, you said the best way to resolve it is to contact parachain support 2023. Do you know where I can find this? @rageruun : Were you able to recover your funds?. All help is welcome. Thank you!

@dudo50
Copy link
Contributor Author

dudo50 commented Feb 2, 2024

Sorry to hear this @Pescador1551 , the fix is currently being issued via opengov. Good luck recovering your assets!

@rageruun
Copy link

rageruun commented Feb 2, 2024 via email

@dudo50
Copy link
Contributor Author

dudo50 commented Feb 29, 2024

@acatangiu , the issue is still not resolved and after Polkadot runtime update users are now loosing assets on Polkadot. Could you reopen? It seems to be issue with when they send XCM transfer that also dusts their account.

Example of Polkadot transaction where user lost his DOT in transfer from AssetHubPolkadot->Polkadot
https://assethub-polkadot.subscan.io/extrinsic/0xe844257b68019176f815104f845c6e18efa2d85d858c95eebc2077a28fac39c4

This deeply affects experience with Polkadot for users using dApps which damages dApps name.

Edit: There is not even need for account to dust in order for asset transfer to fail. If we sent amount that leaves us exactly with minimum deposit it still fails: https://assethub-polkadot.subscan.io/extrinsic/5766838-2

Edit2: For the context other lower amount transfers work just fine.

@acatangiu
Copy link
Contributor

this was fixed back in November in #2405 and first released in polkadot sdk v1.5.0

problem 1. is it wasn't backported to sdk 1.3 or 1.4
problem 2. is fellowship/runtimes is running considerably behind polkadot-sdk so the fix just hasn't hit live runtimes yet

Opened polkadot-fellows/runtimes#210 to track inclusion of this fix in the runtime releases

@dudo50
Copy link
Contributor Author

dudo50 commented Mar 1, 2024

Thanks @acatangiu for quickly letting us know! The function for asset recovery will be awesome to have!

@rageruun
Copy link

rageruun commented Mar 1, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.
Projects
None yet
Development

No branches or pull requests

8 participants