polkadot-js / apps

Basic Polkadot/Substrate UI for interacting with a Polkadot and Substrate node. This is the main user-facing application, allowing access to all features available on Substrate chains.
https://dotapps.io
Apache License 2.0
1.75k stars 1.54k forks source link

`queryInfo` and `queryFeeDetails` of `transactionPaymentApi` Runtime API are broken in the developer tab #10994

Open IkerAlus opened 2 weeks ago

IkerAlus commented 2 weeks ago

When querying any of the queryInfo and queryFeeDetails methods of the transactionPaymentApi Runtime API in any chain from the developer tab the following error is returned:

4003: Client error: Execution failed: Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed WASM backtrace: error while executing at wasm backtrace: 0: 0x9be8 - <unknown>!rust_begin_unwind 1: 0x319c - <unknown>!core::panicking::panic_fmt::hbb5a6b42001bdfec 2: 0x5730f1 - <unknown>!TransactionPaymentApi_query_fee_details

It seems that the new release of PJS API has introduced some changes in certain expected types for these queries on PJS apps.

We had a similar issue on API Sidecar and converting the extrinsic to u8a solved the issue.

TarikGul commented 2 weeks ago

Yes, this is certainly an odd issue - I would of imagined the api underneath would accept any value and transform it as necessary but this seems to not be the case. This issue is probably related to: https://github.com/polkadot-js/api/releases/tag/v13.2.1

Imod7 commented 1 week ago

The issue seems to appear when upgrading the api from 12.4.2 to 13.0.1.

In v12.4.2 if I call

await apiAt.call.transactionPaymentApi.queryInfo(extrinsic, extrinsic.length);

where extrinsic is a Hex string, it will return the fees with no issues.

As soon as I upgrade to v13.0.1 the same call returns a wasm panic error and I need to change it to

await apiAt.call.transactionPaymentApi.queryInfo(u8a, u8a.length);

where u8a is

 const ext = api.registry.createType('Extrinsic', extrinsic);
 const u8a = ext.toU8a();

to get the fees with no issues again.

What I noticed in apps is that for the same extrinsic, when it goes in OnSubmit and I check the value of the extrinsic submitted (values[0].value) it looks like apps converted the input extrinsic into Bytes type

api.registry.createType('Bytes', transaction);

and not into Extrinsic type like I did above. Maybe this is related to the error ?

The script that I used to debug the different versions of the api.