-
Notifications
You must be signed in to change notification settings - Fork 382
Statemine XCM: panic on cross-chain transfer two kinds of assets #892
Comments
What's the full call? @KiChjang can you help? |
Encoded call data: |
Does the |
Even if the XCM is bad, the transaction could fail, but it shouldn't panic the transaction verification logic? |
Indeed, I'll try and look for the source of panic in the runtime in the meantime. |
Okay, so I recently spun up a local westmint parachain, and tried to submit this transaction as-is, and indeed I have ran into an error, but it's different from the one that you see:
This is suggesting to me that somehow decoding of the raw data is wrong, and so I tried to change the
To ensure that this is indeed a decoding problem, I tried changing the call to use
My guess of where exactly the decoding error is in decoding the Vec in the V1 assets parameter:
pub enum VersionedMultiAssets {
V0(Vec<v0::MultiAsset>),
V1(v1::MultiAssets),
} And pub struct MultiAssets(Vec<MultiAsset>); As we can see here, there is an additional |
There is no difference in the SCALE-encoding when you have a struct/tuple with a single param, vs just the field. So the following SCALE encodings would all be equivalent -
So the JS API maps single field structs/tuples to just the inner since it doesn't affect SCALE encoding/decoding at all. |
Okay, I think I'm starting to see where the error is coming from: From the looks of it, it would seem that |
Ahhh... ok, so in submission it needs to be pre-sorted? So this is actually the one place where the JS API can help, i.e. have a specific encoder for |
I just verified it, and yes, the I think it is indeed a good idea for the JS API to pre-sort the inner vec, because IIRC the ordering does matter -- fungibles first, then non-fungibles. And for the fungibles, assets with shorter |
Right ok, Gav has reminded me that it is because we need to ensure that there are no duplicate entries within the vec, and so they need to be sorted in order to be able to validate it in O(n) time. |
I was trying cross-chain transfer from Statemine to Karura, after the HRMP channel opened. Transferring one kind of assets works great, but it panicked every time on transferring two kinds of assets (one for the target asset to send, the other is KSM to pay fees).
The text was updated successfully, but these errors were encountered: