paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.network/
1.82k stars 661 forks source link

dryRunApi.dryRunCall: redundant items in forwardedXcms #5878

Open mrshiposha opened 1 week ago

mrshiposha commented 1 week ago

When dry-running the polkadotXcm.transferAssets extrinsic using the new dryRunApi, AssetHub reports excessive items in the forwardedXcms field.

For instance, if one constructs an extrinsic to transfer USDT to a different chain and dry-runs it to obtain the forwarded messages, they will get the following:

  1. an empty list of messages heading to the relay chain
  2. the ReserveAssetDeposited message heading to the destination chain repeated several times

You can see this by dry-running the following using any account with at least 1 USDT as the Origin.

0x1f0b04010100411f0400010100bee592c66e1f3bd7f438a0800cbd2f2519ccc0ce763325091f778f1809cdbd4704040002043205011f0002093d000000000000

The cause

  1. The InspectMessageQueue trait implementation for tuples doesn't discard empty lists, which is the cause of the first issue.
  2. The InspectMessageQueue trait implementation for SovereignPaidRemoteExporter reuses the Router passed as the generic parameter. AssetHub's XCM config contains bridge routers that use SovereignPaidRemoteExporter and pass the XcmpQueue to the generic parameter. Thus, XcmpQueue's messages got into the final list several times.
bkchr commented 1 week ago

CC @franciscoaguirre

franciscoaguirre commented 1 week ago

Nice catch! I'm working on fixing this alongside https://github.com/paritytech/polkadot-sdk/issues/5708