gnolang / hackerspace

Tinker, build, explore Gno - without the monorepo!
10 stars 8 forks source link

Berty's GnoMobile / Gno Native Kit Builder Journey #28

Open jefft0 opened 1 year ago

jefft0 commented 1 year ago

This documents the journey of Berty into Gno.land.

The two objectives of the first month of our Builder project are:

  1. Create a Proof of Concept of an existing Gno example app running on a mobile phone. This will prove that we can run Gno on a mobile (or identify issues that need further work). The PoC code will go into https://github.com/gnolang/gnomobile .

  2. Based on this experience to produce a detailed technical plan for further work to create a framework where developers can bring their Gno apps to mobile.

In this Journey, we will introduce our team, document our experience using Gno, track our issues and solutions, and keep meeting notes.

moul commented 1 year ago

On our side:

On Berty's side:

jefft0 commented 1 year ago

Introducing our team

Rémi (@d4ryl00)

Jeff (@jefft0)

Fun fact: Was at RSA the company when A Cypherpunk’s Manifesto was published.

Iuri (@iuricmp)

jefft0 commented 1 year ago

Onboarding experience with r/demo/boards

jefft0 commented 1 year ago

Progress: Test node and code repo

jefft0 commented 1 year ago

Gno developer call: August 9

We (Remi, Jeff and Iuri) participated in our first developer call and introduced ourselves.

We explained that we're writing an app where we need to create a transaction by calling the Go code directly (not with the CLI). Manfred and Jae discussed plans for using the Tendermint 2 code as a "library", but not ready yet. Manfred said that, for now, we can use the same approach as other tools like:

jefft0 commented 1 year ago

Progress: Demo videos

jefft0 commented 1 year ago

Progress: Domain name for Berty testnet node

With Manfred's help on the DNS, we have a nice domain name for our Gno testnet node: http://testnet.gno.berty.io

The help pages use this in the copy/paste text for the command: http://testnet.gno.berty.io/r/demo/boards?help

jefft0 commented 1 year ago

Progress: First GnoMobile demo video

Part of milestone M0 is a proof-of-concept for calling a Gno realm function from mobile (GnoMobile). Here is a demo video of the initial PoC app called GnoBoard which interacts with a Gno board. https://www.loom.com/share/028f37f68b34425992baa2c77d0cf6b5

This demonstrates:

The pull request mentioned is here: https://github.com/gnolang/gnomobile/pull/3 The message board on our testnet shown is here: http://testnet.gno.berty.io/r/demo/boards:gnomobile/1

jefft0 commented 1 year ago

Meeting with Guilhem: gnoclient and gomobile dependencies

We had a meeting with Guilhem.

jefft0 commented 1 year ago

Progress: Build dependencies, Android, estimating gas fees

Iuri continues to work on the UI for the "gnoboard" example app and will have some cool demos soon.

jefft0 commented 1 year ago

Progress: Demo video: GnoMobile UI

https://www.loom.com/share/9537299635564761bc3a6d627411e33a As mentioned, Iuri has put a user interface on our "gnoboard" example app. It works on Android and iOS. This gave us more experience of how the app code should interact with Gno, which we will detail in our proposal for the GnoMobile mobile app framework.

jefft0 commented 1 year ago

Progress: Video: GnoMobile system diagram

We made a video to give a quick overview of GnoMobile using the system diagram from our project proposal. (This is useful background for our ongoing design questions.) https://www.loom.com/share/8a991ae4395b448e8e5cdc1c6f250246

jefft0 commented 1 year ago

Question: How to get the return value of the realm function call?

We are writing tests for the GnoMobile API. The basic operation is to Call a realm function. But it's not clear how to get the return value through the RPC call to the remote gnoland node. Here is the question issue: https://github.com/gnolang/gno/issues/1100

We quickly got a good answer from @zivkovicmilos . The return value of the realm RPC call is in DeliverTx.ResponseBase.Data with a custom stringified value like "(20 gno.land/r/demo/boards.PostID)" . There currently is no easy way for the client to unmarshal this into a useable object but this is a known issue (see "ABI Support for Realms"), so we will track that issue and related meta issue https://github.com/gnolang/gno/issues/925 .

