Closed tadeohepperle closed 12 months ago
Currently connecting with a light client is super slow. Ofter 30+ seconds. I think it is due to some state synching smoldot is doing. Also Smoldot makes a lot of P2P requests to random IP addresses that sometimes fail (sometimes a lot), which currently clutters the Javascript Console with error messages.
Just to check (because it wasn't clear to me looking at the code): when does this long loading time occur? is it when the user clicks "generate" after selecting a light client? Or sooner?
We should probably add a warning note on the light client tab that says something like "Clicking generate will instantiate a light client, which could take up to a minute to load and sync with the chain.".
@jsdw The long loading time occurs after the user clicks "Generate". It is purely time spent in this rust future:
LightClientBuilder::new().build(&chain_spec).await
So I guess it is about Smoldot syncing with the provided bootnodes in the chainspec? Not sure what can be done about it.
So I guess it is about Smoldot syncing with the provided bootnodes in the chainspec? Not sure what can be done about it.
Ah yup, if it happens once you click "generate" then that's the best we can do! We could add a warning note just so that people expect it might take a while to load when they click the button :)
Users can now use their own
chain_spec.json
files to connect via the Smoldot lightclient integration that subxt can use under theunstable-lightclient
feature flag. Also at the start of the web app, chain spec presets are fetched from This Repo via the github API. Currently this amounts to 4 chain specs. They are loaded in about 100ms, so it is not that bad. Users can select these presets instead of supplying their own chain specs:Also the app state has been cleaned up a little. Creating a client now involves two data structures, a
ClientCreationConfig
andClientCreationData
. At any point of the app lifecycle, aClientCreationConfig
can be derived from the query params. This is also done at app start. AnyClientCreationConfig
can be used to generateClientCreationData
, which then is passed to the Rust Code in WASM to initiate the connection. However the opposite way (ClientCreationData
->ClientCreationConfig
) is not always possible. That is because aClientCreationConfig
should be 100% representable in terms of query params. Which is e.g. not possible if a user uploads a file.There is now the option to share URLs that use light client presets. For this a url needs to contain
?lightclient=Polkadot
. This creates aClientCreationConfig
at app starts that is checked against any chain specs obtained from the aforementioned substrate connect repo.Currently connecting with a light client is super slow. Ofter 30+ seconds. I think it is due to some state synching smoldot is doing. Also Smoldot makes a lot of P2P requests to random IP addresses that sometimes fail (sometimes a lot), which currently clutters the Javascript Console with error messages.