status-im / swarms

Swarm Home. New, completed and in-progress features for Status
92 stars 31 forks source link

Replace status-go bindings with a single RPC-like one #7

Closed adambabik closed 6 years ago

adambabik commented 7 years ago

Preamble

Idea: DEV#007
Title: Replace status-go bindings with a single RPC-like one
Status: WIP
Created: 2017-11-10

Summary

The idea is to replace most of the currently exposed bindings in status-go with a single one that operates on a JSON-RPC protocol. It will allow us to remove a significant part of glue code that needs to be written between status-go and platforms that use it (status-react, status-desktop, possibly others).

Vision

The vision is to have only two bindings exposed: CallRPC and CallPrivateRPC (subject to change as may be confusing, CallBinding or CallPrivateMethod maybe?). They are totally separate and serve totally different purposes.

CallRPC is used to forward JSON-RPC calls to the ethereum node that status-go runs inside. It will be used to implement custom providers to web3.js.

CallPrivateRPC will be used to perform actions like StartNode, StopNode, Login, CreateAccount and will effectively replace all the bindings that status-go currently exposes.

As bindings are exposed as C functions, glue code is required to call them from status-react (native modules written in Objective-C and Java) and status-desktop (C or C++ code). Reducing the number of bindings and using a single one supporting a protocol like JSON-RPC will allow developers to modify or add new actions without modifying the glue code at all.

Swarm Participants

This project should finish in a week. It will require at least 2 developers who will work on status-go side and at least 1 who can help with React Native modules and Clojure code.

Requirements

TBD

Goals & Implementation Plan

TBD

Minimum Viable Product

The Status app works as before changes. Some currently exposed bindings may be missing but it should be possible to create an account, start node and use chat.

Goal Date: 2017-11-27

Copyright

Copyright and related rights waived via CC0.

jacqueswww commented 7 years ago

+1 - as it would allow easy experimentation with other languages (let's say hacking together basic status chat app in PyQT5 for example). ~Quick question: How would one authenticate against the status-go service?~ nevermind it's off course the login function ;)

divan commented 6 years ago

@adambabik what do you think about using gRPC and Protobuf instead of JSON-RPC? The main advantage is autogenerators for 10+ languages and a single source of truth for RPC method definitions and types.

adambabik commented 6 years ago

+1 @divan It's definitely something we should consider. It's not easy to configure and setup but it would solve a lot of issues that will emerge later.

adambabik commented 6 years ago

During working on https://github.com/status-im/status-go/pull/513, I discovered that we can use a native go-ethereum solution to extend a set of JSON-RPC methods and bind them to different interfaces depending on their visibility. In this way, we could get rid of many bindings that operate on a running node.

naghdy commented 6 years ago

Is this still active, or is it now redundant? @adambabik

adambabik commented 6 years ago

It could be a part of a larger bindings refactoring related to gomobile. I don't believe we will start working on it soon, though.

naghdy commented 6 years ago

OK I'll close it for now, and then we can either re-open or create a new one as part of a larger refactor.