-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prototype smoldot browser extension #82
Comments
For what it's worth, smoldot should be capable in the future of connecting to multiple chains by running only one client. Parachains aren't launched yet, so this isn't implemented, but for example, in order to talk to parachain A, smoldot will need to be connected both to chain A and to Polkadot. It would make sense to me to add the possibility of specifying multiple chains, or even the possibility to add or remove chains while it's running. |
If we have a PolkadotJS API instance on both sides; in the page and in the browser extension what happens for version mismatches? An extension has a long lifetime. It has to exist in a user's browser for many months and it has to have its own upgrade path. This presents challenges / quesions:
The reasons for us to want to upgrade an extension will naturally be different from those for the PolkadotJS API and the benefits of having the PolkadotJS API in the extension are limited. (strawman - what are the benefits? - let me know if you can think of some). Case for having a different abstraction inside the extension
Change in scope for the prototypeThe same but no SmoldotProvider inside the extension - a new BEFORE: Proposed flow: Extension installed: Web page -> SmoldotConnectProvider -> extension -> SmoldotProvider -> smoldot AFTER: Proposed flow: Extension installed: Web page -> SmoldotConnectProvider -> extension -> SmoldotClientManager -> smoldot |
This proposed |
It might be easier to just ask me, in particular because the To give a summary:
|
Thanks @tomaka I think it's good for me to understand what's going on too and it can't hurt if I get to know smoldot internals better. What I want to know is are there implications of having something wrapping smoldot that is multiplexing RPC requests? I.e. there is one smoldot client in the extension but there are potentially many pages making those requests - a map of PolkadotJS API client request ids -> actual request ids in the extension. I don't think this should be a problem but maybe there are assumptions about there only being one actual client. |
Indeed, feel free to read the code as well. Everything should work even in the presence of multiple API clients. Note however that if an API client disconnects and has active subscriptions, you'll need to send unsubscribe requests to clean them up. |
I have turned this into an umbrella issue to track all the tasks and to split up the work. |
Introduction
Create an end-to-end prototype to get more insight into this:
Theory
We can make a polkadot-js API provider that makes the use of an extension transparent to the application developer.
Proposed API :
Proposed flow:
Extension installed:
Web page -> SmoldotConnectProvider -> extension -> SmoldotClientManager -> smoldot
Extension not installed:
Webpage -> SmoldotConnectProvider -> SmoldotProvider -> smoldot
Aim
Approach
Create a browser extension that is not configurable and has minimal UI that is used transparently by webpages instead of embedding a node when the extension is installed.
What should the SmoldotClientManager do
The
SmoldotClientManager
inside the extension must broker RPC requests and responses from multiple clients residing on browser pages (aka content pages) to multiple smoldot blockchain clients in the extension (for now we have one but there will be many). This entails:SmoldotProvider
in each webpage will issue RPC requests with ids in its own namespace (starting from 1). TheSmoldotClientManager
must maintain a translation table of client request ids to the actual request ids and send the correct responses to the correct clients. The translation table will be a map of clients to ID mappings where an ID mapping is the originating request id and the actual request id sent to smoldot. TheSmoldotClientManager
will change the request and response IDs in the JSON on the fly and maintain the list of live mappings.SmoldotClientManager
must detect when clients disconnect and send unsubscribe messages for all that clients' subscriptions.SmoldotClientManager
could also intelligently cache queries in the future (out of scope for now).The text was updated successfully, but these errors were encountered: