-
Notifications
You must be signed in to change notification settings - Fork 63
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
High level thinking from Textile #14
Comments
Hello @astula and Textile team, Sorry for the response time but we had a lot of thought about your proposal and we took the time to look at what you were doing on Textile. We totally agree that the goal of gomobile-ipfs is to create a package that is easily usable for mobile developers. The best in our opinion would be to instanciate an optimized We've been thinking about a proposal and we'd like to have your feedback on it. Init and BindingWe think that the best approach would be to have a lib that is imported, inited and lifecycle managed from native languages as you do with Textile. The init would create a new IPFS-node exposing an HTTP API over Unix domain socket. The advantage of UDS compared to TCP/IP is that you can restrict its access to your own process. So here is the pseudo code of this first step: node = "github.com/ipfs/go-ipfs/core".NewNode()
unix_listener = "net".Listen("unix", unix_socket_path)
"github.com/ipfs/go-ipfs/core/corehttp".Serve(node, unix_listener) Native languagesFor Java/Swift/ObjC/JS(RN) to be able to talk with the Node, it would only be necessary to:
httpclient := "http".Client(unix_socket_path)
shell := "github.com/ipfs/go-ipfs-api".NewShellWithClient(httpclient)
# example: https://docs.ipfs.io/reference/api/http/#api-v0-dht-findpeer
request = shell.NewRequestBuilder("/dht/findpeer")
request.Argument("<peerID>")
request.BoolOption("verbose", true)
response = request.Exec() // returns JSON
# example: https://docs.ipfs.io/reference/api/http/#api-v0-dht-findpeer
response = shell.Request("/dht/findpeer?arg=<peerID>&verbose=true") // returns JSON Pros:
Cons:
GolangIn case a developer would like to write go code using a mobile IPFS node, we think it would be better if they did so in a separate gomobile root package because:
This implies that this second root package must talk with gomobile-ipfs through the same channel as native languages. However, it would still be much better if a golang developer could use the node directly through the CoreAPI. It would be simpler for him, more powerful and its code would be almost identical on mobile and on another platform (we plan to make a Windows, macOS and Linux version of Berty so this issue interests us a lot). To achieve this result, it would be sufficient to use this package and to plug it to the gomobile-ipfs HTTP API over UDS as follows: httpclient := "http".Client(unix_socket_path)
coreapi := "github.com/ipfs/go-ipfs-http-api".NewApiWithClient(httpclient) Packages and lifecycle management
We believe that these are two of the top priorities. We've had hard time to manage this on Berty v1 and we saw that you managed to do something very clean on Textile. It would be really great if it could be managed directly by the lib with as little effort and reflection on the part of the user as possible. Your help would be greatly appreciated to make this works! :)
We really like the way you managed to do that! It is clean, modular and easy to use. We never had to think about these problems on our side because our initial code was not intended to be generic and reusable. Again, we would very much like your help on these points. However, we would like to make a proposal for an alternative to multi-repo. We could have a mono-repo (except for the react-native package) with a structure as follows:
The main advantage would be to manage PRs from contributors that modify both Android, iOS and Go code in one place and without the risk of conflicts/incompatibilities due to the delay between merges on different repos.
We didn't have the chance to publish our app on the App Store yet, so we trust you on this one. The trick is to disable DTrace, right? BTW, we started setting up Bazel for the build of our current version of Berty, it's really powerfull when it comes to manage cross-platform application builds in different languages, its blazing fast but it can be a pain to setup and maintain. It is not a priority and we will probably be more effective in implementing it when we have more experience on the subject. Native driversWe think that one of the best ways to improve gomobile-ipfs would be to optimize it and extend its capabilities using native drivers. On Berty v1 we had a connectivity driver that notified the node of connectivity changes (internet connection yes/no, wifi or cellular, bluetooth yes/no, multicast address available, etc...). In this way, we ensured that unnecessary services were cut and requests were filtered according to the context (mainly to save resources). It was easy to do on our libp2p custom network and we are still thinking about how to integrate it into a complete IPFS node. We also had native drivers used for BLE transports and we plan to add Apple MultipeerConnectivity and Android Nearby transports. It took us a long time to find out how to make the Java/ObjC drivers code totally independent of the Android/IOS project (so only imported and managed by the golang package, without importing it into the main project). Another concern was to have no circular dependencies so we implemented everything using gomobile reverse binding on Android and cgo on iOS. We wanted to make it easy for a gomobile user to import the go package directly with the least setup to do to make it work. After seeing your package and lifecycle management system, we thinking about changing that. But it's complicated to find a solution to do things properly by respecting the following rules:
So we need more time to reflect on this last point. This does not prevent us from starting to implement the rest when we have defined a plan together. :) By the way, as soon as we agree on a plan, we will modify the initial PR #5 to stick to it and then merge it. All that remains is to decide whether to open-source the repo immediately or wait until lifecycle management is implemented. Would your team be willing to implement this part when the initial PR is merged @astula? It would be great to have the opinion of the IPFS team in addition to Textile and ours. @Stebalien @parkan :) |
Hi @aeddi, I just wanted to quickly flag https://github.com/hsanjuan/ipfs-lite. Have you played with this at all? We've been considering migrating to this lighter client for mobile applications. It is quite nice to build up the stack as needed on top of libp2p, e.g., clients just need to get+put blocks, and find local peers with mdns / other future plugable libp2p modules. As in your proposal, an HTTP/gRPC interface could be built around this lighter API. Perhaps there's a way to reuse some infrastructure for both a full and lite node (lifecycle, etc.). The UDS path sounds very interesting. Are you able to have multiple connections open? Thanks for looping us in!
|
Thank you for the thorough and thoughtful response!
|
@sanderpick
It could have been great to reuse exactly the same system but unfortunately IPFS-lite does not offer a Shell nor implement the CoreAPI interface, so the "bridge" defined in our proposal won't be compatible with it. However, the developers behind IPFS-lite could be interested in porting those features to make it compatible with gomobile-ipfs bridge/lifecycle management. But I have the impression that making IPFS-lite compatible with CoreAPI would go against what the creators of the project are trying to do. Another solution could be to implement another version of the bridge and lifecycle management system which is compatible with IPFS-lite.
Do you mean having an HTTP server that listens on multiple UDS paths or having multiple HTTP clients making requests on the same UDS path? I think both are possible without any problem.
At the go-ipfs level you just instantiate a connection over UDS instead of TCP/IP and any difference between these two transports are abstracted by golang net. So yes I think you can just swap them without seeing any difference. We are thinking of allowing developers to init the HTTP API of the node over TCP/IP, so they could why not make the node accessible by other applications on their smartphone by making requests on localhost.
Awesome! :)
Great, so we'll do that!
The setup we have of Bazel today gives us incredible performance in terms of build time but it's complicated to set up and maintain.
As soon as we can free up some time, we will ensure that our work on native drivers is open-source and documented so that it can serve the community and help contributors to further improve the project. |
Very excited to see this repo take shape! At Textile, we've done a lot of the work that will be done here, but instead of wrapping the
go-ipfs
API, we've wrapped thego-textile
API (which wraps thego-ifps
API). I think we can transfer a lot of what we've done to this repo, and ultimately build the Textile mobile SDKs on top ofgomobile-ipfs
.I want to start some general conversation and mention some high-level ideas that could point to more specific issues we could create and work on.
Those are some of the areas that come to mind where I think we can contribute a lot. Let me know if any of those seem particularly important or not important at all. We can break things down into smaller pieces and get to work!
The text was updated successfully, but these errors were encountered: