Skip to content

Commit

Permalink
Add instructions to join MobyMask watcher p2p network (#346)
Browse files Browse the repository at this point in the history
* Refactor L2 enpoint check to contract deployment script

* Add instructions to join to an existing watcher network

* Include mobymask-v2-watcher-ts in repositories setup

* Add a clean up section and expected outputs

* Add a troubleshooting section

* Use lxdao frontend

* Update instructions for updated UI

Former-commit-id: f78176a
  • Loading branch information
prathamesh0 authored Apr 20, 2023
1 parent 363a0b7 commit d6f829e
Show file tree
Hide file tree
Showing 7 changed files with 342 additions and 19 deletions.
13 changes: 5 additions & 8 deletions app/data/compose/docker-compose-watcher-mobymask-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ services:
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER}
CERC_MOBYMASK_APP_BASE_URI: ${CERC_MOBYMASK_APP_BASE_URI}
CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT}
# Waits for L2 Optimism Geth and Node servers to be up before deploying contract
command:
- sh
- -c
- |
./wait-for-it.sh -h ${CERC_L2_GETH_HOST:-$${DEFAULT_CERC_L2_GETH_HOST}} -p ${CERC_L2_GETH_PORT:-$${DEFAULT_CERC_L2_GETH_PORT}} -s -t 0 && \
./wait-for-it.sh -h ${CERC_L2_NODE_HOST:-$${DEFAULT_CERC_L2_NODE_HOST}} -p ${CERC_L2_NODE_PORT:-$${DEFAULT_CERC_L2_NODE_PORT}} -s -t 0 && \
./deploy-and-generate-invite.sh
CERC_L2_GETH_HOST: ${CERC_L2_GETH_HOST}
CERC_L2_GETH_PORT: ${CERC_L2_GETH_PORT}
CERC_L2_NODE_HOST: ${CERC_L2_NODE_HOST}
CERC_L2_NODE_PORT: ${CERC_L2_NODE_PORT}
command: ["sh", "deploy-and-generate-invite.sh"]
volumes:
- ../config/wait-for-it.sh:/app/packages/server/wait-for-it.sh
- ../config/watcher-mobymask-v2/secrets-template.json:/app/packages/server/secrets-template.json
Expand Down
22 changes: 15 additions & 7 deletions app/data/config/watcher-mobymask-v2/deploy-and-generate-invite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ CERC_L1_ACCOUNTS_CSV_URL="${CERC_L1_ACCOUNTS_CSV_URL:-${DEFAULT_CERC_L1_ACCOUNTS
CERC_MOBYMASK_APP_BASE_URI="${CERC_MOBYMASK_APP_BASE_URI:-${DEFAULT_CERC_MOBYMASK_APP_BASE_URI}}"
CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRACT}}"

# Check if CERC_DEPLOYED_CONTRACT environment variable set to skip contract deployment
if [ -n "$CERC_DEPLOYED_CONTRACT" ]; then
echo "CERC_DEPLOYED_CONTRACT is set to '$CERC_DEPLOYED_CONTRACT'"
echo "Skipping contract deployment"
exit 0
fi

echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"

if [ -n "$CERC_L1_ACCOUNTS_CSV_URL" ] && \
Expand All @@ -35,14 +42,15 @@ jq --arg rpcUrl "$CERC_L2_GETH_RPC" '.rpcUrl = $rpcUrl' secrets.json > secrets_u
# Set the MobyMask app base URI
jq --arg baseURI "$CERC_MOBYMASK_APP_BASE_URI" '.baseURI = $baseURI' secrets.json > secrets_updated.json && mv secrets_updated.json secrets.json

export RPC_URL="${CERC_L2_GETH_RPC}"
# Wait for L2 Optimism Geth and Node servers to be up before deploying contract
CERC_L2_GETH_HOST="${CERC_L2_GETH_HOST:-${DEFAULT_CERC_L2_GETH_HOST}}"
CERC_L2_GETH_PORT="${CERC_L2_GETH_PORT:-${DEFAULT_CERC_L2_GETH_PORT}}"
CERC_L2_NODE_HOST="${CERC_L2_NODE_HOST:-${DEFAULT_CERC_L2_NODE_HOST}}"
CERC_L2_NODE_PORT="${CERC_L2_NODE_PORT:-${DEFAULT_CERC_L2_NODE_PORT}}"
./wait-for-it.sh -h "${CERC_L2_GETH_HOST}" -p "${CERC_L2_GETH_PORT}" -s -t 0
./wait-for-it.sh -h "${CERC_L2_GETH_PORT}" -p "${CERC_L2_NODE_PORT}" -s -t 0

# Check if CERC_DEPLOYED_CONTRACT environment variable set to skip contract deployment
if [ -n "$CERC_DEPLOYED_CONTRACT" ]; then
echo "CERC_DEPLOYED_CONTRACT is set to '$CERC_DEPLOYED_CONTRACT'"
echo "Exiting without deploying contract"
exit 0
fi
export RPC_URL="${CERC_L2_GETH_RPC}"

# Check and exit if a deployment already exists (on restarts)
if [ -f ./config.json ]; then
Expand Down
2 changes: 2 additions & 0 deletions app/data/config/watcher-mobymask-v2/optimism-params.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# L2 endpoints
DEFAULT_CERC_L2_GETH_RPC="http://op-geth:8545"

# Endpoints waited on before contract deployment
DEFAULT_CERC_L2_GETH_HOST="op-geth"
DEFAULT_CERC_L2_GETH_PORT=8545

Expand Down
4 changes: 4 additions & 0 deletions app/data/stacks/mobymask-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Checkout to the required versions and branches in repos
cd ~/cerc/watcher-ts
git checkout v0.2.39

# mobymask-v2-watcher-ts
cd ~/cerc/mobymask-v2-watcher-ts
git checkout v0.1.0

# MobyMask
cd ~/cerc/MobyMask
git checkout v0.1.2
Expand Down
2 changes: 1 addition & 1 deletion app/data/stacks/mobymask-v2/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* 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 `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.

Expand Down
12 changes: 9 additions & 3 deletions app/data/stacks/mobymask-v2/mobymask-only.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Prerequisite: L2 Optimism Geth and Node RPC endpoints
Clone required repositories:

```bash
laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/MobyMask,cerc-io/watcher-ts
laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/MobyMask,cerc-io/watcher-ts,cerc-io/mobymask-v2-watcher-ts

# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
```
Expand All @@ -19,7 +19,11 @@ Checkout to the required versions and branches in repos:
```bash
# watcher-ts
cd ~/cerc/watcher-ts
git checkout v0.2.35
git checkout v0.2.39

# mobymask-v2-watcher-ts
cd ~/cerc/mobymask-v2-watcher-ts
git checkout v0.1.0

# MobyMask
cd ~/cerc/MobyMask
Expand All @@ -29,7 +33,7 @@ git checkout v0.1.2
Build the container images:

```bash
laconic-so --stack mobymask-v2 build-containers --include cerc/watcher-mobymask-v2,cerc/mobymask
laconic-so --stack mobymask-v2 build-containers --include cerc/watcher-ts,cerc/watcher-mobymask-v2,cerc/mobymask
```

This should create the required docker images in the local image registry
Expand All @@ -43,6 +47,8 @@ Create and update an env file to be used in the next step ([defaults](../../conf
```bash
# External L2 endpoints
CERC_L2_GETH_RPC=

# Endpoints waited on before contract deployment
CERC_L2_GETH_HOST=
CERC_L2_GETH_PORT=

Expand Down
Loading

0 comments on commit d6f829e

Please sign in to comment.