Add ability to run mobymask-v2 stack with external optimism endpoint (#279)
* Set optimism geth endpoint from env file * Set L1 account private keys from env * Only deploy contract and generate invite in mobymask container * Add readme for running mobymask v2 stack independently * Modify mobymask container to stop running server and update readmes * Check deployer account balance before deploying contract * Fix for checking account balance before deploying * Update readme description * Update MobyMask repo tag in readme Former-commit-id: 94e38ceabaa89a3ec54e25f4a03cf253d5fae5f9
This commit is contained in:
parent
464ef89a01
commit
63fbaa7ae3
@ -55,7 +55,7 @@ services:
|
||||
entrypoint: "sh"
|
||||
command: "/run-op-geth.sh"
|
||||
ports:
|
||||
- "8545"
|
||||
- "0.0.0.0:8545:8545"
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "localhost:8545"]
|
||||
interval: 30s
|
||||
@ -77,7 +77,7 @@ services:
|
||||
- l2_accounts:/l2-accounts:ro
|
||||
command: ["sh", "/app/run-op-node.sh"]
|
||||
ports:
|
||||
- "8547"
|
||||
- "0.0.0.0:8547:8547"
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "localhost:8547"]
|
||||
interval: 30s
|
||||
|
@ -1,25 +0,0 @@
|
||||
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
|
@ -22,45 +22,40 @@ services:
|
||||
start_period: 10s
|
||||
|
||||
mobymask:
|
||||
restart: unless-stopped
|
||||
image: cerc/mobymask:local
|
||||
working_dir: /app/packages/server
|
||||
depends_on:
|
||||
op-node:
|
||||
condition: service_healthy
|
||||
op-geth:
|
||||
condition: service_healthy
|
||||
# TODO: Configure env file for ETH RPC URL & private key
|
||||
env_file:
|
||||
- ../config/watcher-mobymask-v2/optimism-params.env
|
||||
environment:
|
||||
- ENV=PROD
|
||||
command: ["sh", "./deploy-and-generate-invite.sh"]
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
./wait-for-it.sh -h $${L2_GETH_HOST} -p $${L2_GETH_PORT} -s -t 0 && \
|
||||
./wait-for-it.sh -h $${L2_NODE_HOST} -p $${L2_NODE_PORT} -s -t 0 && \
|
||||
./deploy-and-generate-invite.sh
|
||||
volumes:
|
||||
# TODO: add a script to set RPC endpoint from env
|
||||
# add manually if running seperately
|
||||
- ../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/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh
|
||||
- moby_data_server:/app/packages/server
|
||||
- fixturenet_geth_accounts:/geth-accounts:ro
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-v", "localhost", "3330"]
|
||||
interval: 20s
|
||||
timeout: 5s
|
||||
retries: 15
|
||||
start_period: 10s
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
mobymask-watcher-server:
|
||||
# TODO: pass optimism RPC endpoint
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
mobymask-watcher-db:
|
||||
condition: service_healthy
|
||||
mobymask:
|
||||
condition: service_healthy
|
||||
condition: service_completed_successfully
|
||||
image: cerc/watcher-mobymask-v2:local
|
||||
env_file:
|
||||
- ../config/watcher-mobymask-v2/optimism-params.env
|
||||
command: ["sh", "server-start.sh"]
|
||||
volumes:
|
||||
# TODO: add a script to set RPC endpoint from env
|
||||
# add manually if running seperately
|
||||
- ../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/relay-id.json:/app/packages/mobymask-v2-watcher/relay-id.json
|
||||
@ -78,6 +73,8 @@ services:
|
||||
timeout: 5s
|
||||
retries: 15
|
||||
start_period: 5s
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
# TODO: Move to a separate pod
|
||||
mobymask-app:
|
||||
@ -85,7 +82,7 @@ services:
|
||||
mobymask-watcher-server:
|
||||
condition: service_healthy
|
||||
mobymask:
|
||||
condition: service_healthy
|
||||
condition: service_completed_successfully
|
||||
image: cerc/mobymask-ui:local
|
||||
command: ["sh", "mobymask-app-start.sh"]
|
||||
volumes:
|
||||
|
@ -1,8 +1,13 @@
|
||||
# Change if pointing to an external L1 endpoint
|
||||
L1_RPC="http://fixturenet-eth-geth-1:8545"
|
||||
|
||||
# L1 endpoint
|
||||
L1_CHAIN_ID=1212
|
||||
L1_RPC="http://fixturenet-eth-geth-1:8545"
|
||||
L1_HOST="fixturenet-eth-geth-1"
|
||||
L1_PORT=8545
|
||||
|
||||
# Credentials for accounts on L1 to send balance to Optimism Proxy contract from
|
||||
# (enables them to do transactions on L2)
|
||||
L1_ADDRESS=
|
||||
L1_PRIV_KEY=
|
||||
L1_ADDRESS_2=
|
||||
|
38
app/data/config/watcher-mobymask-v2/deploy-and-generate-invite.sh
Normal file → Executable file
38
app/data/config/watcher-mobymask-v2/deploy-and-generate-invite.sh
Normal file → Executable file
@ -1,11 +1,39 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# Read the private key of L1 account to deploy contract
|
||||
# TODO: Take from env if /geth-accounts volume doesn't exist to allow using separately running L1
|
||||
L1_PRIV_KEY=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3)
|
||||
|
||||
if [ -f /geth-accounts/accounts.csv ]; then
|
||||
echo "Using L1 private key from the mounted volume"
|
||||
# Read the private key of L1 account to deploy contract
|
||||
PRIVATE_KEY_DEPLOYER=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3)
|
||||
else
|
||||
echo "Using PRIVATE_KEY_DEPLOYER from env"
|
||||
fi
|
||||
|
||||
# Set the private key
|
||||
jq --arg privateKey "$L1_PRIV_KEY" '.privateKey = ($privateKey)' secrets-template.json > secrets.json
|
||||
jq --arg privateKey "$PRIVATE_KEY_DEPLOYER" '.privateKey = $privateKey' secrets-template.json > secrets.json
|
||||
|
||||
npm start
|
||||
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
|
||||
|
||||
cd ../hardhat
|
||||
export RPC_URL="${L2_GETH_URL}"
|
||||
|
||||
while true; do
|
||||
ACCOUNT_BALANCE=$(yarn hardhat --network optimism balance $PRIVATE_KEY_DEPLOYER | grep ETH)
|
||||
|
||||
if [ "$ACCOUNT_BALANCE" != "0.0 ETH" ]; then
|
||||
echo "Account balance updated: $ACCOUNT_BALANCE"
|
||||
break # exit the loop
|
||||
fi
|
||||
|
||||
echo "Account balance not updated: $ACCOUNT_BALANCE"
|
||||
echo "Checking after 2 seconds"
|
||||
sleep 2
|
||||
done
|
||||
|
||||
cd ../server
|
||||
npm run deployAndGenerateInvite
|
||||
|
@ -1,5 +1,8 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
12
app/data/config/watcher-mobymask-v2/optimism-params.env
Normal file
12
app/data/config/watcher-mobymask-v2/optimism-params.env
Normal file
@ -0,0 +1,12 @@
|
||||
# Change if pointing to an external optimism geth endpoint
|
||||
|
||||
# L2 endpoints
|
||||
# TODO: Add another env for complete URL to handle https
|
||||
L2_GETH_HOST="op-geth"
|
||||
L2_GETH_PORT=8545
|
||||
L2_NODE_HOST="op-node"
|
||||
L2_NODE_PORT=8547
|
||||
|
||||
# Credentials for accounts to perform txs on L2
|
||||
PRIVATE_KEY_DEPLOYER=
|
||||
PRIVATE_KEY_PEER=
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"rpcUrl": "http://op-geth:8545",
|
||||
"rpcUrl": "",
|
||||
"privateKey": "",
|
||||
"baseURI": "http://127.0.0.1:3002/#"
|
||||
}
|
||||
|
@ -1,11 +1,25 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
# Assign deployed contract address from server config
|
||||
CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"')
|
||||
L1_PRIV_KEY_2=$(awk -F, 'NR==2{print $NF}' /geth-accounts/accounts.csv)
|
||||
|
||||
sed "s/REPLACE_WITH_PRIVATE_KEY/${L1_PRIV_KEY_2}/" environments/watcher-config-template.toml > environments/local.toml
|
||||
if [ -f /geth-accounts/accounts.csv ]; then
|
||||
echo "Using L1 private key from the mounted volume"
|
||||
# Read the private key of L1 account for sending txs from peer
|
||||
PRIVATE_KEY_PEER=$(awk -F, 'NR==2{print $NF}' /geth-accounts/accounts.csv)
|
||||
else
|
||||
echo "Using PRIVATE_KEY_PEER from env"
|
||||
fi
|
||||
|
||||
sed "s/REPLACE_WITH_PRIVATE_KEY/${PRIVATE_KEY_PEER}/" environments/watcher-config-template.toml > environments/local.toml
|
||||
sed -i "s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/" environments/local.toml
|
||||
|
||||
export L2_GETH_URL="http://${L2_GETH_HOST}:${L2_GETH_PORT}"
|
||||
sed -i 's|REPLACE_WITH_L2_GETH_URL|'"${L2_GETH_URL}"'|' environments/local.toml
|
||||
|
||||
echo 'yarn server'
|
||||
yarn server
|
||||
|
@ -59,7 +59,7 @@
|
||||
[upstream]
|
||||
[upstream.ethServer]
|
||||
gqlApiEndpoint = "http://ipld-eth-server:8083/graphql"
|
||||
rpcProviderEndpoint = "http://op-geth:8545"
|
||||
rpcProviderEndpoint = "REPLACE_WITH_L2_GETH_URL"
|
||||
blockDelayInMilliSecs = 60000
|
||||
|
||||
[upstream.cache]
|
||||
|
@ -1,6 +1,6 @@
|
||||
FROM node:16.17.1-alpine3.16
|
||||
|
||||
RUN apk --update --no-cache add python3 alpine-sdk jq
|
||||
RUN apk --update --no-cache add python3 alpine-sdk jq bash
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
@ -15,7 +15,8 @@ watcher-erc20
|
||||
watcher-erc721
|
||||
watcher-uniswap-v3
|
||||
watcher-mobymask-v2
|
||||
mobymask-laconicd
|
||||
mobymask-app
|
||||
peer-test-app
|
||||
test
|
||||
eth-probe
|
||||
keycloak
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Instructions to setup and deploy an end-to-end L1+L2 stack with [fixturenet-eth](../fixturenet-eth/) (L1) and [Optimism](https://stack.optimism.io) (L2)
|
||||
|
||||
We support running just the L2 part of stack, given an external L1 endpoint. Follow [L2-ONLY](./L2-ONLY.md) for the same.
|
||||
We support running just the L2 part of stack, given an external L1 endpoint. Follow [l2-only](./l2-only.md) for the same.
|
||||
|
||||
## Setup
|
||||
|
||||
@ -74,10 +74,10 @@ Clear volumes created by this stack:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter name=laconic*
|
||||
docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data"
|
||||
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter name=laconic*)
|
||||
docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
@ -55,7 +55,7 @@ The `fixturenet-optimism-contracts` service may take a while (`~15 mins`) to com
|
||||
To list down and monitor the running containers:
|
||||
|
||||
```bash
|
||||
laconic-so --stack fixturenet-optimism deploy ps
|
||||
laconic-so --stack fixturenet-optimism deploy --include fixturenet-optimism ps
|
||||
|
||||
# With status
|
||||
docker ps
|
||||
@ -76,10 +76,10 @@ Clear volumes created by this stack:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter name=laconic*
|
||||
docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data"
|
||||
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter name=laconic*)
|
||||
docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts|.*l1_deployment|.*l2_accounts|.*l2_config|.*l2_geth_data")
|
||||
```
|
||||
|
||||
## Troubleshooting
|
@ -1,6 +1,9 @@
|
||||
# MobyMask v2 watcher
|
||||
|
||||
Instructions to deploy MobyMask v2 watcher stack using [laconic-stack-orchestrator](/README.md#install)
|
||||
Instructions to setup and deploy an end-to-end MobyMask v2 stack ([L1](../fixturenet-eth/) + [L2](../fixturenet-optimism/) chains + watcher) 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.
|
||||
|
||||
## Setup
|
||||
|
||||
@ -30,7 +33,7 @@ git checkout laconic
|
||||
|
||||
# MobyMask
|
||||
cd ~/cerc/MobyMask
|
||||
git checkout v0.1.1
|
||||
git checkout v0.1.2
|
||||
|
||||
# Optimism
|
||||
cd ~/cerc/optimism
|
||||
@ -68,19 +71,9 @@ Deploy the stack:
|
||||
Find the watcher container's id and export it for later use:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy-system ps | grep "mobymask-watcher-server"
|
||||
|
||||
export CONTAINER_ID=<CONTAINER_ID>
|
||||
export CONTAINER_ID=$(docker ps -q --filter "name=mobymask-watcher-server")
|
||||
```
|
||||
|
||||
Example output:
|
||||
|
||||
```
|
||||
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 `5d3aae4b22039fcd1c9b18feeb91318ede1100581e75bb5ac54f9e436066b02c`
|
||||
|
||||
Run the peer tests:
|
||||
|
||||
```bash
|
||||
@ -128,11 +121,11 @@ Clear volumes:
|
||||
* List all relevant volumes:
|
||||
|
||||
```bash
|
||||
docker volume ls -q --filter name=laconic*
|
||||
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"
|
||||
```
|
||||
|
||||
* Remove all the listed volumes:
|
||||
|
||||
```bash
|
||||
docker volume rm $(docker volume ls -q --filter name=laconic*)
|
||||
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")
|
||||
```
|
||||
|
85
app/data/stacks/mobymask-v2/mobymask-only.md
Normal file
85
app/data/stacks/mobymask-v2/mobymask-only.md
Normal file
@ -0,0 +1,85 @@
|
||||
# MobyMask v2 watcher
|
||||
|
||||
Instructions to setup and deploy MobyMask v2 watcher independently
|
||||
|
||||
## Setup
|
||||
|
||||
Prerequisite: An L2 Optimism RPC endpoint
|
||||
|
||||
Clone required repositories:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/MobyMask,cerc-io/watcher-ts,cerc-io/react-peer,cerc-io/mobymask-ui
|
||||
```
|
||||
|
||||
Checkout to the required versions and branches in repos:
|
||||
|
||||
```bash
|
||||
```bash
|
||||
# watcher-ts
|
||||
cd ~/cerc/watcher-ts
|
||||
git checkout v0.2.34
|
||||
|
||||
# react-peer
|
||||
cd ~/cerc/react-peer
|
||||
git checkout v0.2.31
|
||||
|
||||
# mobymask-ui
|
||||
cd ~/cerc/mobymask-ui
|
||||
git checkout laconic
|
||||
|
||||
# MobyMask
|
||||
cd ~/cerc/MobyMask
|
||||
git checkout v0.1.2
|
||||
```
|
||||
|
||||
Build the container images:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 build-containers --include cerc/watcher-mobymask-v2,cerc/react-peer,cerc/mobymask-ui,cerc/mobymask
|
||||
```
|
||||
|
||||
This should create the required docker images in the local image registry
|
||||
|
||||
## Deploy
|
||||
|
||||
Update the [optimism-params.env](../../config/watcher-mobymask-v2/optimism-params.env) file with Optimism endpoints and other params if running Optimism separately
|
||||
|
||||
* NOTE:
|
||||
* Stack Orchestrator needs to be run in [`dev`](/docs/CONTRIBUTING.md#install-developer-mode) mode to be able to edit the env file
|
||||
* 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 --include watcher-mobymask-v2 up
|
||||
```
|
||||
|
||||
To list down and monitor the running containers:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 ps
|
||||
# With status
|
||||
docker ps
|
||||
# Check logs for a container
|
||||
docker logs -f <CONTAINER_ID>
|
||||
```
|
||||
|
||||
See [Tests](./README.md#tests) and [Demo](./README.md#demo) to interact with stack
|
||||
|
||||
## Clean up
|
||||
|
||||
Stop all services running in the background:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 deploy down --include watcher-mobymask-v2
|
||||
```
|
||||
|
||||
Clear volumes created by this stack:
|
||||
|
||||
```bash
|
||||
# List all relevant volumes
|
||||
docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts"
|
||||
# Remove all the listed volumes
|
||||
docker volume rm $(docker volume ls -q --filter "name=.*mobymask_watcher_db_data|.*moby_data_server|.*fixturenet_geth_accounts")
|
||||
```
|
Loading…
Reference in New Issue
Block a user