Skip to content
New issue

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

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

Already on GitHub? # to your account

subxt metadata does not work when talking to older nodes #1125

Closed
atodorov opened this issue Aug 18, 2023 · 5 comments · Fixed by #1127
Closed

subxt metadata does not work when talking to older nodes #1125

atodorov opened this issue Aug 18, 2023 · 5 comments · Fixed by #1127

Comments

@atodorov
Copy link

I'm trying to download the metadata from a blockchain built with Substrate. I have a local node running and http://localhost:9933 is accessible:

$ curl -H "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "state_getMetadata", "params":[]}' http://localhost:9933 
{"jsonrpc":"2.0","result":"0x6d6574610e5906000c1c73705f636f72651863727970746f2c4163636f756e7449643332000004000401205b75383b2033325d0000040000032000000008000800000503000c08306672616d655f73797374656d2c4163636f756e74496e666f0814496e64657801102c4163636f756e74446174610114001401146e6f6e6365100114496e646578000124636f6e73756d657273100120526566436f756e7400012470726f7669646572

... truncated ...

Trying subxt fails:

$ subxt metadata --format bytes 
Error: 
   0: Other error: The node can only return version 14 metadata using the legacy API but you've asked for something else

Location:
   /home/gluwa/.cargo/registry/src/index.crates.io-6f17d22bba15001f/subxt-cli-0.31.0/src/utils.rs:73

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
@niklasad1
Copy link
Member

hey @atodorov

Can you report which version of substrate that you are using?
I suspect the node is using older metadata than subxt supports

@atodorov
Copy link
Author

@jsdw jsdw changed the title Other error: The node can only return version 14 metadata using the legacy API but you've asked for something else subxt metadata does not work when talking to older nodes Aug 18, 2023
@jsdw
Copy link
Collaborator

jsdw commented Aug 18, 2023

Ooh, sorry about that! Our fallback code was a bit wonky and didn't work in the default case of asking for "latest" metadata (see the fix in #1127)

As a workaround you can ask for an explicit metadata version, which should work, eg:

subxt metadata --version 14 --format bytes

(the node you're talking to won't have version 15 metadata yet)

@atodorov
Copy link
Author

As a workaround you can ask for an explicit metadata version, which should work, eg:

Thanks, that worked in the sense that subxt didn't fail and was able to fetch metadata.

@jsdw
Copy link
Collaborator

jsdw commented Aug 21, 2023

Great! The next release will fix the CLI tool so that the fallback path should work properly without that workaround :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants