substrate-api-client icon indicating copy to clipboard operation
substrate-api-client copied to clipboard

Investigate extended usage of metadata

Open haerdib opened this issue 2 years ago • 4 comments

We have full access to the metadata, but it's hardly used yet. Can we do more with that?

E.g. like this comments suggests: https://github.com/scs/substrate-api-client/blob/7e5962bd2c9149f990b34aa25ad7bc7f6f92c868/compose-macros/src/lib.rs#L38-L39

Check out subxt example: https://github.com/paritytech/subxt/blob/master/subxt/src/tx/tx_client.rs#L56-L73

haerdib avatar Jan 04 '23 13:01 haerdib

It seems that what the comment suggests and what is done in subxt is something entirely different. Subxt does only verify the generic call metadata hash without the arguments of what has been generated at compile time in their macro matches the the hash of the pallet-prefix and the call-name of the supplied call.

Hence, subxt verifies the same thing as we already do with: https://github.com/scs/substrate-api-client/blob/7e5962bd2c9149f990b34aa25ad7bc7f6f92c868/compose-macros/src/lib.rs#L46

Be aware that subxt has more need for validation than us, as it relies on statically generated code that it wants to check against the actual metadata that the client connects to, while the api-client does only know the latter.

but I like the Idea. What could we do with the metadata? :)

clangenb avatar Jan 05 '23 18:01 clangenb

I see. Didn't look too deeply into that. Nonetheless, something like https://github.com/integritee-network/worker/issues/970#issue-1360604404 was possible. Not sure if that's verifiable with the metadata, but I think it should be worth it to investigate a little.

haerdib avatar Jan 06 '23 07:01 haerdib

I suggest timeboxing this task to 8h. If there's a promising lead after investigation, it should be done in a different task.

haerdib avatar Jul 10 '23 07:07 haerdib

There is an extensive discussion on how to change the metadata, especially for (offline-) light clients, and there is an ongoing proposal on polkadot on how to implement this. I suggest waiting for some results there: https://forum.polkadot.network/t/the-ledger-app-debate-united-we-stand-divided-we-fall/3177/9.

clangenb avatar Jul 10 '23 08:07 clangenb