Replace laconicd with optimism in mobymask-v2 stack (#272)

* Remove laconicd to use optimism endpoint

* Use fixturenet-optimism stack for mobymask-v2-watcher

* Fix setting L1 account private key in mobymask-v2 stack
This commit is contained in:
Nabarun Gogoi 2023-04-03 18:13:29 +05:30 committed by GitHub
parent fc522140ba
commit b266ac78b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 92 additions and 101 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"
@ -80,6 +80,8 @@ services:
environment:
L1_RPC: "http://fixturenet-eth-geth-1:8545"
depends_on:
fixturenet-eth-geth-1:
condition: service_healthy
op-node:
condition: service_healthy
op-geth:
@ -87,11 +89,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,12 +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:
- ../config/watcher-mobymask-v2/secrets.json:/app/packages/server/secrets.json
# TODO: add a script to set rpc endpoint from env
# add manually if running seperately
- ../config/watcher-mobymask-v2/secrets-template.json:/app/packages/server/secrets-template.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
@ -39,6 +49,7 @@ services:
start_period: 10s
mobymask-watcher-server:
# TODO: pass optimism rpc endpoint
restart: unless-stopped
depends_on:
mobymask-watcher-db:
@ -48,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"
@ -65,6 +79,7 @@ services:
retries: 15
start_period: 5s
# TODO: Move to a separate pod
mobymask-app:
depends_on:
mobymask-watcher-server:
@ -109,11 +124,4 @@ services:
volumes:
mobymask_watcher_db_data:
moby_data_server:
networks:
# https://docs.docker.com/compose/networking/#configure-the-default-network
default:
# https://docs.docker.com/compose/networking/#use-a-pre-existing-network
name: mobymask-v2-network
external: true
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,13 +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
# 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-template.json > secrets.json
npm start

View File

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

View File

@ -1,5 +0,0 @@
{
"rpcUrl": "http://laconicd:8545",
"privateKey": "GENESIS_ACCOUNT_PRIVATE_KEY",
"baseURI": "http://127.0.0.1:3002/#"
}

View File

@ -1,9 +1,11 @@
#!/bin/sh
# Assign deployed contract address from server config
CONTRACT_ADDRESS=`jq '.address' /server/config.json`
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_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,8 +37,8 @@
enableDebugInfo = true
[server.p2p.peer.l2TxConfig]
privateKey = ''
contractAddress = REPLACE_WITH_CONTRACT_ADDRESS
privateKey = 'REPLACE_WITH_PRIVATE_KEY'
contractAddress = 'REPLACE_WITH_CONTRACT_ADDRESS'
[metrics]
host = "0.0.0.0"
@ -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

@ -28,10 +28,6 @@ git checkout v0.2.31
cd ~/cerc/mobymask-ui
git checkout laconic
# laconicd
cd ~/cerc/laconicd
git checkout v0.8.0
# MobyMask
cd ~/cerc/MobyMask
git checkout v0.1.1
@ -47,55 +43,10 @@ This should create the required docker images in the local image registry.
Deploy the stack:
* Deploy the laconic chain
* Deploy the containers
```bash
laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd up
```
* Check that laconic chain status is healthy
```bash
docker ps
```
* Export the private key from laconicd
```bash
laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd exec laconicd "echo y | laconicd keys export mykey --unarmored-hex --unsafe"
```
* Set the private key in [secrets.json](../../config/watcher-mobymask-v2/secrets.json) file that will be used by mobymask container to deploy contract
* Create a new account named `alice`
```bash
laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd exec laconicd "laconicd keys add alice"
```
* Transfer balance to new account
```bash
laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd exec laconicd 'laconicd tx bank send $(laconicd keys show mykey -a) $(laconicd keys show alice -a) 1000000000000000000000000aphoton --fees 2000aphoton'
```
* Export the private key of new account from laconicd
```bash
laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd exec laconicd "echo y | laconicd keys export alice --unarmored-hex --unsafe"
```
* Set the private key (`server.p2p.peer.l2TxConfig.privateKey`) in [watcher.toml](../../config/watcher-mobymask-v2/watcher.toml) file that will be used to start the peer that sends txs to L2 chain
```toml
[server.p2p.peer.l2TxConfig]
privateKey = 'ALICE_PRIVATE_KEY'
```
* Deploy the other containers
```bash
laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 up
laconic-so --stack mobymask-v2 deploy-system up
```
* Check that all containers are healthy using `docker ps`
@ -103,7 +54,7 @@ Deploy the stack:
NOTE: The `mobymask-ui` container might not start. If mobymask-app is not running at http://localhost:3002, run command again to start the container
```bash
laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 up
laconic-so --stack mobymask-v2 deploy-system up
```
## Tests
@ -111,7 +62,7 @@ Deploy the stack:
Find the watcher container's id:
```bash
laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 ps | grep "mobymask-watcher-server"
laconic-so --stack mobymask-v2 deploy-system ps | grep "mobymask-watcher-server"
```
Example output
@ -163,9 +114,7 @@ Follow the [demo](./demo.md) to try out the MobyMask app with L2 chain
Stop all the services running in background run:
```bash
laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 down
laconic-so --stack mobymask-v2 deploy-system --include mobymask-laconicd down
laconic-so --stack mobymask-v2 deploy-system down
```
Clear volumes:

View File

@ -3,7 +3,7 @@
* Get the root invite link URL for mobymask-app
```
laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 logs mobymask
laconic-so --stack mobymask-v2 deploy-system logs mobymask
```
The invite link is seen at the end of the logs
@ -34,7 +34,7 @@
* Get the container id
```bash
laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 ps | grep mobymask-watcher-server
laconic-so --stack mobymask-v2 deploy-system ps | grep mobymask-watcher-server
```
* Check logs
@ -74,7 +74,7 @@
* Get the deployed contract address
```bash
laconic-so --stack mobymask-v2 deploy-system --include watcher-mobymask-v2 exec mobymask-app "cat src/config.json"
laconic-so --stack mobymask-v2 deploy-system exec mobymask-app "cat src/config.json"
```
The value of `address` field is the deployed contract address

View File

@ -1,17 +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/laconicd
- 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/laconicd
- cerc/mobymask
pods:
- mobymask-laconicd
- fixturenet-eth
- fixturenet-optimism
- watcher-mobymask-v2