2023-04-05 11:56:38 +00:00
# MobyMask v2 watcher
Instructions to setup and deploy MobyMask v2 watcher independently
## Setup
2023-04-06 09:47:00 +00:00
Prerequisite: L2 Optimism Geth and Node RPC endpoints
2023-04-05 11:56:38 +00:00
Clone required repositories:
```bash
2023-04-20 10:00:19 +00:00
laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/MobyMask,cerc-io/watcher-ts,cerc-io/mobymask-v2-watcher-ts
2023-04-11 10:51:03 +00:00
# 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
2023-04-05 11:56:38 +00:00
```
Checkout to the required versions and branches in repos:
```bash
# watcher-ts
cd ~/cerc/watcher-ts
2023-04-20 10:00:19 +00:00
git checkout v0.2.39
# mobymask-v2-watcher-ts
cd ~/cerc/mobymask-v2-watcher-ts
git checkout v0.1.0
2023-04-05 11:56:38 +00:00
# MobyMask
cd ~/cerc/MobyMask
git checkout v0.1.2
```
Build the container images:
```bash
2023-04-20 10:00:19 +00:00
laconic-so --stack mobymask-v2 build-containers --include cerc/watcher-ts,cerc/watcher-mobymask-v2,cerc/mobymask
2023-04-05 11:56:38 +00:00
```
This should create the required docker images in the local image registry
## Deploy
2023-04-06 09:47:00 +00:00
### Configuration
2023-04-05 11:56:38 +00:00
2023-04-11 10:51:03 +00:00
Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v2/)):
```bash
# External L2 endpoints
CERC_L2_GETH_RPC=
2023-04-20 10:00:19 +00:00
# Endpoints waited on before contract deployment
2023-04-11 10:51:03 +00:00
CERC_L2_GETH_HOST=
CERC_L2_GETH_PORT=
CERC_L2_NODE_HOST=
CERC_L2_NODE_PORT=
2023-04-20 09:42:59 +00:00
# URL to get CSV with credentials for accounts on L1 to perform txs on L2
CERC_L1_ACCOUNTS_CSV_URL=
# OR
# Specify the required account credentials
2023-04-11 10:51:03 +00:00
CERC_PRIVATE_KEY_DEPLOYER=
CERC_PRIVATE_KEY_PEER=
# Base URI for mobymask-app
# (used for generating a root invite link after deploying the contract)
CERC_MOBYMASK_APP_BASE_URI="http://127.0.0.1:3002/#"
2023-04-12 12:47:13 +00:00
# (Optional) Set of relay peers to connect to from the relay node
CERC_RELAY_PEERS=[]
# (Optional) Domain to be used in the relay node's announce address
CERC_RELAY_ANNOUNCE_DOMAIN=
2023-04-11 10:51:03 +00:00
# Set to false for disabling watcher peer to send txs to L2
CERC_ENABLE_PEER_L2_TXS=true
# (Optional) Set already deployed MobyMask contract address to avoid deploying contract in the stack
CERC_DEPLOYED_CONTRACT=
```
* NOTE: If Optimism is running on the host machine, use `host.docker.internal` as the hostname to access the host port
2023-04-05 11:56:38 +00:00
2023-04-06 09:47:00 +00:00
### Deploy the stack
2023-04-05 11:56:38 +00:00
```bash
2023-04-11 10:51:03 +00:00
laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 --env-file < PATH_TO_ENV_FILE > up
2023-04-05 11:56:38 +00:00
```
To list down and monitor the running containers:
```bash
laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 ps
2023-04-05 12:22:12 +00:00
2023-04-05 11:56:38 +00:00
# With status
docker ps
2023-04-05 12:22:12 +00:00
2023-04-05 11:56:38 +00:00
# Check logs for a container
docker logs -f < CONTAINER_ID >
```
2023-04-11 10:51:03 +00:00
The watcher endpoint is exposed on host port `3001` and the relay node endpoint is exposed on host port `9090`
Check the logs of the deployment container to get the deployed contract's address and generated root invite link:
```bash
docker logs -f $(docker ps -aq --filter name="mobymask-1")
```
2023-04-06 09:47:00 +00:00
## Tests
See [Tests ](./README.md#tests )
2023-04-05 11:56:38 +00:00
2023-04-11 10:51:03 +00:00
## Web Apps
For deploying the web-app(s) separately after deploying the watcher, follow [web-apps.md ](./web-apps.md )
2023-04-05 11:56:38 +00:00
## Clean up
Stop all services running in the background:
```bash
2023-04-05 12:22:12 +00:00
laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 down
2023-04-05 11:56:38 +00:00
```
Clear volumes created by this stack:
```bash
# List all relevant volumes
2023-04-20 09:42:59 +00:00
docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*peers_ids|.*mobymask_deployment"
2023-04-05 12:22:12 +00:00
2023-04-05 11:56:38 +00:00
# Remove all the listed volumes
2023-04-20 09:42:59 +00:00
docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*peers_ids|.*mobymask_deployment")
2023-04-05 11:56:38 +00:00
```