forked from cerc-io/stack-orchestrator
Rename app -> stack_orchestrator (#625)
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
# MobyMask v2 watcher
|
||||
|
||||
Instructions to setup and deploy an end-to-end MobyMask v2 stack ([L1](../fixturenet-eth/) + [L2](../fixturenet-optimism/) chains + watcher + web-app(s)) using [laconic-stack-orchestrator](/README.md#install)
|
||||
|
||||
We support running just the watcher part of stack, given an external L2 Optimism endpoint.
|
||||
Follow [mobymask-only](./mobymask-only.md) for the same.
|
||||
|
||||
We also support running just the web-app(s), given external watcher GQL (for mobymask-app) and relay node endpoints. Follow [web-apps.md](./web-apps.md) for the same.
|
||||
|
||||
## Setup
|
||||
|
||||
Clone required repositories:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 setup-repositories
|
||||
```
|
||||
|
||||
NOTE: If repositories already exist and are checked out to different versions, `setup-repositories` command will throw an error.
|
||||
For getting around this, the repositories mentioned below can be removed and then run the command.
|
||||
|
||||
Build the container images:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 build-containers
|
||||
```
|
||||
|
||||
This should create the required docker images in the local image registry.
|
||||
|
||||
Deploy the stack:
|
||||
|
||||
* Deploy the containers:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 up
|
||||
```
|
||||
|
||||
NOTE: The `fixturenet-optimism-contracts` service takes a while to run to completion and it may restart a few times after running into errors.
|
||||
|
||||
* To list down and monitor the running containers:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 ps
|
||||
|
||||
# With status
|
||||
docker ps -a
|
||||
|
||||
# Check logs for a container
|
||||
docker logs -f <CONTAINER_ID>
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
Find the watcher container's id and export it for later use:
|
||||
|
||||
```bash
|
||||
export CONTAINER_ID=$(docker ps -q --filter "name=peer-tests")
|
||||
```
|
||||
|
||||
Run the peer tests:
|
||||
|
||||
```bash
|
||||
docker exec $CONTAINER_ID yarn test
|
||||
```
|
||||
|
||||
## Web Apps
|
||||
|
||||
Check that the web-app containers are healthy:
|
||||
|
||||
```bash
|
||||
docker ps | grep -E 'mobymask-app|peer-test-app'
|
||||
```
|
||||
|
||||
### mobymask-app
|
||||
|
||||
* The mobymask-app should be running at http://localhost:3002
|
||||
* The lxdao-mobymask-app should be running at http://localhost:3004
|
||||
|
||||
### 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
|
||||
|
||||
Stop all the services running in background:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 down 30
|
||||
```
|
||||
|
||||
Clear volumes created by this stack:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter "name=mobymask_v2"
|
||||
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter "name=mobymask_v2")
|
||||
```
|
||||
@@ -0,0 +1,123 @@
|
||||
# Demo
|
||||
|
||||
* Get the root invite link URL for mobymask-app:
|
||||
|
||||
```bash
|
||||
docker logs -f $(docker ps -aq --filter name="mobymask-1")
|
||||
```
|
||||
|
||||
The invite link is seen at the end of the logs. Example log:
|
||||
|
||||
```bash
|
||||
http://127.0.0.1:3004/#/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
|
||||
```
|
||||
|
||||
* Open the invite link in a browser to use the mobymask-app.
|
||||
|
||||
NOTE: Before opening the invite link, clear the browser cache (local storage) for http://127.0.0.1:3004 to remove old invitations
|
||||
|
||||
* In the debug panel, check if it is connected to the p2p network (it should be connected to at least one other peer for pubsub to work).
|
||||
|
||||
* Create an invite link in the app by clicking on `Create new invite link` button in the `My invitees` section.
|
||||
|
||||
* 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 a peer in the network.
|
||||
|
||||
* In the `Pending reports` section, enter multiple phisher records and 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:
|
||||
|
||||
```bash
|
||||
docker logs -f $(docker ps -aq --filter name="mobymask-watcher-server")
|
||||
```
|
||||
|
||||
* It should have received the message, sent transaction to L2 chain and received a transaction receipt for an `invoke` message with block details.
|
||||
|
||||
Example log:
|
||||
|
||||
```bash
|
||||
2023-03-23T10:25:19.771Z vulcanize:peer-listener [10:25:19] Received a message on mobymask P2P network from peer: 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
|
||||
docker exec -it $(docker ps -aq --filter name="lxdao-mobymask-app") cat /config/config.yml
|
||||
```
|
||||
|
||||
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 invitations in the `Outstanding invitations (p2p network)` tab in `My Invitations` section.
|
||||
* Revoke the created invitation by clicking on the `Revoke` button.
|
||||
|
||||
* Revocation messages can be seen in the debug panel `MESSAGES` tab of other browsers.
|
||||
|
||||
* Also, check the watcher peer logs. It should receive a message and log the transaction receipt for a `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.
|
||||
@@ -0,0 +1,129 @@
|
||||
# MobyMask v2 watcher
|
||||
|
||||
Instructions to setup and deploy MobyMask v2 watcher independently
|
||||
|
||||
## Setup
|
||||
|
||||
Prerequisite: L2 Optimism Geth and Node RPC endpoints
|
||||
|
||||
Clone required repositories:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 setup-repositories --include github.com/cerc-io/MobyMask,github.com/cerc-io/watcher-ts,github.com/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
|
||||
```
|
||||
|
||||
Build the container images:
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
## Deploy
|
||||
|
||||
### Configuration
|
||||
|
||||
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=
|
||||
|
||||
# Endpoints waited on before contract deployment
|
||||
CERC_L2_GETH_HOST=
|
||||
CERC_L2_GETH_PORT=
|
||||
|
||||
CERC_L2_NODE_HOST=
|
||||
CERC_L2_NODE_PORT=
|
||||
|
||||
# URL (fixturenet-eth-bootnode-lighthouse) 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
|
||||
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:3004/#"
|
||||
|
||||
# (Optional) Domain to be used in the relay node's announce address
|
||||
CERC_RELAY_ANNOUNCE_DOMAIN=
|
||||
|
||||
# (Optional) Set of relay peers to connect to from the relay node
|
||||
CERC_RELAY_PEERS=[]
|
||||
|
||||
# (Optional) Set of multiaddrs to be avoided while dialling
|
||||
CERC_DENY_MULTIADDRS=[]
|
||||
|
||||
# (Optional) Type of pubsub to be used
|
||||
CERC_PUBSUB=""
|
||||
|
||||
# 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
|
||||
|
||||
### Deploy the stack
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include watcher-mobymask-v2 --env-file <PATH_TO_ENV_FILE> up
|
||||
```
|
||||
|
||||
To list down and monitor the running containers:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include watcher-mobymask-v2 ps
|
||||
|
||||
# With status
|
||||
docker ps -a
|
||||
|
||||
# Check logs for a container
|
||||
docker logs -f <CONTAINER_ID>
|
||||
```
|
||||
|
||||
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")
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
See [Tests](./README.md#tests)
|
||||
|
||||
## Web Apps
|
||||
|
||||
For deploying the web-app(s) separately after deploying the watcher, follow [web-apps.md](./web-apps.md)
|
||||
|
||||
## Clean up
|
||||
|
||||
Stop all services running in the background:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include watcher-mobymask-v2 down
|
||||
```
|
||||
|
||||
Clear volumes created by this stack:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter "name=mobymask_v2"
|
||||
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter "name=mobymask_v2")
|
||||
|
||||
# WARNING: To avoid changing peer ids for the watcher, `peers_ids` volume can be persisted
|
||||
# To delete all volumes except for `peers_ids`
|
||||
docker volume rm $(docker volume ls -q --filter "name=mobymask_v2" | grep -v "peers_ids$")
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
version: "1.0"
|
||||
name: mobymask-v2
|
||||
repos:
|
||||
- git.vdb.to/cerc-io/go-ethereum@v1.11.6-statediff-v5
|
||||
- git.vdb.to/cerc-io/lighthouse
|
||||
- github.com/dboreham/foundry
|
||||
- github.com/ethereum-optimism/optimism@v1.0.4
|
||||
- github.com/ethereum-optimism/op-geth@v1.101105.2
|
||||
- github.com/cerc-io/watcher-ts@v0.2.56
|
||||
- github.com/cerc-io/mobymask-v2-watcher-ts@v0.1.3
|
||||
- github.com/cerc-io/MobyMask@v0.1.3
|
||||
- github.com/cerc-io/mobymask-ui
|
||||
containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
- cerc/lighthouse-cli
|
||||
- cerc/fixturenet-eth-genesis
|
||||
- cerc/fixturenet-eth-geth
|
||||
- cerc/fixturenet-eth-lighthouse
|
||||
- cerc/foundry
|
||||
- cerc/optimism-contracts
|
||||
- cerc/optimism-l2geth
|
||||
- cerc/optimism-op-batcher
|
||||
- cerc/optimism-op-proposer
|
||||
- cerc/optimism-op-node
|
||||
- cerc/watcher-ts
|
||||
- cerc/watcher-mobymask-v2
|
||||
- cerc/react-peer
|
||||
- cerc/mobymask-ui
|
||||
- cerc/mobymask
|
||||
pods:
|
||||
- fixturenet-eth
|
||||
- fixturenet-optimism
|
||||
- watcher-mobymask-v2
|
||||
- mobymask-app
|
||||
- peer-test-app
|
||||
@@ -0,0 +1,303 @@
|
||||
# MobyMask Watcher P2P Network
|
||||
|
||||
Instructions to setup and deploy a watcher that connects to the existing watcher p2p network
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Laconic Stack Orchestrator ([installation](/README.md#install))
|
||||
* A publicly reachable domain name with SSL setup
|
||||
|
||||
This demo has been tested on a `Ubuntu 22.04 LTS` machine with `8GB` of RAM
|
||||
|
||||
## Setup
|
||||
|
||||
Clone required repositories:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 setup-repositories --include github.com/cerc-io/MobyMask,github.com/cerc-io/watcher-ts,github.com/cerc-io/mobymask-v2-watcher-ts
|
||||
|
||||
# This will clone the required repositories at ~/cerc
|
||||
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned in the next step and re-run the command
|
||||
|
||||
# Expected output:
|
||||
|
||||
# Dev Root is: /home/xyz/cerc
|
||||
# Checking: /home/xyz/cerc/watcher-ts: Needs to be fetched
|
||||
# 100%|#############################################################################################################################################| 9.96k/9.96k [00:05<00:00, 1.70kB/s]
|
||||
# Checking: /home/xyz/cerc/mobymask-v2-watcher-ts: Needs to be fetched
|
||||
# 100%|################################################################################################################################################| 19.0/19.0 [00:01<00:00, 13.6B/s]
|
||||
# Checking: /home/xyz/cerc/MobyMask: Needs to be fetched
|
||||
# 100%|##############################################################################################################################################| 1.41k/1.41k [00:18<00:00, 76.4B/s]
|
||||
```
|
||||
|
||||
Build the container images:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 build-containers --include cerc/watcher-ts,cerc/watcher-mobymask-v2,cerc/mobymask
|
||||
```
|
||||
|
||||
Check that the required images are created in the local image registry:
|
||||
|
||||
```bash
|
||||
docker image ls
|
||||
|
||||
# Expected output:
|
||||
|
||||
# REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
# cerc/watcher-mobymask-v2 local c4dba5dc8d48 24 seconds ago 1.02GB
|
||||
# cerc/watcher-ts local 9ef61478c243 9 minutes ago 1.84GB
|
||||
# cerc/mobymask local 9db3f1a69966 2 weeks ago 3.82GB
|
||||
# .
|
||||
# .
|
||||
```
|
||||
|
||||
## Deploy
|
||||
|
||||
### Configuration
|
||||
|
||||
Create an env file `mobymask-watcher.env`:
|
||||
|
||||
```bash
|
||||
touch mobymask-watcher.env
|
||||
```
|
||||
|
||||
Add the following contents to `mobymask-watcher.env`:
|
||||
|
||||
```bash
|
||||
# Domain to be used in the relay node's announce address
|
||||
CERC_RELAY_ANNOUNCE_DOMAIN="mobymask.example.com"
|
||||
|
||||
|
||||
# DO NOT CHANGE THESE VALUES
|
||||
CERC_L2_GETH_RPC="https://mobymask-l2.dev.vdb.to"
|
||||
CERC_DEPLOYED_CONTRACT="0x2B6AFbd4F479cE4101Df722cF4E05F941523EaD9"
|
||||
CERC_ENABLE_PEER_L2_TXS=false
|
||||
CERC_RELAY_PEERS=["/dns4/relay1.dev.vdb.to/tcp/443/wss/p2p/12D3KooWAx83SM9GWVPc9v9fNzLzftRX6EaAFMjhYiFxRYqctcW1", "/dns4/relay2.dev.vdb.to/tcp/443/wss/p2p/12D3KooWBycy6vHVEfUwwYRbPLBdb5gx9gtFSEMpErYPUjUkDNkm", "/dns4/relay3.dev.vdb.to/tcp/443/wss/p2p/12D3KooWARcUJsiGCgiygiRVVK94U8BNSy8DFBbzAF3B6orrabwn"]
|
||||
```
|
||||
|
||||
Replace `CERC_RELAY_ANNOUNCE_DOMAIN` with your public domain name
|
||||
|
||||
### Deploy the stack
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include watcher-mobymask-v2 --env-file mobymask-watcher.env up
|
||||
|
||||
# Expected output (ignore the "The X variable is not set. Defaulting to a blank string." warnings):
|
||||
|
||||
# [+] Running 9/9
|
||||
# ✔ Network mobymask_v2_default Created 0.1s
|
||||
# ✔ Volume "mobymask_v2_peers_ids" Created 0.0s
|
||||
# ✔ Volume "mobymask_v2_mobymask_watcher_db_data" Created 0.0s
|
||||
# ✔ Volume "mobymask_v2_mobymask_deployment" Created 0.0s
|
||||
# ✔ Container mobymask_v2-mobymask-watcher-db-1 Healthy 22.2s
|
||||
# ✔ Container mobymask_v2-mobymask-1 Exited 2.2s
|
||||
# ✔ Container mobymask_v2-peer-ids-gen-1 Exited 23.9s
|
||||
# ✔ Container mobymask_v2-mobymask-watcher-server-1 Healthy 43.6s
|
||||
# ✔ Container mobymask_v2-peer-tests-1 Started 44.5s
|
||||
```
|
||||
|
||||
This will run the `mobymask-v2-watcher` including:
|
||||
* A relay node which is in a federated setup with relay nodes set in the env file
|
||||
* A peer node which connects to the watcher relay node as an entrypoint to the MobyMask watcher p2p network. This peer listens for messages from other peers on the network and logs them out to the console
|
||||
|
||||
The watcher GraphQL endpoint is exposed on host port `3001` and the relay node endpoint is exposed on host port `9090`
|
||||
|
||||
To list down and monitor the running containers:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include watcher-mobymask-v2 ps
|
||||
|
||||
# Expected output:
|
||||
|
||||
# Running containers:
|
||||
# id: 25cc3a1cbda27fcd9c2ad4c772bd753ccef1e178f901a70e6ff4191d4a8684e9, name: mobymask_v2-mobymask-watcher-db-1, ports: 127.0.0.1:15432->5432/tcp
|
||||
# id: c9806f78680d68292ffe942222af2003aa3ed5d5c69d7121b573f5028444391d, name: mobymask_v2-mobymask-watcher-server-1, ports: 127.0.0.1:3001->3001/tcp, 127.0.0.1:9001->9001/tcp, 127.0.0.1:9090->9090/tcp
|
||||
# id: 6b30a1d313a88fb86f8a3b37a1b1a3bc053f238664e4b2d196c3ec74e04faf13, name: mobymask_v2-peer-tests-1, ports:
|
||||
|
||||
|
||||
# With status
|
||||
docker ps
|
||||
|
||||
# Expected output:
|
||||
|
||||
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
# 6b30a1d313a8 cerc/watcher-ts:local "docker-entrypoint.s…" 5 minutes ago Up 4 minutes mobymask_v2-peer-tests-1
|
||||
# c9806f78680d cerc/watcher-mobymask-v2:local "sh start-server.sh" 5 minutes ago Up 5 minutes (healthy) 127.0.0.1:3001->3001/tcp, 127.0.0.1:9001->9001/tcp, 127.0.0.1:9090->9090/tcp mobymask_v2-mobymask-watcher-server-1
|
||||
# 25cc3a1cbda2 postgres:14-alpine "docker-entrypoint.s…" 5 minutes ago Up 5 minutes (healthy) 127.0.0.1:15432->5432/tcp mobymask_v2-mobymask-watcher-db-1
|
||||
|
||||
|
||||
# Check logs for a container
|
||||
docker logs -f <CONTAINER_ID>
|
||||
```
|
||||
|
||||
Check watcher container logs to get multiaddr advertised by the watcher's relay node and note it down for further usage:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include watcher-mobymask-v2 logs mobymask-watcher-server | grep -A 2 "Relay node started"
|
||||
|
||||
# The multiaddr will be of form /dns4/<CERC_RELAY_ANNOUNCE_DOMAIN>/tcp/443/wss/p2p/<RELAY_PEER_ID>
|
||||
# Expected output:
|
||||
|
||||
# mobymask_v2-mobymask-watcher-server-1 | 2023-04-20T04:22:57.069Z laconic:relay Relay node started with id 12D3KooWKef84LAcBNb9wZNs6jC5kQFXjddo47hK6AGHD2dSvGai (characteristic-black-pamella)
|
||||
# mobymask_v2-mobymask-watcher-server-1 | 2023-04-20T04:22:57.069Z laconic:relay Listening on:
|
||||
# mobymask_v2-mobymask-watcher-server-1 | 2023-04-20T04:22:57.070Z laconic:relay /dns4/mobymask.example.com/tcp/443/wss/p2p/12D3KooWKef84LAcBNb9wZNs6jC5kQFXjddo47hK6AGHD2dSvGai
|
||||
```
|
||||
|
||||
## Web App
|
||||
|
||||
To be able to connect to the relay node from remote peers, it needs to be publicly reachable.
|
||||
Configure your website with SSL and the `https` traffic reverse proxied as:
|
||||
* `/graphql` to port `3001` (watcher GQL endpoint)
|
||||
* `/` to port `9090` (relay node)
|
||||
|
||||
For example, a Nginx configuration for domain `mobymask.example.com` would look something like:
|
||||
|
||||
```bash
|
||||
server {
|
||||
server_name mobymask.example.com;
|
||||
|
||||
location /graphql {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_pass http://127.0.0.1:3001;
|
||||
proxy_read_timeout 90;
|
||||
}
|
||||
|
||||
# https://nginx.org/en/docs/http/websocket.html
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:9090;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# set a large timeout to avoid websocket disconnects
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
listen [::]:443 ssl ipv6only=on; # managed by Certbot
|
||||
listen 443 ssl; # managed by Certbot
|
||||
ssl_certificate /etc/letsencrypt/live/mobymask.example.com/fullchain.pem; # managed by Certbot
|
||||
ssl_certificate_key /etc/letsencrypt/live/mobymask.example.com/privkey.pem; # managed by Certbot
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
|
||||
}
|
||||
|
||||
server {
|
||||
if ($host = mobymask.example.com) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name mobymask.example.com;
|
||||
return 404; # managed by Certbot
|
||||
}
|
||||
```
|
||||
|
||||
To test the web-app, either visit https://mobymask-lxdao-app.dev.vdb.to/ or follow [web-app.md](./web-app.md) to deploy the app locally that hits your watcher's GQL endpoint
|
||||
|
||||
Connect a browser peer to the watcher's relay node:
|
||||
* Click on debug panel on bottom right of the homepage
|
||||
* Select `<custom>` in `Primary Relay` dropdown on the right and enter the watcher relay node's multiaddr
|
||||
* Click on `UPDATE` to refresh the page and connect to the watcher's relay node; you should see the relay node's multiaddr in `Self Node Info` on the debug panel
|
||||
* Switch to the `GRAPH (PEERS)` tab to see peers connected to this browser node and the `GRAPH (NETWORK)` tab to see the whole MobyMask p2p network
|
||||
|
||||
Perform transactions:
|
||||
* An invitation is required to be able to perform transactions; ask an existing user of the app for an invite
|
||||
* In a browser, close the app if it's already open and then open the invite link
|
||||
* From the debug panel, confirm that the browser peer is connected to at least one other peer
|
||||
* Check the status for a phisher to be reported in the `Check Phisher Status` section on homepage
|
||||
* Select `Report Phisher` option in the `Pending reports` section, enter multiple phisher records and click on the `Submit batch to p2p network` button; this broadcasts signed invocations to peers on the network, including the watcher peer
|
||||
* Check the watcher container logs to see the message received:
|
||||
```bash
|
||||
docker logs $(docker ps -aq --filter name="mobymask-watcher-server")
|
||||
|
||||
# Expected output:
|
||||
|
||||
# .
|
||||
# .
|
||||
# 2023-04-20T04:42:01.072Z vulcanize:libp2p-utils [4:42:1] Received a message on mobymask P2P network from peer: 12D3KooWDKCke8hrjm4evwc9HzUzPZXeVTEQqmfLCkdNaXQ7efAZ
|
||||
# 2023-04-20T04:42:01.072Z vulcanize:libp2p-utils Signed invocations:
|
||||
# 2023-04-20T04:42:01.073Z vulcanize:libp2p-utils [
|
||||
# {
|
||||
# "signature": "0x18dc2f4092473cbcc4636eb922f6abf17675368363675779e67d2c14bb0a135f6029da12671a3367463d41720938c84bb3ceed727721c3bbc50d8739859412801c",
|
||||
# "invocations": {
|
||||
# "batch": [
|
||||
# {
|
||||
# "transaction": {
|
||||
# "to": "0x2B6AFbd4F479cE4101Df722cF4E05F941523EaD9",
|
||||
# "data": "0x6b6dc9de00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000c5457543a70686973686572310000000000000000000000000000000000000000",
|
||||
# "gasLimit": 500000
|
||||
# },
|
||||
# "authority": [
|
||||
# {
|
||||
# "signature": "0x0f91c765faaf851550ddd4345d1bc11eebbf29fde0306a8051f9d3c679c6d6856f66753cad8fcff25203a3e0528b3d7673371343f66a39424f6281c474eada431c",
|
||||
# "delegation": {
|
||||
# "delegate": "0x1B85a1485582C3389F62EB9F2C88f0C89bb1C1F4",
|
||||
# "authority": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
# "caveats": [
|
||||
# {
|
||||
# "enforcer": "0x2B6AFbd4F479cE4101Df722cF4E05F941523EaD9",
|
||||
# "terms": "0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
# ],
|
||||
# "replayProtection": {
|
||||
# "nonce": 1,
|
||||
# "queue": 64298938
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
# ]
|
||||
# 2023-04-20T04:42:01.087Z vulcanize:libp2p-utils method: claimIfPhisher, value: TWT:phisher1
|
||||
# 2023-04-20T04:42:01.087Z vulcanize:libp2p-utils ------------------------------------------
|
||||
# .
|
||||
# .
|
||||
```
|
||||
* Now, check the status for reported phishers again and confirm that they have been registered
|
||||
|
||||
## Clean up
|
||||
|
||||
Stop all services running in the background:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include watcher-mobymask-v2 down
|
||||
|
||||
# Expected output:
|
||||
|
||||
# [+] Running 6/6
|
||||
# ✔ Container mobymask_v2-peer-tests-1 Removed 10.5s
|
||||
# ✔ Container mobymask_v2-mobymask-watcher-server-1 Removed 10.8s
|
||||
# ✔ Container mobymask_v2-peer-ids-gen-1 Removed 0.0s
|
||||
# ✔ Container mobymask_v2-mobymask-1 Removed 0.0s
|
||||
# ✔ Container mobymask_v2-mobymask-watcher-db-1 Removed 0.6s
|
||||
# ✔ Network mobymask_v2_default Removed 0.5s
|
||||
```
|
||||
|
||||
Clear volumes created by this stack:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter "name=mobymask_v2"
|
||||
|
||||
# Expected output:
|
||||
|
||||
# mobymask_v2_mobymask_deployment
|
||||
# mobymask_v2_mobymask_watcher_db_data
|
||||
# mobymask_v2_peers_ids
|
||||
|
||||
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter "name=mobymask_v2")
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
* If you don't see any peer connections being formed in the debug panel on https://mobymask-lxdao-app.dev.vdb.to/, try clearing out the website's local storage and refreshing the page
|
||||
@@ -0,0 +1,162 @@
|
||||
# MobyMask Watcher P2P Network - Web App
|
||||
|
||||
Instructions to setup and deploy the MobyMask app locally, pointed to a watcher on the p2p network
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* Laconic Stack Orchestrator ([installation](/README.md#install))
|
||||
* Watcher GQL endpoint
|
||||
|
||||
## Setup
|
||||
|
||||
Build the container images:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 build-containers --include cerc/react-peer,cerc/mobymask-ui
|
||||
```
|
||||
|
||||
Check that the required images are created in the local image registry:
|
||||
|
||||
```bash
|
||||
docker image ls
|
||||
|
||||
# Expected output:
|
||||
|
||||
# REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
# cerc/react-peer local d66b144dbb53 4 days ago 868MB
|
||||
# cerc/mobymask-ui local e456bf9937ec 4 days ago 1.67GB
|
||||
# .
|
||||
# .
|
||||
```
|
||||
|
||||
## Deploy
|
||||
|
||||
### Configuration
|
||||
|
||||
Create an env file `mobymask-app.env`:
|
||||
|
||||
```bash
|
||||
touch mobymask-app.env
|
||||
```
|
||||
|
||||
Add the following contents to `mobymask-app.env`:
|
||||
|
||||
```bash
|
||||
# Watcher endpoint used by the app for GQL queries
|
||||
CERC_APP_WATCHER_URL="http://127.0.0.1:3001"
|
||||
|
||||
|
||||
# DO NOT CHANGE THESE VALUES
|
||||
CERC_DEPLOYED_CONTRACT="0x2B6AFbd4F479cE4101Df722cF4E05F941523EaD9"
|
||||
CERC_RELAY_NODES=["/dns4/relay1.dev.vdb.to/tcp/443/wss/p2p/12D3KooWAx83SM9GWVPc9v9fNzLzftRX6EaAFMjhYiFxRYqctcW1","/dns4/relay2.dev.vdb.to/tcp/443/wss/p2p/12D3KooWBycy6vHVEfUwwYRbPLBdb5gx9gtFSEMpErYPUjUkDNkm","/dns4/relay3.dev.vdb.to/tcp/443/wss/p2p/12D3KooWARcUJsiGCgiygiRVVK94U8BNSy8DFBbzAF3B6orrabwn"]
|
||||
```
|
||||
|
||||
Replace `CERC_APP_WATCHER_URL` with the watcher's endpoint (eg. `https://mobymask.example.com`)
|
||||
|
||||
### Deploy the stack
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mm_v2 --include mobymask-app --env-file mobymask-app.env up lxdao-mobymask-app
|
||||
|
||||
# Expected output (ignore the "The X variable is not set. Defaulting to a blank string." warnings):
|
||||
|
||||
# [+] Running 4/4
|
||||
# ✔ Network mm_v2_default Created 0.1s
|
||||
# ✔ Volume "mm_v2_peers_ids" Created 0.0s
|
||||
# ✔ Volume "mm_v2_mobymask_deployment" Created 0.0s
|
||||
# ✔ Container mm_v2-lxdao-mobymask-app-1 Started 1.1s
|
||||
```
|
||||
|
||||
This will run the `lxdao-mobymask-app` (at `http://localhost:3004`) pointed to `CERC_APP_WATCHER_URL` for GQL queries
|
||||
|
||||
To monitor the running container:
|
||||
|
||||
```bash
|
||||
# With status
|
||||
docker ps
|
||||
|
||||
# Expected output:
|
||||
|
||||
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
# f1369dbae1c9 cerc/mobymask-ui:local "docker-entrypoint.s…" 2 minutes ago Up 2 minutes (healthy) 127.0.0.1:3004->80/tcp mm_v2-lxdao-mobymask-app-1
|
||||
|
||||
# Check logs for a container
|
||||
docker logs -f mm_v2-lxdao-mobymask-app-1
|
||||
|
||||
# Expected output:
|
||||
|
||||
# .
|
||||
# .
|
||||
# .
|
||||
# Available on:
|
||||
# http://127.0.0.1:80
|
||||
# http://192.168.0.2:80
|
||||
# Hit CTRL-C to stop the server
|
||||
```
|
||||
|
||||
Note: For opening an invite link on this deployed app, replace the URL part before `/#` with `http://localhost:3004`
|
||||
For example: `http://localhost:3004/#/members?invitation=XYZ`
|
||||
|
||||
In order to host the app using a public domain, configure your website with SSL and `https` traffic reverse proxied to port `3004`.
|
||||
|
||||
For example, a Nginx configuration for domain `my-mobymask-app.example.com` would look something like:
|
||||
|
||||
```bash
|
||||
server {
|
||||
server_name my-mobymask-app.example.com;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:3004;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
listen [::]:443 ssl;
|
||||
listen 443 ssl;
|
||||
ssl_certificate /etc/letsencrypt/live/my-mobymask-app.example.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/my-mobymask-app.example.com/privkey.pem;
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||
}
|
||||
|
||||
server {
|
||||
if ($host = my-mobymask-app.example.com) {
|
||||
return 301 https://$host$request_uri;
|
||||
} # managed by Certbot
|
||||
|
||||
server_name my-mobymask-app.example.com;
|
||||
listen 80;
|
||||
return 404; # managed by Certbot
|
||||
}
|
||||
```
|
||||
|
||||
## Clean up
|
||||
|
||||
Stop all services running in the background:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mm_v2 --include mobymask-app down
|
||||
|
||||
# Expected output:
|
||||
|
||||
# [+] Running 2/2
|
||||
# ✔ Container mm_v2-lxdao-mobymask-app-1 Removed 10.6s
|
||||
# ✔ Network mm_v2_default Removed 0.5s
|
||||
```
|
||||
|
||||
Clear volumes created by this stack:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter "name=mm_v2"
|
||||
|
||||
# Expected output:
|
||||
|
||||
# mm_v2_mobymask_deployment
|
||||
# mm_v2_peers_ids
|
||||
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter "name=mm_v2")
|
||||
```
|
||||
@@ -0,0 +1,109 @@
|
||||
# Web Apps
|
||||
|
||||
Instructions to setup and deploy MobyMask and Peer Test web apps
|
||||
|
||||
## Setup
|
||||
|
||||
Prerequisite: Watcher with GQL and relay node endpoints
|
||||
|
||||
Clone required repositories:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 setup-repositories --include github.com/cerc-io/mobymask-ui
|
||||
```
|
||||
|
||||
Build the container images:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 build-containers --include cerc/react-peer,cerc/mobymask-ui
|
||||
```
|
||||
|
||||
This should create the required docker images in the local image registry
|
||||
|
||||
## Deploy
|
||||
|
||||
### Configuration
|
||||
|
||||
Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v2/mobymask-params.env)):
|
||||
|
||||
```bash
|
||||
# Set of relay nodes to be used by the web-app
|
||||
# (use double quotes " for strings, avoid space after commas)
|
||||
# Eg. CERC_RELAY_NODES=["/dns4/example.com/tcp/443/wss/p2p/12D3KooWGHmDDCc93XUWL16FMcTPCGu2zFaMkf67k8HZ4gdQbRDr"]
|
||||
CERC_RELAY_NODES=[]
|
||||
|
||||
# Set of multiaddrs to be avoided while dialling
|
||||
CERC_DENY_MULTIADDRS=[]
|
||||
|
||||
# Also add if running MobyMask app:
|
||||
|
||||
# Watcher endpoint used by the app for GQL queries
|
||||
CERC_APP_WATCHER_URL="http://127.0.0.1:3001"
|
||||
|
||||
# Set deployed MobyMask contract address to be used in MobyMask app's config
|
||||
CERC_DEPLOYED_CONTRACT=
|
||||
|
||||
# L2 Chain ID used by mobymask web-app for L2 txs
|
||||
CERC_CHAIN_ID=42069
|
||||
|
||||
# (Optional) Type of pubsub to be used ("floodsub" | "gossipsub")
|
||||
CERC_PUBSUB=""
|
||||
```
|
||||
|
||||
* NOTE: If watcher is running on the host machine, use `host.docker.internal` as the hostname to access the host port
|
||||
|
||||
### Deploy the stack
|
||||
|
||||
For running mobymask-app
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include mobymask-app --env-file <PATH_TO_ENV_FILE> up
|
||||
|
||||
# Runs mobymask-app on host port 3002 and lxdao-mobymask-app on host port 3004
|
||||
```
|
||||
|
||||
For running peer-test-app
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include peer-test-app --env-file <PATH_TO_ENV_FILE> up
|
||||
|
||||
# Runs on host port 3003
|
||||
```
|
||||
|
||||
To list down and monitor the running containers:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include [mobymask-app | peer-test-app] ps
|
||||
|
||||
# With status
|
||||
docker ps -a
|
||||
|
||||
# Check logs for a container
|
||||
docker logs -f <CONTAINER_ID>
|
||||
```
|
||||
|
||||
## Demo
|
||||
|
||||
Follow the [demo](./demo.md) to try out the MobyMask app with L2 chain
|
||||
|
||||
## Clean up
|
||||
|
||||
Stop all services running in the background:
|
||||
|
||||
For mobymask-app
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include mobymask-app down
|
||||
```
|
||||
|
||||
For peer-test-app
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --cluster mobymask_v2 --include peer-test-app down
|
||||
```
|
||||
|
||||
Clear volumes created by this stack:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter "name=mobymask_v2"
|
||||
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter "name=mobymask_v2")
|
||||
```
|
||||
Reference in New Issue
Block a user