From 21e9f9677173cee479b894c7ea96b6a562d035d9 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Thu, 23 Mar 2023 16:03:35 -0600 Subject: [PATCH 01/10] Build foundry with Debian base container --- app/data/container-build/cerc-foundry/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/data/container-build/cerc-foundry/build.sh b/app/data/container-build/cerc-foundry/build.sh index 9dfad156..a2fe605f 100755 --- a/app/data/container-build/cerc-foundry/build.sh +++ b/app/data/container-build/cerc-foundry/build.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash # Build a local version of the foundry-rs/foundry image -docker build -t cerc/foundry:local ${CERC_REPO_BASE_DIR}/foundry +docker build -t cerc/foundry:local -f ${CERC_REPO_BASE_DIR}/Dockerfile.debian ${CERC_REPO_BASE_DIR}/foundry From 06288fd9e19b35e8b2e14a126ce52cecbe15d33e Mon Sep 17 00:00:00 2001 From: David Boreham Date: Thu, 23 Mar 2023 16:09:27 -0600 Subject: [PATCH 02/10] Fix filename --- app/data/container-build/cerc-foundry/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/data/container-build/cerc-foundry/build.sh b/app/data/container-build/cerc-foundry/build.sh index a2fe605f..c765f03d 100755 --- a/app/data/container-build/cerc-foundry/build.sh +++ b/app/data/container-build/cerc-foundry/build.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash # Build a local version of the foundry-rs/foundry image -docker build -t cerc/foundry:local -f ${CERC_REPO_BASE_DIR}/Dockerfile.debian ${CERC_REPO_BASE_DIR}/foundry +docker build -t cerc/foundry:local -f ${CERC_REPO_BASE_DIR}/foundry/Dockerfile-debian ${CERC_REPO_BASE_DIR}/foundry From 870a9877603f5b1d0e2839575e56dff84bcd31b0 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 24 Mar 2023 02:08:56 -0600 Subject: [PATCH 03/10] Add lirewine repos and npms --- app/data/npm-package-list.txt | 1 + app/data/repository-list.txt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/app/data/npm-package-list.txt b/app/data/npm-package-list.txt index 3adedb5a..34ec73f8 100644 --- a/app/data/npm-package-list.txt +++ b/app/data/npm-package-list.txt @@ -2,3 +2,4 @@ gem laconic-sdk debug laconic-registry-cli +gem diff --git a/app/data/repository-list.txt b/app/data/repository-list.txt index 073c664b..2922d8cb 100644 --- a/app/data/repository-list.txt +++ b/app/data/repository-list.txt @@ -19,3 +19,6 @@ vulcanize/assemblyscript cerc-io/eth-probe cerc-io/tx-spammer dboreham/foundry +lirewine/gem +lirewine/debug +lirewine/crypto From 9e322203e9f07364a4ba28b28920aa6c9b945144 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 24 Mar 2023 02:30:04 -0600 Subject: [PATCH 04/10] Support the @lirewine npm scope --- .../build-npm-package-local-dependencies.sh | 28 ++++++++++--------- .../cerc-builder-js/build-npm-package.sh | 2 +- .../cerc-laconic-registry-cli/Dockerfile | 3 +- app/data/npm-package-list.txt | 2 ++ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh b/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh index 69e8e99e..7f372af7 100755 --- a/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh +++ b/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh @@ -1,7 +1,7 @@ #!/bin/bash # Usage: build-npm-package-local-dependencies.sh # Runs build-npm-package.sh after first fixing up yarn.lock to use a local -# npm registry for all packages in a spcific scope (currently @cerc-io) +# npm registry for all packages in a spcific scope (currently @cerc-io and @lirewine) if [ -n "$CERC_SCRIPT_DEBUG" ]; then set -x fi @@ -17,18 +17,20 @@ fi set -e local_npm_registry_url=$1 package_publish_version=$2 -# TODO: make this a paramater and allow a list of scopes -npm_scope_for_local="@cerc-io" -# We need to configure the local registry -npm config set ${npm_scope_for_local}:registry ${local_npm_registry_url} -npm config set -- ${local_npm_registry_url}:_authToken ${CERC_NPM_AUTH_TOKEN} -# Find the set of dependencies from the specified scope -mapfile -t dependencies_from_scope < <(cat package.json | jq -r '.dependencies | with_entries(if (.key|test("^'${npm_scope_for_local}'/.*$")) then ( {key: .key, value: .value } ) else empty end ) | keys[]') -echo "Fixing up dependencies" -for package in "${dependencies_from_scope[@]}" -do - echo "Fixing up package ${package}" - yarn-local-registry-fixup.sh $package ${local_npm_registry_url} +# If we need to handle an additional scope, add it to the list below: +npm_scopes_to_handle=("@cerc-io" "@lirewine") +for npm_scope_for_local in ${npm_scopes_to_handle[@]}; do + # We need to configure the local registry + npm config set ${npm_scope_for_local}:registry ${local_npm_registry_url} + npm config set -- ${local_npm_registry_url}:_authToken ${CERC_NPM_AUTH_TOKEN} + # Find the set of dependencies from the specified scope + mapfile -t dependencies_from_scope < <(cat package.json | jq -r '.dependencies | with_entries(if (.key|test("^'${npm_scope_for_local}'/.*$")) then ( {key: .key, value: .value } ) else empty end ) | keys[]') + echo "Fixing up dependencies" + for package in "${dependencies_from_scope[@]}" + do + echo "Fixing up package ${package}" + yarn-local-registry-fixup.sh $package ${local_npm_registry_url} + done done echo "Running build" build-npm-package.sh ${local_npm_registry_url} ${package_publish_version} diff --git a/app/data/container-build/cerc-builder-js/build-npm-package.sh b/app/data/container-build/cerc-builder-js/build-npm-package.sh index e0d19481..c8c1e810 100755 --- a/app/data/container-build/cerc-builder-js/build-npm-package.sh +++ b/app/data/container-build/cerc-builder-js/build-npm-package.sh @@ -22,8 +22,8 @@ set -e # Get the name of this package from package.json since we weren't passed that package_name=$( cat package.json | jq -r .name ) local_npm_registry_url=$1 -npm config set @lirewine:registry ${local_npm_registry_url} npm config set @cerc-io:registry ${local_npm_registry_url} +npm config set @lirewine:registry ${local_npm_registry_url} npm config set -- ${local_npm_registry_url}:_authToken ${CERC_NPM_AUTH_TOKEN} # First check if the version of this package we're trying to build already exists in the registry package_exists=$( yarn info --json ${package_name}@${package_publish_version} 2>/dev/null | jq -r .data.dist.tarball ) diff --git a/app/data/container-build/cerc-laconic-registry-cli/Dockerfile b/app/data/container-build/cerc-laconic-registry-cli/Dockerfile index cef3b36f..e0b1ae1e 100644 --- a/app/data/container-build/cerc-laconic-registry-cli/Dockerfile +++ b/app/data/container-build/cerc-laconic-registry-cli/Dockerfile @@ -40,8 +40,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # RUN su node -c "npm install -g " # Configure the local npm registry -RUN npm config set @lirewine:registry ${CERC_NPM_URL} \ - && npm config set @cerc-io:registry ${CERC_NPM_URL} \ +RUN npm config set @cerc-io:registry ${CERC_NPM_URL} \ && npm config set @lirewine:registry ${CERC_NPM_URL} \ && npm config set -- ${CERC_NPM_URL}:_authToken ${CERC_NPM_AUTH_TOKEN} diff --git a/app/data/npm-package-list.txt b/app/data/npm-package-list.txt index 34ec73f8..3def3d63 100644 --- a/app/data/npm-package-list.txt +++ b/app/data/npm-package-list.txt @@ -3,3 +3,5 @@ laconic-sdk debug laconic-registry-cli gem +debug +crypto From 2e7ef1e52eefbd4fc995cdc371be7930650a09c1 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 24 Mar 2023 02:31:19 -0600 Subject: [PATCH 05/10] Remove trailing whitespace --- .../cerc-builder-js/build-npm-package-local-dependencies.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh b/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh index 7f372af7..47869e16 100755 --- a/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh +++ b/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh @@ -20,7 +20,7 @@ package_publish_version=$2 # If we need to handle an additional scope, add it to the list below: npm_scopes_to_handle=("@cerc-io" "@lirewine") for npm_scope_for_local in ${npm_scopes_to_handle[@]}; do - # We need to configure the local registry + # We need to configure the local registry npm config set ${npm_scope_for_local}:registry ${local_npm_registry_url} npm config set -- ${local_npm_registry_url}:_authToken ${CERC_NPM_AUTH_TOKEN} # Find the set of dependencies from the specified scope From e6b91acdeacc5eb27e03fb7d12f13ad23cd7e681 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 24 Mar 2023 02:52:37 -0600 Subject: [PATCH 06/10] Fix up script and npm list --- .../cerc-builder-js/build-npm-package-local-dependencies.sh | 5 +++-- app/data/npm-package-list.txt | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh b/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh index 47869e16..33b6c613 100755 --- a/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh +++ b/app/data/container-build/cerc-builder-js/build-npm-package-local-dependencies.sh @@ -19,13 +19,14 @@ local_npm_registry_url=$1 package_publish_version=$2 # If we need to handle an additional scope, add it to the list below: npm_scopes_to_handle=("@cerc-io" "@lirewine") -for npm_scope_for_local in ${npm_scopes_to_handle[@]}; do +for npm_scope_for_local in ${npm_scopes_to_handle[@]} +do # We need to configure the local registry npm config set ${npm_scope_for_local}:registry ${local_npm_registry_url} npm config set -- ${local_npm_registry_url}:_authToken ${CERC_NPM_AUTH_TOKEN} # Find the set of dependencies from the specified scope mapfile -t dependencies_from_scope < <(cat package.json | jq -r '.dependencies | with_entries(if (.key|test("^'${npm_scope_for_local}'/.*$")) then ( {key: .key, value: .value } ) else empty end ) | keys[]') - echo "Fixing up dependencies" + echo "Fixing up dependencies in scope ${npm_scope_for_local}" for package in "${dependencies_from_scope[@]}" do echo "Fixing up package ${package}" diff --git a/app/data/npm-package-list.txt b/app/data/npm-package-list.txt index 3def3d63..3b6656be 100644 --- a/app/data/npm-package-list.txt +++ b/app/data/npm-package-list.txt @@ -1,6 +1,4 @@ -gem laconic-sdk -debug laconic-registry-cli gem debug From cacd306b22dbd12096c3b78d3c4222a8b8772489 Mon Sep 17 00:00:00 2001 From: Nabarun Gogoi Date: Fri, 24 Mar 2023 17:23:54 +0530 Subject: [PATCH 07/10] Add web-apps and laconicd in MobyMask v2 watcher stack (#226) * Rename .env file * Add web app services to docker compose file * Add laconicd to deploy contract and send txs * Add demo with steps for running mobymask app with L2 chain * Add fix for yarn install on M1 platform in react-peer * Update multiaddrs to use websockets * Add notes in readmes --------- Co-authored-by: prathamesh0 --- .../docker-compose-mobymask-laconicd.yml | 25 ++++ .../docker-compose-watcher-mobymask-v2.yml | 87 +++++++++++- app/data/config/watcher-mobymask-v2/.env | 1 - .../config/watcher-mobymask-v2/config.json | 8 -- .../mobymask-app-config.json | 8 ++ .../watcher-mobymask-v2/mobymask-app-start.sh | 9 ++ .../watcher-mobymask-v2/mobymask-app.env | 1 + .../config/watcher-mobymask-v2/peer-id.json | 5 + .../config/watcher-mobymask-v2/peer-start.sh | 10 ++ app/data/config/watcher-mobymask-v2/peer.env | 1 + .../config/watcher-mobymask-v2/secrets.json | 5 + .../watcher-mobymask-v2/test-app-config.json | 8 ++ .../config/watcher-mobymask-v2/watcher.toml | 4 +- .../cerc-mobymask-ui/Dockerfile | 4 +- .../container-build/cerc-mobymask/Dockerfile | 13 ++ .../container-build/cerc-mobymask/build.sh | 7 + .../cerc-react-peer/Dockerfile | 6 +- .../cerc-watcher-mobymask-v2/Dockerfile | 2 +- app/data/container-image-list.txt | 1 + app/data/pod-list.txt | 1 + app/data/repository-list.txt | 1 + app/data/stacks/mobymask-v2/README.md | 131 ++++++++++++++++-- app/data/stacks/mobymask-v2/demo.md | 130 +++++++++++++++++ app/data/stacks/mobymask-v2/stack.yml | 6 + 24 files changed, 449 insertions(+), 25 deletions(-) create mode 100644 app/data/compose/docker-compose-mobymask-laconicd.yml delete mode 100644 app/data/config/watcher-mobymask-v2/.env delete mode 100644 app/data/config/watcher-mobymask-v2/config.json create mode 100644 app/data/config/watcher-mobymask-v2/mobymask-app-config.json create mode 100755 app/data/config/watcher-mobymask-v2/mobymask-app-start.sh create mode 100644 app/data/config/watcher-mobymask-v2/mobymask-app.env create mode 100644 app/data/config/watcher-mobymask-v2/peer-id.json create mode 100755 app/data/config/watcher-mobymask-v2/peer-start.sh create mode 100644 app/data/config/watcher-mobymask-v2/peer.env create mode 100644 app/data/config/watcher-mobymask-v2/secrets.json create mode 100644 app/data/config/watcher-mobymask-v2/test-app-config.json create mode 100644 app/data/container-build/cerc-mobymask/Dockerfile create mode 100755 app/data/container-build/cerc-mobymask/build.sh create mode 100644 app/data/stacks/mobymask-v2/demo.md diff --git a/app/data/compose/docker-compose-mobymask-laconicd.yml b/app/data/compose/docker-compose-mobymask-laconicd.yml new file mode 100644 index 00000000..4847aeb3 --- /dev/null +++ b/app/data/compose/docker-compose-mobymask-laconicd.yml @@ -0,0 +1,25 @@ +version: "3.2" + +services: + laconicd: + restart: unless-stopped + image: cerc/laconicd:local + command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"] + volumes: + - ../config/fixturenet-laconicd/create-fixturenet.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh + ports: + - "9473" + - "8545" + - "8546" + - "1317" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "8545"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + +networks: + # https://docs.docker.com/compose/networking/#configure-the-default-network + default: + name: mobymask-v2-network diff --git a/app/data/compose/docker-compose-watcher-mobymask-v2.yml b/app/data/compose/docker-compose-watcher-mobymask-v2.yml index 250653f1..9835ada4 100644 --- a/app/data/compose/docker-compose-watcher-mobymask-v2.yml +++ b/app/data/compose/docker-compose-watcher-mobymask-v2.yml @@ -21,6 +21,26 @@ services: retries: 15 start_period: 10s + mobymask: + restart: unless-stopped + depends_on: + mobymask-watcher-db: + condition: service_healthy + image: cerc/mobymask:local + working_dir: /app/packages/server + environment: + - ENV=PROD + command: ["sh", "-c", "npm start"] + volumes: + - ../config/watcher-mobymask-v2/secrets.json:/app/packages/server/secrets.json + - moby_data_server:/app/packages/server + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3330"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + mobymask-watcher-server: restart: unless-stopped depends_on: @@ -30,18 +50,81 @@ services: command: ["sh", "-c", "yarn server"] volumes: - ../config/watcher-mobymask-v2/watcher.toml:/app/packages/mobymask-v2-watcher/environments/local.toml - - ../config/watcher-mobymask-v2/.env:/app/packages/peer/.env + - ../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 ports: - "0.0.0.0:3001:3001" - "0.0.0.0:9001:9001" - "0.0.0.0:9090:9090" healthcheck: - test: ["CMD", "nc", "-v", "localhost", "9090"] + test: ["CMD", "busybox", "nc", "localhost", "9090"] interval: 20s timeout: 5s 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: + condition: service_healthy + mobymask: + condition: service_healthy + image: cerc/mobymask-ui:local + command: ["sh", "mobymask-app-start.sh"] + volumes: + - ../config/watcher-mobymask-v2/mobymask-app.env:/app/.env + - ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/mobymask-app-config.json + - ../config/watcher-mobymask-v2/mobymask-app-start.sh:/app/mobymask-app-start.sh + - moby_data_server:/server + ports: + - "0.0.0.0:3002:3000" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3000"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + shm_size: '1GB' + + peer-test-app: + depends_on: + mobymask-watcher-server: + condition: service_healthy + image: cerc/react-peer:local + working_dir: /app/packages/test-app + command: ["sh", "-c", "yarn build && serve -s build"] + volumes: + - ../config/watcher-mobymask-v2/test-app-config.json:/app/packages/test-app/src/config.json + ports: + - "0.0.0.0:3003:3000" + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "3000"] + interval: 20s + timeout: 5s + retries: 15 + start_period: 10s + volumes: mobymask_watcher_db_data: + moby_data_server: + +networks: + # https://docs.docker.com/compose/networking/#configure-the-default-network + default: + # https://docs.docker.com/compose/networking/#use-a-pre-existing-network + name: mobymask-v2-network + external: true + diff --git a/app/data/config/watcher-mobymask-v2/.env b/app/data/config/watcher-mobymask-v2/.env deleted file mode 100644 index 05af7658..00000000 --- a/app/data/config/watcher-mobymask-v2/.env +++ /dev/null @@ -1 +0,0 @@ -RELAY="/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t" diff --git a/app/data/config/watcher-mobymask-v2/config.json b/app/data/config/watcher-mobymask-v2/config.json deleted file mode 100644 index 35c6f609..00000000 --- a/app/data/config/watcher-mobymask-v2/config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "relayNodes": [ - "/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t" - ], - "peer": { - "enableDebugInfo": true - } -} diff --git a/app/data/config/watcher-mobymask-v2/mobymask-app-config.json b/app/data/config/watcher-mobymask-v2/mobymask-app-config.json new file mode 100644 index 00000000..3b00674f --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/mobymask-app-config.json @@ -0,0 +1,8 @@ +{ + "relayNodes": [ + "/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t" + ], + "peer": { + "enableDebugInfo": true + } +} diff --git a/app/data/config/watcher-mobymask-v2/mobymask-app-start.sh b/app/data/config/watcher-mobymask-v2/mobymask-app-start.sh new file mode 100755 index 00000000..fa3870cf --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/mobymask-app-start.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +# Merging config files to get deployed contract address +jq -s '.[0] * .[1]' /app/src/mobymask-app-config.json /server/config.json > /app/src/config.json + +npm run build + +serve -s build diff --git a/app/data/config/watcher-mobymask-v2/mobymask-app.env b/app/data/config/watcher-mobymask-v2/mobymask-app.env new file mode 100644 index 00000000..698d3502 --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/mobymask-app.env @@ -0,0 +1 @@ +REACT_APP_WATCHER_URI=http://localhost:3001/graphql diff --git a/app/data/config/watcher-mobymask-v2/peer-id.json b/app/data/config/watcher-mobymask-v2/peer-id.json new file mode 100644 index 00000000..ceb55fc0 --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/peer-id.json @@ -0,0 +1,5 @@ +{ + "id": "12D3KooWK6myjc8r1KBnfP9igp31qJkPaVfsKDjKrjoSefV5SDEo", + "privKey": "CAESQJMHbMaH+UEOtjGOzXYtoPO/cdHakCtN1hcnknIWzx/6ie1lxb+8kfzBjwt7apfj8fHlTCYSIVK8Q2AWu9a2h3g=", + "pubKey": "CAESIIntZcW/vJH8wY8Le2qX4/Hx5UwmEiFSvENgFrvWtod4" +} diff --git a/app/data/config/watcher-mobymask-v2/peer-start.sh b/app/data/config/watcher-mobymask-v2/peer-start.sh new file mode 100755 index 00000000..9749f97a --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/peer-start.sh @@ -0,0 +1,10 @@ +#!/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/peer.env b/app/data/config/watcher-mobymask-v2/peer.env new file mode 100644 index 00000000..4cce4d9a --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/peer.env @@ -0,0 +1 @@ +RELAY="/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t" diff --git a/app/data/config/watcher-mobymask-v2/secrets.json b/app/data/config/watcher-mobymask-v2/secrets.json new file mode 100644 index 00000000..127735cd --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/secrets.json @@ -0,0 +1,5 @@ +{ + "rpcUrl": "http://laconicd:8545", + "privateKey": "GENESIS_ACCOUNT_PRIVATE_KEY", + "baseURI": "http://127.0.0.1:3002/#" +} diff --git a/app/data/config/watcher-mobymask-v2/test-app-config.json b/app/data/config/watcher-mobymask-v2/test-app-config.json new file mode 100644 index 00000000..3b00674f --- /dev/null +++ b/app/data/config/watcher-mobymask-v2/test-app-config.json @@ -0,0 +1,8 @@ +{ + "relayNodes": [ + "/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t" + ], + "peer": { + "enableDebugInfo": true + } +} diff --git a/app/data/config/watcher-mobymask-v2/watcher.toml b/app/data/config/watcher-mobymask-v2/watcher.toml index f765db61..3f50d137 100644 --- a/app/data/config/watcher-mobymask-v2/watcher.toml +++ b/app/data/config/watcher-mobymask-v2/watcher.toml @@ -31,7 +31,7 @@ enableDebugInfo = true [server.p2p.peer] - relayMultiaddr = '/ip4/mobymask-watcher-server/tcp/9090/http/p2p-webrtc-direct/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t' + relayMultiaddr = '/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t' pubSubTopic = 'mobymask' peerIdFile = './peer-id.json' enableDebugInfo = true @@ -55,7 +55,7 @@ [upstream] [upstream.ethServer] gqlApiEndpoint = "http://ipld-eth-server:8083/graphql" - rpcProviderEndpoint = "http://ipld-eth-server:8082" + rpcProviderEndpoint = "http://laconicd:8545" blockDelayInMilliSecs = 60000 [upstream.cache] diff --git a/app/data/container-build/cerc-mobymask-ui/Dockerfile b/app/data/container-build/cerc-mobymask-ui/Dockerfile index 86a056b7..68e3c77c 100644 --- a/app/data/container-build/cerc-mobymask-ui/Dockerfile +++ b/app/data/container-build/cerc-mobymask-ui/Dockerfile @@ -1,11 +1,13 @@ FROM node:18.15.0-alpine3.16 -RUN apk --update --no-cache add make git +RUN apk --update --no-cache add make git jq WORKDIR /app COPY . . +RUN npm install -g serve + RUN echo "Building mobymask-ui" && \ npm install diff --git a/app/data/container-build/cerc-mobymask/Dockerfile b/app/data/container-build/cerc-mobymask/Dockerfile new file mode 100644 index 00000000..e7b09cf8 --- /dev/null +++ b/app/data/container-build/cerc-mobymask/Dockerfile @@ -0,0 +1,13 @@ +FROM node:16.17.1-alpine3.16 + +RUN apk --update --no-cache add python3 alpine-sdk + +WORKDIR /app + +COPY . . + +RUN yarn + +# Add scripts +RUN mkdir /scripts +ENV PATH="${PATH}:/scripts" diff --git a/app/data/container-build/cerc-mobymask/build.sh b/app/data/container-build/cerc-mobymask/build.sh new file mode 100755 index 00000000..7628a228 --- /dev/null +++ b/app/data/container-build/cerc-mobymask/build.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# Build cerc/mobymask + +# See: https://stackoverflow.com/a/246128/1701505 +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker build -t cerc/mobymask:local -f ${SCRIPT_DIR}/Dockerfile ${CERC_REPO_BASE_DIR}/MobyMask diff --git a/app/data/container-build/cerc-react-peer/Dockerfile b/app/data/container-build/cerc-react-peer/Dockerfile index 2511d623..cc852441 100644 --- a/app/data/container-build/cerc-react-peer/Dockerfile +++ b/app/data/container-build/cerc-react-peer/Dockerfile @@ -1,12 +1,14 @@ FROM node:18.15.0-alpine3.16 -RUN apk --update --no-cache add make git +RUN apk --update --no-cache add make git python3 WORKDIR /app COPY . . +RUN yarn global add serve + RUN echo "Building react-peer" && \ - yarn && yarn workspace @cerc-io/react-peer build + yarn install --ignore-scripts && yarn build --ignore @cerc-io/test-app WORKDIR /app diff --git a/app/data/container-build/cerc-watcher-mobymask-v2/Dockerfile b/app/data/container-build/cerc-watcher-mobymask-v2/Dockerfile index 501c8f10..18aff5cd 100644 --- a/app/data/container-build/cerc-watcher-mobymask-v2/Dockerfile +++ b/app/data/container-build/cerc-watcher-mobymask-v2/Dockerfile @@ -4,7 +4,7 @@ RUN apt-get update \ && apt-get install -y curl gnupg build-essential \ && curl --silent --location https://deb.nodesource.com/setup_18.x | bash - \ && apt-get update \ - && apt-get install -y nodejs git \ + && apt-get install -y nodejs git busybox jq \ && node -v RUN corepack enable \ diff --git a/app/data/container-image-list.txt b/app/data/container-image-list.txt index 58e5e054..4dc4b137 100644 --- a/app/data/container-image-list.txt +++ b/app/data/container-image-list.txt @@ -21,6 +21,7 @@ cerc/uniswap-v3-info cerc/watcher-mobymask-v2 cerc/react-peer cerc/mobymask-ui +cerc/mobymask cerc/test-container cerc/eth-probe cerc/builder-js diff --git a/app/data/pod-list.txt b/app/data/pod-list.txt index 99974fa6..abb4ab1f 100644 --- a/app/data/pod-list.txt +++ b/app/data/pod-list.txt @@ -15,6 +15,7 @@ watcher-erc20 watcher-erc721 watcher-uniswap-v3 watcher-mobymask-v2 +mobymask-laconicd test eth-probe keycloak diff --git a/app/data/repository-list.txt b/app/data/repository-list.txt index 2922d8cb..440d093a 100644 --- a/app/data/repository-list.txt +++ b/app/data/repository-list.txt @@ -13,6 +13,7 @@ cerc-io/mobymask-watcher cerc-io/watcher-ts cerc-io/react-peer cerc-io/mobymask-ui +cerc-io/MobyMask vulcanize/uniswap-watcher-ts vulcanize/uniswap-v3-info vulcanize/assemblyscript diff --git a/app/data/stacks/mobymask-v2/README.md b/app/data/stacks/mobymask-v2/README.md index 82886783..83bfd259 100644 --- a/app/data/stacks/mobymask-v2/README.md +++ b/app/data/stacks/mobymask-v2/README.md @@ -10,6 +10,30 @@ Clone required repositories: laconic-so --stack mobymask-v2 setup-repositories ``` +Checkout to the required versions and branches in repos + +```bash +# watcher-ts +cd ~/cerc/watcher-ts +git checkout v0.2.31 + +# react-peer +cd ~/cerc/react-peer +git checkout v0.2.29 + +# mobymask-ui +cd ~/cerc/mobymask-ui +git checkout laconic + +# laconicd +cd ~/cerc/laconicd +git checkout v0.8.0 + +# MobyMask +cd ~/cerc/MobyMask +git checkout v0.1.1 +``` + Build the container images: ```bash @@ -20,25 +44,75 @@ This should create the required docker images in the local image registry. Deploy the stack: -```bash -laconic-so --stack mobymask-v2 deploy-system up -``` +* Deploy the laconic chain + + ```bash + laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd up + ``` + +* Check that laconic chain status is healthy + + ```bash + docker ps + ``` + +* Export the private key from laconicd + + ```bash + laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd exec laconicd "echo y | laconicd keys export mykey --unarmored-hex --unsafe" + ``` + +* 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 + + ```bash + laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd exec laconicd "laconicd keys add alice" + ``` + +* Transfer balance to new account + + ```bash + laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd exec laconicd 'laconicd tx bank send $(laconicd keys show mykey -a) $(laconicd keys show alice -a) 1000000000000000000000000aphoton --fees 2000aphoton' + ``` + +* Export the private key of new account from laconicd + + ```bash + 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 + +* Deploy the other containers + + ```bash + laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 up + ``` + +* Check that all containers are healthy using `docker ps` + + NOTE: The `mobymask-ui` container might not start. If mobymask-app is not running at http://localhost:3002, run command again to start the container + + ```bash + laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 up + ``` ## Tests Find the watcher container's id: ```bash -docker ps | grep "cerc/watcher-mobymask-v2:local" +laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 ps | grep "mobymask-watcher-server" ``` Example output ``` -8b38e9a64d7e cerc/watcher-mobymask-v2:local "sh -c 'yarn server'" 35 seconds ago Up 14 seconds (health: starting) 0.0.0.0:3001->3001/tcp, 0.0.0.0:9001->9001/tcp, 0.0.0.0:9090->9090/tcp laconic-aeb84676de2b0a7671ae90d537fc7d26-mobymask-watcher-server-1 +id: 5d3aae4b22039fcd1c9b18feeb91318ede1100581e75bb5ac54f9e436066b02c, name: laconic-bfb01caf98b1b8f7c8db4d33f11b905a-mobymask-watcher-server-1, ports: 0.0.0.0:3001->3001/tcp, 0.0.0.0:9001->9001/tcp, 0.0.0.0:9090->9090/tcp ``` -In above output the container ID is `8b38e9a64d7e` +In above output the container ID is `5d3aae4b22039fcd1c9b18feeb91318ede1100581e75bb5ac54f9e436066b02c` Export it for later use: @@ -52,10 +126,51 @@ Run the peer tests: docker exec -w /app/packages/peer $CONTAINER_ID yarn test ``` +## Web Apps + +Check that the status for web-app containers are healthy by using `docker ps` + +### mobymask-app + +The mobymask-app should be running at http://localhost:3002 + +### peer-test-app + +The peer-test-app should be running at http://localhost:3003 + +## Details + +* The relay node for p2p network is running at http://localhost:9090 + +* The [peer package](https://github.com/cerc-io/watcher-ts/tree/main/packages/peer) (published in [gitea](https://git.vdb.to/cerc-io/-/packages/npm/@cerc-io%2Fpeer)) can be used in client code for connecting to the network + +* The [react-peer package](https://github.com/cerc-io/react-peer/tree/main/packages/react-peer) (published in [gitea](https://git.vdb.to/cerc-io/-/packages/npm/@cerc-io%2Freact-peer)) which uses the peer package can be used in react app for connecting to the network + +## Demo + +Follow the [demo](./demo.md) to try out the MobyMask app with L2 chain + ## Clean up -To stop all the services running in background run: +Stop all the services running in background run: ```bash -laconic-so --stack mobymask-v2 deploy-system down +laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 down + +laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd down ``` + +Clear volumes: + +* List all volumes + + ```bash + docker volume ls + ``` + +* Remove volumes created by this stack + + Example: + ```bash + docker volume rm laconic-bfb01caf98b1b8f7c8db4d33f11b905a_moby_data_server + ``` diff --git a/app/data/stacks/mobymask-v2/demo.md b/app/data/stacks/mobymask-v2/demo.md new file mode 100644 index 00000000..af5ec2d0 --- /dev/null +++ b/app/data/stacks/mobymask-v2/demo.md @@ -0,0 +1,130 @@ +# Demo + +* Get the root invite link URL for mobymask-app + + ``` + laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 logs mobymask + ``` + + NOTE: Clear the browser cache (local storage) for http://127.0.0.1:3002 to remove old invitations + + The invite link is seen at the end of the logs + Example: + ``` + laconic-bfb01caf98b1b8f7c8db4d33f11b905a-mobymask-1 | http://127.0.0.1:3002/#/members?invitation=%7B%22v%22%3A1%2C%22signedDelegations%22%3A%5B%7B%22signature%22%3A%220x7559bd412f02677d60820e38243acf61547f79339395a34f7d4e1630e645aeb30535fc219f79b6fbd3af0ce3bd05132ad46d2b274a9fbc4c36bc71edd09850891b%22%2C%22delegation%22%3A%7B%22delegate%22%3A%220xc0838c92B2b71756E0eAD5B3C1e1F186baeEAAac%22%2C%22authority%22%3A%220x0000000000000000000000000000000000000000000000000000000000000000%22%2C%22caveats%22%3A%5B%7B%22enforcer%22%3A%220x558024C7d593B840E1BfD83E9B287a5CDad4db15%22%2C%22terms%22%3A%220x0000000000000000000000000000000000000000000000000000000000000000%22%7D%5D%7D%7D%5D%2C%22key%22%3A%220x98da9805821f1802196443e578fd32af567bababa0a249c07c82df01ecaa7d8d%22%7D + ``` + +* In the debug panel, check if it is connected to the p2p network (It should be connected to atleast one other peer for pubsub to work). + +* Create an invite link in the app by clicking on `Create new invite link` button. + +* Switch to the `MESSAGES` tab in debug panel for viewing incoming messages later. + +* Open the invite link in a new browser with different profile (to simulate remote browser) + * Check that it is connected to any other peer in the network. + +* In `Report a phishing attempt` section, report multiple phishers using the `submit` button. Click on the `Submit batch to p2p network` button. This broadcasts signed invocations to the connected peers. + +* In the `MESSAGES` tab of other browsers, a message can be seen with the signed invocations. + +* In a terminal check logs from the watcher peer container. + + * Get the container id + + ```bash + laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 ps | grep mobymask-watcher-peer + ``` + + * Check logs + + ```bash + docker logs -f CONTAINER_ID + ``` + +* It should have received the message, sent transaction to L2 chain and received a transaction receipt with block details. + + Example log: + + ``` + 2023-03-23T10:25:19.771Z vulcanize:peer-listener [10:25:19] Received a message on mobymask P2P network from peer: PeerId(12D3KooWAVNswtcrX12iDYukEoxdQwD34kJyRWcQTfZ4unGg2xjd) + 2023-03-23T10:25:24.143Z laconic:libp2p-utils Transaction receipt for invoke message { + to: '0x558024C7d593B840E1BfD83E9B287a5CDad4db15', + blockNumber: 1996, + blockHash: '0xebef19c21269654804b2ef2d4bb5cb6c88743b37ed77e82222dc5671debf3afb', + transactionHash: '0xf8c5a093a93f793012196073a7d0cb3ed6fbd2846126c066cb31c72100960cb1', + effectiveGasPrice: '1500000007', + gasUsed: '250000' + } + ``` + +* Check the phisher in watcher GQL: http://localhost:3001/graphql + * Use the blockHash from transaction receipt details or query for latest block + + ```gql + query { + latestBlock { + hash + number + } + } + ``` + + * Get the deployed contract address + + ```bash + laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 exec mobymask-app "cat src/config.json" + ``` + + The value of `address` field is the deployed contract address + + * Check for phisher value + + ```gql + query { + isPhisher( + blockHash: "TX_OR_LATEST_BLOCK_HASH", + contractAddress: "CONTRACT_ADDRESS", + # If reported phisher name was "test" then key0 value is "TWT:test" + key0: "TWT:PHISHER_NAME" + ) { + value + } + } + ``` + + It should return true for reported phisher names. + + * Watcher internally is using L2 chain `eth_getStorageAt` method. + +* Check the phisher name in mobymask app in `Check Phisher Status` section. + * Watcher GQL API is used for checking phisher. + +* Manage the invitations by clicking on the `Outstanding Invitations in p2p network`. + +* Revoke the created invitation by clicking on `Revoke (p2p network)` + +* Revocation messages can be seen in the debug panel `MESSAGES` tab of other browsers. + +* Check the watcher peer logs. It should receive a message and log the transaction receipt for revoke message. + +* Try reporting a phisher from the revoked invitee's browser. + + * The invocation message for reporting phisher would be broadcasted to all peers. + + * Check the watcher peer logs. A transaction failed error should be logged. + + * Check the reported phisher in [watcher GQL](https://localhost:3001/graphql) + + ```gql + query { + isPhisher( + blockHash: "LATEST_BLOCK_HASH", + contractAddress: "CONTRACT_ADDRESS", + key0: "TWT:PHISHER_NAME" + ) { + value + } + } + ``` + + It should return false as the invitation/delegation used for reporting phishers has been revoked. diff --git a/app/data/stacks/mobymask-v2/stack.yml b/app/data/stacks/mobymask-v2/stack.yml index c9b13aa5..e3b36bfe 100644 --- a/app/data/stacks/mobymask-v2/stack.yml +++ b/app/data/stacks/mobymask-v2/stack.yml @@ -4,8 +4,14 @@ repos: - cerc-io/watcher-ts - cerc-io/react-peer - cerc-io/mobymask-ui + - cerc-io/laconicd + - cerc-io/MobyMask containers: - cerc/watcher-mobymask-v2 + - cerc/react-peer - cerc/mobymask-ui + - cerc/laconicd + - cerc/mobymask pods: + - mobymask-laconicd - watcher-mobymask-v2 From a5dd62e457c1ef1a865e96fe190c2aeb8834cd97 Mon Sep 17 00:00:00 2001 From: Zach Date: Fri, 24 Mar 2023 08:56:01 -0400 Subject: [PATCH 08/10] doc jq requirement --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6eb5b94d..607a41bb 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Ensure that the following are already installed: - [Python3](https://wiki.python.org/moin/BeginnersGuide/Download): `python3 --version` >= `3.8.10` (the Python3 shipped in Ubuntu 20+ is good to go) - [Docker](https://docs.docker.com/get-docker/): `docker --version` >= `20.10.21` +- [jq](https://stedolan.github.io/jq/download/): `jq --version` >= `1.5` Note: if installing docker-compose via package manager on Linux (as opposed to Docker Desktop), you must [install the plugin](https://docs.docker.com/compose/install/linux/#install-the-plugin-manually), e.g. : From 07de83e6d7a1495659260ccb62e4d84a81c7fb65 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 24 Mar 2023 10:26:48 -0600 Subject: [PATCH 09/10] Update version file --- app/data/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/data/version.txt b/app/data/version.txt index df76da3b..14872d47 100644 --- a/app/data/version.txt +++ b/app/data/version.txt @@ -1,2 +1,2 @@ # This file should be re-generated running: scripts/update-version-file.sh script -v1.0.29-5fca9bd +v1.0.30-3d03b10 From da24a4edf66f9475d5f7c730ff0342b52cd7fa4c Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 24 Mar 2023 18:23:35 -0600 Subject: [PATCH 10/10] Use our locally built foundry container --- app/data/container-build/cerc-go-ethereum-foundry/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/data/container-build/cerc-go-ethereum-foundry/Dockerfile b/app/data/container-build/cerc-go-ethereum-foundry/Dockerfile index bbbc64fc..b9a5a30b 100644 --- a/app/data/container-build/cerc-go-ethereum-foundry/Dockerfile +++ b/app/data/container-build/cerc-go-ethereum-foundry/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/foundry-rs/foundry +FROM cerc/foundry:local RUN apk update ; apk add --no-cache --allow-untrusted ca-certificates curl bash git jq RUN apk add --no-cache --upgrade grep