jefft0 commented 1 year ago

GnoMobile, a Gno Framework for Mobile. Implementation Plan

As the culminating step of milestone M0, we submitted our proposal for the GnoMobile framework implementation plan which we will do during M1. If you have comments, let us know on the issue. https://github.com/gnolang/gnomobile/issues/15

jefft0 commented 1 year ago

Question: Design of gnoclient API

Our proof-of-concept app has a working version of the gnoclient Client API. The near-term goal is to complete the original PR. We have posted a question which came up when we wrote this code, so that we can discuss with the Gno devs. https://github.com/gnolang/gno/pull/1047#issuecomment-1713476628

jefft0 commented 1 year ago

Gno developer call: Sept. 13

We presented the completion of milestone M0 and discussed our plans for GnoMobile in M1. We discussed some of the design issues we're working on:

jefft0 commented 1 year ago

Question: How can amino include doc comments?

We are making progress with using amino so that our gRPC types are defined in Go structs. But when amino creates the protobuf file, the doc comments are lost. See the issue for details. We may be able to contribute code to amino to help support doc comments. https://github.com/gnolang/gno/issues/1157

jefft0 commented 1 year ago

Question: How can amino preserve enum definitions?

Related to the previous question, we opened an issue we came across where the Protofuf output from amino doesn't preserve the names of enum constants. As mentioned, both issues may have a similar solution with parsing the AST of the original Go code. For further discussion. https://github.com/gnolang/gno/issues/1161

jefft0 commented 1 year ago

Progress: Demo video: GnoMobile gRPC and amino

https://www.loom.com/share/52f6fc51a60a432896a50639ac5e6cce This video shows progress for implementing the gRPC interface on iOS and Android, and with defining the interface with Go structs using amino.

jefft0 commented 1 year ago

Trip report: Barcelona Web3 conference

On Friday and Saturday I (Jeff) went to the Web3 Family Conference in Barcelona. https://web3fc.xyz

jefft0 commented 1 year ago

Progress: Using the gnoclient API

We have merged pull request https://github.com/gnolang/gnomobile/pull/22 where GnoMobile uses a local copy of the gnoclient API. The code is copied from https://github.com/gnolang/gno/pull/1047 which will be merged into the Gno codebase so that any app can use Gno as an SDK. (When it is merged, GnoMobile will easily switch to using the "official" version.) The example app is now working with this code.

Next steps are to make all the gnoclient functionality useable from the GnoClient API, to add wallet support in the example app, and to implement gRPC directly for React Native which is explained in this issue: https://github.com/gnolang/gnomobile/issues/20

jefft0 commented 1 year ago

Progress: Demo video: GnoMobile wallet UI

https://www.loom.com/share/c0f68f707d3e47089c2fdbd2698fc92f This video show the example app using the wallet functions to create and restore accounts, and discusses next steps.

jefft0 commented 1 year ago

Progress: Merged GnoMobile wallet UI code

We have merged pull request https://github.com/gnolang/gnomobile/pull/18 which has the code for the wallet UI shown in the demo video above. In addition to the new screens for wallet functions, this pull request fixes issues with the Makefile for React Native and gRPC. We can now proceed quickly with the next steps mentioned in the video.

jefft0 commented 1 year ago

Gno Contribution: Amino to use snake case for Protobuf field names

As explained in issue https://github.com/gnolang/gno/issues/1211, Amino should use lower_snake_case for Protobuf field names. We submitted PR https://github.com/gnolang/gno/pull/1213 to fix this. This PR is merged.

On todays developer call, we also discussed Amino-related issues https://github.com/gnolang/gno/issues/1157 for doc comments and https://github.com/gnolang/gno/issues/1161 for enums. We now have a way forward to implement doc comments and will do a PR soon.

jefft0 commented 1 year ago

Gno Contribution: Amino to copy doc comments to the Protobuf file

