Skip to content

Commit

Permalink
chore_: add env STATUS_BACKEND_SERVER_MEDIA_SERVER_ENABLE_TLS (#21648)
Browse files Browse the repository at this point in the history
* chore_: add env STATUS_BACKEND_SERVER_MEDIA_SERVER_ENABLE_TLS

status-im/status-go@b3dbe91...cae9d35

* update status-go version and doc

status-im/status-go@b3dbe91...906c50b
  • Loading branch information
qfrank authored Nov 22, 2024
1 parent 5442a85 commit 26ae330
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
12 changes: 10 additions & 2 deletions doc/use-status-backend-server.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
## Solution to use Status Backend Server
## What is Status Backend Server
Status Backend Server is a http server that runs status-go, it exposed endpoints come from [mobile/status.go](https://github.com/status-im/status-go/blob/master/mobile/status.go) so that you can call them through http requests. It brings the following benefits:
- When verifying changes made in status-go, you only need to run these commands once (unless modifying Kotlin/Objective-C code):
- `make clean && make run-clojure`
- `make run-android` or `make run-ios`
This avoids repeatedly rebuilding and saves development time.
- Debug status-go while running status mobile app

## Solution to use Status Backend Server for mobile development
`StatusBackendClient` is the entry point to use Status Backend Server. We need always to call `status-im.setup.status-backend-client/init` whether `STATUS_BACKEND_SERVER_ENABLED` is `1` or not. If it's not enabled, the invocation to functions in `native-module.core` will be delegated to built-in status-go library, otherwise it will be delegated to status-go running in status-backend server. Currently, all functions has usages in `native-module.core` should be supported delegated to.
NOTE: not all the native functions used `StatusBackendClient`, only the corresponding functions in `native-module.core` has usages should be supported delegated to ATM.

Expand Down Expand Up @@ -38,7 +46,7 @@ Basically, you don't have to run `make generate` again and again, just run it on

## Known Android simulator issues
- Issue#1: Android simulator may not display images due to TLS certificate validation issues with the image server
- solution: use http instead of https for media server with command: `MEDIA_HTTPS=false PORT=60000 make run-status-backend`, currently status-go does not support http for media server. You have to use this draft [PR](https://github.com/status-im/status-go/pull/6060), you also need to set env variable `STATUS_BACKEND_SERVER_IMAGE_SERVER_URI_PREFIX` to "http://10.0.2.2:" so that `image_server.cljs` can work, and to make `/accountInitials` work, you need to copy `Inter-Medium.ttf` to your host machine from the android simulator, let's say you store it in `/Users/mac/Downloads/Inter-Medium.ttf`, then you need to update `get-font-file-ready` manually in `image_server.cljs` to return the correct path so that status backend server can access it.
- solution: use http instead of https for media server with set env: `export STATUS_BACKEND_SERVER_MEDIA_SERVER_ENABLE_TLS=0`, you also need to set env variable `STATUS_BACKEND_SERVER_IMAGE_SERVER_URI_PREFIX` to "http://10.0.2.2:" so that `image_server.cljs` can work, and to make `/accountInitials` work, you need to copy `Inter-Medium.ttf` to your host machine from the android simulator, let's say you store it in `/Users/mac/Downloads/Inter-Medium.ttf`, then you need to update `get-font-file-ready` manually in `image_server.cljs` to return the correct path so that status backend server can access it.
- Issue#2: exportUnencryptedDatabaseV2/import-multiaccount does not work for android, probably cause of tech debt, I found it during creating the draft PR.
- Issue#3: unable to invoke `multiaccounts_storeIdentityImage` to change avatar image.
- The reason is that we path the absolute path of the image to the backend server, but the image file is stored in the android simulator. the backend server cannot access it as it runs in the host machine.
Expand Down
2 changes: 2 additions & 0 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
status-im.config/STATUS_BUILD_PROXY_PASSWORD #shadow/env "STATUS_BUILD_PROXY_PASSWORD"
status-im.config/STATUS_BACKEND_SERVER_ENABLED #shadow/env "STATUS_BACKEND_SERVER_ENABLED"
status-im.config/STATUS_BACKEND_SERVER_HOST #shadow/env "STATUS_BACKEND_SERVER_HOST"
status-im.config/STATUS_BACKEND_SERVER_MEDIA_SERVER_ENABLE_TLS
#shadow/env "STATUS_BACKEND_SERVER_MEDIA_SERVER_ENABLE_TLS"
status-im.config/STATUS_BACKEND_SERVER_IMAGE_SERVER_URI_PREFIX
#shadow/env "STATUS_BACKEND_SERVER_IMAGE_SERVER_URI_PREFIX"
status-im.config/STATUS_BACKEND_SERVER_ROOT_DATA_DIR #shadow/env
Expand Down
3 changes: 3 additions & 0 deletions src/status_im/config.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
;; The port comes from your running status backend server.
;; If you run it by PORT=60000 make run-status-backend , then host will likely be 127.0.0.1:60000
(goog-define STATUS_BACKEND_SERVER_HOST "")
;; enable media server over https or http
;; if you're using android simulator, set it to "0"
(goog-define STATUS_BACKEND_SERVER_MEDIA_SERVER_ENABLE_TLS "1")
;; /path/to/root/data/dir
;; make sure it exists, it should be in absolute path
(goog-define STATUS_BACKEND_SERVER_ROOT_DATA_DIR "")
Expand Down
10 changes: 6 additions & 4 deletions src/status_im/contexts/profile/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
(rf/reg-fx
:profile/get-profiles-overview
(fn [callback]
(native-module/initialize-application {:dataDir (native-module/backup-disabled-data-dir)
:mixpanelAppId config/mixpanel-app-id
:mixpanelToken config/mixpanel-token}
callback)))
(native-module/initialize-application
{:dataDir (native-module/backup-disabled-data-dir)
:mixpanelAppId config/mixpanel-app-id
:mixpanelToken config/mixpanel-token
:mediaServerEnableTLS (config/enabled? config/STATUS_BACKEND_SERVER_MEDIA_SERVER_ENABLE_TLS)}
callback)))

(rf/reg-event-fx
:profile/profile-selected
Expand Down
6 changes: 3 additions & 3 deletions status-go-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v3.9.0",
"commit-sha1": "79e662e4a563d650358e778871dc20ed71b0eb33",
"src-sha256": "035hz6pn0hkbb2383bdzmzdg214yjkv3aax6bq3dzvyxz002p0m7"
"version": "v3.10.0",
"commit-sha1": "906c50bf26ef85b9a15eb3b640a6cbe2e1071260",
"src-sha256": "05di85jgy2avnl6y1pgx1kzqng9k068braj5fhaknpalm8yyln7k"
}

0 comments on commit 26ae330

Please sign in to comment.