Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[XCM] Panic in the specific case of reserveTransferAssets when it contains multiple assets #6074

Closed
jiguantong opened this issue Sep 29, 2022 · 4 comments

Comments

@jiguantong
Copy link
Contributor

jiguantong commented Sep 29, 2022

Polkadot related version: v0.9.26
XCM version: 2
Possible related issue: paritytech/cumulus#1700

This seems to be related to the order of MultiAssets as @KiChjang mentioned here, because it won't panic if I reorder the assets.

This would not only happen on parachains, but also on relay chains

TestCase

1. MultiAssets: 0: {parents: 0, interior: X1(PalletInstance(7)} 1: {parents: 0, interior: X1(PalletInstance(5)}

Encoded call data on pangolin parachain: 0x0d0201010100a10f0100010100d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d01080000010407001ec806000000010405001ed1430001000000
image
The console log of chrome:

2022-09-29 08:21:47        RPC-CORE: submitAndWatchExtrinsic(extrinsic: Extrinsic): ExtrinsicStatus:: 1002: Verification Error: Runtime error: Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed
WASM backtrace:

    0: 0x260bfa - <unknown>!rust_begin_unwind
    1: 0x67dc - <unknown>!core::panicking::panic_fmt::h781687f2782526ba
    2: 0xd1eb0 - <unknown>!TaggedTransactionQueue_validate_transaction
: Runtime error: Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed
WASM backtrace:

    0: 0x260bfa - <unknown>!rust_begin_unwind
    1: 0x67dc - <unknown>!core::panicking::panic_fmt::h781687f2782526ba

And if I test it on my dev node, the node log shows: pangolin-parachain/src/lib.rs:194:1

2022-09-29 08:12:33.560 ERROR tokio-runtime-worker runtime: panicked at 'Bad input data provided to query_info: Codec error', /home/workspace/test/darwinia-parachain/runtime/pangolin-parachain/src/lib.rs:194:1
2022-09-29 08:12:34.379 ERROR tokio-runtime-worker runtime: panicked at 'Bad input data provided to validate_transaction: Codec error', /home/workspace/test/darwinia-parachain/runtime/pangolin-parachain/src/lib.rs:194:1

2. It won't panic if I swap the order of assets, MultiAssets: 0: {parents: 0, interior: X1(PalletInstance(5)} 1: {parents: 0, interior: X1(PalletInstance(7)}

Encoded call data on pangolin parachain:
0x0d0201010100a10f0100010100d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d01080000010405001ec806000000010407001ed1430001000000
image

@xlc
Copy link
Contributor

xlc commented Sep 29, 2022

This is expected behavior. You are passing an invalid data. As you already discovered, the order of assets must sorted or it will panic.

@jiguantong
Copy link
Contributor Author

This is expected behavior. You are passing an invalid data. As you already discovered, the order of assets must sorted or it will panic.

Really? I don't think it's UX friendly

@KiChjang
Copy link
Contributor

I've posted this issue on polkadot.js before: polkadot-js/api#4537.

On the chain side, we have to get the MultiAssets sorted, because we specifically want them to not contain duplicate entries, otherwise the validation algorithm would be an O(NlogN) operation instead of it being O(N).

In other words, this is really a UI/UX issue, and we won't fix it on the chain side.

@jiguantong
Copy link
Contributor Author

Ok, I see.

@KiChjang KiChjang closed this as not planned Won't fix, can't repro, duplicate, stale Sep 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants