Add a fixturenet-payments stack (#540)

* Add a fixturenet-payments stack

* Export the WebSocket port in fixturenet-eth-geth service

* Add container to run a go-nitro node

* Add container to deploy Nitro contracts

* Read contract addresses from a volume when running the Nitro node

* Add a service for Nitro reverse payment proxy

* Expose payment proxy endpoint to be accessible from host

* Map nitro node messaging and payment proxy ports to host

* Use container to deploy Nitro contracts in mobymask-v3 stack

* Use a common contract deployment script from mobymask-v3 stack

* Add MobyMask contract deployment and watcher services

* Fixes for contract deployment and watcher scripts

* Add a container and service for mobymask-snap

* Add MobyMask app service

* Add container and service for a ponder app

* Fix ponder setup and update instructions

* Handle review comments

* Use enablepaidrpcmethods flag in reverse payment proxy server

* Update go-nitro branch

* Fixes for mobymask-v3 stack

---------

Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
This commit is contained in:
prathamesh0 2023-10-03 17:40:34 +05:30 committed by GitHub
parent b485a3b8d8
commit cf039d9562
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 836 additions and 212 deletions

View File

@ -40,6 +40,7 @@ services:
- fixturenet-eth-bootnode-geth - fixturenet-eth-bootnode-geth
ports: ports:
- "8545" - "8545"
- "8546"
- "40000" - "40000"
- "6060" - "6060"

View File

@ -0,0 +1,39 @@
version: '3.7'
services:
go-nitro:
image: cerc/go-nitro:local
hostname: go-nitro
restart: on-failure
depends_on:
# Wait for Nitro contracts to be deployed
nitro-contracts:
condition: service_completed_successfully
environment:
NITRO_CHAIN_URL: ${NITRO_CHAIN_URL:-ws://fixturenet-eth-geth-1:8546}
NITRO_PK: ${NITRO_PK:-2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d}
NITRO_CHAIN_PK: ${NITRO_CHAIN_PK:-570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597}
NITRO_USE_DURABLE_STORE: ${NITRO_USE_DURABLE_STORE:-true}
NITRO_DURABLE_STORE_FOLDER: ${NITRO_DURABLE_STORE_FOLDER:-/app/data/nitro-store}
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
entrypoint: ["bash", "-c", "/app/run-nitro-node.sh"]
volumes:
- go_nitro_data:/app/data
- nitro_deployment:/app/deployment
- ../config/go-nitro/run-nitro-node.sh:/app/run-nitro-node.sh
healthcheck:
test: ["CMD", "nc", "-vz", "localhost", "4005"]
interval: 10s
timeout: 5s
retries: 10
start_period: 10s
ports:
- "3005"
- "4005"
- "5005:5005"
volumes:
go_nitro_data:
nitro_deployment:

View File

@ -15,18 +15,19 @@ services:
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS} CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
CERC_PUBSUB: ${CERC_PUBSUB} CERC_PUBSUB: ${CERC_PUBSUB}
CERC_GOSSIPSUB_DIRECT_PEERS: ${CERC_GOSSIPSUB_DIRECT_PEERS} CERC_GOSSIPSUB_DIRECT_PEERS: ${CERC_GOSSIPSUB_DIRECT_PEERS}
CERC_RELEASE: "laconic-v3"
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS} CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS} CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS} CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL} CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL}
CERC_PAYMENT_NITRO_ADDRESS: ${CERC_PAYMENT_NITRO_ADDRESS} CERC_PAYMENT_NITRO_ADDRESS: ${CERC_PAYMENT_NITRO_ADDRESS:-0xBBB676f9cFF8D242e9eaC39D063848807d3D1D94}
CERC_SNAP_URL: ${CERC_SNAP_URL} CERC_SNAP_URL: ${CERC_SNAP_URL}
working_dir: /scripts working_dir: /app
command: ["sh", "mobymask-app-start.sh"] command: ["bash", "/scripts/mobymask-app-start.sh"]
volumes: volumes:
- ../config/watcher-mobymask-v3/mobymask-app-start.sh:/scripts/mobymask-app-start.sh - ../config/watcher-mobymask-v3/mobymask-app-start.sh:/scripts/mobymask-app-start.sh
- ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/mobymask-app-config.json - peers_ids:/peers
- mobymask_deployment:/server
- nitro_deployment:/nitro
ports: ports:
- "127.0.0.1:3004:80" - "127.0.0.1:3004:80"
healthcheck: healthcheck:
@ -37,3 +38,8 @@ services:
start_period: 10s start_period: 10s
extra_hosts: extra_hosts:
- "host.docker.internal:host-gateway" - "host.docker.internal:host-gateway"
volumes:
peers_ids:
mobymask_deployment:
nitro_deployment:

View File

@ -0,0 +1,14 @@
version: '3.7'
services:
mobymask-snap:
restart: unless-stopped
image: cerc/mobymask-snap:local
ports:
- "127.0.0.1:8080:8080"
healthcheck:
test: ["CMD", "nc", "-vz", "localhost", "8080"]
interval: 10s
timeout: 5s
retries: 10
start_period: 10s

View File

@ -0,0 +1,23 @@
version: '3.7'
services:
# Optionally deploys the Nitro contracts
nitro-contracts:
image: cerc/nitro-contracts:local
restart: on-failure
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT:-http://fixturenet-eth-geth-1:8545}
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER:-0x888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218}
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
volumes:
- ../config/nitro-contracts/deploy.sh:/app/deploy.sh
- nitro_deployment:/app/deployment
command: ["bash", "-c", "/app/deploy.sh"]
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
nitro_deployment:

View File

@ -0,0 +1,27 @@
version: '3.7'
services:
nitro-reverse-payment-proxy:
image: cerc/go-nitro:local
hostname: nitro-reverse-payment-proxy
restart: on-failure
depends_on:
# Wait for the go-nitro node to start
go-nitro:
condition: service_healthy
environment:
PROXY_ADDRESS: 0.0.0.0:8081
PROXY_NITRO_ENDPOINT: ${PROXY_NITRO_ENDPOINT:-go-nitro:4005/api/v1}
PROXY_DESTINATION_URL: ${PROXY_DESTINATION_URL:-http://ipld-eth-server:8081}
PROXY_COST_PER_BYTE: ${PROXY_COST_PER_BYTE:-1}
entrypoint: ["bash", "-c", "/app/run-reverse-payment-proxy.sh"]
volumes:
- ../config/go-nitro/run-reverse-payment-proxy.sh:/app/run-reverse-payment-proxy.sh
healthcheck:
test: ["CMD", "nc", "-vz", "localhost", "8081"]
interval: 10s
timeout: 5s
retries: 10
start_period: 10s
ports:
- "8081:8081"

View File

@ -0,0 +1,31 @@
version: '3.7'
services:
ponder-app:
restart: unless-stopped
image: cerc/ponder:local
working_dir: /app/examples/token-erc20
environment:
PONDER_CHAIN_ID: ${PONDER_CHAIN_ID:-99}
PONDER_RPC_URL_1: ${PONDER_RPC_URL_1:-http://nitro-reverse-payment-proxy:8081}
CERC_PONDER_NITRO_PK: ${CERC_PONDER_NITRO_PK:-58368d20ff12f17669c06158c21d885897aa56f9be430edc789614bf9851d53f}
CERC_PONDER_NITRO_CHAIN_PK: ${CERC_PONDER_NITRO_CHAIN_PK:-fb1e9af328c283ca3e2486e7c24d13582b7912057d8b9542ff41503c85bc05c0}
CERC_PONDER_NITRO_CHAIN_URL: ${CERC_PONDER_NITRO_CHAIN_URL:-http://fixturenet-eth-geth-1:8545}
CERC_RELAY_MULTIADDR: ${CERC_RELAY_MULTIADDR}
CERC_UPSTREAM_NITRO_ADDRESS: ${CERC_UPSTREAM_NITRO_ADDRESS:-0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE}
CERC_UPSTREAM_NITRO_MULTIADDR: ${CERC_UPSTREAM_NITRO_MULTIADDR:-/dns4/go-nitro/tcp/5005/ws/p2p/16Uiu2HAmSjXJqsyBJgcBUU2HQmykxGseafSatbpq5471XmuaUqyv}
CERC_UPSTREAM_NITRO_PAY_AMOUNT: ${CERC_UPSTREAM_NITRO_PAY_AMOUNT:-5000}
command: ["bash", "./ponder-start.sh"]
volumes:
- ../config/ponder/ponder-start.sh:/app/examples/token-erc20/ponder-start.sh
- ../config/ponder/ponder.config.ts:/app/examples/token-erc20/ponder.config.ts
- peers_ids:/peers
- nitro_deployment:/nitro
- ponder_nitro_data:/app/examples/token-erc20/.ponder/nitro-db
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
peers_ids:
nitro_deployment:
ponder_nitro_data:

View File

@ -32,20 +32,13 @@ services:
environment: environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
ENV: "PROD" ENV: "PROD"
CERC_L2_GETH_RPC: ${CERC_L2_GETH_RPC} CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT}
CERC_L1_ACCOUNTS_CSV_URL: ${CERC_L1_ACCOUNTS_CSV_URL} CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER:-0x888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218}
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER}
CERC_MOBYMASK_APP_BASE_URI: ${CERC_MOBYMASK_APP_BASE_URI} CERC_MOBYMASK_APP_BASE_URI: ${CERC_MOBYMASK_APP_BASE_URI}
CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT} CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT}
CERC_L2_GETH_HOST: ${CERC_L2_GETH_HOST} command: ["bash", "-c", "./deploy-and-generate-invite.sh"]
CERC_L2_GETH_PORT: ${CERC_L2_GETH_PORT}
CERC_L2_NODE_HOST: ${CERC_L2_NODE_HOST}
CERC_L2_NODE_PORT: ${CERC_L2_NODE_PORT}
command: ["sh", "deploy-and-generate-invite.sh"]
volumes: volumes:
- ../config/network/wait-for-it.sh:/app/packages/server/wait-for-it.sh - ../config/watcher-mobymask-v3/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh
- ../config/watcher-mobymask-v2/secrets-template.json:/app/packages/server/secrets-template.json
- ../config/watcher-mobymask-v2/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh
- mobymask_deployment:/app/packages/server - mobymask_deployment:/app/packages/server
extra_hosts: extra_hosts:
- "host.docker.internal:host-gateway" - "host.docker.internal:host-gateway"
@ -62,7 +55,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
@ -74,13 +66,14 @@ services:
condition: service_completed_successfully condition: service_completed_successfully
mobymask: mobymask:
condition: service_completed_successfully condition: service_completed_successfully
nitro-contracts:
condition: service_completed_successfully
env_file: env_file:
- ../config/watcher-mobymask-v3/mobymask-params.env - ../config/watcher-mobymask-v3/mobymask-params.env
environment: environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_L2_GETH_RPC: ${CERC_L2_GETH_RPC} CERC_ETH_RPC_QUERY_ENDPOINT: ${CERC_ETH_RPC_QUERY_ENDPOINT}
CERC_L1_ACCOUNTS_CSV_URL: ${CERC_L1_ACCOUNTS_CSV_URL} CERC_ETH_RPC_MUTATION_ENDPOINT: ${CERC_ETH_RPC_MUTATION_ENDPOINT}
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER}
CERC_RELAY_PEERS: ${CERC_RELAY_PEERS} CERC_RELAY_PEERS: ${CERC_RELAY_PEERS}
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS} CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
CERC_PUBSUB: ${CERC_PUBSUB} CERC_PUBSUB: ${CERC_PUBSUB}
@ -90,21 +83,22 @@ services:
CERC_NA_ADDRESS: ${CERC_NA_ADDRESS} CERC_NA_ADDRESS: ${CERC_NA_ADDRESS}
CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS} CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS}
CERC_CA_ADDRESS: ${CERC_CA_ADDRESS} CERC_CA_ADDRESS: ${CERC_CA_ADDRESS}
CERC_PRIVATE_KEY_PEER: ${CERC_PRIVATE_KEY_PEER} CERC_PRIVATE_KEY_PEER: ${CERC_PRIVATE_KEY_PEER:-111b7500bdce494d6f4bcfe8c2a0dde2ef92f751d9070fac6475dbd6d8021b3f}
CERC_PRIVATE_KEY_NITRO: ${CERC_PRIVATE_KEY_NITRO} CERC_WATCHER_NITRO_PK: ${CERC_WATCHER_NITRO_PK:-0279651921cd800ac560c21ceea27aab0107b67daf436cdd25ce84cad30159b4}
CERC_PEER_ID: ${CERC_PEER_ID} CERC_PEER_ID: ${CERC_PEER_ID}
entrypoint: ["bash", "-c"] CERC_ENABLE_UPSTREAM_PAYMENTS: ${CERC_ENABLE_UPSTREAM_PAYMENTS}
command: ["./deploy-nitro-contracts.sh && ./start-server.sh"] CERC_UPSTREAM_NITRO_ADDRESS: ${CERC_UPSTREAM_NITRO_ADDRESS:-0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE}
CERC_UPSTREAM_NITRO_MULTIADDR: ${CERC_UPSTREAM_NITRO_MULTIADDR:-/dns4/go-nitro/tcp/5005/ws/p2p/16Uiu2HAmSjXJqsyBJgcBUU2HQmykxGseafSatbpq5471XmuaUqyv}
CERC_UPSTREAM_NITRO_PAY_AMOUNT: ${CERC_UPSTREAM_NITRO_PAY_AMOUNT:-5000}
command: ["bash", "./start-server.sh"]
volumes: volumes:
- ../config/watcher-mobymask-v3/deploy-nitro-contracts.sh:/app/deploy-nitro-contracts.sh
- ../config/watcher-mobymask-v3/deploy-nitro-contracts.ts:/app/deploy-nitro-contracts.ts
- ../config/watcher-mobymask-v3/watcher-config-template.toml:/app/environments/watcher-config-template.toml - ../config/watcher-mobymask-v3/watcher-config-template.toml:/app/environments/watcher-config-template.toml
- ../config/watcher-mobymask-v3/watcher-config-rates.toml:/app/environments/rates.toml - ../config/watcher-mobymask-v3/watcher-config-rates.toml:/app/environments/rates.toml
- ../config/watcher-mobymask-v3/keys:/app/keys - ../config/watcher-mobymask-v3/keys:/app/keys
- ../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 - watcher_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 +118,5 @@ volumes:
mobymask_watcher_db_data: mobymask_watcher_db_data:
peers_ids: peers_ids:
mobymask_deployment: mobymask_deployment:
nitro_addresses: nitro_deployment:
nitro_data: watcher_nitro_data:

View File

@ -0,0 +1,35 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
nitro_addresses_file="/app/deployment/nitro-addresses.json"
# 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"
NA_ADDRESS=${CERC_NA_ADDRESS}
VPA_ADDRESS=${CERC_VPA_ADDRESS}
CA_ADDRESS=${CERC_CA_ADDRESS}
elif [ -f ${nitro_addresses_file} ]; then
echo "Reading Nitro addresses from ${nitro_addresses_file}"
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 "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}

View File

@ -0,0 +1,14 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
echo "Running Nitro reverse payment proxy"
echo "Using PROXY_ADDRESS ${PROXY_ADDRESS}"
echo "Using PROXY_NITRO_ENDPOINT ${PROXY_NITRO_ENDPOINT}"
echo "Using PROXY_DESTINATION_URL ${PROXY_DESTINATION_URL}"
echo "Using PROXY_COST_PER_BYTE ${PROXY_COST_PER_BYTE}"
./start-reverse-payment-proxy -proxyaddress ${PROXY_ADDRESS} -nitroendpoint=${PROXY_NITRO_ENDPOINT} -destinationurl=${PROXY_DESTINATION_URL} -costperbyte ${PROXY_COST_PER_BYTE} -enablepaidrpcmethods

View File

@ -0,0 +1,57 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
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
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 "Skipping Nitro contracts deployment"
exit
fi
# Check and exit if a deployment already exists (on restarts)
if [ -f ${nitro_addresses_file} ]; then
echo "${nitro_addresses_file} already exists, skipping Nitro contracts deployment"
cat ${nitro_addresses_file}
exit
fi
echo "Using ETH RPC endpoint ${CERC_ETH_RPC_ENDPOINT}"
# Wait till ETH RPC endpoint is available with block number > 1
retry_interval=5
while true; do
block_number_hex=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ${CERC_ETH_RPC_ENDPOINT} | jq -r '.result')
# Check if the request call was successful
if [ $? -ne 0 ]; then
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
sleep $retry_interval
continue
fi
# Convert hex to decimal
block_number_dec=$(printf %u ${block_number_hex})
# Check if block number is > 1 to avoid failures in the deployment
if [ "$block_number_dec" -ge 1 ]; then
echo "RPC endpoint is up"
break
else
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
sleep $retry_interval
continue
fi
done
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}
cat ${nitro_addresses_file}

View File

@ -0,0 +1,69 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
# Wait till RPC endpoint is available
retry_interval=5
while true; do
rpc_response=$(curl -s -o /dev/null -w '%{http_code}' ${PONDER_RPC_URL_1})
if [ ${rpc_response} = 200 ]; then
echo "RPC endpoint is available"
break
fi
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
sleep $retry_interval
done
nitro_addresses_file="/nitro/nitro-addresses.json"
nitro_addresses_destination_file="/app/examples/token-erc20/nitro-addresses.json"
# 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 "Nitro addresses not available"
exit 1
fi
echo "Using CERC_PONDER_NITRO_PK from env for Nitro account"
echo "Using CERC_PONDER_NITRO_CHAIN_PK (account with funds) from env for sending Nitro txs"
echo "Using ${CERC_PONDER_NITRO_CHAIN_URL} as the RPC endpoint for Nitro txs"
# If not set, check the mounted volume for relay peer id
if [ -z "$CERC_RELAY_MULTIADDR" ]; then
echo "CERC_RELAY_MULTIADDR not provided, taking from the mounted volume"
CERC_RELAY_MULTIADDR="/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/$(jq -r '.id' /peers/relay-id.json)"
fi
env_file='.env.local'
echo "PONDER_CHAIN_ID=\"$PONDER_CHAIN_ID\"" > "$env_file"
echo "PONDER_RPC_URL_1=\"$PONDER_RPC_URL_1\"" >> "$env_file"
echo "CERC_PONDER_NITRO_PK=\"$CERC_PONDER_NITRO_PK\"" >> "$env_file"
echo "CERC_PONDER_NITRO_CHAIN_PK=\"$CERC_PONDER_NITRO_CHAIN_PK\"" >> "$env_file"
echo "CERC_PONDER_NITRO_CHAIN_URL=\"$CERC_PONDER_NITRO_CHAIN_URL\"" >> "$env_file"
echo "CERC_RELAY_MULTIADDR=\"$CERC_RELAY_MULTIADDR\"" >> "$env_file"
echo "CERC_UPSTREAM_NITRO_ADDRESS=\"$CERC_UPSTREAM_NITRO_ADDRESS\"" >> "$env_file"
echo "CERC_UPSTREAM_NITRO_MULTIADDR=\"$CERC_UPSTREAM_NITRO_MULTIADDR\"" >> "$env_file"
echo "CERC_UPSTREAM_NITRO_PAY_AMOUNT=\"$CERC_UPSTREAM_NITRO_PAY_AMOUNT\"" >> "$env_file"
# Keep the container running
tail -f

View File

@ -0,0 +1,37 @@
import type { Config } from "@ponder/core";
import contractAddresses from "./nitro-addresses.json";
export const config: Config = {
networks: [
{
name: "fixturenet",
chainId: Number(process.env.PONDER_CHAIN_ID),
rpcUrl: process.env.PONDER_RPC_URL_1,
maxRpcRequestConcurrency: 1,
},
],
contracts: [
{
name: "AdventureGold",
network: "fixturenet",
abi: "./abis/AdventureGold.json",
address: "0x32353A6C91143bfd6C7d363B546e62a9A2489A20",
startBlock: 5,
maxBlockRange: 100,
},
],
nitro: {
privateKey: process.env.CERC_PONDER_NITRO_PK!,
chainPrivateKey: process.env.CERC_PONDER_NITRO_CHAIN_PK!,
chainURL: process.env.CERC_PONDER_NITRO_CHAIN_URL!,
contractAddresses,
relayMultiAddr: process.env.CERC_RELAY_MULTIADDR!,
store: "./.ponder/nitro-db",
rpcNitroNode: {
address: process.env.CERC_UPSTREAM_NITRO_ADDRESS!,
multiAddr: process.env.CERC_UPSTREAM_NITRO_MULTIADDR!,
},
payAmount: process.env.CERC_UPSTREAM_NITRO_PAY_AMOUNT!,
},
};

View File

@ -0,0 +1,78 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
CERC_ETH_RPC_ENDPOINT="${CERC_ETH_RPC_ENDPOINT:-${DEFAULT_CERC_ETH_RPC_ENDPOINT}}"
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}}"
# Check if CERC_DEPLOYED_CONTRACT environment variable set to skip contract deployment
if [ -n "$CERC_DEPLOYED_CONTRACT" ]; then
echo "CERC_DEPLOYED_CONTRACT is set to '$CERC_DEPLOYED_CONTRACT'"
echo "Skipping contract deployment"
exit 0
fi
echo "Using ETH RPC endpoint ${CERC_ETH_RPC_ENDPOINT}"
# Wait till ETH RPC endpoint is available with block number > 1
retry_interval=5
while true; do
block_number_hex=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ${CERC_ETH_RPC_ENDPOINT} | jq -r '.result')
# Check if the request call was successful
if [ $? -ne 0 ]; then
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
sleep $retry_interval
continue
fi
# Convert hex to decimal
block_number_dec=$(printf %u ${block_number_hex})
# Check if block number is > 1 to avoid failures in the deployment
if [ "$block_number_dec" -ge 1 ]; then
echo "RPC endpoint is up"
break
else
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
sleep $retry_interval
continue
fi
done
echo "Using CERC_PRIVATE_KEY_DEPLOYER from env"
# Create the required JSON and write it to a file
secrets_file="secrets.json"
secrets_json=$(jq -n \
--arg privateKey "$CERC_PRIVATE_KEY_DEPLOYER" \
--arg rpcUrl "$CERC_ETH_RPC_ENDPOINT" \
--arg baseURI "$CERC_MOBYMASK_APP_BASE_URI" \
'.privateKey = $privateKey | .rpcUrl = $rpcUrl | .baseURI = $baseURI')
echo "$secrets_json" > "${secrets_file}"
export RPC_URL="${CERC_ETH_RPC_ENDPOINT}"
# Check and exit if a deployment already exists (on restarts)
if [ -f ./config.json ]; then
echo "config.json already exists, checking the contract deployment"
# Read JSON file
deployment_details=$(cat config.json)
deployed_contract=$(echo "$deployment_details" | jq -r '.address')
cd ../hardhat
if yarn verifyDeployment --network optimism --contract "${deployed_contract}"; then
echo "Deployment verfication successful"
cd ../server
else
echo "Deployment verfication failed, please clear MobyMask deployment volume before starting"
exit 1
fi
fi
npm run deployAndGenerateInvite

View File

@ -1,58 +0,0 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
CERC_NA_ADDRESS="${CERC_NA_ADDRESS:-${DEFAULT_CERC_NA_ADDRESS}}"
CERC_VPA_ADDRESS="${CERC_VPA_ADDRESS:-${DEFAULT_CERC_VPA_ADDRESS}}"
CERC_CA_ADDRESS="${CERC_CA_ADDRESS:-${DEFAULT_CERC_CA_ADDRESS}}"
NITRO_ADDRESSES_FILE_PATH="/nitro/nitro-addresses.json"
# Check if CERC_NA_ADDRESS environment variable set to skip contract deployment
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 addresses and skipping Nitro contracts deployment"
# 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_FILE_PATH}"
exit
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"
exit
fi
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
if [ -n "$CERC_L1_ACCOUNTS_CSV_URL" ] && \
l1_accounts_response=$(curl -L --write-out '%{http_code}' --silent --output /dev/null "$CERC_L1_ACCOUNTS_CSV_URL") && \
[ "$l1_accounts_response" -eq 200 ];
then
echo "Fetching L1 account credentials using provided URL"
mkdir -p /geth-accounts
wget -O /geth-accounts/accounts.csv "$CERC_L1_ACCOUNTS_CSV_URL"
# Read the private key of an L1 account to deploy contract
CERC_PRIVATE_KEY_DEPLOYER=$(head -n 1 /geth-accounts/accounts.csv | cut -d ',' -f 3)
else
echo "Couldn't fetch L1 account credentials, using CERC_PRIVATE_KEY_DEPLOYER from env"
fi
echo "RPC_URL=${CERC_L2_GETH_RPC}" > .env
echo "NITRO_ADDRESSES_FILE_PATH=${NITRO_ADDRESSES_FILE_PATH}" >> .env
echo "PRIVATE_KEY=${CERC_PRIVATE_KEY_DEPLOYER}" >> .env
yarn ts-node --esm deploy-nitro-contracts.ts

View File

@ -1,49 +0,0 @@
import 'dotenv/config';
import fs from 'fs';
import { providers, Wallet } from 'ethers';
import { deployContracts } from '@cerc-io/nitro-util';
async function main () {
const rpcURL = process.env.RPC_URL;
const addressesFilePath = process.env.NITRO_ADDRESSES_FILE_PATH;
const deployerKey = process.env.PRIVATE_KEY;
if (!rpcURL) {
console.log('RPC_URL not set, skipping deployment');
return;
}
if (!addressesFilePath) {
console.log('NITRO_ADDRESSES_FILE_PATH not set, skipping deployment');
return;
}
if (!deployerKey) {
console.log('PRIVATE_KEY not set, skipping deployment');
return;
}
const provider = new providers.JsonRpcProvider(process.env.RPC_URL);
const signer = new Wallet(deployerKey, provider);
const [
nitroAdjudicatorAddress,
virtualPaymentAppAddress,
consensusAppAddress
] = await deployContracts(signer as any);
const output = {
nitroAdjudicatorAddress,
virtualPaymentAppAddress,
consensusAppAddress
};
fs.writeFileSync(addressesFilePath, JSON.stringify(output, null, 2));
console.log('Nitro contracts deployed, addresses written to', addressesFilePath);
console.log('Result:', JSON.stringify(output, null, 2));
}
main()
.catch((err) => {
console.log(err);
});

View File

@ -11,21 +11,36 @@ CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}"
CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}" CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}"
CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}" CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}"
CERC_GOSSIPSUB_DIRECT_PEERS="${CERC_GOSSIPSUB_DIRECT_PEERS:-${DEFAULT_CERC_GOSSIPSUB_DIRECT_PEERS}}" CERC_GOSSIPSUB_DIRECT_PEERS="${CERC_GOSSIPSUB_DIRECT_PEERS:-${DEFAULT_CERC_GOSSIPSUB_DIRECT_PEERS}}"
CERC_APP_WATCHER_URL="${CERC_APP_WATCHER_URL:-${DEFAULT_CERC_APP_WATCHER_URL}}"
CERC_SNAP_URL="${CERC_SNAP_URL:-${DEFAULT_CERC_SNAP_URL}}"
# If not set (or []), check the mounted volume for relay peer id
if [ -z "$CERC_RELAY_NODES" ] || [ "$CERC_RELAY_NODES" = "[]" ]; then
echo "CERC_RELAY_NODES not provided, taking from the mounted volume"
CERC_RELAY_NODES="[\"/ip4/127.0.0.1/tcp/9090/ws/p2p/$(jq -r '.id' /peers/relay-id.json)\"]"
fi
echo "Using CERC_RELAY_NODES $CERC_RELAY_NODES" echo "Using CERC_RELAY_NODES $CERC_RELAY_NODES"
if [ -z "$CERC_DEPLOYED_CONTRACT" ]; then if [ -z "$CERC_DEPLOYED_CONTRACT" ]; then
echo "CERC_DEPLOYED_CONTRACT not set" # Use config from mounted volume (when running web-app along with watcher stack)
exit 1 echo "Taking config for deployed contract from mounted volume"
while [ ! -f /server/config.json ]; do
echo "Config not found, retrying in 5 seconds..."
sleep 5
done
# Get deployed contract address and chain id
CERC_DEPLOYED_CONTRACT=$(jq -r '.address' /server/config.json | tr -d '"')
CERC_CHAIN_ID=$(jq -r '.chainId' /server/config.json)
else else
echo "Using CERC_DEPLOYED_CONTRACT ${CERC_DEPLOYED_CONTRACT} from env as the MobyMask contract address" echo "Using CERC_DEPLOYED_CONTRACT ${CERC_DEPLOYED_CONTRACT} from env as the MobyMask contract address"
fi fi
# Checkout to the required release/branch nitro_addresses_file="/nitro/nitro-addresses.json"
cd /app nitro_addresses_destination_file="/app/src/utils/nitro-addresses.json"
git checkout $CERC_RELEASE
# Check if CERC_NA_ADDRESS is set # Check if CERC_NA_ADDRESS environment variable is set
if [ -n "$CERC_NA_ADDRESS" ]; then if [ -n "$CERC_NA_ADDRESS" ]; then
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'" echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'" echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
@ -38,24 +53,31 @@ if [ -n "$CERC_NA_ADDRESS" ]; then
--arg vpa "$CERC_VPA_ADDRESS" \ --arg vpa "$CERC_VPA_ADDRESS" \
--arg ca "$CERC_CA_ADDRESS" \ --arg ca "$CERC_CA_ADDRESS" \
'.nitroAdjudicatorAddress = $na | .virtualPaymentAppAddress = $vpa | .consensusAppAddress = $ca') '.nitroAdjudicatorAddress = $na | .virtualPaymentAppAddress = $vpa | .consensusAppAddress = $ca')
echo "$nitro_addresses_json" > /app/src/utils/nitro-addresses.json 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 "Nitro addresses not provided" echo "Nitro addresses not available"
exit 1 exit 1
fi fi
# Export config values in a json file # Export config values in a json file
jq --arg address "$CERC_DEPLOYED_CONTRACT" \ app_config_file="/app/src/utils/config.json"
app_config_json=$(jq -n \
--arg name "MobyMask" \
--argjson enableDebugInfo true \
--arg address "$CERC_DEPLOYED_CONTRACT" \
--argjson chainId "$CERC_CHAIN_ID" \ --argjson chainId "$CERC_CHAIN_ID" \
--argjson relayNodes "$CERC_RELAY_NODES" \ --argjson relayNodes "$CERC_RELAY_NODES" \
--argjson denyMultiaddrs "$CERC_DENY_MULTIADDRS" \ --argjson denyMultiaddrs "$CERC_DENY_MULTIADDRS" \
--arg pubsub "$CERC_PUBSUB" \ --arg pubsub "$CERC_PUBSUB" \
--argjson directPeers "$CERC_GOSSIPSUB_DIRECT_PEERS" \ --argjson directPeers "$CERC_GOSSIPSUB_DIRECT_PEERS" \
'.address = $address | .chainId = $chainId | .relayNodes = $relayNodes | .peer.denyMultiaddrs = $denyMultiaddrs | .peer.pubsub = $pubsub | .peer.directPeers = $directPeers' \ '.name = $name | .address = $address | .chainId = $chainId | .relayNodes = $relayNodes | .peer.enableDebugInfo = $enableDebugInfo | .peer.denyMultiaddrs = $denyMultiaddrs | .peer.pubsub = $pubsub | .peer.directPeers = $directPeers')
/app/src/mobymask-app-config.json > /app/src/utils/config.json echo "$app_config_json" > "${app_config_file}"
yarn install
REACT_APP_DEBUG_PEER=true \
REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" \ REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" \
REACT_APP_PAY_TO_NITRO_ADDRESS="$CERC_PAYMENT_NITRO_ADDRESS" \ REACT_APP_PAY_TO_NITRO_ADDRESS="$CERC_PAYMENT_NITRO_ADDRESS" \
REACT_APP_SNAP_ORIGIN="local:$CERC_SNAP_URL" \ REACT_APP_SNAP_ORIGIN="local:$CERC_SNAP_URL" \

View File

@ -1,5 +1,14 @@
# Defaults # Defaults
# ETH RPC endpoint used for contract(s) deployment
DEFAULT_CERC_ETH_RPC_ENDPOINT="http://fixturenet-eth-geth-1:8545"
# ETH RPC endpoint used for queries in the watcher
DEFAULT_CERC_ETH_RPC_QUERY_ENDPOINT="http://nitro-reverse-payment-proxy:8081"
# ETH RPC endpoint used for mutations in the watcher
DEFAULT_CERC_ETH_RPC_MUTATION_ENDPOINT="http://fixturenet-eth-geth-1:8545"
# Set of relay peers to connect to from the relay node # Set of relay peers to connect to from the relay node
DEFAULT_CERC_RELAY_PEERS=[] DEFAULT_CERC_RELAY_PEERS=[]
@ -17,7 +26,13 @@ DEFAULT_CERC_ENABLE_PEER_L2_TXS=true
DEFAULT_CERC_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
DEFAULT_CERC_CHAIN_ID=42069 DEFAULT_CERC_CHAIN_ID=1212
# Watcher endpoint used by the web-app
DEFAULT_CERC_APP_WATCHER_URL="http://localhost:3001"
# MobyMask snap URL to be used by the web-app
DEFAULT_CERC_SNAP_URL=http://localhost:8080
# Set of relay nodes to be used by web-apps # Set of relay nodes to be used by web-apps
DEFAULT_CERC_RELAY_NODES=[] DEFAULT_CERC_RELAY_NODES=[]
@ -31,7 +46,5 @@ DEFAULT_CERC_PUBSUB=""
# Set of direct peers to be used when pubsub is set to gossipsub # Set of direct peers to be used when pubsub is set to gossipsub
DEFAULT_CERC_GOSSIPSUB_DIRECT_PEERS=[] DEFAULT_CERC_GOSSIPSUB_DIRECT_PEERS=[]
# Set deployed Nitro addresses to avoid deploying them in the stack # Whether to enable payments to upstream ETH server
DEFAULT_CERC_NA_ADDRESS= DEFAULT_CERC_ENABLE_UPSTREAM_PAYMENTS=true
DEFAULT_CERC_VPA_ADDRESS=
DEFAULT_CERC_CA_ADDRESS=

View File

@ -5,21 +5,20 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
CERC_L2_GETH_RPC="${CERC_L2_GETH_RPC:-${DEFAULT_CERC_L2_GETH_RPC}}" CERC_ETH_RPC_QUERY_ENDPOINT="${CERC_ETH_RPC_QUERY_ENDPOINT:-${DEFAULT_CERC_ETH_RPC_QUERY_ENDPOINT}}"
CERC_ETH_RPC_MUTATION_ENDPOINT="${CERC_ETH_RPC_MUTATION_ENDPOINT:-${DEFAULT_CERC_ETH_RPC_MUTATION_ENDPOINT}}"
CERC_RELAY_PEERS="${CERC_RELAY_PEERS:-${DEFAULT_CERC_RELAY_PEERS}}" CERC_RELAY_PEERS="${CERC_RELAY_PEERS:-${DEFAULT_CERC_RELAY_PEERS}}"
CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}" CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}"
CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}" CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}"
CERC_RELAY_ANNOUNCE_DOMAIN="${CERC_RELAY_ANNOUNCE_DOMAIN:-${DEFAULT_CERC_RELAY_ANNOUNCE_DOMAIN}}" CERC_RELAY_ANNOUNCE_DOMAIN="${CERC_RELAY_ANNOUNCE_DOMAIN:-${DEFAULT_CERC_RELAY_ANNOUNCE_DOMAIN}}"
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}}"
CERC_ENABLE_UPSTREAM_PAYMENTS="${CERC_ENABLE_UPSTREAM_PAYMENTS:-${DEFAULT_CERC_ENABLE_UPSTREAM_PAYMENTS}}"
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 RPC query endpoint ${CERC_ETH_RPC_QUERY_ENDPOINT}"
echo "Using RPC mutation endpoint ${CERC_ETH_RPC_MUTATION_ENDPOINT}"
# Use public domain for relay multiaddr in peer config if specified # Use public domain for relay multiaddr in peer config if specified
# Otherwise, use the docker container's host IP # Otherwise, use the docker container's host IP
@ -37,20 +36,37 @@ 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 "Nitro addresses not available"
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_WATCHER_NITRO_PK from env for Nitro account"
if [ -n "$CERC_PEER_ID" ]; then if [ -n "$CERC_PEER_ID" ]; then
echo "Using CERC_PEER_ID ${CERC_PEER_ID} from env for watcher fixture" echo "Using CERC_PEER_ID ${CERC_PEER_ID} from env for watcher fixture"
@ -107,6 +123,16 @@ else
CONSENSUS_PRIVATE_KEY='' CONSENSUS_PRIVATE_KEY=''
fi fi
if [ "$CERC_ENABLE_UPSTREAM_PAYMENTS" = true ]; then
UPSTREAM_NITRO_ADDRESS=${CERC_UPSTREAM_NITRO_ADDRESS}
UPSTREAM_NITRO_MULTIADDR=${CERC_UPSTREAM_NITRO_MULTIADDR}
UPSTREAM_NITRO_PAY_AMOUNT=${CERC_UPSTREAM_NITRO_PAY_AMOUNT}
else
UPSTREAM_NITRO_ADDRESS=""
UPSTREAM_NITRO_MULTIADDR=""
UPSTREAM_NITRO_PAY_AMOUNT=""
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" | \
@ -118,13 +144,17 @@ WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \
s|REPLACE_WITH_PEER_ID_FILE|${PEER_ID_FILE}|g; \ s|REPLACE_WITH_PEER_ID_FILE|${PEER_ID_FILE}|g; \
s/REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS/${CERC_ENABLE_PEER_L2_TXS}/g; \ s/REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS/${CERC_ENABLE_PEER_L2_TXS}/g; \
s/REPLACE_WITH_CERC_PRIVATE_KEY_PEER/${CERC_PRIVATE_KEY_PEER}/g; \ s/REPLACE_WITH_CERC_PRIVATE_KEY_PEER/${CERC_PRIVATE_KEY_PEER}/g; \
s/REPLACE_WITH_CERC_PRIVATE_KEY_NITRO/${CERC_PRIVATE_KEY_NITRO}/g; \ s/REPLACE_WITH_CERC_WATCHER_NITRO_PK/${CERC_WATCHER_NITRO_PK}/g; \
s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/g; \ s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/g; \
s/REPLACE_WITH_CONSENSUS_ENABLED/${CONSENSUS_ENABLED}/g; \ s/REPLACE_WITH_CONSENSUS_ENABLED/${CONSENSUS_ENABLED}/g; \
s/REPLACE_WITH_CONSENSUS_PUBLIC_KEY/${CONSENSUS_PUBLIC_KEY}/g; \ s/REPLACE_WITH_CONSENSUS_PUBLIC_KEY/${CONSENSUS_PUBLIC_KEY}/g; \
s/REPLACE_WITH_CONSENSUS_PRIVATE_KEY/${CONSENSUS_PRIVATE_KEY}/g; \ s/REPLACE_WITH_CONSENSUS_PRIVATE_KEY/${CONSENSUS_PRIVATE_KEY}/g; \
s|REPLACE_WITH_WATCHER_PARTY_PEERS_FILE|${WATCHER_PARTY_PEERS_FILE}|g; \ s|REPLACE_WITH_WATCHER_PARTY_PEERS_FILE|${WATCHER_PARTY_PEERS_FILE}|g; \
s|REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT|${CERC_L2_GETH_RPC}| ") s|REPLACE_WITH_CERC_ETH_RPC_QUERY_ENDPOINT|${CERC_ETH_RPC_QUERY_ENDPOINT}|g; \
s|REPLACE_WITH_CERC_ETH_RPC_MUTATION_ENDPOINT|${CERC_ETH_RPC_MUTATION_ENDPOINT}|g; \
s/REPLACE_WITH_UPSTREAM_NITRO_ADDRESS/${UPSTREAM_NITRO_ADDRESS}/g; \
s|REPLACE_WITH_UPSTREAM_NITRO_MULTIADDR|${UPSTREAM_NITRO_MULTIADDR}|g; \
s/REPLACE_WITH_UPSTREAM_NITRO_PAY_AMOUNT/${UPSTREAM_NITRO_PAY_AMOUNT}/ ")
# 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

@ -19,6 +19,9 @@
# Use -1 for skipping check on block range. # Use -1 for skipping check on block range.
maxEventsBlockRange = -1 maxEventsBlockRange = -1
# Flag to specify whether RPC endpoint supports block hash as block tag parameter
rpcSupportsBlockHashParam = true
[server.p2p] [server.p2p]
enableRelay = true enableRelay = true
enablePeer = true enablePeer = true
@ -41,6 +44,9 @@
pubsub = 'REPLACE_WITH_CERC_PUBSUB' pubsub = 'REPLACE_WITH_CERC_PUBSUB'
enableDebugInfo = true enableDebugInfo = true
enableL2Txs = REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS enableL2Txs = REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS
pingInterval = 4000
pingTimeout = 1500
maxRelayConnections = 10
[server.p2p.peer.l2TxsConfig] [server.p2p.peer.l2TxsConfig]
privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER' privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER'
@ -48,7 +54,7 @@
[server.p2p.nitro] [server.p2p.nitro]
store = './out/nitro-db' store = './out/nitro-db'
privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_NITRO' privateKey = 'REPLACE_WITH_CERC_WATCHER_NITRO_PK'
chainPrivateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER' chainPrivateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER'
[server.p2p.nitro.payments] [server.p2p.nitro.payments]
@ -67,7 +73,7 @@
enabled = REPLACE_WITH_CONSENSUS_ENABLED enabled = REPLACE_WITH_CONSENSUS_ENABLED
publicKey = 'REPLACE_WITH_CONSENSUS_PUBLIC_KEY' publicKey = 'REPLACE_WITH_CONSENSUS_PUBLIC_KEY'
privateKey = 'REPLACE_WITH_CONSENSUS_PRIVATE_KEY' privateKey = 'REPLACE_WITH_CONSENSUS_PRIVATE_KEY'
watcherPartyFile = 'REPLACE_WITH_WATCHER_PARTY_PEERS_FILE' watcherPartyPeersFile = 'REPLACE_WITH_WATCHER_PARTY_PEERS_FILE'
[metrics] [metrics]
host = "0.0.0.0" host = "0.0.0.0"
@ -87,9 +93,14 @@
[upstream] [upstream]
[upstream.ethServer] [upstream.ethServer]
gqlApiEndpoint = "http://ipld-eth-server:8083/graphql" gqlApiEndpoint = 'http://ipld-eth-server:8083/graphql'
rpcProviderEndpoint = "REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT" rpcProviderEndpoint = 'REPLACE_WITH_CERC_ETH_RPC_QUERY_ENDPOINT'
blockDelayInMilliSecs = 60000 rpcProviderMutationEndpoint = 'REPLACE_WITH_CERC_ETH_RPC_MUTATION_ENDPOINT'
[upstream.ethServer.rpcProviderNitroNode]
address = 'REPLACE_WITH_UPSTREAM_NITRO_ADDRESS'
multiAddr = 'REPLACE_WITH_UPSTREAM_NITRO_MULTIADDR'
amount = 'REPLACE_WITH_UPSTREAM_NITRO_PAY_AMOUNT'
[upstream.cache] [upstream.cache]
name = "requests" name = "requests"
@ -101,3 +112,4 @@
maxCompletionLagInSecs = 300 maxCompletionLagInSecs = 300
jobDelayInMilliSecs = 100 jobDelayInMilliSecs = 100
eventsInBatch = 50 eventsInBatch = 50
blockDelayInMilliSecs = 60000

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Build cerc/go-nitro
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
docker build -t cerc/go-nitro:local -f ${CERC_REPO_BASE_DIR}/go-nitro/docker/local/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/go-nitro

View File

@ -0,0 +1,13 @@
FROM node:18.15.0-alpine3.16
RUN apk --update --no-cache add git python3 alpine-sdk bash
WORKDIR /app
COPY . .
RUN echo "Installing dependencies..." && \
yarn install && \
cd packages/snap
CMD ["bash", "-c", "yarn start"]

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Build cerc/mobymask-snap
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
docker build -t cerc/mobymask-snap:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/mobymask-snap

View File

@ -0,0 +1,12 @@
FROM node:18.17.1-alpine3.18
RUN apk --update --no-cache add python3 alpine-sdk bash curl jq
WORKDIR /app
COPY . .
RUN echo "Installing dependencies" && \
yarn
WORKDIR /app/packages/nitro-util

View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Build cerc/nitro-contracts
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
# See: https://stackoverflow.com/a/246128/1701505
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
docker build -t cerc/nitro-contracts:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/ts-nitro

View File

@ -0,0 +1,13 @@
FROM node:18.15.0-alpine3.16
RUN apk --update --no-cache add git alpine-sdk bash jq curl
RUN curl -L https://unpkg.com/@pnpm/self-installer | node
WORKDIR /app
COPY . .
RUN echo "Installing dependencies and building..." && \
pnpm install && pnpm build && \
cd examples/token-erc20 && \
pnpm install

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Build cerc/ponder
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
docker build -t cerc/ponder:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/ponder

View File

@ -51,3 +51,7 @@ cerc/graph-node
cerc/sushiswap-subgraphs cerc/sushiswap-subgraphs
cerc/webapp-base cerc/webapp-base
cerc/watcher-mobymask-v3 cerc/watcher-mobymask-v3
cerc/go-nitro
cerc/nitro-contracts
cerc/mobymask-snap
cerc/ponder

View File

@ -37,3 +37,8 @@ sushiswap-subgraph-v3
fixturenet-sushiswap-subgraph-v3 fixturenet-sushiswap-subgraph-v3
watcher-mobymask-v3 watcher-mobymask-v3
mobymask-app-v3 mobymask-app-v3
go-nitro
nitro-contracts
nitro-reverse-payment-proxy
mobymask-snap
ponder

View File

@ -43,3 +43,7 @@ github.com/cerc-io/sushiswap-v3-core
github.com/cerc-io/sushiswap-v3-periphery github.com/cerc-io/sushiswap-v3-periphery
github.com/graphprotocol/graph-node github.com/graphprotocol/graph-node
github.com/sushiswap/subgraphs github.com/sushiswap/subgraphs
github.com/cerc-io/go-nitro
github.com/cerc-io/ts-nitro
github.com/cerc-io/mobymask-snap
github.com/cerc-io/ponder

View File

@ -0,0 +1,25 @@
# Required for:
# Nitro contracts deployment
# MobyMask contract deployment
CERC_PRIVATE_KEY_DEPLOYER="0x888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218"
# ipld-eth-server's go-nitro node credentials
NITRO_PK=2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d
NITRO_CHAIN_PK=570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597
# Watcher's nitro node credentials
CERC_WATCHER_NITRO_PK="0279651921cd800ac560c21ceea27aab0107b67daf436cdd25ce84cad30159b4"
# Used for sending MobyMask chain txs; also serves as chain pk for watcher's nitro node
CERC_PRIVATE_KEY_PEER="111b7500bdce494d6f4bcfe8c2a0dde2ef92f751d9070fac6475dbd6d8021b3f"
# Ponder app's nitro node credentials
CERC_PONDER_NITRO_PK=58368d20ff12f17669c06158c21d885897aa56f9be430edc789614bf9851d53f
CERC_PONDER_NITRO_CHAIN_PK=fb1e9af328c283ca3e2486e7c24d13582b7912057d8b9542ff41503c85bc05c0
# Used by watcher and ponder app for sending upstream payments
CERC_UPSTREAM_NITRO_ADDRESS="0xAAA6628Ec44A8a742987EF3A114dDFE2D4F7aDCE" # corresponds to NITRO_PK
CERC_UPSTREAM_NITRO_MULTIADDR="/dns4/go-nitro/tcp/5005/ws/p2p/16Uiu2HAmSjXJqsyBJgcBUU2HQmykxGseafSatbpq5471XmuaUqyv"
# Used by the the MobyMask app to make payments to watcher
CERC_PAYMENT_NITRO_ADDRESS="0xBBB676f9cFF8D242e9eaC39D063848807d3D1D94" # corresponds to CERC_WATCHER_NITRO_PK

View File

@ -0,0 +1,70 @@
# fixturenet-payments
## Setup
Clone required repositories:
```bash
laconic-so --stack fixturenet-payments setup-repositories --pull
```
Build the container images:
```bash
laconic-so --stack fixturenet-payments build-containers
```
## Deploy
### Configuration
Deploy the stack:
```bash
laconic-so --stack fixturenet-payments deploy --cluster payments up
# Exposed on host ports:
# 5005: go-nitro node's p2p msg port
# 8081: reverse payment proxy's RPC endpoint
# 15432: MobyMask v3 watcher's db endpoint
# 3001: MobyMask v3 watcher endpoint
# 9090: MobyMask v3 watcher relay node endpoint
# 8080: MobyMask snap
# 3004: MobyMask v3 app
```
Check the logs of the MobyMask contract 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")
```
Check the reverse payment proxy container logs:
```bash
docker logs -f $(docker ps -aq --filter name="nitro-reverse-payment-proxy")
```
Run the ponder app:
```bash
docker exec -it payments-ponder-app-1 bash -c "pnpm start"
```
## Clean up
Stop all the services running in background:
```bash
laconic-so --stack fixturenet-payments deploy --cluster payments down 30
```
Clear volumes created by this stack:
```bash
# List all relevant volumes
docker volume ls -q --filter "name=[payments"
# Remove all the listed volumes
docker volume rm $(docker volume ls -q --filter "name=[payments")
```

View File

@ -0,0 +1,53 @@
version: "1.0"
name: fixturenet-payments
description: "Stack to demonstrate payments between various services"
repos:
# fixturenet repos
- github.com/cerc-io/go-ethereum
- 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@v0.1.12
- github.com/cerc-io/go-nitro@v0.1.0-ts-port-0.1.4 # TODO: Update after fixes
# mobymask watcher repos
- github.com/cerc-io/watcher-ts@v0.2.61
- github.com/cerc-io/mobymask-v2-watcher-ts@v3 # TODO: Update after fixes
- github.com/cerc-io/MobyMask@v0.1.3
# mobymask app repos
- github.com/cerc-io/mobymask-snap
- github.com/cerc-io/mobymask-ui@v0.2.0
# ponder repo
- github.com/cerc-io/ponder@laconic
containers:
# fixturenet images
- cerc/go-ethereum
- cerc/lighthouse
- cerc/lighthouse-cli
- cerc/fixturenet-eth-genesis
- cerc/fixturenet-eth-geth
- cerc/fixturenet-eth-lighthouse
- cerc/ipld-eth-db
- cerc/ipld-eth-server
- cerc/nitro-contracts
- cerc/go-nitro
# mobymask watcher images
- cerc/watcher-ts
- cerc/watcher-mobymask-v3
- cerc/mobymask
# mobymask app images
- cerc/mobymask-snap
- cerc/mobymask-ui
# ponder image
- cerc/ponder
pods:
- fixturenet-eth
- ipld-eth-server
- ipld-eth-db
- nitro-contracts
- go-nitro
- nitro-reverse-payment-proxy
- watcher-mobymask-v3
- mobymask-snap
- mobymask-app-v3
- ponder

View File

@ -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-nitrov0.1.12
- 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 # TODO: Update after fixes
- 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@v0.2.0
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

View File

@ -2,7 +2,7 @@
## Setup ## Setup
Prerequisite: L2 Optimism Geth and Node RPC endpoints Prerequisite: L2 Optimism Geth RPC endpoint
Clone required repositories: Clone required repositories:
@ -23,21 +23,16 @@ laconic-so --stack mobymask-v3 build-containers --exclude cerc/mobymask-ui
Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v3/mobymask-params.env)): Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v3/mobymask-params.env)):
```bash ```bash
# External L2 endpoints # External ETH RPC endpoint (L2 Optimism geth)
CERC_L2_GETH_RPC= CERC_ETH_RPC_ENDPOINT=
# Endpoints waited on before contract deployment # External ETH RPC endpoint used for queries in the watcher
CERC_L2_GETH_HOST= CERC_ETH_RPC_QUERY_ENDPOINT=
CERC_L2_GETH_PORT=
CERC_L2_NODE_HOST= # External ETH RPC endpoint used for mutations in the watcher
CERC_L2_NODE_PORT= CERC_ETH_RPC_MUTATION_ENDPOINT=
# URL (fixturenet-eth-bootnode-lighthouse) to get CSV with credentials for accounts on L1 to perform txs on L2 # Specify the an account PK for contract deployment
CERC_L1_ACCOUNTS_CSV_URL=
# OR
# Specify the required account credentials
CERC_PRIVATE_KEY_DEPLOYER= CERC_PRIVATE_KEY_DEPLOYER=
# Base URI for mobymask-app # Base URI for mobymask-app
@ -71,11 +66,14 @@ Create and update an env file to be used in the next step ([defaults](../../conf
CERC_PRIVATE_KEY_PEER= CERC_PRIVATE_KEY_PEER=
# Specify private key for the Nitro account # Specify private key for the Nitro account
CERC_PRIVATE_KEY_NITRO= CERC_WATCHER_NITRO_PK=
# (Optional) Set a pre-existing peer id to be used (enables consensus) # (Optional) Set a pre-existing peer id to be used (enables consensus)
# Uses a generated peer id if not set (disables consensus) # Uses a generated peer id if not set (disables consensus)
CERC_PEER_ID= CERC_PEER_ID=
# Disable payments to upstream ETH server
CERC_ENABLE_UPSTREAM_PAYMENTS=false
``` ```
* NOTE: If Optimism is running on the host machine, use `host.docker.internal` as the hostname to access the host port * NOTE: If Optimism is running on the host machine, use `host.docker.internal` as the hostname to access the host port
@ -83,13 +81,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,18 +104,18 @@ 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
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:

View File

@ -56,7 +56,7 @@ Create and update an env file to be used in the next step ([defaults](../../conf
# Nitro account address to make the query and mutation payments to # Nitro account address to make the query and mutation payments to
CERC_PAYMENT_NITRO_ADDRESS= CERC_PAYMENT_NITRO_ADDRESS=
# Endpoint for Mobymask snap installation # (Optional) Endpoint for Mobymask snap installation
CERC_SNAP_URL= CERC_SNAP_URL=
``` ```