-
Notifications
You must be signed in to change notification settings - Fork 300
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
support using KSM as fee(cases: transfer back asset to Statemine) #698
Comments
I have a question regarding this, which seems completely valid: will you allow KSM to be transferred directly from Statemine? Because if so I think you would need to map it to a different token than the one you have, and its kinda hard to do with the current executor layout (we would need to distinguish based on origin, because the multiasset is identical). If not, in order for this approach to work your sovereign in Statemine needs KSM funds. WIll you manually (or the user) fund it? |
@girazoki @xlc I think previous we've some discussion in this issue: #663 in order to transfer RMRK back to Statemine, I think we could allow fund KSM to parachain sovereign account on Statemine. but of course the weakness is If someone in Karura(sender parachain) set too much KSM as fee, the parachain sovereign account will soon be exhausted so that other user can't transfer RMRK back to Statemine. I'm not sure is this a potential problem? A solution maybe: we don't allow user set the KSM fee, instead provide a fixed KSM fee(this could be done on Dapp frontend). and this fee is just enough for BuyExecution on Statemine. in this way, the user provide just enough KSM fee, and there're no additional KSM lefted for the user on Statemine. but consider there is a issue reported: paritytech/cumulus#892 which allow Statemine transfer RMRK and use KRM as fee to Karura. and if that issue is fixed, that'll be problem too as you mentioned in case one(allow transfer KSM from Statemine). that should discuss more sufficient and need audit. |
Yeah I remember having discussed this issue before. Seems fair to just allow the dapp to provide the fixed KSM fee, but if you have the polkadotXCM pallet enabled I think a user could craft the request in which they exhaust thes tatemine sovereign of KSM. I am unsure if this is a problem, as a user might potentially have to spend quite a bunch of KSM just to pause sending back RMRK to Statemine for a short period of time (until it is funded again)- To be honest, I might be overthinking this problem, but it seems to me we need better support for common good parachains in general in the XCM ecosystem. We have this issue in which paritytech/cumulus#925 we communicate our concerns to parity, but not sure this will get improved. Anyway, thanks for your response @zqhxuyuan! Really appreciated your clarification |
Just a heads up that https://github.com/paritytech/polkadot/pull/4756/files might solve our issues. If the transactor receives an origin parameter, we can simply mint a different token if the transfer came from Statemine, which would simplify all the issues we discussed above |
even though we can disable polkadotXCM by call filter as Acala current did, but as xTokens is still exposed with the new PR, I'm afraid we can't stop user/bot setting too much KSM fee when transfer asset back to Statemine. unless we set fixed KSM fee(which relay on trader config on Statemine) in the code. I guess that's why bifrost @yrong previous did in bifrost-io/bifrost#420 instead of specify fee amount to prevent above potential attack happend. |
Yes, remeber some discussion with @girazoki before in bifrost-io/bifrost#420, ksm from statemine should not be mapped to the same token as from kusama. Our workround now is to deduct extra fee and then manually fund our sovereign account in statemine as compensation. I do think there should be some better solution. |
I see, thanks for the clarification guys! that makes total sense. I think there will be a way after xcm v3, since assetTransactors will receive the context of the call,which includes the origin. Therefore we can map the parent token to a different token depending if the origin is Statemine or the Relay. |
After talk to @shaunxw and @xlc, we got two solution for this case before v3 released.
we choose second solution for now(detail see the PR), the bad thing for user is need more fee, the good thing for parachain is they would't need pre-fund anymore and balance between parachains and relaychain is balanced. |
closed by #700 |
current, we have multi assets support, and use
fee_item
asset as reserveopen-runtime-module-library/xtokens/src/lib.rs
Line 590 in 4a66b29
i.e. if
currencies=vec![(CurrencyId::R, 100), (CurrencyId::B, 450)]
, and fee_item=0, reserve=Parent, because fee asset is R, then xcm sent to Relaychain likes:this will error when execute second WithdrawAsset because relaychain doesn't have
(0, Parachain(2), GeneralKey(B))
asset.if currencies=
vec![(CurrencyId::R, 100), (CurrencyId::B, 450)]
, and fee_item=1, reserve=(1,Parachain(2))
, because fee asset is B, then xcm send to Sibling Parachain(2) likes:this can sucess if we open gate here(if not, there'll be
DistinctReserveForAssetAndFee
error):open-runtime-module-library/xtokens/src/lib.rs
Lines 584 to 587 in 4a66b29
and the xcm above use
(0, GeneralKey(B))
as fee, although this is what the fee_item exactly wanted.but in some cases we want use sibling parachain as reserve chain, and also use relaychain asset as fee.
i.e. transfer RMRK from Karura to Statemine, we use KSM as fee. the xcm on recipient parachain should be like:
PS: in the case of transfer RMRK from Karura to Statemine, if we transfer only RMRK, in the Statemine side, as trader not matched, xcm executed in Statemine will failed, and throw TooExpsensive error. so we must use KSM as fee, because Statemine only support KSM as fee for now.
https://github.com/paritytech/cumulus/blob/86f76c5619c64d1300315612695ad4b4fcd0f562/polkadot-parachains/statemine/src/lib.rs#L557
The text was updated successfully, but these errors were encountered: