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'
|
version: '3.7'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Deploys the Nitro contracts
|
# Optionally deploys the Nitro contracts
|
||||||
nitro-contracts:
|
nitro-contracts:
|
||||||
image: cerc/nitro-contracts:local
|
image: cerc/nitro-contracts:local
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
|
@ -62,7 +62,6 @@ services:
|
|||||||
- ../config/watcher-mobymask-v2/generate-peer-ids.sh:/app/packages/peer/generate-peer-ids.sh
|
- ../config/watcher-mobymask-v2/generate-peer-ids.sh:/app/packages/peer/generate-peer-ids.sh
|
||||||
- peers_ids:/peer-ids
|
- peers_ids:/peer-ids
|
||||||
|
|
||||||
# Optionally deploys the Nitro contracts; sets them at the required path
|
|
||||||
# Starts the MobyMask v3 watcher server
|
# Starts the MobyMask v3 watcher server
|
||||||
mobymask-watcher-server:
|
mobymask-watcher-server:
|
||||||
image: cerc/watcher-mobymask-v3:local
|
image: cerc/watcher-mobymask-v3:local
|
||||||
@ -104,7 +103,7 @@ services:
|
|||||||
- ../config/watcher-mobymask-v3/start-server.sh:/app/start-server.sh
|
- ../config/watcher-mobymask-v3/start-server.sh:/app/start-server.sh
|
||||||
- nitro_data:/app/out/nitro-db
|
- nitro_data:/app/out/nitro-db
|
||||||
- peers_ids:/app/peers
|
- peers_ids:/app/peers
|
||||||
- nitro_addresses:/nitro
|
- nitro_deployment:/nitro
|
||||||
- mobymask_deployment:/server
|
- mobymask_deployment:/server
|
||||||
# Expose GQL, metrics and relay node ports
|
# Expose GQL, metrics and relay node ports
|
||||||
ports:
|
ports:
|
||||||
@ -124,5 +123,5 @@ volumes:
|
|||||||
mobymask_watcher_db_data:
|
mobymask_watcher_db_data:
|
||||||
peers_ids:
|
peers_ids:
|
||||||
mobymask_deployment:
|
mobymask_deployment:
|
||||||
nitro_addresses:
|
nitro_deployment:
|
||||||
nitro_data:
|
nitro_data:
|
||||||
|
@ -5,7 +5,7 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|||||||
set -x
|
set -x
|
||||||
fi
|
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
|
# Check if CERC_NA_ADDRESS environment variable set to skip contract deployment
|
||||||
if [ -n "$CERC_NA_ADDRESS" ]; then
|
if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||||
@ -17,17 +17,19 @@ if [ -n "$CERC_NA_ADDRESS" ]; then
|
|||||||
NA_ADDRESS=${CERC_NA_ADDRESS}
|
NA_ADDRESS=${CERC_NA_ADDRESS}
|
||||||
VPA_ADDRESS=${CERC_VPA_ADDRESS}
|
VPA_ADDRESS=${CERC_VPA_ADDRESS}
|
||||||
CA_ADDRESS=${CERC_CA_ADDRESS}
|
CA_ADDRESS=${CERC_CA_ADDRESS}
|
||||||
elif [ -f ${NITRO_ADDRESSES_FILE_PATH} ]; then
|
elif [ -f ${nitro_addresses_file} ]; then
|
||||||
echo "Reading Nitro addresses from ${NITRO_ADDRESSES_FILE_PATH}"
|
echo "Reading Nitro addresses from ${nitro_addresses_file}"
|
||||||
|
|
||||||
NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${NITRO_ADDRESSES_FILE_PATH})
|
NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${nitro_addresses_file})
|
||||||
VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${NITRO_ADDRESSES_FILE_PATH})
|
VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${nitro_addresses_file})
|
||||||
CA_ADDRESS=$(jq -r '.consensusAppAddress' ${NITRO_ADDRESSES_FILE_PATH})
|
CA_ADDRESS=$(jq -r '.consensusAppAddress' ${nitro_addresses_file})
|
||||||
else
|
else
|
||||||
echo "${NITRO_ADDRESSES_FILE_PATH} not found"
|
echo "File ${nitro_addresses_file} not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Running Nitro node"
|
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}
|
./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
|
set -x
|
||||||
fi
|
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
|
# Check if CERC_NA_ADDRESS environment variable set to skip contract deployment
|
||||||
if [ -n "$CERC_NA_ADDRESS" ]; then
|
if [ -n "$CERC_NA_ADDRESS" ]; then
|
||||||
@ -17,8 +17,9 @@ if [ -n "$CERC_NA_ADDRESS" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check and exit if a deployment already exists (on restarts)
|
# Check and exit if a deployment already exists (on restarts)
|
||||||
if [ -f ${NITRO_ADDRESSES_FILE_PATH} ]; then
|
if [ -f ${nitro_addresses_file} ]; then
|
||||||
echo "${NITRO_ADDRESSES_FILE_PATH} already exists, skipping Nitro contracts deployment"
|
echo "${nitro_addresses_file} already exists, skipping Nitro contracts deployment"
|
||||||
|
cat ${nitro_addresses_file}
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -53,4 +54,5 @@ done
|
|||||||
# TODO: Fetch pk from ACCOUNTS_CSV_URL?
|
# TODO: Fetch pk from ACCOUNTS_CSV_URL?
|
||||||
echo "Using CERC_PRIVATE_KEY_DEPLOYER from env"
|
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_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}}"
|
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"
|
watcher_keys_dir="./keys"
|
||||||
|
|
||||||
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
|
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
|
||||||
@ -37,18 +34,35 @@ else
|
|||||||
CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"')
|
CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the deployed Nitro addresses to the required path
|
nitro_addresses_file="/nitro/nitro-addresses.json"
|
||||||
if [ -f "$nitro_addresses_file" ]; then
|
nitro_addresses_destination_file="./src/nitro-addresses.json"
|
||||||
cat "$nitro_addresses_file" > "$nitro_addresses_destination_file"
|
|
||||||
echo "Nitro addresses set to ${nitro_addresses_destination_file}"
|
|
||||||
|
|
||||||
# Build after setting the Nitro addresses
|
# Check if CERC_NA_ADDRESS environment variable is set
|
||||||
yarn build
|
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
|
else
|
||||||
echo "File ${nitro_addresses_file} does not exist"
|
echo "File ${nitro_addresses_file} not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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_PEER (account with funds) from env for sending txs to L2"
|
||||||
echo "Using CERC_PRIVATE_KEY_NITRO from env for Nitro account"
|
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/lighthouse
|
||||||
- github.com/cerc-io/ipld-eth-db
|
- github.com/cerc-io/ipld-eth-db
|
||||||
- github.com/cerc-io/ipld-eth-server
|
- github.com/cerc-io/ipld-eth-server
|
||||||
|
# nitro repos
|
||||||
- github.com/cerc-io/ts-nitro
|
- github.com/cerc-io/ts-nitro
|
||||||
- github.com/cerc-io/go-nitro@pm-disable-compression
|
- github.com/cerc-io/go-nitro@pm-disable-compression
|
||||||
containers:
|
containers:
|
||||||
|
@ -2,15 +2,18 @@ version: "1.0"
|
|||||||
description: "MobyMask v3 stack"
|
description: "MobyMask v3 stack"
|
||||||
name: mobymask-v3
|
name: mobymask-v3
|
||||||
repos:
|
repos:
|
||||||
|
- github.com/cerc-io/ts-nitro
|
||||||
- github.com/cerc-io/watcher-ts@v0.2.57
|
- github.com/cerc-io/watcher-ts@v0.2.57
|
||||||
- github.com/cerc-io/mobymask-v2-watcher-ts@v3
|
- github.com/cerc-io/mobymask-v2-watcher-ts@v3
|
||||||
- github.com/cerc-io/MobyMask@v0.1.3
|
- github.com/cerc-io/MobyMask@v0.1.3
|
||||||
- github.com/cerc-io/mobymask-ui
|
- github.com/cerc-io/mobymask-ui
|
||||||
containers:
|
containers:
|
||||||
|
- cerc/nitro-contracts
|
||||||
- cerc/watcher-ts
|
- cerc/watcher-ts
|
||||||
- cerc/watcher-mobymask-v3
|
- cerc/watcher-mobymask-v3
|
||||||
- cerc/mobymask
|
- cerc/mobymask
|
||||||
- cerc/mobymask-ui
|
- cerc/mobymask-ui
|
||||||
pods:
|
pods:
|
||||||
|
- nitro-contracts
|
||||||
- watcher-mobymask-v3
|
- watcher-mobymask-v3
|
||||||
- mobymask-app-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
|
### Deploy the stack
|
||||||
|
|
||||||
```bash
|
```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:
|
* To list down and monitor the running containers:
|
||||||
|
|
||||||
```bash
|
```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
|
# With status
|
||||||
docker ps -a
|
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")
|
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
|
```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
|
## 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:
|
Stop all services running in the background:
|
||||||
|
|
||||||
```bash
|
```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:
|
Clear volumes created by this stack:
|
||||||
|
Loading…
Reference in New Issue
Block a user