polkascan / py-substrate-interface

Python Substrate Interface
https://polkascan.github.io/py-substrate-interface/
Apache License 2.0
240 stars 111 forks source link

Querying chain with pre-V14 metadata history #283

Closed h4nsu closed 1 year ago

h4nsu commented 1 year ago

I'm trying to use py-substrate-interface to scrape some data from Aleph Zero blockchain, which has switched from V13 to V14 metadata at some point in its history. Queries I'm trying to make for older state (blocks before the metadata switch) fail with:

NotImplementedError: Decoder class for "XXX" not found

Is there any way to circumvent that and have one instance of SubstrateInterface handle both V13 and V14 metadata seamlessly?

arjanz commented 1 year ago

Depends on the runtime. Because a pre-V14 metadata requires a manually provided type composition information and for some popular runtimes is such a type registry included (like Polkadot, Kusama, Moonbeam, Acala etc). You can find a list of included type registries here: https://github.com/polkascan/py-scale-codec/tree/master/scalecodec/type_registry

I already saw there is no type registry provided for Aleph Zero, so that would mean you will have to make one yourself by defining the types used in the runtime or convert a type registry file used by PolkadotJS (if there is any)

h4nsu commented 1 year ago

Hi @arjanz, thanks for the reply! I investigated these type registry presets and tried naively to use "legacy", but it didn't work.

Could you possibly point me in a general direction how to manually prepare such a type registry? Is there any tooling or documentation available for that?

By the way, would you be interested in including Aleph Zero in the list of presets?

arjanz commented 1 year ago

Could you possibly point me in a general direction how to manually prepare such a type registry? I there any tooling or documentation available for that?

Basically it is a process of defining all types used in the runtime, like this example: https://github.com/polkascan/py-scale-codec/issues/94#issuecomment-1346205326

By the way, would you be interested in including Aleph Zero in the list of presets?

I'll put it on the todo list , but because it is only concerning historical runtimes, it would not be the highest priority to be honest..