Skip to content

[subxt-historic] Build type information up for Kusama and Westend. #2088

@jsdw

Description

@jsdw

We have polkadot_types.yaml already, which describes the legacy types for the Polkadot RC from genesis.

The aim of this issue is to create type definitions for Kusama too, and put the malongside the Polkadot ones. We may also want to create type definitions for Kusama AH, Westend and Westend AH; this needs to be decided on still!

How?

The Polkadot type definitions were constructed largely with the help of the historic decoding tool, which has commands to iterate over a bunch of blocks and decode all of the extrinsics within, as well as iterating in a deterministic way over specific blocks across runtimes and decoding all storage at those blocks. In the event that decoding fails, it returns a “pretty” error noting what went wrong.

Lets run this against Kusama, starting with our Polkadot type definitions, find things that fail to decode, and then work out which types need adding to successfully decode them. The repository also contains a simple PJS script which tries decoding a block or storage using PJS instead, so that we can compare the outputs, and hopefully see better what went wrong.

  • It would be really nice if we can work out which types aren't needed/used anywhere too so we can remove anything unnecessary. Perhaps the historic decoding tool could be tweaked with some command to check against all of the metadatas for each runtime and see which types are listed in our definitions but not needed?
    • We would likely see a bunch of types listed in the metadata that aren't in our type definitions too and it would be great to flag those too! It might be that we don't need them because the rleevant functionality was never actually used, but would be a good way to sanity check!

Ro run against a Kusama node, what I usually do is go to PJS and then open the left sidebar by clicking the chain icon/text in the top left and selecting some chain of interest. There are several RPC nodes listed for each chain, and when you select one you can pull the URL from the address bar (or, I think here is the code in which the URLs are defined for eg all Kusama chains).

Running against live archive nodes lets you easily test historic blocks :)

Because PJS already has successfully decoded most old entries, we can also look through the polkadot type definitions to try and understand how PJS is decoding them. As an example, here is information about spec version changes in kusama, here are the “roor” types for a specific pallet, and here are the differences in types across spec versions for Kusama. With this information, we can often find a type matching the name we are failing to decode, try that, and have success. Rinse and repeat until everything decodes!

Note: Of the system chains, Kusama AssetHub and Westend AssetHub also need some type definitions as they begin at V12 metadata. All other system chains appear to be V14+.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions