Add an option to pass env file to deploy command (#304)

* Add an option to pass env file to deploy command

* Use env variable mapping in fixturenet-optimism stack

* Use default values from checked in env files

* Use env variable mapping in mobymask-v2 stack

* Update instructions

* Add extra hosts in app compose files and update instructions

* Add CERC prefix to env variables in fixturenet-optimism stack

* Add CERC prefix to env variables in mobymask-v2 stack
This commit is contained in:
prathamesh0 2023-04-11 16:21:03 +05:30 committed by GitHub
parent 9a4b5810af
commit 6b62247ef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 276 additions and 120 deletions

View File

@ -9,9 +9,17 @@ services:
image: cerc/optimism-contracts:local image: cerc/optimism-contracts:local
env_file: env_file:
- ../config/fixturenet-optimism/l1-params.env - ../config/fixturenet-optimism/l1-params.env
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_L1_CHAIN_ID: ${CERC_L1_CHAIN_ID}
CERC_L1_RPC: ${CERC_L1_RPC}
CERC_L1_ADDRESS: ${CERC_L1_ADDRESS}
CERC_L1_PRIV_KEY: ${CERC_L1_PRIV_KEY}
CERC_L1_ADDRESS_2: ${CERC_L1_ADDRESS_2}
CERC_L1_PRIV_KEY_2: ${CERC_L1_PRIV_KEY_2}
# Waits for L1 endpoint to be up before running the script # Waits for L1 endpoint to be up before running the script
command: | command: |
"./wait-for-it.sh -h $${L1_HOST} -p $${L1_PORT} -s -t 60 -- ./run.sh" "./wait-for-it.sh -h ${CERC_L1_HOST:-$${DEFAULT_CERC_L1_HOST}} -p ${CERC_L1_PORT:-$${DEFAULT_CERC_L1_PORT}} -s -t 60 -- ./run.sh"
volumes: volumes:
- ../config/wait-for-it.sh:/app/packages/contracts-bedrock/wait-for-it.sh - ../config/wait-for-it.sh:/app/packages/contracts-bedrock/wait-for-it.sh
- ../container-build/cerc-optimism-contracts/hardhat-tasks/verify-contract-deployment.ts:/app/packages/contracts-bedrock/tasks/verify-contract-deployment.ts - ../container-build/cerc-optimism-contracts/hardhat-tasks/verify-contract-deployment.ts:/app/packages/contracts-bedrock/tasks/verify-contract-deployment.ts
@ -33,6 +41,9 @@ services:
condition: service_completed_successfully condition: service_completed_successfully
env_file: env_file:
- ../config/fixturenet-optimism/l1-params.env - ../config/fixturenet-optimism/l1-params.env
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_L1_RPC: ${CERC_L1_RPC}
volumes: volumes:
- ../config/fixturenet-optimism/generate-l2-config.sh:/app/generate-l2-config.sh - ../config/fixturenet-optimism/generate-l2-config.sh:/app/generate-l2-config.sh
- l1_deployment:/contracts-bedrock:ro - l1_deployment:/contracts-bedrock:ro
@ -65,12 +76,15 @@ services:
# Runs the L2 consensus client (Sequencer node) # Runs the L2 consensus client (Sequencer node)
op-node: op-node:
env_file: image: cerc/optimism-op-node:local
- ../config/fixturenet-optimism/l1-params.env
depends_on: depends_on:
op-geth: op-geth:
condition: service_healthy condition: service_healthy
image: cerc/optimism-op-node:local env_file:
- ../config/fixturenet-optimism/l1-params.env
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_L1_RPC: ${CERC_L1_RPC}
volumes: volumes:
- ../config/fixturenet-optimism/run-op-node.sh:/app/run-op-node.sh - ../config/fixturenet-optimism/run-op-node.sh:/app/run-op-node.sh
- l2_config:/op-node-data:ro - l2_config:/op-node-data:ro
@ -89,14 +103,17 @@ services:
# Runs the batcher (takes transactions from the Sequencer and publishes them to L1) # Runs the batcher (takes transactions from the Sequencer and publishes them to L1)
op-batcher: op-batcher:
env_file: image: cerc/optimism-op-batcher:local
- ../config/fixturenet-optimism/l1-params.env
depends_on: depends_on:
op-node: op-node:
condition: service_healthy condition: service_healthy
op-geth: op-geth:
condition: service_healthy condition: service_healthy
image: cerc/optimism-op-batcher:local env_file:
- ../config/fixturenet-optimism/l1-params.env
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_L1_RPC: ${CERC_L1_RPC}
volumes: volumes:
- ../config/wait-for-it.sh:/wait-for-it.sh - ../config/wait-for-it.sh:/wait-for-it.sh
- ../config/fixturenet-optimism/run-op-batcher.sh:/run-op-batcher.sh - ../config/fixturenet-optimism/run-op-batcher.sh:/run-op-batcher.sh
@ -104,7 +121,7 @@ services:
entrypoint: ["sh", "-c"] entrypoint: ["sh", "-c"]
# Waits for L1 endpoint to be up before running the batcher # Waits for L1 endpoint to be up before running the batcher
command: | command: |
"/wait-for-it.sh -h $${L1_HOST} -p $${L1_PORT} -s -t 60 -- /run-op-batcher.sh" "/wait-for-it.sh -h ${CERC_L1_HOST:-$${DEFAULT_CERC_L1_HOST}} -p ${CERC_L1_PORT:-$${DEFAULT_CERC_L1_PORT}} -s -t 60 -- /run-op-batcher.sh"
extra_hosts: extra_hosts:
- "host.docker.internal:host-gateway" - "host.docker.internal:host-gateway"

View File

@ -6,12 +6,18 @@ services:
image: cerc/mobymask-ui:local image: cerc/mobymask-ui:local
env_file: env_file:
- ../config/watcher-mobymask-v2/mobymask-params.env - ../config/watcher-mobymask-v2/mobymask-params.env
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_CHAIN_ID: ${CERC_CHAIN_ID}
CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT}
CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL}
CERC_RELAY_NODES: ${CERC_RELAY_NODES}
# Waits for watcher server to be up before app build # Waits for watcher server to be up before app build
# Required when running with watcher stack to get deployed contract address # Required when running with watcher stack to get deployed contract address
command: command:
- sh - sh
- -c - -c
- ./wait-for-it.sh -h $${WATCHER_HOST} -p $${WATCHER_PORT} -s -t 0 -- ./mobymask-app-start.sh - ./wait-for-it.sh -h ${CERC_WATCHER_HOST:-$${DEFAULT_CERC_WATCHER_HOST}} -p ${CERC_WATCHER_PORT:-$${DEFAULT_CERC_WATCHER_PORT}} -s -t 0 -- ./mobymask-app-start.sh
volumes: volumes:
- ../config/wait-for-it.sh:/app/wait-for-it.sh - ../config/wait-for-it.sh:/app/wait-for-it.sh
- ../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
@ -26,6 +32,8 @@ services:
retries: 15 retries: 15
start_period: 10s start_period: 10s
shm_size: '1GB' shm_size: '1GB'
extra_hosts:
- "host.docker.internal:host-gateway"
volumes: volumes:
mobymask_deployment: mobymask_deployment:

View File

@ -7,6 +7,9 @@ services:
working_dir: /app/packages/test-app working_dir: /app/packages/test-app
env_file: env_file:
- ../config/watcher-mobymask-v2/mobymask-params.env - ../config/watcher-mobymask-v2/mobymask-params.env
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_RELAY_NODES: ${CERC_RELAY_NODES}
command: ["sh", "./test-app-start.sh"] command: ["sh", "./test-app-start.sh"]
volumes: volumes:
- ../config/watcher-mobymask-v2/test-app-config.json:/app/packages/test-app/src/test-app-config.json - ../config/watcher-mobymask-v2/test-app-config.json:/app/packages/test-app/src/test-app-config.json
@ -19,3 +22,5 @@ services:
timeout: 5s timeout: 5s
retries: 15 retries: 15
start_period: 10s start_period: 10s
extra_hosts:
- "host.docker.internal:host-gateway"

View File

@ -22,8 +22,8 @@ services:
retries: 15 retries: 15
start_period: 10s start_period: 10s
# Deploys MobyMask contract and generates an invite link # Deploys the MobyMask contract and generates an invite link
# Deployment is skipped if DEPLOYED_CONTRACT env is already set # Deployment is skipped if CERC_DEPLOYED_CONTRACT env is set
mobymask: mobymask:
image: cerc/mobymask:local image: cerc/mobymask:local
working_dir: /app/packages/server working_dir: /app/packages/server
@ -31,14 +31,19 @@ services:
- ../config/watcher-mobymask-v2/optimism-params.env - ../config/watcher-mobymask-v2/optimism-params.env
- ../config/watcher-mobymask-v2/mobymask-params.env - ../config/watcher-mobymask-v2/mobymask-params.env
environment: environment:
- ENV=PROD CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
ENV: "PROD"
CERC_L2_GETH_RPC: ${CERC_L2_GETH_RPC}
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER}
CERC_MOBYMASK_APP_BASE_URI: ${CERC_MOBYMASK_APP_BASE_URI}
CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT}
# Waits for L2 Optimism Geth and Node servers to be up before deploying contract # Waits for L2 Optimism Geth and Node servers to be up before deploying contract
command: command:
- sh - sh
- -c - -c
- | - |
./wait-for-it.sh -h $${L2_GETH_HOST} -p $${L2_GETH_PORT} -s -t 0 && \ ./wait-for-it.sh -h ${CERC_L2_GETH_HOST:-$${DEFAULT_CERC_L2_GETH_HOST}} -p ${CERC_L2_GETH_PORT:-$${DEFAULT_CERC_L2_GETH_PORT}} -s -t 0 && \
./wait-for-it.sh -h $${L2_NODE_HOST} -p $${L2_NODE_PORT} -s -t 0 && \ ./wait-for-it.sh -h ${CERC_L2_NODE_HOST:-$${DEFAULT_CERC_L2_NODE_HOST}} -p ${CERC_L2_NODE_PORT:-$${DEFAULT_CERC_L2_NODE_PORT}} -s -t 0 && \
./deploy-and-generate-invite.sh ./deploy-and-generate-invite.sh
volumes: volumes:
- ../config/wait-for-it.sh:/app/packages/server/wait-for-it.sh - ../config/wait-for-it.sh:/app/packages/server/wait-for-it.sh
@ -51,16 +56,22 @@ services:
# Starts the mobymask-v2-watcher server # Starts the mobymask-v2-watcher server
mobymask-watcher-server: mobymask-watcher-server:
image: cerc/watcher-mobymask-v2:local
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
mobymask-watcher-db: mobymask-watcher-db:
condition: service_healthy condition: service_healthy
mobymask: mobymask:
condition: service_completed_successfully condition: service_completed_successfully
image: cerc/watcher-mobymask-v2:local
env_file: env_file:
- ../config/watcher-mobymask-v2/optimism-params.env - ../config/watcher-mobymask-v2/optimism-params.env
- ../config/watcher-mobymask-v2/mobymask-params.env - ../config/watcher-mobymask-v2/mobymask-params.env
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_L2_GETH_RPC: ${CERC_L2_GETH_RPC}
CERC_PRIVATE_KEY_PEER: ${CERC_PRIVATE_KEY_PEER}
CERC_ENABLE_PEER_L2_TXS: ${CERC_ENABLE_PEER_L2_TXS}
CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT}
command: ["sh", "start-server.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

View File

@ -4,6 +4,8 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}"
# Check existing config if it exists # Check existing config if it exists
if [ -f /app/jwt.txt ] && [ -f /app/rollup.json ]; then if [ -f /app/jwt.txt ] && [ -f /app/rollup.json ]; then
echo "Found existing L2 config, cross-checking with L1 deployment config" echo "Found existing L2 config, cross-checking with L1 deployment config"
@ -30,6 +32,6 @@ op-node genesis l2 \
--deployment-dir /contracts-bedrock/deployments/getting-started/ \ --deployment-dir /contracts-bedrock/deployments/getting-started/ \
--outfile.l2 /app/genesis.json \ --outfile.l2 /app/genesis.json \
--outfile.rollup /app/rollup.json \ --outfile.rollup /app/rollup.json \
--l1-rpc $L1_RPC --l1-rpc $CERC_L1_RPC
openssl rand -hex 32 > /app/jwt.txt openssl rand -hex 32 > /app/jwt.txt

