Use container to deploy Nitro contracts in mobymask-v3 stack
This commit is contained in:
parent
0b30f911be
commit
f1cb56d0f1
@ -1,7 +1,7 @@
|
||||
version: '3.7'
|
||||
|
||||
services:
|
||||
# Deploys the Nitro contracts
|
||||
# Optionally deploys the Nitro contracts
|
||||
nitro-contracts:
|
||||
image: cerc/nitro-contracts:local
|
||||
restart: on-failure
|
||||
|
@ -62,7 +62,6 @@ services:
|
||||
- ../config/watcher-mobymask-v2/generate-peer-ids.sh:/app/packages/peer/generate-peer-ids.sh
|
||||
- peers_ids:/peer-ids
|
||||
|
||||
# Optionally deploys the Nitro contracts; sets them at the required path
|
||||
# Starts the MobyMask v3 watcher server
|
||||
mobymask-watcher-server:
|
||||
image: cerc/watcher-mobymask-v3:local
|
||||
@ -104,7 +103,7 @@ services:
|
||||
- ../config/watcher-mobymask-v3/start-server.sh:/app/start-server.sh
|
||||
- nitro_data:/app/out/nitro-db
|
||||
- peers_ids:/app/peers
|
||||
- nitro_addresses:/nitro
|
||||
- nitro_deployment:/nitro
|
||||
- mobymask_deployment:/server
|
||||
# Expose GQL, metrics and relay node ports
|
||||
ports:
|
||||
@ -124,5 +123,5 @@ volumes:
|
||||
mobymask_watcher_db_data:
|
||||
peers_ids:
|
||||
mobymask_deployment:
|
||||
nitro_addresses:
|
||||
nitro_deployment:
|
||||
nitro_data:
|
||||
|
@ -5,7 +5,7 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
NITRO_ADDRESSES_FILE_PATH="/app/deployment/nitro-addresses.json"
|
||||
nitro_addresses_file="/app/deployment/nitro-addresses.json"
|
||||
|
||||
# Check if CERC_NA_ADDRESS environment variable set to skip contract deployment
|
||||
if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||
@ -17,17 +17,19 @@ if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||
NA_ADDRESS=${CERC_NA_ADDRESS}
|
||||
VPA_ADDRESS=${CERC_VPA_ADDRESS}
|
||||
CA_ADDRESS=${CERC_CA_ADDRESS}
|
||||
elif [ -f ${NITRO_ADDRESSES_FILE_PATH} ]; then
|
||||
echo "Reading Nitro addresses from ${NITRO_ADDRESSES_FILE_PATH}"
|
||||
elif [ -f ${nitro_addresses_file} ]; then
|
||||
echo "Reading Nitro addresses from ${nitro_addresses_file}"
|
||||
|
||||
NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${NITRO_ADDRESSES_FILE_PATH})
|
||||
VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${NITRO_ADDRESSES_FILE_PATH})
|
||||
CA_ADDRESS=$(jq -r '.consensusAppAddress' ${NITRO_ADDRESSES_FILE_PATH})
|
||||
NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${nitro_addresses_file})
|
||||
VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${nitro_addresses_file})
|
||||
CA_ADDRESS=$(jq -r '.consensusAppAddress' ${nitro_addresses_file})
|
||||
else
|
||||
echo "${NITRO_ADDRESSES_FILE_PATH} not found"
|
||||
echo "File ${nitro_addresses_file} not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Running Nitro node"
|
||||
|
||||
# TODO Wait for RPC endpoint to come up
|
||||
|
||||
./nitro -chainurl ${NITRO_CHAIN_URL} -msgport 3005 -rpcport 4005 -wsmsgport 5005 -pk ${NITRO_PK} -chainpk ${NITRO_CHAIN_PK} -naaddress ${NA_ADDRESS} -vpaaddress ${VPA_ADDRESS} -caaddress ${CA_ADDRESS} -usedurablestore ${NITRO_USE_DURABLE_STORE} -durablestorefolder ${NITRO_DURABLE_STORE_FOLDER}
|
||||
|
@ -5,7 +5,7 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
NITRO_ADDRESSES_FILE_PATH="/app/deployment/nitro-addresses.json"
|
||||
nitro_addresses_file="/app/deployment/nitro-addresses.json"
|
||||
|
||||
# Check if CERC_NA_ADDRESS environment variable set to skip contract deployment
|
||||
if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||
@ -17,8 +17,9 @@ if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||
fi
|
||||
|
||||
# Check and exit if a deployment already exists (on restarts)
|
||||
if [ -f ${NITRO_ADDRESSES_FILE_PATH} ]; then
|
||||
echo "${NITRO_ADDRESSES_FILE_PATH} already exists, skipping Nitro contracts deployment"
|
||||
if [ -f ${nitro_addresses_file} ]; then
|
||||
echo "${nitro_addresses_file} already exists, skipping Nitro contracts deployment"
|
||||
cat ${nitro_addresses_file}
|
||||
exit
|
||||
fi
|
||||
|
||||
@ -53,4 +54,5 @@ done
|
||||
# TODO: Fetch pk from ACCOUNTS_CSV_URL?
|
||||
echo "Using CERC_PRIVATE_KEY_DEPLOYER from env"
|
||||
|
||||
yarn test:deploy-contracts --chainurl ${CERC_ETH_RPC_ENDPOINT} --key ${CERC_PRIVATE_KEY_DEPLOYER} --addressesFilePath ${NITRO_ADDRESSES_FILE_PATH}
|
||||
yarn test:deploy-contracts --chainurl ${CERC_ETH_RPC_ENDPOINT} --key ${CERC_PRIVATE_KEY_DEPLOYER} --addressesFilePath ${nitro_addresses_file}
|
||||
cat ${nitro_addresses_file}
|
||||
|
@ -14,9 +14,6 @@ CERC_RELAY_ANNOUNCE_DOMAIN="${CERC_RELAY_ANNOUNCE_DOMAIN:-${DEFAULT_CERC_RELAY_A
|
||||
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}}"
|
||||
|
||||
nitro_addresses_file="/nitro/nitro-addresses.json"
|
||||
nitro_addresses_destination_file="./src/nitro-addresses.json"
|
||||
|
||||
watcher_keys_dir="./keys"
|
||||
|
||||
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
|
||||
@ -37,18 +34,35 @@ else
|
||||
CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"')
|
||||
fi
|
||||
|
||||
# Copy the deployed Nitro addresses to the required path
|
||||
if [ -f "$nitro_addresses_file" ]; then
|
||||
cat "$nitro_addresses_file" > "$nitro_addresses_destination_file"
|
||||
echo "Nitro addresses set to ${nitro_addresses_destination_file}"
|
||||
nitro_addresses_file="/nitro/nitro-addresses.json"
|
||||
nitro_addresses_destination_file="./src/nitro-addresses.json"
|
||||
|
||||
# Build after setting the Nitro addresses
|
||||
yarn build
|
||||
# Check if CERC_NA_ADDRESS environment variable is set
|
||||
if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
|
||||
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
|
||||
echo "CERC_CA_ADDRESS is set to '$CERC_CA_ADDRESS'"
|
||||
echo "Using the above Nitro addresses"
|
||||
|
||||
# Create the required JSON and write it to a file
|
||||
nitro_addresses_json=$(jq -n \
|
||||
--arg na "$CERC_NA_ADDRESS" \
|
||||
--arg vpa "$CERC_VPA_ADDRESS" \
|
||||
--arg ca "$CERC_CA_ADDRESS" \
|
||||
'.nitroAdjudicatorAddress = $na | .virtualPaymentAppAddress = $vpa | .consensusAppAddress = $ca')
|
||||
echo "$nitro_addresses_json" > "${nitro_addresses_destination_file}"
|
||||
elif [ -f ${nitro_addresses_file} ]; then
|
||||
echo "Using Nitro addresses from ${nitro_addresses_file}:"
|
||||
cat "$nitro_addresses_file"
|
||||
cat "$nitro_addresses_file" > "$nitro_addresses_destination_file"
|
||||
else
|
||||
echo "File ${nitro_addresses_file} does not exist"
|
||||
echo "File ${nitro_addresses_file} not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build after setting the Nitro addresses
|
||||
yarn build
|
||||
|
||||
echo "Using CERC_PRIVATE_KEY_PEER (account with funds) from env for sending txs to L2"
|
||||
echo "Using CERC_PRIVATE_KEY_NITRO from env for Nitro account"
|
||||
|
||||
|
@ -7,6 +7,7 @@ repos:
|
||||
- github.com/cerc-io/lighthouse
|
||||
- github.com/cerc-io/ipld-eth-db
|
||||
- github.com/cerc-io/ipld-eth-server
|
||||
# nitro repos
|
||||
- github.com/cerc-io/ts-nitro
|
||||
- github.com/cerc-io/go-nitro@pm-disable-compression
|
||||
containers:
|
||||
|
@ -2,15 +2,18 @@ version: "1.0"
|
||||
description: "MobyMask v3 stack"
|
||||
name: mobymask-v3
|
||||
repos:
|
||||
- github.com/cerc-io/ts-nitro
|
||||
- github.com/cerc-io/watcher-ts@v0.2.57
|
||||
- github.com/cerc-io/mobymask-v2-watcher-ts@v3
|
||||
- github.com/cerc-io/MobyMask@v0.1.3
|
||||
- github.com/cerc-io/mobymask-ui
|
||||
containers:
|
||||
- cerc/nitro-contracts
|
||||
- cerc/watcher-ts
|
||||
- cerc/watcher-mobymask-v3
|
||||
- cerc/mobymask
|
||||
- cerc/mobymask-ui
|
||||
pods:
|
||||
- nitro-contracts
|
||||
- watcher-mobymask-v3
|
||||
- mobymask-app-v3
|
||||
|
@ -83,13 +83,13 @@ Create and update an env file to be used in the next step ([defaults](../../conf
|
||||
### Deploy the stack
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mobymask-v3 --env-file <PATH_TO_ENV_FILE> up
|
||||
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-app-v3 --env-file <PATH_TO_ENV_FILE> up
|
||||
```
|
||||
|
||||
* To list down and monitor the running containers:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mobymask-v3 ps
|
||||
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-app-v3 ps
|
||||
|
||||
# With status
|
||||
docker ps -a
|
||||
@ -106,10 +106,10 @@ laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mo
|
||||
docker logs -f $(docker ps -aq --filter name="mobymask-1")
|
||||
```
|
||||
|
||||
* Check the logs of the watcher server container to get the deployed Nitro contracts' addresses:
|
||||
* Check logs of the Nitro contracts container to get the deployed Nitro contracts' addresses:
|
||||
|
||||
```bash
|
||||
docker exec -it $(docker ps -q --filter name="mobymask-watcher-server") bash -c "cat /nitro/nitro-addresses.json"
|
||||
docker exec -it $(docker ps -q --filter name="nitro-contracts") bash -c "cat /app/deployment/nitro-addresses.json"
|
||||
```
|
||||
|
||||
## Clean up
|
||||
@ -117,7 +117,7 @@ docker exec -it $(docker ps -q --filter name="mobymask-watcher-server") bash -c
|
||||
Stop all services running in the background:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mobymask-v3 down
|
||||
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-app-v3 down
|
||||
```
|
||||
|
||||
Clear volumes created by this stack:
|
||||
|
Loading…
Reference in New Issue
Block a user