xx-labs / xxstats

Integration of xx network in Polkastats web app
Apache License 2.0
2 stars 1 forks source link

Error getting extrinsic fee info in crawler #29

Open mariopino opened 1 year ago

mariopino commented 1 year ago
{"level":20,"time":1671440528713,"pid":44,"hostname":"f11a79e883e1","crawler":"blockHarvester","msg":"Error getting extrinsic fee info: Error: createType(RuntimeDispatchInfo):: Struct: failed on weight: u64:: Assertion failed"}
{"level":20,"time":1671440528714,"pid":44,"hostname":"f11a79e883e1","crawler":"blockHarvester","msg":"Error getting extrinsic fee info: Error: createType(RuntimeDispatchInfo):: Struct: failed on weight: u64:: Assertion failed"}
{"level":20,"time":1671440528731,"pid":44,"hostname":"f11a79e883e1","crawler":"blockHarvester","msg":"Error getting extrinsic fee info: RpcError: 1: Unable to query dispatch info.: Failed to decode return value of TransactionPaymentApi_query_info"}
mariopino commented 1 year ago

Another example showing block hash:

2022-12-19 09:44:50        RPC-CORE: queryInfo(extrinsic: Bytes, at?: BlockHash): RuntimeDispatchInfoV1:: createType(RuntimeDispatchInfoV1):: Struct: failed on weight: u64:: Unable to construct number from multi-key object
{"level":20,"time":1671443090282,"pid":44,"hostname":"6b400119f8bb","crawler":"blockHarvester","msg":"Error getting extrinsic fee info (blockHash: 0xa01aa7e1eb4095c96abb1eaca786edcd266c7ef38c8db6508a6e5011938a380d): Error: createType(RuntimeDispatchInfoV1):: Struct: failed on weight: u64:: Unable to construct number from multi-key object"}

Script to reproduce the bug:

import { ApiPromise, WsProvider } from '@polkadot/api';

async function main() {

  const wsProvider = 'ws://dev.xx.polkastats.io:9944';

  // Initialise the provider to connect to the remote node
  const provider = new WsProvider(wsProvider);

  // Create the API and wait until ready
  const api = await ApiPromise.create({ provider });

  const block = await api.derive.chain.getBlock('0xa01aa7e1eb4095c96abb1eaca786edcd266c7ef38c8db6508a6e5011938a380d');
  console.log(JSON.stringify(block, null, 2));

  const feeInfo = await api.rpc.payment.queryInfo('0x45028400669a0b768bdc34fdbc06e87d7e07659825e12e60a2d8575c88a651fe0f2a427501165e2911d3e569a9187a462b22e90e4dcd6effbae4f6bc7cfea71ba547cb5e5aec363ab3b5c42706a82ac86f954baf9a31e3060e445890b5225dc565a397e78435030400040300e28d1fe54dbb78a0460afee227367705a9da405d9bf8e1a88d2f6974466bba790b00d8998bd603', '0xa01aa7e1eb4095c96abb1eaca786edcd266c7ef38c8db6508a6e5011938a380d');
  console.log(JSON.stringify(feeInfo, null, 2));

}

main().catch(console.error).finally(() => process.exit());
mariopino commented 1 year ago

After upgrading polkadot-js to v9.10.3 and xxchain node to v0.2.5-1 (https://github.com/xx-labs/xxchain/releases/tag/v0.2.5-1) I noticed that the error is related to a breaking change introduced in polkadot-js v9.2.2 and also changes introduced to the runtime related to weights (Weights V2).

Check:

https://substrate.stackexchange.com/questions/4835/rpc-core-queryinfoextrinsic-bytes-at-blockhash-failed-on-weight-u64

Fix is being tested right now...