From 71aaa41069196836f2186e83583c91b6c6cae161 Mon Sep 17 00:00:00 2001 From: prathamesh0 <42446521+prathamesh0@users.noreply.github.com> Date: Thu, 30 Mar 2023 09:44:15 +0530 Subject: [PATCH] Upgrade dependencies and start inline watcher peer in mobymask-v2 stack (#256) * Upgrade dependencies in mobymask-v2 stack * Run inline watcher peer in mobymask v2 stack --------- Co-authored-by: nabarun --- .../docker-compose-watcher-mobymask-v2.yml | 25 ++++++------------- .../config/watcher-mobymask-v2/peer-start.sh | 10 -------- .../watcher-mobymask-v2/server-start.sh | 9 +++++++ ...cher.toml => watcher-config-template.toml} | 6 ++++- app/data/stacks/mobymask-v2/README.md | 13 +++++++--- app/data/stacks/mobymask-v2/demo.md | 2 +- 6 files changed, 31 insertions(+), 34 deletions(-) delete mode 100755 app/data/config/watcher-mobymask-v2/peer-start.sh create mode 100755 app/data/config/watcher-mobymask-v2/server-start.sh rename app/data/config/watcher-mobymask-v2/{watcher.toml => watcher-config-template.toml} (92%) diff --git a/app/data/compose/docker-compose-watcher-mobymask-v2.yml b/app/data/compose/docker-compose-watcher-mobymask-v2.yml index 9835ada4..dc4f6928 100644 --- a/app/data/compose/docker-compose-watcher-mobymask-v2.yml +++ b/app/data/compose/docker-compose-watcher-mobymask-v2.yml @@ -23,9 +23,6 @@ services: mobymask: restart: unless-stopped - depends_on: - mobymask-watcher-db: - condition: service_healthy image: cerc/mobymask:local working_dir: /app/packages/server environment: @@ -46,12 +43,17 @@ services: depends_on: mobymask-watcher-db: condition: service_healthy + mobymask: + condition: service_healthy image: cerc/watcher-mobymask-v2:local - command: ["sh", "-c", "yarn server"] + command: ["sh", "server-start.sh"] volumes: - - ../config/watcher-mobymask-v2/watcher.toml:/app/packages/mobymask-v2-watcher/environments/local.toml + - ../config/watcher-mobymask-v2/watcher-config-template.toml:/app/packages/mobymask-v2-watcher/environments/watcher-config-template.toml - ../config/watcher-mobymask-v2/peer.env:/app/packages/peer/.env - ../config/watcher-mobymask-v2/relay-id.json:/app/packages/mobymask-v2-watcher/relay-id.json + - ../config/watcher-mobymask-v2/peer-id.json:/app/packages/mobymask-v2-watcher/peer-id.json + - ../config/watcher-mobymask-v2/server-start.sh:/app/packages/mobymask-v2-watcher/server-start.sh + - moby_data_server:/server ports: - "0.0.0.0:3001:3001" - "0.0.0.0:9001:9001" @@ -63,19 +65,6 @@ services: retries: 15 start_period: 5s - mobymask-watcher-peer: - restart: unless-stopped - depends_on: - mobymask: - condition: service_healthy - image: cerc/watcher-mobymask-v2:local - command: ["sh", "peer-start.sh"] - volumes: - - ../config/watcher-mobymask-v2/watcher.toml:/app/packages/mobymask-v2-watcher/environments/local.toml - - ../config/watcher-mobymask-v2/peer-id.json:/app/packages/mobymask-v2-watcher/peer-id.json - - ../config/watcher-mobymask-v2/peer-start.sh:/app/packages/mobymask-v2-watcher/peer-start.sh - - moby_data_server:/server - mobymask-app: depends_on: mobymask-watcher-server: diff --git a/app/data/config/watcher-mobymask-v2/peer-start.sh b/app/data/config/watcher-mobymask-v2/peer-start.sh deleted file mode 100755 index 9749f97a..00000000 --- a/app/data/config/watcher-mobymask-v2/peer-start.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# Private key of account with balance -PRIVATE_KEY= - -# Assign deployed contract address from server config -CONTRACT_ADDRESS=`jq '.address' /server/config.json` - -echo 'yarn peer-listener --contract-address --private-key ' -yarn peer-listener --contract-address $CONTRACT_ADDRESS --private-key $PRIVATE_KEY diff --git a/app/data/config/watcher-mobymask-v2/server-start.sh b/app/data/config/watcher-mobymask-v2/server-start.sh new file mode 100755 index 00000000..80bf4d34 --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/server-start.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Assign deployed contract address from server config +CONTRACT_ADDRESS=`jq '.address' /server/config.json` + +sed "s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/" environments/watcher-config-template.toml > environments/local.toml + +echo 'yarn server' +yarn server diff --git a/app/data/config/watcher-mobymask-v2/watcher.toml b/app/data/config/watcher-mobymask-v2/watcher-config-template.toml similarity index 92% rename from app/data/config/watcher-mobymask-v2/watcher.toml rename to app/data/config/watcher-mobymask-v2/watcher-config-template.toml index 3f50d137..1a05e225 100644 --- a/app/data/config/watcher-mobymask-v2/watcher.toml +++ b/app/data/config/watcher-mobymask-v2/watcher-config-template.toml @@ -21,7 +21,7 @@ [server.p2p] enableRelay = true - enablePeer = false + enablePeer = true [server.p2p.relay] host = "0.0.0.0" @@ -36,6 +36,10 @@ peerIdFile = './peer-id.json' enableDebugInfo = true + [server.p2p.peer.l2TxConfig] + privateKey = '' + contractAddress = REPLACE_WITH_CONTRACT_ADDRESS + [metrics] host = "0.0.0.0" port = 9000 diff --git a/app/data/stacks/mobymask-v2/README.md b/app/data/stacks/mobymask-v2/README.md index 5cea8570..fc6f6b05 100644 --- a/app/data/stacks/mobymask-v2/README.md +++ b/app/data/stacks/mobymask-v2/README.md @@ -18,11 +18,11 @@ Checkout to the required versions and branches in repos ```bash # watcher-ts cd ~/cerc/watcher-ts -git checkout v0.2.31 +git checkout v0.2.34 # react-peer cd ~/cerc/react-peer -git checkout v0.2.29 +git checkout v0.2.31 # mobymask-ui cd ~/cerc/mobymask-ui @@ -67,7 +67,7 @@ Deploy the stack: * Set the private key in [secrets.json](../../config/watcher-mobymask-v2/secrets.json) file that will be used by mobymask container to deploy contract -* Create a new account +* Create a new account named `alice` ```bash laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd exec laconicd "laconicd keys add alice" @@ -85,7 +85,12 @@ Deploy the stack: laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd exec laconicd "echo y | laconicd keys export alice --unarmored-hex --unsafe" ``` -* Set the private key (`PRIVATE_KEY`) in [peer-start.sh](../../config/watcher-mobymask-v2/peer-start.sh) file that will be used to start the peer that sends txs to L2 chain +* Set the private key (`server.p2p.peer.l2TxConfig.privateKey`) in [watcher.toml](../../config/watcher-mobymask-v2/watcher.toml) file that will be used to start the peer that sends txs to L2 chain + + ```toml + [server.p2p.peer.l2TxConfig] + privateKey = 'ALICE_PRIVATE_KEY' + ``` * Deploy the other containers diff --git a/app/data/stacks/mobymask-v2/demo.md b/app/data/stacks/mobymask-v2/demo.md index 63ad0a21..09085b89 100644 --- a/app/data/stacks/mobymask-v2/demo.md +++ b/app/data/stacks/mobymask-v2/demo.md @@ -34,7 +34,7 @@ * Get the container id ```bash - laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 ps | grep mobymask-watcher-peer + laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 ps | grep mobymask-watcher-server ``` * Check logs