scs / substrate-api-client

Library for connecting to substrate API over WebSockets
Apache License 2.0
259 stars 122 forks source link

Investigate extended usage of metadata #416

Open haerdib opened 1 year ago

haerdib commented 1 year ago

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

clangenb commented 1 year ago

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? :)

haerdib commented 1 year ago

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 commented 1 year ago

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

clangenb commented 1 year ago

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.