paritytech / json-rpc-interface-spec

30 stars 3 forks source link

Add `chainSpec_unstable_spec` method #124

Open lexnv opened 10 months ago

lexnv commented 10 months ago

This PR adds the chainSpec_unstable_spec method to fetch the chainSpec from a running node.

Substrate nodes expose currently sync_state_genSyncSpec. The new method unifies the format of substrate chain-spec needed for the light-clients to sync to the head of the chain.

There are several differences from the traditional chain-spec:

The checkpoint object could then be extended to include the syncState needed by lightclients: https://github.com/paritytech/substrate/issues/11184

Block numbers are represented as string unsigned integers, similar to the current chainSpec. I believe this may be an artifact of javaScript users.

Would love to get your thoughts on this 🙏 // cc @jsdw @tomaka @bkchr @skunert

tomaka commented 10 months ago

While I like the idea of defining the format of the chain spec in the JSON-RPC specification, it is unfortunately a bit complicated to define a proper format, due to a lot of details.

In smoldot, I intended to indeed add a JSON-RPC function that returns the chain spec, but I wanted to leave this JSON-RPC function unstable forever and make it smoldot-specific.

Apart from which name to give to things, here's a list of remarks:

lexnv commented 3 months ago

In this revision I've added the consensus and finality bits we need to sync with the chain. Its a bit less elegant than the agnostic checkpoint, but this way smoldot can provide the chainSpec without making queries to the full nodes.

I suggest adding this as unstable and implementing it in substrate to have a starting point. We can always go back to the agnostic checkpoint if you think it is not too error prone

Would love your feedback on this @tomaka @jsdw 🙏