Use fixturenet-optimism stack for mobymask-v2-watcher

This commit is contained in:
nabarun 2023-04-03 15:37:45 +05:30
parent 2d745075e2
commit d97c4bf14d
12 changed files with 74 additions and 34 deletions

View File

@ -25,7 +25,7 @@ services:
- ../config/fixturenet-eth/fixturenet-eth.env
image: cerc/fixturenet-eth-geth:local
volumes:
- fixturenet-geth-accounts:/opt/testnet/build/el
- fixturenet_geth_accounts:/opt/testnet/build/el
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "8545"]
interval: 30s
@ -111,4 +111,4 @@ services:
condition: service_healthy
volumes:
fixturenet-geth-accounts:
fixturenet_geth_accounts:

View File

@ -18,9 +18,9 @@ services:
- ../config/fixturenet-optimism/optimism-contracts/send-balance.ts:/app/packages/contracts-bedrock/tasks/send-balance.ts
- ../config/fixturenet-optimism/optimism-contracts/update-config.js:/app/packages/contracts-bedrock/update-config.js
- ../config/fixturenet-optimism/optimism-contracts/run.sh:/app/packages/contracts-bedrock/run.sh
- fixturenet-geth-accounts:/geth-accounts:ro
- l2-accounts:/l2-accounts
- l1-deployment:/app/packages/contracts-bedrock
- fixturenet_geth_accounts:/geth-accounts:ro
- l2_accounts:/l2-accounts
- l1_deployment:/app/packages/contracts-bedrock
op-node-l2-config-gen:
image: cerc/optimism-op-node:local
@ -31,7 +31,7 @@ services:
L1_RPC: "http://fixturenet-eth-geth-1:8545"
volumes:
- ../config/fixturenet-optimism/generate-l2-config.sh:/app/generate-l2-config.sh
- l1-deployment:/contracts-bedrock:ro
- l1_deployment:/contracts-bedrock:ro
- op_node_data:/app
command: ["sh", "/app/generate-l2-config.sh"]
@ -43,7 +43,7 @@ services:
volumes:
- ../config/fixturenet-optimism/run-op-geth.sh:/run-op-geth.sh
- op_node_data:/op-node:ro
- l2-accounts:/l2-accounts:ro
- l2_accounts:/l2-accounts:ro
entrypoint: "sh"
command: "/run-op-geth.sh"
ports:
@ -64,8 +64,8 @@ services:
image: cerc/optimism-op-node:local
volumes:
- ../config/fixturenet-optimism/run-op-node.sh:/app/run-op-node.sh
- op_node_data:/app:ro
- l2-accounts:/l2-accounts:ro
- op_node_data:/op-node-data:ro
- l2_accounts:/l2-accounts:ro
command: ["sh", "/app/run-op-node.sh"]
ports:
- "8547"
@ -87,11 +87,11 @@ services:
image: cerc/optimism-op-batcher:local
volumes:
- ../config/fixturenet-optimism/run-op-batcher.sh:/run-op-batcher.sh
- l2-accounts:/l2-accounts:ro
- l2_accounts:/l2-accounts:ro
entrypoint: "sh"
command: "/run-op-batcher.sh"
volumes:
op_node_data:
l2-accounts:
l1-deployment:
l2_accounts:
l1_deployment:

View File

@ -25,13 +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
environment:
- ENV=PROD
command: ["sh", "-c", "npm start"]
command: ["sh", "./deploy-invite.sh"]
volumes:
# TODO: add a script to set rpc endpoint from env
# add manually if running seperately
- ../config/watcher-mobymask-v2/secrets.json:/app/packages/server/secrets.json
- ../config/watcher-mobymask-v2/deploy-invite.sh:/app/packages/server/deploy-invite.sh
- moby_data_server:/app/packages/server
- fixturenet_geth_accounts:/geth-accounts:ro
healthcheck:
test: ["CMD", "nc", "-v", "localhost", "3330"]
interval: 20s
@ -40,6 +49,7 @@ services:
start_period: 10s
mobymask-watcher-server:
# TODO: pass optimism rpc endpoint
restart: unless-stopped
depends_on:
mobymask-watcher-db:
@ -49,12 +59,15 @@ services:
image: cerc/watcher-mobymask-v2:local
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
ports:
- "0.0.0.0:3001:3001"
- "0.0.0.0:9001:9001"
@ -66,6 +79,7 @@ services:
retries: 15
start_period: 5s
# TODO: Move to a separate pod
mobymask-app:
depends_on:
mobymask-watcher-server:
@ -110,3 +124,4 @@ services:
volumes:
mobymask_watcher_db_data:
moby_data_server:
fixturenet_geth_accounts:

View File

@ -28,10 +28,12 @@ PROPOSER_ADDRESS=$(echo "$KEYS_JSON" | jq -r '.Proposer.address')
BATCHER_ADDRESS=$(echo "$KEYS_JSON" | jq -r '.Batcher.address')
SEQUENCER_ADDRESS=$(echo "$KEYS_JSON" | jq -r '.Sequencer.address')
# Read the private key of a L1 account
# Read the private key of L1 accounts
# TODO: Take from env if /geth-accounts volume doesn't exist to allow using separately running L1
L1_ADDRESS=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 2)
L1_PRIV_KEY=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3)
L1_ADDRESS_2=$(awk -F, 'NR==2{print $(NF-1)}' /geth-accounts/accounts.csv)
L1_PRIV_KEY_2=$(awk -F, 'NR==2{print $NF}' /geth-accounts/accounts.csv)
# Send balances to the above L2 addresses
yarn hardhat send-balance --to "${ADMIN_ADDRESS}" --amount 2 --private-key "${L1_PRIV_KEY}" --network getting-started
@ -69,14 +71,18 @@ yarn hardhat deploy --network getting-started
echo "Deployed the L1 smart contracts"
# Read Proxy contarct's JSON and get the address
# Read Proxy contract's JSON and get the address
PROXY_JSON=$(cat deployments/getting-started/Proxy__OVM_L1StandardBridge.json)
PROXY_ADDRESS=$(echo "$PROXY_JSON" | jq -r '.address')
# Send balance to the above L2 address
# TODO: Send balance using second account to reflect in L2
# Send balance to the above Proxy contract in L1 for reflecting balance in L2
# First account
yarn hardhat send-balance --to "${PROXY_ADDRESS}" --amount 1 --private-key "${L1_PRIV_KEY}" --network getting-started
# Second account
yarn hardhat send-balance --to "${PROXY_ADDRESS}" --amount 1 --private-key "${L1_PRIV_KEY_2}" --network getting-started
echo "Balance sent to Proxy L2 contract"
echo "Use account ${L1_ADDRESS} to deploy contracts to L2"
echo "Use following accounts for transactions in L2:"
echo "${L1_ADDRESS}"
echo "${L1_ADDRESS_2}"
echo "Done"

View File

@ -6,11 +6,11 @@ SEQUENCER_KEY=$(jq -r '.Sequencer.privateKey' /l2-accounts/keys.json | tr -d '"'
op-node \
--l2=http://op-geth:8551 \
--l2.jwt-secret=/app/jwt.txt \
--l2.jwt-secret=/op-node-data/jwt.txt \
--sequencer.enabled \
--sequencer.l1-confs=3 \
--verifier.l1-confs=3 \
--rollup.config=/app/rollup.json \
--rollup.config=/op-node-data/rollup.json \
--rpc.addr=0.0.0.0 \
--rpc.port=8547 \
--p2p.disable \

View File

@ -0,0 +1,11 @@
#!/bin/sh
set -e
# 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)
# Set the private key
jq --arg privateKey "$L1_PRIV_KEY" '.privateKey = ($privateKey)' secrets.json > tmp.json && mv tmp.json secrets.json
npm start

View File

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

View File

@ -2,8 +2,10 @@
# Assign deployed contract address from server config
CONTRACT_ADDRESS=`jq '.address' /server/config.json`
L1_PRIV_KEY_2=$(awk -F, 'NR==2{print $NF}' /geth-accounts/accounts.csv)
sed "s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/" environments/watcher-config-template.toml > environments/local.toml
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
echo 'yarn server'
yarn server

View File

@ -37,7 +37,7 @@
enableDebugInfo = true
[server.p2p.peer.l2TxConfig]
privateKey = ''
privateKey = REPLACE_WITH_PRIVATE_KEY
contractAddress = REPLACE_WITH_CONTRACT_ADDRESS
[metrics]
@ -59,7 +59,7 @@
[upstream]
[upstream.ethServer]
gqlApiEndpoint = "http://ipld-eth-server:8083/graphql"
rpcProviderEndpoint = "http://laconicd:8545"
rpcProviderEndpoint = "http://op-geth:8545"
blockDelayInMilliSecs = 60000
[upstream.cache]

View File

@ -1,6 +1,6 @@
FROM node:16.17.1-alpine3.16
RUN apk --update --no-cache add python3 alpine-sdk
RUN apk --update --no-cache add python3 alpine-sdk jq
WORKDIR /app

View File

@ -43,15 +43,6 @@ This should create the required docker images in the local image registry.
Deploy the stack:
* Set the private key in [secrets.json](../../config/watcher-mobymask-v2/secrets.json) file that will be used by mobymask container to deploy contract
* Set the private key (`server.p2p.peer.l2TxConfig.privateKey`) in [watcher.toml](../../config/watcher-mobymask-v2/watcher-config-template.toml) file that will be used to start the peer that sends txs to L2 chain
```toml
[server.p2p.peer.l2TxConfig]
privateKey = 'SECOND_ACCOUNT_PRIVATE_KEY'
```
* Deploy the containers
```bash

View File

@ -1,14 +1,29 @@
version: "1.0"
name: mobymask-v2
repos:
- cerc-io/go-ethereum
- dboreham/foundry
- ethereum-optimism/optimism
- ethereum-optimism/op-geth
- cerc-io/watcher-ts
- cerc-io/react-peer
- cerc-io/mobymask-ui
- cerc-io/MobyMask
containers:
- cerc/go-ethereum
- cerc/lighthouse
- cerc/fixturenet-eth-geth
- cerc/fixturenet-eth-lighthouse
- cerc/foundry
- cerc/optimism-contracts
- cerc/optimism-l2geth
- cerc/optimism-op-batcher
- cerc/optimism-op-node
- cerc/watcher-mobymask-v2
- cerc/react-peer
- cerc/mobymask-ui
- cerc/mobymask
pods:
- fixturenet-eth
- fixturenet-optimism
- watcher-mobymask-v2