As explained in issue https://github.com/gnolang/gno/issues/1157, Amino should optionally support copying doc comments from the Go struct to the Protobuf file output. We submitted PR https://github.com/gnolang/gno/pull/1235 to add WithComments which is optionally used when making the Package object. The PR includes a Go test for this. This PR is merged.

jefft0 commented 1 year ago

Progress: Temporary gno fork, Amino support

As mentioned, we have a few pull requests for Gno. But we need to let the devs take their time to review. Therefore, we made a fork where we will cherry pick the pull request commits into branch with-gno-PRs . This allows GnoMobile to use a replace command in go.mod to temporarily use this fork (which we did in PR https://github.com/gnolang/gnomobile/pull/46).

Now that we have the Amino functionality, the Protobuf field names produced by Amino are lower_snake_case, and comments from the Go struct are included, as in this example. This also allows a doc comment for enumerated values.

jefft0 commented 1 year ago

Progress in setting up Buf documentation

We opened an issue to track progress in setting up a GnoMobile web page at the Buf documentation registry. https://github.com/gnolang/gnomobile/issues/53 . The organization account has been created and now we need to get permissions to create a new repository. Once this is done, we will move forward with making sure that the GnoMobile API documentation looks good.

jefft0 commented 1 year ago

Gno Contribution: Improve error handling in HTTP client

The Gno HTTP client is used in many places, including GnoMobile, to sign transactions and communicate with the blockchain. There is code to return the specific error ErrWrongPassword if the transaction cannot be signed because of a bad (or missing) password. As explained in our pull request https://github.com/gnolang/gno/pull/1289, there were some bugs in properly returning this specific error and checking for it. Thanks to the Gno devs, this bug fix has been merged.

Why is this important? GnoMobile is a toolkit API. Part of a good API design is clear error handling. When an application uses GnoMobile to call a remote blockchain function, the API should return a clear error if the password is wrong (or missing) so that the application can prompt the user to fix the problem. Next we will update the GnoMobile example app to use this and we'll make a demo video.

(Today we also submitted a little pull request https://github.com/gnolang/gno/pull/1301 so that make test passes. Thanks for the quick review and merge!)

jefft0 commented 1 year ago

Progress: Demo video: New GnoMobile wallet UI functions, gRPC streaming

We have made a lot of progress in the example app for wallet functions. Remi has also implemented returning a stream object from a gRPC method. Details are in the video: https://www.loom.com/share/d1cef60199c0487e86deab2a9e61d61c

Next: A few more wallet UI functions, and to make use of gRPC streaming.

jefft0 commented 1 year ago

Progress: In Keybase, add HasByName, etc.

Support for HasByName

In GnoMobile, when a user wants to create an account, we need to check if the local Keybase already has an account with the same name. As explained in our new PR https://github.com/gnolang/gno/pull/1313, the Keybase already has GetByName which either copies and returns all the key info, or returns an error. We created the PR because we need support for the simpler HasByName which just checks if an account with the name exists. We have already added support for this to our fork of gno, and added it to the GnoMobile gRPC interface, along with support for the related HasByAddress and HasByNameOrAddress. This PR is merged.

GetByAddress error handling

The GnoMobile API needs consistent error handling, so we submitted a smaller pull request https://github.com/gnolang/gno/pull/1316 so that GetByAddress returns the same error keyerror.NewErrKeyNotFound as returned by GetByName. This PR is merged.

Checking for valid password

Finally, when the app prompts the user for the password, we want the GnoMobile method SetPassword to check if it is valid. As explained in issue https://github.com/gnolang/gno/issues/1324, we implement the password check by trying to sign a blank transaction. This works and we are moving forward, but the issue asks for feedback if this is a good solution.

jefft0 commented 11 months ago

Progress: Buf documentation web page

The gRPC interface uses Protobuf where methods and message objects have doc comments. This is a great place to document the API. We have set up the GnoMobile Buf web page for this documentation. We will continue to add more including details for error codes and how the methods interact.

jefft0 commented 11 months ago

Gno developer call: November 15

jefft0 commented 11 months ago

Gno contribution: Improve error message and docs for using test3.gno.land

Jeff was having trouble using gnokey to call a realm function on test3.gno.land. On a call with @moul we fixed it. (In short, Jeff was using the wrong chain ID.) The result is two PRs to clarify error messages and documentation:

jefft0 commented 11 months ago

Gno contribution: Updates to gnoclient

As mentioned in a previous post, there is a PR to add the gnoclient interface to the Gno codebase. In GnoMobile, we added some extra functionality. To submit those changes to gnoclient we created PR https://github.com/moul/gno/pull/18 . Among other changes, this addresses the question of how to validate a password that we described in issue https://github.com/gnolang/gno/issues/1324 . This has been merged.

jefft0 commented 11 months ago

Progress: Demo video: Call event stream

Demo the support for gRPC stream when calling a realm function. Discuss how we're waiting for the Gno.land functionality for the endpoint to return status events, and better error types from realm functions. https://www.loom.com/share/42f2dcb0b4a34f77a95a0f8012e4b52b

jefft0 commented 11 months ago

Progress: Demo Video: Minimal app "Hello Gno"

In this video, Iuri demonstrates a minimal GnoMobile example app which was made by the new make new-app functionality. This is how you (developer) can start your GnoMobile project to communicate with the Gno blockchain. https://www.loom.com/share/41a20a764f0f4caf91f068b62e1f16c4

jefft0 commented 11 months ago

Progess: Demo Video: Minimal command-line example in Go

Remi has implemented a minimal gRPC server and client in Go. This lets us make simple GnoMobile command-line example apps in Go which don't have all the GUI code of a full React Native app. Here is a short demo video of goserver and goclient. https://www.loom.com/share/093ae52b222d474ba4e75ecd8abed90e

jefft0 commented 11 months ago

Demo Video: Comparing GnoMobile with tm2-JS

In this short video we compare the features of GnoMobile with tm2-JS, which is another framework for building Gno apps. using this comparison, the video explains why GnoMobile was created and why a dev might choose to use it. This also shows why we want to rename the framework because it's useful for more than making mobile apps. https://www.loom.com/share/bff0a21d330b4e44a62d32383130ffed

jefft0 commented 10 months ago

Announcement: Renaming to Gno Native Kit

We started the GnoMobile project to demonstrate that we can use Gno.land on mobile, by bridging the native code of the app to the core Go code. During this journey we discovered that this toolkit has other uses beyond mobile (highlighted in the demo of the previous post). With helpful feedback from the Gno team, we have renamed this project to Gno Native Kit. This is short for "A toolkit to use the core Gno code from your app's native programming language".

jefft0 commented 10 months ago

Video: Fireside chat with Jeff

In Johnny B's continuing series of fireside chats, here is an hour-long chat with Jeff. It includes the origins of Berty, Gno Native Kit and reasons for renaming, plus future plans with Gno Social. https://www.youtube.com/watch?v=XSuJJStU2X0

jefft0 commented 10 months ago

Our journey continues...

Our journey into Gno.land continues with dSocial.

D4ryl00 commented 8 months ago

Securing gRPC channel communication

The communication between the React-Native gRPC client and the backend server used an encrypted TCP connection. When a gRPC server listens to a local TCP port, any program on your system can use it to communicate also with the server and impersonate or spy you. To offer private communications, we decided to use a Unix Domain Socket (UDS) instead of a TCP connection. Because UDS is only available for the current process, other applications cannot use it. This is now implemented in the PR https://github.com/gnolang/gnonative/pull/113

jefft0 commented 7 months ago

Gno Native Kit video series: Episode One: Overview

Here is the first in a series of videos presenting Gno Native Kit. https://www.youtube.com/watch?v=N1HLyQDHGQ0

jefft0 commented 6 months ago

Gno Native Kit video series: Episode Two: System Diagram

Be sure the check out our second in a series of videos presenting Gno Native Kit. https://www.youtube.com/watch?v=5s-6GFzivBQ