6

I'm quite new at this, but I'm having trouble understanding the "metadata version".

My confusion stems from the fact that I know that Polkadot/Kusama has upgraded to v14 a while back, but I don't see the runtime version on-chain reflecting that. The same with chains from the Acala team, they are v14 chains, but in this case the runtime version number I can see if very far away from that and what is on Polkadot and Kusama.

Am I missing something basic? How does the runtime relate to the metadata?

2
  • Sorry, it's not that clear what your question is. Can you please rephrase it?
    – Squirrel
    Mar 28, 2022 at 21:36
  • 1
    Edited above to clarify.
    – Werner S
    Mar 29, 2022 at 15:37

3 Answers 3

8

I believe your confusion stems from "metadata version" and "runtime version" and what the metadata contains at a specific point of the chain.

Metadata exposes all the constants, storage, extrinsics, events, errors and runtime types to the outside world. The metadata version refers to the format in which this data is provided. Connecting to a chain and retrieving the metadata will yield a result where the contents fully describes the runtime modules.

  • Metadata version - ecosystem-wide, a format definition
  • Runtime version - chain-specific, related to runtime features

Each runtime upgrade does change the metadata contents and this stays static until the chain is upgraded again. The formatting of the way this information is provided changes relatively infrequently.

1
  • This is where I was confised, the "format" vs "content" made the penny drop for me
    – Werner S
    Mar 29, 2022 at 15:37
7

I believe Jaco and Sacha explained the "content" concept quite nicely.

If you wish to only use the JS UI to query, you can do the following making RPC calls (the lazy version of cli tools) -

Metadata version -

getMetadata

Runtime version -

getRuntimeVersion

All queries in the above UI under chain state & extrinsics is decorated by the metadata content.

1
  • Thank you! This helps, no I can clearly tie to what is above.
    – Werner S
    Mar 29, 2022 at 15:38
5

The metadata version is specified as an enum variant in the frame_metadata crate, which all runtime pallets use. When a runtime gets compiled to Wasm, the most reliable way to know its metadata information is by inspecting it.

So the on-chain source of truth for which metadata version a chain is running can be found by looking at a chain's Wasm binary. You can verify this using subwasm (go here to follow instructions on installing it). For example:

  1. Get Polkadot's Wasm binary (replace polkadot with local if you're running a chain you want to check locally).
subwasm get --chain polkadot  -o polkadot.wasm
  1. Save the metadata in a JSON file.
 subwasm --json meta polkadot.wasm  > polkadot-metadata.json
  1. Look at the second line of polkadot-metadata.json you've created and you'll see the version:
{
  "V14": {
//--snip--

Yes, one day this may change to V15 to add more features to the metadata system, but this is a much bigger undertaking than any other kind of version bump, such as a runtime version bump which is chain-specific. Adding to Jaco's point, the versioning is more like a universal format in this way.

1
  • Thank you! Will give the tools a whirl.
    – Werner S
    Mar 29, 2022 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.