paritytech / polkadot-sdk

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

Transport error on custom XCM Instruction #3195

Closed dudo50 closed 4 months ago

dudo50 commented 5 months ago

I am building a custom XCM pallet for Non-fungibles.

While executing specific call:

      match send_xcm::<T::XcmSender>(
          (Parent, Junction::Parachain(destination.into())).into(),
          Xcm(vec![Transact {
              origin_kind: OriginKind::Native,
              require_weight_at_most: Weight::from_parts(1_000, 1_000),
              call: <T as Config>::RuntimeCall::from(Call::<T>::mint_collection_received {
                  collection_name,
                  collection_description,
                  origin_parachain_id: 2000.into(),
                  owner: recipient.clone(),
              })
              .encode()
              .into(),
          }]),            ) {
          Ok((hash, cost)) => Self::deposit_event(Event::CollectionCreatedAndTransferedXCM {
              collection_hash,
              owner: recipient.clone(),
              destination,
          }),
          Err(e) => Self::deposit_event(Event::CollectionFailedToXCM {
              e,
              collection_hash,
              owner: recipient.clone(),
              destination,
          }),             }

I receive an error: "Transport". I looked it up on the XCM_Format repository and error does not tell me much. Transport = 14: Destination is routable, but there is some issue with the transport mechanism. The destination is of ParaId type.

What am I missing or doing wrong?

Screenshot 2024-02-03 at 17 11 08

Thanks in advance.

bkchr commented 5 months ago

CC @franciscoaguirre

franciscoaguirre commented 4 months ago

I'll take a look at this.

@dudo50 is this live on some chain? Can you send me an extrinsic if that's the case? Could you share a link to the code if it's possible?

dudo50 commented 4 months ago

Hey @franciscoaguirre, It is not live on chain I test it locally through Zombienet. I can share the code with you, however: https://github.com/ParaSpell-Research-Foundation/polkadot-sdk-nft-pallet/blob/master/cumulus/parachain-template/pallets/xnft/src/lib.rs

It is a custom pallet implemented in the Parachain Template. PoC for cross-chain NFT sharing.

The XCM part that fails starts at line: https://github.com/ParaSpell-Research-Foundation/polkadot-sdk-nft-pallet/blob/master/cumulus/parachain-template/pallets/xnft/src/lib.rs#L337

To test code pull the repo compile parachain template cargo b -r -p parachain-template-node compile polkadot node cd Polkadot && cargo build --release

Then launch via Zombienet: Navigate to binaries cd binaries add your zombienet binary and run command: ./zombienet-macos -p native -c 1 spawn config.toml

Thanks for your time!

franciscoaguirre commented 4 months ago

I couldn't get the runtime XCM logs with zombienet, where I would've been able to diagnose the issue. Do you know how to? I don't use zombienet much.

dudo50 commented 4 months ago

Thank you for your time @franciscoaguirre , I do not know how to get them through Zombienet unfortunately. Perhaps @pepoviola could help us on this one? Is there any way to get XCM logs through Zombienet?

Edit: @franciscoaguirre perhaps try with debug option?

DEBUG=zombie* zombienet-macos -p native -c 1 spawn config.toml
pepoviola commented 4 months ago

Hi @dudo50, does the logs are produced by the pallet? in that case you can search in the node logs (in native we store all the logs for the nodes in the same tmp directory).

Thx!

bkontur commented 4 months ago

@dudo50 it is the same issue as here: https://substrate.stackexchange.com/questions/10950/error-bad-origin-on-custom-xcm-integration?

dudo50 commented 4 months ago

Hey @bkontur , yes, I figured, the best and fastest way to resolve this issue is to contact both platforms.

bkontur commented 4 months ago

Hey @bkontur , yes, I figured, the best and fastest way to resolve this issue is to contact both platforms.

@dudo50 I see, the more noise, the higher the success rate :D (co uz s tebou narobime), please check that https://substrate.stackexchange.com/questions/10950/error-bad-origin-on-custom-xcm-integration/11002#11002 , I think that missing HRMP channel and wrong para id is your problem

dudo50 commented 4 months ago

@bkontur opening HRMP channels between 1000 and 1001 using parasudowrapper results in weird error "unsupported" any idea as to why that might happen? HRMP channels are opened correctly on Relay chain side.

Screenshot 2024-02-12 at 12 31 52 Screenshot 2024-02-12 at 12 31 16
dudo50 commented 4 months ago

@bkontur After opening HRMP channels I am now able to send XCM, but receiving Parachain also returns Unsupported.

Screenshot 2024-02-12 at 12 34 38 Screenshot 2024-02-12 at 12 35 48

EDIT: (Už asi nič so mnou nenarobíte no :D)

bkontur commented 4 months ago

@dudo50 you can add this to the zombienet here:

        args = [
        "-lparachain=debug,xcm::process-message=trace,xcm::execute=trace,xcm::process=trace"
    ]

and it will show you the reason in the logs, could please share then?

dudo50 commented 4 months ago

@bkontur , here are the logs: parachain1000log.txt parachain1001log.txt relaychainlog.txt

bkontur commented 4 months ago

ok, there are several issues, I can see now:

parachain-template expects paid XCM execution: https://github.com/ParaSpell-Research-Foundation/polkadot-sdk-nft-pallet/blob/master/cumulus/parachain-template/runtime/src/xcm_config.rs#L100-L102

So, there are several fixes:

  1. You need to add e.g. WithdrawAsset + BuyExecution to your program here: https://github.com/ParaSpell-Research-Foundation/polkadot-sdk-nft-pallet/blob/master/cumulus/parachain-template/pallets/xnft/src/lib.rs#L338 but then you need to make sure that sovereign account of Parachain(1000) on Parachain(1001) has some tokens (maybe just to teleport from relay). You can check more: https://wiki.polkadot.network/docs/learn/xcm/journey/transfers-summary

  2. You can add UnpaidExecution(Unlimited) before your Transact instruction, but then you need to add another exception here: https://github.com/ParaSpell-Research-Foundation/polkadot-sdk-nft-pallet/blob/master/cumulus/parachain-template/runtime/src/xcm_config.rs#L87 : `

    parameter_types! {
    pub MyPara1000: MultiLocation = (Parent, Parachain(1000)).into();
    }
    
    ...
    
    AllowExplicitUnpaidExecutionFrom<(ParentOrParentsExecutivePlurality, Equals<MyPara1000>)>,

And the last one, I am not sure about require_weight_at_most: Weight::from_parts(1_000, 1_000), here: https://github.com/ParaSpell-Research-Foundation/polkadot-sdk-nft-pallet/blob/master/cumulus/parachain-template/pallets/xnft/src/lib.rs#L340 , because you set a different numbers for extrinsic mint_collection_received here: https://github.com/ParaSpell-Research-Foundation/polkadot-sdk-nft-pallet/blob/master/cumulus/parachain-template/pallets/xnft/src/lib.rs#L370-L371, you can check the real weight for extrinsic call with PJS, there is a runtime call: transactionPaymentCallApi::queryCallInfo, so you can take this value, double it and set as a require_weight_at_most

image

dudo50 commented 4 months ago

@bkontur This did not entirely resolve our issue, unfortunately. We are still getting an error "unsupported" when opening HRMP channels between our Parachains through parasudowrapper.

Screenshot 2024-02-12 at 17 14 02
dudo50 commented 4 months ago

@pepoviola , I've concluded, that the issue is probably in zombienet or config. I have pulled fresh polkadot-sdk and launched the network via Zombienet config here: https://github.com/ParaSpell-Research-Foundation/polkadot-sdk-nft-pallet/blob/master/binaries/config.toml

Could you please try if you can open the HRMP channel between 2 parachains successfully when you follow these steps: https://github.com/paritytech/polkadot-sdk/issues/3195#issuecomment-1934235575? Because I could not see an issue as to why it would during opening of the HRMP channel say - the error message "unsupported" on Parachains if something during startup was not handled incorrectly - https://github.com/paritytech/polkadot-sdk/issues/3195#issuecomment-1939038585.

dudo50 commented 4 months ago

Closing this in favor of https://github.com/paritytech/polkadot-sdk/issues/3436