View File

@ -1,14 +1,14 @@
# Change if pointing to an external L1 endpoint # Defaults
# L1 endpoint # L1 endpoint
L1_CHAIN_ID=1212 DEFAULT_CERC_L1_CHAIN_ID=1212
L1_RPC="http://fixturenet-eth-geth-1:8545" DEFAULT_CERC_L1_RPC="http://fixturenet-eth-geth-1:8545"
L1_HOST="fixturenet-eth-geth-1" DEFAULT_CERC_L1_HOST="fixturenet-eth-geth-1"
L1_PORT=8545 DEFAULT_CERC_L1_PORT=8545
# Credentials for accounts on L1 to send balance to Optimism Proxy contract from # Credentials for accounts on L1 to send balance to Optimism Proxy contract from
# (enables them to do transactions on L2) # (enables them to do transactions on L2)
L1_ADDRESS= DEFAULT_CERC_L1_ADDRESS=
L1_PRIV_KEY= DEFAULT_CERC_L1_PRIV_KEY=
L1_ADDRESS_2= DEFAULT_CERC_L1_ADDRESS_2=
L1_PRIV_KEY_2= DEFAULT_CERC_L1_PRIV_KEY_2=

View File

@ -4,7 +4,15 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
echo "Using L1 RPC endpoint ${L1_RPC}" CERC_L1_CHAIN_ID="${CERC_L1_CHAIN_ID:-${DEFAULT_CERC_L1_CHAIN_ID}}"
CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}"
CERC_L1_ADDRESS="${CERC_L1_ADDRESS:-${DEFAULT_CERC_L1_ADDRESS}}"
CERC_L1_PRIV_KEY="${CERC_L1_PRIV_KEY:-${DEFAULT_CERC_L1_PRIV_KEY}}"
CERC_L1_ADDRESS_2="${CERC_L1_ADDRESS_2:-${DEFAULT_CERC_L1_ADDRESS_2}}"
CERC_L1_PRIV_KEY_2="${CERC_L1_PRIV_KEY_2:-${DEFAULT_CERC_L1_PRIV_KEY_2}}"
echo "Using L1 RPC endpoint ${CERC_L1_RPC}"
IMPORT_1="import './verify-contract-deployment'" IMPORT_1="import './verify-contract-deployment'"
IMPORT_2="import './rekey-json'" IMPORT_2="import './rekey-json'"
@ -18,7 +26,7 @@ if ! grep -Fxq "$IMPORT_1" tasks/index.ts; then
fi fi
# Update the chainId in the hardhat config # Update the chainId in the hardhat config
sed -i "/getting-started/ {n; s/.*chainId.*/ chainId: $L1_CHAIN_ID,/}" hardhat.config.ts sed -i "/getting-started/ {n; s/.*chainId.*/ chainId: $CERC_L1_CHAIN_ID,/}" hardhat.config.ts
# Exit if a deployment already exists (on restarts) # Exit if a deployment already exists (on restarts)
# Note: fixturenet-eth-geth currently starts fresh on a restart # Note: fixturenet-eth-geth currently starts fresh on a restart
@ -57,16 +65,16 @@ SEQUENCER_ADDRESS=$(echo "$KEYS_JSON" | jq -r '.Sequencer.address')
# Read the private key of L1 accounts # Read the private key of L1 accounts
if [ -f /geth-accounts/accounts.csv ]; then if [ -f /geth-accounts/accounts.csv ]; then
echo "Using L1 account credentials from the mounted volume" echo "Using L1 account credentials from the mounted volume"
L1_ADDRESS=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 2) CERC_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) CERC_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) CERC_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) CERC_L1_PRIV_KEY_2=$(awk -F, 'NR==2{print $NF}' /geth-accounts/accounts.csv)
else else
echo "Using L1 account credentials from env" echo "Using L1 account credentials from env"
fi fi
# Select a finalized L1 block as the starting point for roll ups # Select a finalized L1 block as the starting point for roll ups
until FINALIZED_BLOCK=$(cast block finalized --rpc-url "$L1_RPC"); do until FINALIZED_BLOCK=$(cast block finalized --rpc-url "$CERC_L1_RPC"); do
echo "Waiting for a finalized L1 block to exist, retrying after 10s" echo "Waiting for a finalized L1 block to exist, retrying after 10s"
sleep 10 sleep 10
done done
@ -78,22 +86,22 @@ L1_BLOCKTIMESTAMP=$(echo "$FINALIZED_BLOCK" | awk '/timestamp/{print $2}')
echo "Selected L1 block ${L1_BLOCKNUMBER} as the starting block for roll ups" echo "Selected L1 block ${L1_BLOCKNUMBER} as the starting block for roll ups"
# Send balances to the above L2 addresses # Send balances to the above L2 addresses
yarn hardhat send-balance --to "${ADMIN_ADDRESS}" --amount 2 --private-key "${L1_PRIV_KEY}" --network getting-started yarn hardhat send-balance --to "${ADMIN_ADDRESS}" --amount 2 --private-key "${CERC_L1_PRIV_KEY}" --network getting-started
yarn hardhat send-balance --to "${PROPOSER_ADDRESS}" --amount 5 --private-key "${L1_PRIV_KEY}" --network getting-started yarn hardhat send-balance --to "${PROPOSER_ADDRESS}" --amount 5 --private-key "${CERC_L1_PRIV_KEY}" --network getting-started
yarn hardhat send-balance --to "${BATCHER_ADDRESS}" --amount 1000 --private-key "${L1_PRIV_KEY}" --network getting-started yarn hardhat send-balance --to "${BATCHER_ADDRESS}" --amount 1000 --private-key "${CERC_L1_PRIV_KEY}" --network getting-started
echo "Balances sent to L2 accounts" echo "Balances sent to L2 accounts"
# Update the deployment config # Update the deployment config
sed -i 's/"l2OutputOracleStartingTimestamp": TIMESTAMP/"l2OutputOracleStartingTimestamp": '"$L1_BLOCKTIMESTAMP"'/g' deploy-config/getting-started.json sed -i 's/"l2OutputOracleStartingTimestamp": TIMESTAMP/"l2OutputOracleStartingTimestamp": '"$L1_BLOCKTIMESTAMP"'/g' deploy-config/getting-started.json
jq --arg chainid "$L1_CHAIN_ID" '.l1ChainID = ($chainid | tonumber)' deploy-config/getting-started.json > tmp.json && mv tmp.json deploy-config/getting-started.json jq --arg chainid "$CERC_L1_CHAIN_ID" '.l1ChainID = ($chainid | tonumber)' deploy-config/getting-started.json > tmp.json && mv tmp.json deploy-config/getting-started.json
node update-config.js deploy-config/getting-started.json "$ADMIN_ADDRESS" "$PROPOSER_ADDRESS" "$BATCHER_ADDRESS" "$SEQUENCER_ADDRESS" "$L1_BLOCKHASH" node update-config.js deploy-config/getting-started.json "$ADMIN_ADDRESS" "$PROPOSER_ADDRESS" "$BATCHER_ADDRESS" "$SEQUENCER_ADDRESS" "$L1_BLOCKHASH"
echo "Updated the deployment config" echo "Updated the deployment config"
# Create a .env file # Create a .env file
echo "L1_RPC=$L1_RPC" > .env echo "CERC_L1_RPC=$CERC_L1_RPC" > .env
echo "PRIVATE_KEY_DEPLOYER=$ADMIN_PRIV_KEY" >> .env echo "PRIVATE_KEY_DEPLOYER=$ADMIN_PRIV_KEY" >> .env
echo "Deploying the L1 smart contracts, this will take a while..." echo "Deploying the L1 smart contracts, this will take a while..."
@ -109,12 +117,12 @@ PROXY_ADDRESS=$(echo "$PROXY_JSON" | jq -r '.address')
# Send balance to the above Proxy contract in L1 for reflecting balance in L2 # Send balance to the above Proxy contract in L1 for reflecting balance in L2
# First account # First account
yarn hardhat send-balance --to "${PROXY_ADDRESS}" --amount 1 --private-key "${L1_PRIV_KEY}" --network getting-started yarn hardhat send-balance --to "${PROXY_ADDRESS}" --amount 1 --private-key "${CERC_L1_PRIV_KEY}" --network getting-started
# Second account # Second account
yarn hardhat send-balance --to "${PROXY_ADDRESS}" --amount 1 --private-key "${L1_PRIV_KEY_2}" --network getting-started yarn hardhat send-balance --to "${PROXY_ADDRESS}" --amount 1 --private-key "${CERC_L1_PRIV_KEY_2}" --network getting-started
echo "Balance sent to Proxy L2 contract" echo "Balance sent to Proxy L2 contract"
echo "Use following accounts for transactions in L2:" echo "Use following accounts for transactions in L2:"
echo "${L1_ADDRESS}" echo "${CERC_L1_ADDRESS}"
echo "${L1_ADDRESS_2}" echo "${CERC_L1_ADDRESS_2}"
echo "Done" echo "Done"

View File

@ -4,6 +4,8 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}"
# Get BACTHER_KEY from keys.json # Get BACTHER_KEY from keys.json
BATCHER_KEY=$(jq -r '.Batcher.privateKey' /l2-accounts/keys.json | tr -d '"') BATCHER_KEY=$(jq -r '.Batcher.privateKey' /l2-accounts/keys.json | tr -d '"')
@ -20,5 +22,5 @@ op-batcher \
--rpc.enable-admin \ --rpc.enable-admin \
--max-channel-duration=1 \ --max-channel-duration=1 \
--target-l1-tx-size-bytes=2048 \ --target-l1-tx-size-bytes=2048 \
--l1-eth-rpc=$L1_RPC \ --l1-eth-rpc=$CERC_L1_RPC \
--private-key=$BATCHER_KEY --private-key=$BATCHER_KEY

View File

@ -4,6 +4,8 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
CERC_L1_RPC="${CERC_L1_RPC:-${DEFAULT_CERC_L1_RPC}}"
# Get SEQUENCER KEY from keys.json # Get SEQUENCER KEY from keys.json
SEQUENCER_KEY=$(jq -r '.Sequencer.privateKey' /l2-accounts/keys.json | tr -d '"') SEQUENCER_KEY=$(jq -r '.Sequencer.privateKey' /l2-accounts/keys.json | tr -d '"')
@ -19,5 +21,5 @@ op-node \
--p2p.disable \ --p2p.disable \
--rpc.enable-admin \ --rpc.enable-admin \
--p2p.sequencer.key=$SEQUENCER_KEY \ --p2p.sequencer.key=$SEQUENCER_KEY \
--l1=$L1_RPC \ --l1=$CERC_L1_RPC \
--l1.rpckind=any --l1.rpckind=any

View File

@ -4,30 +4,36 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
echo "Using L2 RPC endpoint ${L2_GETH_RPC}" CERC_L2_GETH_RPC="${CERC_L2_GETH_RPC:-${DEFAULT_CERC_L2_GETH_RPC}}"
CERC_PRIVATE_KEY_DEPLOYER="${CERC_PRIVATE_KEY_DEPLOYER:-${DEFAULT_CERC_PRIVATE_KEY_DEPLOYER}}"
CERC_MOBYMASK_APP_BASE_URI="${CERC_MOBYMASK_APP_BASE_URI:-${DEFAULT_CERC_MOBYMASK_APP_BASE_URI}}"
CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRACT}}"
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
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
PRIVATE_KEY_DEPLOYER=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3) CERC_PRIVATE_KEY_DEPLOYER=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3)
else else
echo "Using PRIVATE_KEY_DEPLOYER from env" echo "Using CERC_PRIVATE_KEY_DEPLOYER from env"
fi 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 "$CERC_PRIVATE_KEY_DEPLOYER" '.privateKey = $privateKey' secrets-template.json > secrets.json
# Set the RPC URL # Set the RPC URL
jq --arg rpcUrl "$L2_GETH_RPC" '.rpcUrl = $rpcUrl' secrets.json > secrets_updated.json && mv secrets_updated.json secrets.json jq --arg rpcUrl "$CERC_L2_GETH_RPC" '.rpcUrl = $rpcUrl' secrets.json > secrets_updated.json && mv secrets_updated.json secrets.json
# Set the MobyMask app base URI # Set the MobyMask app base URI
jq --arg baseURI "$MOBYMASK_APP_BASE_URI" '.baseURI = $baseURI' secrets.json > secrets_updated.json && mv secrets_updated.json secrets.json jq --arg baseURI "$CERC_MOBYMASK_APP_BASE_URI" '.baseURI = $baseURI' secrets.json > secrets_updated.json && mv secrets_updated.json secrets.json
export RPC_URL="${L2_GETH_RPC}" export RPC_URL="${CERC_L2_GETH_RPC}"
# Check if DEPLOYED_CONTRACT environment variable set to skip contract deployment # Check if CERC_DEPLOYED_CONTRACT environment variable set to skip contract deployment
if [[ -n "$DEPLOYED_CONTRACT" ]]; then if [ -n "$CERC_DEPLOYED_CONTRACT" ]; then
echo "DEPLOYED_CONTRACT is set to '$DEPLOYED_CONTRACT'" echo "CERC_DEPLOYED_CONTRACT is set to '$CERC_DEPLOYED_CONTRACT'"
echo "Exiting without deploying contract" echo "Exiting without deploying contract"
exit 0 exit 0
fi fi
@ -53,7 +59,7 @@ fi
# Wait until balance for deployer account is updated # Wait until balance for deployer account is updated
cd ../hardhat cd ../hardhat
while true; do while true; do
ACCOUNT_BALANCE=$(yarn balance --network optimism "$PRIVATE_KEY_DEPLOYER" | grep ETH) ACCOUNT_BALANCE=$(yarn balance --network optimism "$CERC_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

@ -4,6 +4,11 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
CERC_CHAIN_ID="${CERC_CHAIN_ID:-${DEFAULT_CERC_CHAIN_ID}}"
CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRACT}}"
CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}"
CERC_APP_WATCHER_URL="${CERC_APP_WATCHER_URL:-${DEFAULT_CERC_APP_WATCHER_URL}}"
# Use config from mounted volume if available (when running web-app along with watcher stack) # Use config from mounted volume if available (when running web-app along with watcher stack)
if [ -f /server/config.json ]; then if [ -f /server/config.json ]; then
echo "Merging config for deployed contract from mounted volume" echo "Merging config for deployed contract from mounted volume"
@ -13,13 +18,13 @@ else
echo "Setting deployed contract details from env" echo "Setting deployed contract details from env"
# Set config values from environment variables # Set config values from environment variables
jq --arg address "$DEPLOYED_CONTRACT" \ jq --arg address "$CERC_DEPLOYED_CONTRACT" \
--argjson chainId $CHAIN_ID \ --argjson chainId $CERC_CHAIN_ID \
--argjson relayNodes "$RELAY_NODES" \ --argjson relayNodes "$CERC_RELAY_NODES" \
'.address = $address | .chainId = $chainId | .relayNodes = $relayNodes' \ '.address = $address | .chainId = $chainId | .relayNodes = $relayNodes' \
/app/src/mobymask-app-config.json > /app/src/config.json /app/src/mobymask-app-config.json > /app/src/config.json
fi fi
REACT_APP_WATCHER_URI="$APP_WATCHER_URL/graphql" npm run build REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" npm run build
serve -s build serve -s build

View File

@ -1,20 +1,22 @@
# Change if pointing web app to external watcher endpoint # Defaults
WATCHER_HOST="mobymask-watcher-server"
WATCHER_PORT=3001 # Watcher endpoint
APP_WATCHER_URL="http://localhost:3001" DEFAULT_CERC_WATCHER_HOST="mobymask-watcher-server"
DEFAULT_CERC_WATCHER_PORT=3001
DEFAULT_CERC_APP_WATCHER_URL="http://localhost:3001"
# Base URI for mobymask-app (used for generating invite) # Base URI for mobymask-app (used for generating invite)
MOBYMASK_APP_BASE_URI="http://127.0.0.1:3002/#" DEFAULT_CERC_MOBYMASK_APP_BASE_URI="http://127.0.0.1:3002/#"
# Set to false for disabling watcher peer to send txs to L2 # Set to false for disabling watcher peer to send txs to L2
ENABLE_PEER_L2_TXS=true DEFAULT_CERC_ENABLE_PEER_L2_TXS=true
# Set deployed MobyMask contract address to avoid deploying contract in stack # Set deployed MobyMask contract address to avoid deploying contract in stack
# mobymask-app will use this contract address in config if run separately # mobymask-app will use this contract address in config if run separately
DEPLOYED_CONTRACT= DEFAULT_CERC_DEPLOYED_CONTRACT=
# Chain ID is used by mobymask web-app for txs # Chain ID is used by mobymask web-app for txs
CHAIN_ID=42069 DEFAULT_CERC_CHAIN_ID=42069
# Set relay nodes to be used by web-apps # Set relay nodes to be used by web-apps
RELAY_NODES=["/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"] DEFAULT_CERC_RELAY_NODES=["/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"]

View File

@ -1,13 +1,13 @@
# Change if pointing to an external optimism geth endpoint # Defaults
# L2 endpoints # L2 endpoints
L2_GETH_RPC="http://op-geth:8545" DEFAULT_CERC_L2_GETH_RPC="http://op-geth:8545"
L2_GETH_HOST="op-geth" DEFAULT_CERC_L2_GETH_HOST="op-geth"
L2_GETH_PORT=8545 DEFAULT_CERC_L2_GETH_PORT=8545
L2_NODE_HOST="op-node" DEFAULT_CERC_L2_NODE_HOST="op-node"
L2_NODE_PORT=8547 DEFAULT_CERC_L2_NODE_PORT=8547
# Credentials for accounts to perform txs on L2 # Credentials for accounts to perform txs on L2
PRIVATE_KEY_DEPLOYER= DEFAULT_CERC_PRIVATE_KEY_DEPLOYER=
PRIVATE_KEY_PEER= DEFAULT_CERC_PRIVATE_KEY_PEER=

View File

