Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to decode OpaqueCall on Westend #2858

Closed
emostov opened this issue Nov 17, 2020 · 4 comments
Closed

Fails to decode OpaqueCall on Westend #2858

emostov opened this issue Nov 17, 2020 · 4 comments
Labels
Support Tracks issues or requests related to troubleshooting, answering questions, and user assistance.

Comments

@emostov
Copy link
Contributor

emostov commented Nov 17, 2020

The below code errors trying to decode an OpaqueCall from a block #2223354 on Westend:

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

async function main() {
	const provider = new WsProvider('wss://westend-rpc.polkadot.io');
	const api = new ApiPromise({ provider });
	const hash = await api.rpc.chain.getBlockHash(2223354);
	const { block } = await api.rpc.chain.getBlock(hash);

	block.extrinsics.forEach((ext) => {
		if (ext.method.method == 'asMulti') {
			const callArgs = ext.method.get('args') as any;
			for (const paramName of callArgs.defKeys) {
				const argument = callArgs.get(paramName);
				if (paramName === 'call' && argument?.toRawType() === 'Bytes') {
					// Fails here with: `Error: createType(Call):: findMetaCall: Unable to find Call with index 0x9004/[144,4]`
					const decodedCall = block.registry.createType(
						'Call',
						argument.toHex()
					);
					console.log(decodedCall.toHuman());
				}
			}
		}
	});
}

main().catch(console.log);

I had a similar problem before, but that was due to using the wrong registry (see #2753). In this case, from what I understand, I am using the correct registry.

Is this expected behavior on Westend? I recall seeing something about having problems supporting older Westend runtimes, but I couldn't find a concrete github issue to confirm.

(relates to paritytech/substrate-api-sidecar#343)

@jacogr
Copy link
Member

jacogr commented Nov 18, 2020

Extrinsic -

6d03 // length
84 // signed
400d6ffd525971da179e1c864bcd8ca51ec8f3d8d13ddcf98e8b15f959050466 // sender
01 // sr25519
3c532650bcae0793e2ce78dfbba93acb8171336f832a06df3b22cc4a7a975859 // sig 1st 32
910caa2c2e1149b9cb52a800af251e5c7b274dd0a19e4667803d18700bffd98d // sig 2nd 32
5503 // mortal
04 // nonce 1 (1 << 2)
00 // tip 0
1701 // multisig.asMulti
0200 // threshold, u16
08 // 2 signatories (2 << 2)
c86798f5202849ea7fe20554e85a7ea2d9bdfb4453989ffac2f88444c6930c4d // signatory 1
d4eef1635c3a3c9db33dc403111f946c778daa292f67dfa6fb4df4c80e1c777d // signatory 2
00 // no timepoint

// <OpaqueCall>
94 // length 37 (37 << 2)
9004 // invalid call index, there are not that many modules
// no idea... call data
04007a96c46c060fff242ef788c4e3f4c50c7d7ec3131ec3513571a1c6994017fb1704
// </OpaqueCall>

00 // don't store?
0000000000000000 // 0 weight?

So, yes, whatever it is, cannot decode it manually either, it is invalid. (length does match up nicely with the 37 for the actual data, so the store and weight params is most-probably correct)

TL;DR Expected, also see https://westend.subscan.io/extrinsic/0x5b7ee199447a71c0a3f411ea64a919e2a02b0e9d5ba565668b89026ea11675fa

@jacogr jacogr added the Support Tracks issues or requests related to troubleshooting, answering questions, and user assistance. label Nov 18, 2020
@jacogr
Copy link
Member

jacogr commented Nov 18, 2020

Closing. Operating as expected with the data provided.

@jacogr jacogr closed this as completed Nov 18, 2020
@emostov
Copy link
Contributor Author

emostov commented Nov 18, 2020

Thank you for the detailed break down!

@polkadot-js-bot
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

@polkadot-js polkadot-js locked as resolved and limited conversation to collaborators Jun 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Support Tracks issues or requests related to troubleshooting, answering questions, and user assistance.
Projects
None yet
Development

No branches or pull requests

3 participants