Handle restarts in mobymask-v2 stack (#286)

* Verify existing contract deployment

* Update mobymask-v2 demo instructions

Former-commit-id: 59fe9aae59
This commit is contained in:
prathamesh0 2023-04-05 17:52:12 +05:30 committed by GitHub
parent 63fbaa7ae3
commit 72737bfa29
6 changed files with 47 additions and 37 deletions

View File

@ -39,7 +39,7 @@ services:
- ../config/wait-for-it.sh:/app/packages/server/wait-for-it.sh - ../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 - ../config/watcher-mobymask-v2/secrets-template.json:/app/packages/server/secrets-template.json
- ../config/watcher-mobymask-v2/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh - ../config/watcher-mobymask-v2/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh
- moby_data_server:/app/packages/server - mobymask_deployment:/app/packages/server
- fixturenet_geth_accounts:/geth-accounts:ro - fixturenet_geth_accounts:/geth-accounts:ro
extra_hosts: extra_hosts:
- "host.docker.internal:host-gateway" - "host.docker.internal:host-gateway"
@ -54,14 +54,14 @@ services:
image: cerc/watcher-mobymask-v2:local image: cerc/watcher-mobymask-v2:local
env_file: env_file:
- ../config/watcher-mobymask-v2/optimism-params.env - ../config/watcher-mobymask-v2/optimism-params.env
command: ["sh", "server-start.sh"] command: ["sh", "start-server.sh"]
volumes: volumes:
- ../config/watcher-mobymask-v2/watcher-config-template.toml:/app/packages/mobymask-v2-watcher/environments/watcher-config-template.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/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/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/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 - ../config/watcher-mobymask-v2/start-server.sh:/app/packages/mobymask-v2-watcher/start-server.sh
- moby_data_server:/server - mobymask_deployment:/server
- fixturenet_geth_accounts:/geth-accounts:ro - fixturenet_geth_accounts:/geth-accounts:ro
ports: ports:
- "0.0.0.0:3001:3001" - "0.0.0.0:3001:3001"
@ -89,7 +89,7 @@ services:
- ../config/watcher-mobymask-v2/mobymask-app.env:/app/.env - ../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-config.json:/app/src/mobymask-app-config.json
- ../config/watcher-mobymask-v2/mobymask-app-start.sh:/app/mobymask-app-start.sh - ../config/watcher-mobymask-v2/mobymask-app-start.sh:/app/mobymask-app-start.sh
- moby_data_server:/server - mobymask_deployment:/server
ports: ports:
- "0.0.0.0:3002:3000" - "0.0.0.0:3002:3000"
healthcheck: healthcheck:
@ -120,5 +120,5 @@ services:
volumes: volumes:
mobymask_watcher_db_data: mobymask_watcher_db_data:
moby_data_server: mobymask_deployment:
fixturenet_geth_accounts: fixturenet_geth_accounts:

View File

@ -4,7 +4,6 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
if [ -f /geth-accounts/accounts.csv ]; then if [ -f /geth-accounts/accounts.csv ]; then
echo "Using L1 private key from the mounted volume" echo "Using L1 private key from the mounted volume"
# Read the private key of L1 account to deploy contract # Read the private key of L1 account to deploy contract
@ -16,14 +15,34 @@ fi
# Set the private key # Set the private key
jq --arg privateKey "$PRIVATE_KEY_DEPLOYER" '.privateKey = $privateKey' secrets-template.json > secrets.json jq --arg privateKey "$PRIVATE_KEY_DEPLOYER" '.privateKey = $privateKey' secrets-template.json > secrets.json
# Set the RPC URL
export L2_GETH_URL="http://${L2_GETH_HOST}:${L2_GETH_PORT}" export L2_GETH_URL="http://${L2_GETH_HOST}:${L2_GETH_PORT}"
jq --arg rpcUrl "$L2_GETH_URL" '.rpcUrl = $rpcUrl' secrets.json > secrets_updated.json && mv secrets_updated.json secrets.json jq --arg rpcUrl "$L2_GETH_URL" '.rpcUrl = $rpcUrl' secrets.json > secrets_updated.json && mv secrets_updated.json secrets.json
cd ../hardhat
export RPC_URL="${L2_GETH_URL}" export RPC_URL="${L2_GETH_URL}"
# Check and exit if a deployment already exists (on restarts)
if [ -f ./config.json ]; then
echo "config.json already exists, checking the contract deployment"
# Read JSON file
DEPLOYMENT_DETAILS=$(cat config.json)
CONTRACT_ADDRESS=$(echo "$DEPLOYMENT_DETAILS" | jq -r '.address')
cd ../hardhat
if yarn verifyDeployment --network optimism --contract "${CONTRACT_ADDRESS}"; then
echo "Deployment verfication successful"
cd ../server
else
echo "Deployment verfication failed, please clear MobyMask deployment volume before starting"
exit 1
fi
fi
# Wait until balance for deployer account is reflected
cd ../hardhat
while true; do while true; do
ACCOUNT_BALANCE=$(yarn hardhat --network optimism balance $PRIVATE_KEY_DEPLOYER | grep ETH) ACCOUNT_BALANCE=$(yarn balance --network optimism $PRIVATE_KEY_DEPLOYER | grep ETH)
if [ "$ACCOUNT_BALANCE" != "0.0 ETH" ]; then if [ "$ACCOUNT_BALANCE" != "0.0 ETH" ]; then
echo "Account balance updated: $ACCOUNT_BALANCE" echo "Account balance updated: $ACCOUNT_BALANCE"

View File

@ -116,16 +116,12 @@ Stop all the services running in background run:
laconic-so --stack mobymask-v2 deploy-system down laconic-so --stack mobymask-v2 deploy-system down
``` ```
Clear volumes: Clear volumes created by this stack:
* List all relevant volumes: ```bash
# List all relevant volumes
docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*mobymask_deployment|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data"
```bash # Remove all the listed volumes
docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data" docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*mobymask_deployment|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
``` ```
* Remove all the listed volumes:
```bash
docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
```

View File

@ -3,7 +3,7 @@
* Get the root invite link URL for mobymask-app: * Get the root invite link URL for mobymask-app:
```bash ```bash
laconic-so --stack mobymask-v2 deploy-system logs mobymask docker logs -f $(docker ps -aq --filter name="mobymask-1")
``` ```
The invite link is seen at the end of the logs. Example log: The invite link is seen at the end of the logs. Example log:
@ -29,18 +29,10 @@
* In the `MESSAGES` tab of other browsers, a message can be seen with the signed invocations. * 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. * In a terminal, check logs from the watcher peer container:
* Get the container id:
```bash ```bash
laconic-so --stack mobymask-v2 deploy-system ps | grep mobymask-watcher-server docker logs -f $(docker ps -aq --filter name="mobymask-watcher-server")
```
* Check logs:
```bash
docker logs -f <CONTAINER_ID>
``` ```
* It should have received the message, sent transaction to L2 chain and received a transaction receipt for an `invoke` message with block details. * It should have received the message, sent transaction to L2 chain and received a transaction receipt for an `invoke` message with block details.
@ -74,7 +66,7 @@
* Get the deployed contract address: * Get the deployed contract address:
```bash ```bash
laconic-so --stack mobymask-v2 deploy-system exec mobymask-app "cat src/config.json" docker exec -it $(docker ps -aq --filter name="mobymask-app") cat src/config.json
``` ```
The value of `address` field is the deployed contract address The value of `address` field is the deployed contract address

View File

@ -59,8 +59,10 @@ To list down and monitor the running containers:
```bash ```bash
laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 ps laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 ps
# With status # With status
docker ps docker ps
# Check logs for a container # Check logs for a container
docker logs -f <CONTAINER_ID> docker logs -f <CONTAINER_ID>
``` ```
@ -72,14 +74,15 @@ See [Tests](./README.md#tests) and [Demo](./README.md#demo) to interact with sta
Stop all services running in the background: Stop all services running in the background:
```bash ```bash
laconic-so --stack mobymask-v2 deploy down --include watcher-mobymask-v2 laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 down
``` ```
Clear volumes created by this stack: Clear volumes created by this stack:
```bash ```bash
# List all relevant volumes # List all relevant volumes
docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts" docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*mobymask_deployment|.*fixturenet_geth_accounts"
# Remove all the listed volumes # Remove all the listed volumes
docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts") docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*mobymask_deployment|.*fixturenet_geth_accounts")
``` ```