@ -4,11 +4,17 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
echo "Using L2 RPC endpoint ${L2_GETH_RPC}" CERC_L2_GETH_RPC="${CERC_L2_GETH_RPC:-${DEFAULT_CERC_L2_GETH_RPC}}"
CERC_PRIVATE_KEY_PEER="${CERC_PRIVATE_KEY_PEER:-${DEFAULT_CERC_PRIVATE_KEY_PEER}}"
CERC_ENABLE_PEER_L2_TXS="${CERC_ENABLE_PEER_L2_TXS:-${DEFAULT_CERC_ENABLE_PEER_L2_TXS}}"
CERC_DEPLOYED_CONTRACT="${CERC_DEPLOYED_CONTRACT:-${DEFAULT_CERC_DEPLOYED_CONTRACT}}"
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
# Use contract address from environment variable or set from config.json in mounted volume # Use contract address from environment variable or set from config.json in mounted volume
if [ -n "$DEPLOYED_CONTRACT" ]; then if [ -n "$CERC_DEPLOYED_CONTRACT" ]; then
CONTRACT_ADDRESS="${DEPLOYED_CONTRACT}" CONTRACT_ADDRESS="${CERC_DEPLOYED_CONTRACT}"
else else
# Assign deployed contract address from server config (created by mobymask container after deploying contract) # Assign deployed contract address from server config (created by mobymask container after deploying contract)
CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"') CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"')
@ -17,19 +23,19 @@ 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 for sending txs from peer # 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) CERC_PRIVATE_KEY_PEER=$(awk -F, 'NR==2{print $NF}' /geth-accounts/accounts.csv)
else else
echo "Using PRIVATE_KEY_PEER from env" echo "Using CERC_PRIVATE_KEY_PEER from env"
fi fi
# Read in the config template TOML file and modify it # Read in the config template TOML file and modify it
WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml) WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml)
WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \ WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \
sed -E "s/REPLACE_WITH_ENABLE_PEER_L2_TXS/${ENABLE_PEER_L2_TXS}/g; \ sed -E "s/REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS/${CERC_ENABLE_PEER_L2_TXS}/g; \
s/REPLACE_WITH_PRIVATE_KEY_PEER/${PRIVATE_KEY_PEER}/g; \ s/REPLACE_WITH_CERC_PRIVATE_KEY_PEER/${CERC_PRIVATE_KEY_PEER}/g; \
s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/g; \ s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/g; \
s|REPLACE_WITH_L2_GETH_RPC_ENDPOINT|${L2_GETH_RPC}| ") s|REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT|${CERC_L2_GETH_RPC}| ")
# Write the modified content to a new file # Write the modified content to a new file
echo "$WATCHER_CONFIG" > environments/local.toml echo "$WATCHER_CONFIG" > environments/local.toml

View File

@ -4,8 +4,10 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
# Set relay nodes in config from RELAY_NODES environment variable CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}"
jq --argjson relayNodes "$RELAY_NODES" \
# Set relay nodes in config from CERC_RELAY_NODES environment variable
jq --argjson relayNodes "$CERC_RELAY_NODES" \
'.relayNodes = $relayNodes' \ '.relayNodes = $relayNodes' \
./src/test-app-config.json > ./src/config.json ./src/test-app-config.json > ./src/config.json

View File

@ -35,10 +35,10 @@
pubSubTopic = 'mobymask' pubSubTopic = 'mobymask'
peerIdFile = './peer-id.json' peerIdFile = './peer-id.json'
enableDebugInfo = true enableDebugInfo = true
enableL2Txs = REPLACE_WITH_ENABLE_PEER_L2_TXS enableL2Txs = REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS
[server.p2p.peer.l2TxsConfig] [server.p2p.peer.l2TxsConfig]
privateKey = 'REPLACE_WITH_PRIVATE_KEY_PEER' privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER'
contractAddress = 'REPLACE_WITH_CONTRACT_ADDRESS' contractAddress = 'REPLACE_WITH_CONTRACT_ADDRESS'
[metrics] [metrics]
@ -60,7 +60,7 @@
[upstream] [upstream]
[upstream.ethServer] [upstream.ethServer]
gqlApiEndpoint = "http://ipld-eth-server:8083/graphql" gqlApiEndpoint = "http://ipld-eth-server:8083/graphql"
rpcProviderEndpoint = "REPLACE_WITH_L2_GETH_RPC_ENDPOINT" rpcProviderEndpoint = "REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT"
blockDelayInMilliSecs = 60000 blockDelayInMilliSecs = 60000
[upstream.cache] [upstream.cache]

View File

