Set optimism geth endpoint from env file

This commit is contained in:
nabarun 2023-04-04 13:11:09 +05:30
parent 9ffa9bb5a9
commit 64c08a529e
8 changed files with 46 additions and 18 deletions

View File

@ -25,22 +25,22 @@ services:
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
# TODO: Configure env file for private key
env_file:
- ../config/watcher-mobymask-v2/optimism-params.env
environment:
- ENV=PROD
command: ["sh", "./deploy-and-generate-invite.sh"]
command: |-
./wait-for-it.sh -h $${L2_GETH_HOST} -p $${L2_GETH_PORT} -s \
./wait-for-it.sh -h $${L2_NODE_HOST} -p $${L2_NODE_PORT} -s \
sh ./deploy-and-generate-invite.sh
volumes:
# TODO: add a script to set RPC endpoint from env
# add manually if running seperately
# TODO: Move out to config dir
- ../config/fixturenet-optimism/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
- ../test/fixturenet_geth_accounts:/geth-accounts:ro
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "3330"]
interval: 20s
@ -49,7 +49,6 @@ services:
start_period: 10s
mobymask-watcher-server:
# TODO: pass optimism RPC endpoint
restart: unless-stopped
depends_on:
mobymask-watcher-db:
@ -57,17 +56,18 @@ services:
mobymask:
condition: service_healthy
image: cerc/watcher-mobymask-v2:local
# TODO: Configure env file for private key
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
- ../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
- moby_data_server:/server
- fixturenet_geth_accounts:/geth-accounts:ro
- ../test/fixturenet_geth_accounts:/geth-accounts:ro
ports:
- "0.0.0.0:3001:3001"
- "0.0.0.0:9001:9001"

View File

@ -6,6 +6,9 @@ set -e
L1_PRIV_KEY=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3)
# Set the private key
jq --arg privateKey "$L1_PRIV_KEY" '.privateKey = ($privateKey)' secrets-template.json > secrets.json
jq --arg privateKey "$L1_PRIV_KEY" '.privateKey = $privateKey' secrets-template.json > secrets.json
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
npm start

View File

@ -0,0 +1,7 @@
# Change if pointing to an external optimism geth endpoint
L2_GETH_HOST="op-geth"
L2_GETH_PORT=8545
L2_NODE_HOST="op-node"
L2_NODE_PORT=8547
PRIVATE_KEY_DEPLOYER=
PRIVATE_KEY_PEER=

View File

@ -1,5 +1,5 @@
{
"rpcUrl": "http://op-geth:8545",
"rpcUrl": "",
"privateKey": "",
"baseURI": "http://127.0.0.1:3002/#"
}

View File

@ -7,5 +7,8 @@ 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
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

View File

@ -58,7 +58,7 @@
[upstream]
[upstream.ethServer]
gqlApiEndpoint = "http://ipld-eth-server:8083/graphql"
gqlApiEndpoint = "REPLACE_WITH_L2_GETH_URL"
rpcProviderEndpoint = "http://op-geth:8545"
blockDelayInMilliSecs = 60000

View File

@ -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

View File

@ -8,6 +8,9 @@ Clone required repositories:
```bash
laconic-so --stack mobymask-v2 setup-repositories
# Include repositories required for MobyMask if running optimism separately
laconic-so --stack fixturenet-optimism setup-repositories --include cerc-io/MobyMask,cerc-io/watcher-ts,cerc-io/react-peer,cerc-io/mobymask-ui
```
NOTE: If repositories already exist and are checked out to different versions, `setup-repositories` command will throw an error.
@ -41,16 +44,28 @@ Build the container images:
```bash
laconic-so --stack mobymask-v2 build-containers
# Only build containers required for MobyMask if running optimism separately
laconic-so --stack fixturenet-optimism 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 the stack:
* (Optional) 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 containers:
```bash
laconic-so --stack mobymask-v2 deploy-system up
# Only start watcher-mobymask-v2 pod if running optimism separately
laconic-so --stack mobymask-v2 deploy up --include watcher-mobymask-v2
```
* List and check the health status of all the containers using `docker ps` and wait for them to be `healthy`