smol-dot / smoldot

Lightweight client for Substrate-based chains, such as Polkadot and Kusama.
GNU General Public License v3.0
188 stars 50 forks source link

Add unstable JSON-RPC function that exports recent networking events #72

Open tomaka opened 1 year ago

tomaka commented 1 year ago

https://github.com/paritytech/smoldot/issues/2245

tomaka commented 1 year ago

This function should be added as a PR to https://github.com/paritytech/json-rpc-interface-spec/

tomaka commented 1 year ago

cc https://github.com/paritytech/json-rpc-interface-spec/pull/91

tomaka commented 9 months ago

We need to add a few events in established.rs:

All the JSON-RPC events can then be derived from this.

Then, the events service.rs need to be updated as well. This part is unfortunately not completely clear to me.

tomaka commented 9 months ago

When a notifications out request has successfully negotiated the substream. When a request has successfully negotiated the substream.

Actually, we can just pretend that the substream has opened when we start the opening, so there's no need for these two events.

tomaka commented 9 months ago

Then, the events service.rs need to be updated as well. This part is unfortunately not completely clear to me.

The solution (which I feel stupid for not thinking of earlier) is to provide an OpaqueEvent which can be turned into either a LowLevelEvent or an optional HighLevelEvent.

tomaka commented 9 months ago

A big difficulty, which I didn't anticipate, is that the connections that the network service opens do not target a chain in particular, but the JSON-RPC function does target a specific chain.

This means that we have to somehow report to the API user only connections that we think might belong to a specific chain. Reporting only some connections might be misleading? Maybe we should report all connections?