@ -8,7 +8,7 @@ task('send-balance', 'Sends Ether to a specified Ethereum account')
.addParam('privateKey', 'The private key of the sender') .addParam('privateKey', 'The private key of the sender')
.setAction(async ({ to, amount, privateKey }, {}) => { .setAction(async ({ to, amount, privateKey }, {}) => {
// Open the wallet using sender's private key // Open the wallet using sender's private key
const provider = new ethers.providers.JsonRpcProvider(`${process.env.L1_RPC}`) const provider = new ethers.providers.JsonRpcProvider(`${process.env.CERC_L1_RPC}`)
const wallet = new ethers.Wallet(privateKey, provider) const wallet = new ethers.Wallet(privateKey, provider)
// Send amount to the specified address // Send amount to the specified address

View File

@ -9,7 +9,7 @@ task(
.addParam('transactionHash', 'Hash of the deployment transaction') .addParam('transactionHash', 'Hash of the deployment transaction')
.setAction(async ({ contract, transactionHash }, { ethers }) => { .setAction(async ({ contract, transactionHash }, { ethers }) => {
const provider = new ethers.providers.JsonRpcProvider( const provider = new ethers.providers.JsonRpcProvider(
`${process.env.L1_RPC}` `${process.env.CERC_L1_RPC}`
) )
// Get the deployment tx receipt // Get the deployment tx receipt

View File

@ -10,6 +10,8 @@ Clone required repositories:
```bash ```bash
laconic-so --stack fixturenet-optimism setup-repositories laconic-so --stack fixturenet-optimism setup-repositories
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
``` ```
Checkout to the required versions and branches in repos: Checkout to the required versions and branches in repos:
@ -109,7 +111,7 @@ docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts
docker volume rm $(docker volume ls -q --filter name=l2_geth_data) docker volume rm $(docker volume ls -q --filter name=l2_geth_data)
``` ```
* Reuse the deployment command used in [Deploy](#deploy) to restart the stopped containers * Re-run the deployment command used in [Deploy](#deploy) to restart the stopped containers
## Known Issues ## Known Issues

View File

@ -10,6 +10,8 @@ Clone required repositories:
```bash ```bash
laconic-so --stack fixturenet-optimism setup-repositories --exclude cerc-io/go-ethereum laconic-so --stack fixturenet-optimism setup-repositories --exclude cerc-io/go-ethereum
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
``` ```
Checkout to the required versions and branches in repos: Checkout to the required versions and branches in repos:
@ -35,16 +37,29 @@ This should create the required docker images in the local image registry:
## Deploy ## Deploy
Update the [l1-params.env](../../config/fixturenet-optimism/l1-params.env) file with L1 endpoint (`L1_RPC`, `L1_HOST` and `L1_PORT`) and other params Create and update an env file to be used in the next step ([defaults](../../config/fixturenet-optimism/l1-params.env)):
* NOTE: ```bash
* Stack Orchestrator needs to be run in [`dev`](/docs/CONTRIBUTING.md#install-developer-mode) mode to be able to edit the env file # External L1 endpoint
* If L1 is running on the host machine, use `host.docker.internal` as the hostname to access the host port CERC_L1_CHAIN_ID=
CERC_L1_RPC=
CERC_L1_HOST=
CERC_L1_PORT=
# Credentials for accounts on L1 to send balance to Optimism Proxy contract from
# (enables them to do transactions on L2)
CERC_L1_ADDRESS=
CERC_L1_PRIV_KEY=
CERC_L1_ADDRESS_2=
CERC_L1_PRIV_KEY_2=
```
* NOTE: If L1 is running on the host machine, use `host.docker.internal` as the hostname to access the host port
Deploy the stack: Deploy the stack:
```bash ```bash
laconic-so --stack fixturenet-optimism deploy up --include fixturenet-optimism laconic-so --stack fixturenet-optimism deploy --include fixturenet-optimism --env-file <PATH_TO_ENV_FILE> up
``` ```
The `fixturenet-optimism-contracts` service may take a while (`~15 mins`) to complete running as it: The `fixturenet-optimism-contracts` service may take a while (`~15 mins`) to complete running as it:
@ -69,7 +84,7 @@ docker logs -f <CONTAINER_ID>
Stop all services running in the background: Stop all services running in the background:
```bash ```bash
laconic-so --stack fixturenet-optimism deploy down --include fixturenet-optimism laconic-so --stack fixturenet-optimism deploy --include fixturenet-optimism down
``` ```
Clear volumes created by this stack: Clear volumes created by this stack:
@ -84,4 +99,4 @@ docker volume rm $(docker volume ls -q --filter "name=.*fixturenet_geth_accounts
## Troubleshooting ## Troubleshooting
See [Troubleshooting](./README.md#troubleshooting) See [Troubleshooting](./README.md#troubleshooting)

View File

@ -1,10 +1,12 @@
# MobyMask v2 watcher # MobyMask v2 watcher
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) Instructions to setup and deploy an end-to-end MobyMask v2 stack ([L1](../fixturenet-eth/) + [L2](../fixturenet-optimism/) chains + watcher + web-app(s)) using [laconic-stack-orchestrator](/README.md#install)
We support running just the watcher part of stack, given an external L2 Optimism endpoint. We support running just the watcher part of stack, given an external L2 Optimism endpoint.
Follow [mobymask-only](./mobymask-only.md) for the same. Follow [mobymask-only](./mobymask-only.md) for the same.
We also support running just the web-app(s), given external watcher GQL (for mobymask-app) and relay node endpoints. Follow [web-apps.md](./web-apps.md) for the same.
## Setup ## Setup
Clone required repositories: Clone required repositories:

View File

@ -10,6 +10,8 @@ Clone required repositories:
```bash ```bash
laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/MobyMask,cerc-io/watcher-ts laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/MobyMask,cerc-io/watcher-ts
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
``` ```
Checkout to the required versions and branches in repos: Checkout to the required versions and branches in repos:
@ -36,19 +38,38 @@ This should create the required docker images in the local image registry
### Configuration ### Configuration
* In [mobymask-params.env](../../config/watcher-mobymask-v2/mobymask-params.env) file set `DEPLOYED_CONTRACT` to existing deployed mobymask contract address Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v2/)):
* Setting `DEPLOYED_CONTRACT` will skip contract deployment when running stack
* `ENABLE_PEER_L2_TXS` is used to enable/disable sending txs to L2 chain from watcher peer. ```bash
* Update the [optimism-params.env](../../config/watcher-mobymask-v2/optimism-params.env) file with Optimism endpoints and other params for the Optimism running separately # External L2 endpoints
* `PRIVATE_KEY_PEER` is used by watcher peer to send txs to L2 chain CERC_L2_GETH_RPC=
* NOTE: CERC_L2_GETH_HOST=
* Stack Orchestrator needs to be run in [`dev`](/docs/CONTRIBUTING.md#install-developer-mode) mode to be able to edit the env file CERC_L2_GETH_PORT=
* If Optimism is running on the host machine, use `host.docker.internal` as the hostname to access the host port
CERC_L2_NODE_HOST=
CERC_L2_NODE_PORT=
# Credentials for accounts to perform txs on L2
CERC_PRIVATE_KEY_DEPLOYER=
CERC_PRIVATE_KEY_PEER=
# Base URI for mobymask-app
# (used for generating a root invite link after deploying the contract)
CERC_MOBYMASK_APP_BASE_URI="http://127.0.0.1:3002/#"
# Set to false for disabling watcher peer to send txs to L2
CERC_ENABLE_PEER_L2_TXS=true
# (Optional) Set already deployed MobyMask contract address to avoid deploying contract in the stack
CERC_DEPLOYED_CONTRACT=
```
* NOTE: If Optimism is running on the host machine, use `host.docker.internal` as the hostname to access the host port
### Deploy the stack ### Deploy the stack
```bash ```bash
laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 up laconic-so --stack mobymask-v2 deploy --include watcher-mobymask-v2 --env-file <PATH_TO_ENV_FILE> up
``` ```
To list down and monitor the running containers: To list down and monitor the running containers:
@ -63,10 +84,22 @@ docker ps
docker logs -f <CONTAINER_ID> docker logs -f <CONTAINER_ID>
``` ```
The watcher endpoint is exposed on host port `3001` and the relay node endpoint is exposed on host port `9090`
Check the logs of the deployment container to get the deployed contract's address and generated root invite link:
```bash
docker logs -f $(docker ps -aq --filter name="mobymask-1")
```
## Tests ## Tests
See [Tests](./README.md#tests) See [Tests](./README.md#tests)
## Web Apps
For deploying the web-app(s) separately after deploying the watcher, follow [web-apps.md](./web-apps.md)
## Clean up ## Clean up
Stop all services running in the background: Stop all services running in the background:

View File

@ -10,6 +10,8 @@ Clone required repositories:
```bash ```bash
laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/react-peer,cerc-io/mobymask-ui laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/react-peer,cerc-io/mobymask-ui
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
``` ```
Checkout to the required versions and branches in repos: Checkout to the required versions and branches in repos:
@ -36,36 +38,61 @@ This should create the required docker images in the local image registry
### Configuration ### Configuration
* Update the [mobymask-params.env](../../config/watcher-mobymask-v2/mobymask-params.env) file with watcher endpoints and other params required by the web-apps Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v2/mobymask-params.env)):
* `WATCHER_HOST` and `WATCHER_PORT` is used to check if watcher is up before building and deploying mobymask-app
* `APP_WATCHER_URL` is used by mobymask-app to make GQL queries ```bash
* `DEPLOYED_CONTRACT` and `CHAIN_ID` is used by mobymask-app in app config when creating messgaes for L2 txs # Set relay nodes to be used by the web-app
* `RELAY_NODES` is used by the web-apps to connect to the relay nodes (run in watcher) CERC_RELAY_NODES=["/ip4/127.0.0.1/tcp/9090/ws/p2p/12D3KooWSPCsVkHVyLQoCqhu2YRPvvM7o6r6NRYyLM5zeA6Uig5t"]
* NOTE:
* Stack Orchestrator needs to be run in [`dev`](/docs/CONTRIBUTING.md#install-developer-mode) mode to be able to edit the env file # Also add if running MobyMask app:
* If watcher is running on the host machine, use `host.docker.internal` as the hostname to access the host port
# External watcher endpoint (to check if watcher is up)
CERC_WATCHER_HOST=
CERC_WATCHER_PORT=
# Watcher endpoint used by the app for GQL queries
CERC_APP_WATCHER_URL="http://127.0.0.1:3001"
# Set deployed MobyMask contract address to be used in MobyMask app's config
CERC_DEPLOYED_CONTRACT=
# L2 Chain ID used by mobymask web-app for L2 txs
CERC_CHAIN_ID=42069
```
* NOTE: If watcher is running on the host machine, use `host.docker.internal` as the hostname to access the host port
### Deploy the stack ### Deploy the stack
For running mobymask-app For running mobymask-app
```bash ```bash
laconic-so --stack mobymask-v2 deploy --include mobymask-app up laconic-so --stack mobymask-v2 deploy --include mobymask-app --env-file <PATH_TO_ENV_FILE> up
# Runs on host port 3002
``` ```
For running peer-test-app For running peer-test-app
```bash ```bash
laconic-so --stack mobymask-v2 deploy --include peer-test-app up laconic-so --stack mobymask-v2 deploy --include peer-test-app --env-file <PATH_TO_ENV_FILE> up
# Runs on host port 3003
``` ```
To list down and monitor the running containers: To list down and monitor the running containers:
```bash ```bash
laconic-so --stack mobymask-v2 deploy --include [mobymask-app | peer-test-app] ps
docker ps docker ps
# Check logs for a container # Check logs for a container
docker logs -f <CONTAINER_ID> docker logs -f <CONTAINER_ID>
``` ```
## Demo
Follow the [demo](./demo.md) to try out the MobyMask app with L2 chain
## Clean up ## Clean up
Stop all services running in the background: Stop all services running in the background:

View File

@ -32,11 +32,12 @@ from .util import include_exclude_check, get_parsed_stack_config
@click.command() @click.command()
@click.option("--include", help="only start these components") @click.option("--include", help="only start these components")
@click.option("--exclude", help="don\'t start these components") @click.option("--exclude", help="don\'t start these components")
@click.option("--env-file", help="env file to be used")
@click.option("--cluster", help="specify a non-default cluster name") @click.option("--cluster", help="specify a non-default cluster name")
@click.argument('command', required=True) # help: command: up|down|ps @click.argument('command', required=True) # help: command: up|down|ps
@click.argument('extra_args', nargs=-1) # help: command: up|down|ps <service1> <service2> @click.argument('extra_args', nargs=-1) # help: command: up|down|ps <service1> <service2>
@click.pass_context @click.pass_context
def command(ctx, include, exclude, cluster, command, extra_args): def command(ctx, include, exclude, env_file, cluster, command, extra_args):
'''deploy a stack''' '''deploy a stack'''
# TODO: implement option exclusion and command value constraint lost with the move from argparse to click # TODO: implement option exclusion and command value constraint lost with the move from argparse to click
@ -51,7 +52,7 @@ def command(ctx, include, exclude, cluster, command, extra_args):
cluster_context = _make_cluster_context(ctx.obj, include, exclude, cluster) cluster_context = _make_cluster_context(ctx.obj, include, exclude, cluster)
# See: https://gabrieldemarmiesse.github.io/python-on-whales/sub-commands/compose/ # See: https://gabrieldemarmiesse.github.io/python-on-whales/sub-commands/compose/
docker = DockerClient(compose_files=cluster_context.compose_files, compose_project_name=cluster_context.cluster) docker = DockerClient(compose_files=cluster_context.compose_files, compose_project_name=cluster_context.cluster, compose_env_file=env_file)
extra_args_list = list(extra_args) or None extra_args_list = list(extra_args) or None