diff --git a/app/data/compose/docker-compose-fixturenet-eth.yml b/app/data/compose/docker-compose-fixturenet-eth.yml index bd25c528..663b53c5 100644 --- a/app/data/compose/docker-compose-fixturenet-eth.yml +++ b/app/data/compose/docker-compose-fixturenet-eth.yml @@ -40,7 +40,6 @@ services: - fixturenet-eth-bootnode-geth ports: - "8545" - - "8546" - "40000" - "6060" diff --git a/app/data/compose/docker-compose-go-nitro.yml b/app/data/compose/docker-compose-go-nitro.yml deleted file mode 100644 index 414a83ce..00000000 --- a/app/data/compose/docker-compose-go-nitro.yml +++ /dev/null @@ -1,39 +0,0 @@ -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: diff --git a/app/data/compose/docker-compose-mobymask-app-v3.yml b/app/data/compose/docker-compose-mobymask-app-v3.yml index 244fb29b..a0de0d0c 100644 --- a/app/data/compose/docker-compose-mobymask-app-v3.yml +++ b/app/data/compose/docker-compose-mobymask-app-v3.yml @@ -15,19 +15,18 @@ services: CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS} CERC_PUBSUB: ${CERC_PUBSUB} CERC_GOSSIPSUB_DIRECT_PEERS: ${CERC_GOSSIPSUB_DIRECT_PEERS} + CERC_RELEASE: "laconic-v3" CERC_NA_ADDRESS: ${CERC_NA_ADDRESS} CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS} CERC_CA_ADDRESS: ${CERC_CA_ADDRESS} CERC_APP_WATCHER_URL: ${CERC_APP_WATCHER_URL} - CERC_PAYMENT_NITRO_ADDRESS: ${CERC_PAYMENT_NITRO_ADDRESS:-0xBBB676f9cFF8D242e9eaC39D063848807d3D1D94} + CERC_PAYMENT_NITRO_ADDRESS: ${CERC_PAYMENT_NITRO_ADDRESS} CERC_SNAP_URL: ${CERC_SNAP_URL} - working_dir: /app - command: ["bash", "/scripts/mobymask-app-start.sh"] + working_dir: /scripts + command: ["sh", "mobymask-app-start.sh"] volumes: - ../config/watcher-mobymask-v3/mobymask-app-start.sh:/scripts/mobymask-app-start.sh - - peers_ids:/peers - - mobymask_deployment:/server - - nitro_deployment:/nitro + - ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/mobymask-app-config.json ports: - "127.0.0.1:3004:80" healthcheck: @@ -38,8 +37,3 @@ services: start_period: 10s extra_hosts: - "host.docker.internal:host-gateway" - -volumes: - peers_ids: - mobymask_deployment: - nitro_deployment: diff --git a/app/data/compose/docker-compose-mobymask-snap.yml b/app/data/compose/docker-compose-mobymask-snap.yml deleted file mode 100644 index d2cec254..00000000 --- a/app/data/compose/docker-compose-mobymask-snap.yml +++ /dev/null @@ -1,14 +0,0 @@ -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 diff --git a/app/data/compose/docker-compose-nitro-contracts.yml b/app/data/compose/docker-compose-nitro-contracts.yml deleted file mode 100644 index 8357d25a..00000000 --- a/app/data/compose/docker-compose-nitro-contracts.yml +++ /dev/null @@ -1,23 +0,0 @@ -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: diff --git a/app/data/compose/docker-compose-nitro-reverse-payment-proxy.yml b/app/data/compose/docker-compose-nitro-reverse-payment-proxy.yml deleted file mode 100644 index 37f49407..00000000 --- a/app/data/compose/docker-compose-nitro-reverse-payment-proxy.yml +++ /dev/null @@ -1,27 +0,0 @@ -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" diff --git a/app/data/compose/docker-compose-ponder.yml b/app/data/compose/docker-compose-ponder.yml deleted file mode 100644 index 62d46b47..00000000 --- a/app/data/compose/docker-compose-ponder.yml +++ /dev/null @@ -1,31 +0,0 @@ -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: diff --git a/app/data/compose/docker-compose-test.yml b/app/data/compose/docker-compose-test.yml index 19660f89..5fbf46d0 100644 --- a/app/data/compose/docker-compose-test.yml +++ b/app/data/compose/docker-compose-test.yml @@ -4,6 +4,7 @@ services: restart: always environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} + CERC_TEST_PARAM_1: ${CERC_TEST_PARAM_1:-FAILED} volumes: - test-data:/data ports: diff --git a/app/data/compose/docker-compose-watcher-mobymask-v3.yml b/app/data/compose/docker-compose-watcher-mobymask-v3.yml index 107c9bba..8c351ae7 100644 --- a/app/data/compose/docker-compose-watcher-mobymask-v3.yml +++ b/app/data/compose/docker-compose-watcher-mobymask-v3.yml @@ -32,13 +32,20 @@ services: environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} ENV: "PROD" - CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT} - CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER:-0x888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218} + CERC_L2_GETH_RPC: ${CERC_L2_GETH_RPC} + CERC_L1_ACCOUNTS_CSV_URL: ${CERC_L1_ACCOUNTS_CSV_URL} + CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER} CERC_MOBYMASK_APP_BASE_URI: ${CERC_MOBYMASK_APP_BASE_URI} CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT} - command: ["bash", "-c", "./deploy-and-generate-invite.sh"] + CERC_L2_GETH_HOST: ${CERC_L2_GETH_HOST} + 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: - - ../config/watcher-mobymask-v3/deploy-and-generate-invite.sh:/app/packages/server/deploy-and-generate-invite.sh + - ../config/network/wait-for-it.sh:/app/packages/server/wait-for-it.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 extra_hosts: - "host.docker.internal:host-gateway" @@ -55,6 +62,7 @@ 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 @@ -66,14 +74,13 @@ services: condition: service_completed_successfully mobymask: condition: service_completed_successfully - nitro-contracts: - condition: service_completed_successfully env_file: - ../config/watcher-mobymask-v3/mobymask-params.env environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} - CERC_ETH_RPC_QUERY_ENDPOINT: ${CERC_ETH_RPC_QUERY_ENDPOINT} - CERC_ETH_RPC_MUTATION_ENDPOINT: ${CERC_ETH_RPC_MUTATION_ENDPOINT} + CERC_L2_GETH_RPC: ${CERC_L2_GETH_RPC} + CERC_L1_ACCOUNTS_CSV_URL: ${CERC_L1_ACCOUNTS_CSV_URL} + CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER} CERC_RELAY_PEERS: ${CERC_RELAY_PEERS} CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS} CERC_PUBSUB: ${CERC_PUBSUB} @@ -83,22 +90,21 @@ services: CERC_NA_ADDRESS: ${CERC_NA_ADDRESS} CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS} CERC_CA_ADDRESS: ${CERC_CA_ADDRESS} - CERC_PRIVATE_KEY_PEER: ${CERC_PRIVATE_KEY_PEER:-111b7500bdce494d6f4bcfe8c2a0dde2ef92f751d9070fac6475dbd6d8021b3f} - CERC_WATCHER_NITRO_PK: ${CERC_WATCHER_NITRO_PK:-0279651921cd800ac560c21ceea27aab0107b67daf436cdd25ce84cad30159b4} + CERC_PRIVATE_KEY_PEER: ${CERC_PRIVATE_KEY_PEER} + CERC_PRIVATE_KEY_NITRO: ${CERC_PRIVATE_KEY_NITRO} CERC_PEER_ID: ${CERC_PEER_ID} - CERC_ENABLE_UPSTREAM_PAYMENTS: ${CERC_ENABLE_UPSTREAM_PAYMENTS} - 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"] + entrypoint: ["bash", "-c"] + command: ["./deploy-nitro-contracts.sh && ./start-server.sh"] 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-rates.toml:/app/environments/rates.toml - ../config/watcher-mobymask-v3/keys:/app/keys - ../config/watcher-mobymask-v3/start-server.sh:/app/start-server.sh - - watcher_nitro_data:/app/out/nitro-db + - nitro_data:/app/out/nitro-db - peers_ids:/app/peers - - nitro_deployment:/nitro + - nitro_addresses:/nitro - mobymask_deployment:/server # Expose GQL, metrics and relay node ports ports: @@ -118,5 +124,5 @@ volumes: mobymask_watcher_db_data: peers_ids: mobymask_deployment: - nitro_deployment: - watcher_nitro_data: + nitro_addresses: + nitro_data: diff --git a/app/data/config/go-nitro/run-nitro-node.sh b/app/data/config/go-nitro/run-nitro-node.sh deleted file mode 100755 index 3131a826..00000000 --- a/app/data/config/go-nitro/run-nitro-node.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/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} diff --git a/app/data/config/go-nitro/run-reverse-payment-proxy.sh b/app/data/config/go-nitro/run-reverse-payment-proxy.sh deleted file mode 100755 index f884f20a..00000000 --- a/app/data/config/go-nitro/run-reverse-payment-proxy.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/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 diff --git a/app/data/config/nitro-contracts/deploy.sh b/app/data/config/nitro-contracts/deploy.sh deleted file mode 100755 index f4c896f7..00000000 --- a/app/data/config/nitro-contracts/deploy.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/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} diff --git a/app/data/config/ponder/ponder-start.sh b/app/data/config/ponder/ponder-start.sh deleted file mode 100755 index 5fa5c491..00000000 --- a/app/data/config/ponder/ponder-start.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/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 diff --git a/app/data/config/ponder/ponder.config.ts b/app/data/config/ponder/ponder.config.ts deleted file mode 100644 index c3a80830..00000000 --- a/app/data/config/ponder/ponder.config.ts +++ /dev/null @@ -1,37 +0,0 @@ -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!, - }, -}; diff --git a/app/data/config/watcher-mobymask-v3/deploy-and-generate-invite.sh b/app/data/config/watcher-mobymask-v3/deploy-and-generate-invite.sh deleted file mode 100755 index 7ac5fd9a..00000000 --- a/app/data/config/watcher-mobymask-v3/deploy-and-generate-invite.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/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 diff --git a/app/data/config/watcher-mobymask-v3/deploy-nitro-contracts.sh b/app/data/config/watcher-mobymask-v3/deploy-nitro-contracts.sh new file mode 100755 index 00000000..b12e9ce2 --- /dev/null +++ b/app/data/config/watcher-mobymask-v3/deploy-nitro-contracts.sh @@ -0,0 +1,58 @@ +#!/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 diff --git a/app/data/config/watcher-mobymask-v3/deploy-nitro-contracts.ts b/app/data/config/watcher-mobymask-v3/deploy-nitro-contracts.ts new file mode 100644 index 00000000..c738083d --- /dev/null +++ b/app/data/config/watcher-mobymask-v3/deploy-nitro-contracts.ts @@ -0,0 +1,49 @@ +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); + }); diff --git a/app/data/config/watcher-mobymask-v3/mobymask-app-start.sh b/app/data/config/watcher-mobymask-v3/mobymask-app-start.sh index 73990965..b7ad3a7a 100644 --- a/app/data/config/watcher-mobymask-v3/mobymask-app-start.sh +++ b/app/data/config/watcher-mobymask-v3/mobymask-app-start.sh @@ -11,36 +11,21 @@ CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}" CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}" CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}" 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" if [ -z "$CERC_DEPLOYED_CONTRACT" ]; then - # Use config from mounted volume (when running web-app along with watcher stack) - 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) + echo "CERC_DEPLOYED_CONTRACT not set" + exit 1 else echo "Using CERC_DEPLOYED_CONTRACT ${CERC_DEPLOYED_CONTRACT} from env as the MobyMask contract address" fi -nitro_addresses_file="/nitro/nitro-addresses.json" -nitro_addresses_destination_file="/app/src/utils/nitro-addresses.json" +# Checkout to the required release/branch +cd /app +git checkout $CERC_RELEASE -# Check if CERC_NA_ADDRESS environment variable is set +# Check if CERC_NA_ADDRESS 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'" @@ -53,31 +38,24 @@ if [ -n "$CERC_NA_ADDRESS" ]; then --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" + echo "$nitro_addresses_json" > /app/src/utils/nitro-addresses.json else - echo "Nitro addresses not available" + echo "Nitro addresses not provided" exit 1 fi # Export config values in a json file -app_config_file="/app/src/utils/config.json" -app_config_json=$(jq -n \ - --arg name "MobyMask" \ - --argjson enableDebugInfo true \ - --arg address "$CERC_DEPLOYED_CONTRACT" \ +jq --arg address "$CERC_DEPLOYED_CONTRACT" \ --argjson chainId "$CERC_CHAIN_ID" \ --argjson relayNodes "$CERC_RELAY_NODES" \ --argjson denyMultiaddrs "$CERC_DENY_MULTIADDRS" \ --arg pubsub "$CERC_PUBSUB" \ --argjson directPeers "$CERC_GOSSIPSUB_DIRECT_PEERS" \ - '.name = $name | .address = $address | .chainId = $chainId | .relayNodes = $relayNodes | .peer.enableDebugInfo = $enableDebugInfo | .peer.denyMultiaddrs = $denyMultiaddrs | .peer.pubsub = $pubsub | .peer.directPeers = $directPeers') -echo "$app_config_json" > "${app_config_file}" + '.address = $address | .chainId = $chainId | .relayNodes = $relayNodes | .peer.denyMultiaddrs = $denyMultiaddrs | .peer.pubsub = $pubsub | .peer.directPeers = $directPeers' \ + /app/src/mobymask-app-config.json > /app/src/utils/config.json + +yarn install -REACT_APP_DEBUG_PEER=true \ REACT_APP_WATCHER_URI="$CERC_APP_WATCHER_URL/graphql" \ REACT_APP_PAY_TO_NITRO_ADDRESS="$CERC_PAYMENT_NITRO_ADDRESS" \ REACT_APP_SNAP_ORIGIN="local:$CERC_SNAP_URL" \ diff --git a/app/data/config/watcher-mobymask-v3/mobymask-params.env b/app/data/config/watcher-mobymask-v3/mobymask-params.env index f96aae31..88b83942 100644 --- a/app/data/config/watcher-mobymask-v3/mobymask-params.env +++ b/app/data/config/watcher-mobymask-v3/mobymask-params.env @@ -1,14 +1,5 @@ # 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 DEFAULT_CERC_RELAY_PEERS=[] @@ -26,13 +17,7 @@ DEFAULT_CERC_ENABLE_PEER_L2_TXS=true DEFAULT_CERC_DEPLOYED_CONTRACT= # Chain ID is used by mobymask web-app for txs -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 +DEFAULT_CERC_CHAIN_ID=42069 # Set of relay nodes to be used by web-apps DEFAULT_CERC_RELAY_NODES=[] @@ -46,5 +31,7 @@ DEFAULT_CERC_PUBSUB="" # Set of direct peers to be used when pubsub is set to gossipsub DEFAULT_CERC_GOSSIPSUB_DIRECT_PEERS=[] -# Whether to enable payments to upstream ETH server -DEFAULT_CERC_ENABLE_UPSTREAM_PAYMENTS=true +# Set deployed Nitro addresses to avoid deploying them in the stack +DEFAULT_CERC_NA_ADDRESS= +DEFAULT_CERC_VPA_ADDRESS= +DEFAULT_CERC_CA_ADDRESS= diff --git a/app/data/config/watcher-mobymask-v3/start-server.sh b/app/data/config/watcher-mobymask-v3/start-server.sh index b3546e81..9ff4020f 100755 --- a/app/data/config/watcher-mobymask-v3/start-server.sh +++ b/app/data/config/watcher-mobymask-v3/start-server.sh @@ -5,20 +5,21 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then set -x fi -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_L2_GETH_RPC="${CERC_L2_GETH_RPC:-${DEFAULT_CERC_L2_GETH_RPC}}" + CERC_RELAY_PEERS="${CERC_RELAY_PEERS:-${DEFAULT_CERC_RELAY_PEERS}}" CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}" CERC_PUBSUB="${CERC_PUBSUB:-${DEFAULT_CERC_PUBSUB}}" 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_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" -echo "Using RPC query endpoint ${CERC_ETH_RPC_QUERY_ENDPOINT}" -echo "Using RPC mutation endpoint ${CERC_ETH_RPC_MUTATION_ENDPOINT}" +echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}" # Use public domain for relay multiaddr in peer config if specified # Otherwise, use the docker container's host IP @@ -36,37 +37,20 @@ else CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"') fi -nitro_addresses_file="/nitro/nitro-addresses.json" -nitro_addresses_destination_file="./src/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" +# 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}" + + # Build after setting the Nitro addresses + yarn build else - echo "Nitro addresses not available" + echo "File ${nitro_addresses_file} does not exist" 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_WATCHER_NITRO_PK from env for Nitro account" +echo "Using CERC_PRIVATE_KEY_NITRO from env for Nitro account" if [ -n "$CERC_PEER_ID" ]; then echo "Using CERC_PEER_ID ${CERC_PEER_ID} from env for watcher fixture" @@ -123,38 +107,24 @@ else CONSENSUS_PRIVATE_KEY='' 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 WATCHER_CONFIG_TEMPLATE=$(cat environments/watcher-config-template.toml) WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \ sed -E "s|REPLACE_WITH_CERC_RELAY_PEERS|${CERC_RELAY_PEERS}|g; \ - s|REPLACE_WITH_CERC_DENY_MULTIADDRS|${CERC_DENY_MULTIADDRS}|g; \ - s/REPLACE_WITH_CERC_PUBSUB/${CERC_PUBSUB}/g; \ - s/REPLACE_WITH_CERC_RELAY_ANNOUNCE_DOMAIN/${CERC_RELAY_ANNOUNCE_DOMAIN}/g; \ - s|REPLACE_WITH_CERC_RELAY_MULTIADDR|${CERC_RELAY_MULTIADDR}|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_PRIVATE_KEY_PEER/${CERC_PRIVATE_KEY_PEER}/g; \ - s/REPLACE_WITH_CERC_WATCHER_NITRO_PK/${CERC_WATCHER_NITRO_PK}/g; \ - s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/g; \ - s/REPLACE_WITH_CONSENSUS_ENABLED/${CONSENSUS_ENABLED}/g; \ - s/REPLACE_WITH_CONSENSUS_PUBLIC_KEY/${CONSENSUS_PUBLIC_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_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}/ ") + s|REPLACE_WITH_CERC_DENY_MULTIADDRS|${CERC_DENY_MULTIADDRS}|g; \ + s/REPLACE_WITH_CERC_PUBSUB/${CERC_PUBSUB}/g; \ + s/REPLACE_WITH_CERC_RELAY_ANNOUNCE_DOMAIN/${CERC_RELAY_ANNOUNCE_DOMAIN}/g; \ + s|REPLACE_WITH_CERC_RELAY_MULTIADDR|${CERC_RELAY_MULTIADDR}|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_PRIVATE_KEY_PEER/${CERC_PRIVATE_KEY_PEER}/g; \ + s/REPLACE_WITH_CERC_PRIVATE_KEY_NITRO/${CERC_PRIVATE_KEY_NITRO}/g; \ + s/REPLACE_WITH_CONTRACT_ADDRESS/${CONTRACT_ADDRESS}/g; \ + s/REPLACE_WITH_CONSENSUS_ENABLED/${CONSENSUS_ENABLED}/g; \ + s/REPLACE_WITH_CONSENSUS_PUBLIC_KEY/${CONSENSUS_PUBLIC_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_CERC_L2_GETH_RPC_ENDPOINT|${CERC_L2_GETH_RPC}| ") # Write the modified content to a new file echo "$WATCHER_CONFIG" > environments/local.toml diff --git a/app/data/config/watcher-mobymask-v3/watcher-config-template.toml b/app/data/config/watcher-mobymask-v3/watcher-config-template.toml index e2b5d1aa..dbf5b407 100644 --- a/app/data/config/watcher-mobymask-v3/watcher-config-template.toml +++ b/app/data/config/watcher-mobymask-v3/watcher-config-template.toml @@ -19,9 +19,6 @@ # Use -1 for skipping check on block range. maxEventsBlockRange = -1 - # Flag to specify whether RPC endpoint supports block hash as block tag parameter - rpcSupportsBlockHashParam = true - [server.p2p] enableRelay = true enablePeer = true @@ -44,9 +41,6 @@ pubsub = 'REPLACE_WITH_CERC_PUBSUB' enableDebugInfo = true enableL2Txs = REPLACE_WITH_CERC_ENABLE_PEER_L2_TXS - pingInterval = 4000 - pingTimeout = 1500 - maxRelayConnections = 10 [server.p2p.peer.l2TxsConfig] privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER' @@ -54,7 +48,7 @@ [server.p2p.nitro] store = './out/nitro-db' - privateKey = 'REPLACE_WITH_CERC_WATCHER_NITRO_PK' + privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_NITRO' chainPrivateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER' [server.p2p.nitro.payments] @@ -73,7 +67,7 @@ enabled = REPLACE_WITH_CONSENSUS_ENABLED publicKey = 'REPLACE_WITH_CONSENSUS_PUBLIC_KEY' privateKey = 'REPLACE_WITH_CONSENSUS_PRIVATE_KEY' - watcherPartyPeersFile = 'REPLACE_WITH_WATCHER_PARTY_PEERS_FILE' + watcherPartyFile = 'REPLACE_WITH_WATCHER_PARTY_PEERS_FILE' [metrics] host = "0.0.0.0" @@ -93,14 +87,9 @@ [upstream] [upstream.ethServer] - gqlApiEndpoint = 'http://ipld-eth-server:8083/graphql' - rpcProviderEndpoint = 'REPLACE_WITH_CERC_ETH_RPC_QUERY_ENDPOINT' - 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' + gqlApiEndpoint = "http://ipld-eth-server:8083/graphql" + rpcProviderEndpoint = "REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT" + blockDelayInMilliSecs = 60000 [upstream.cache] name = "requests" @@ -112,4 +101,3 @@ maxCompletionLagInSecs = 300 jobDelayInMilliSecs = 100 eventsInBatch = 50 - blockDelayInMilliSecs = 60000 diff --git a/app/data/container-build/cerc-go-nitro/build.sh b/app/data/container-build/cerc-go-nitro/build.sh deleted file mode 100755 index 0637f46d..00000000 --- a/app/data/container-build/cerc-go-nitro/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/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 diff --git a/app/data/container-build/cerc-mobymask-snap/Dockerfile b/app/data/container-build/cerc-mobymask-snap/Dockerfile deleted file mode 100644 index f80969c3..00000000 --- a/app/data/container-build/cerc-mobymask-snap/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -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"] diff --git a/app/data/container-build/cerc-mobymask-snap/build.sh b/app/data/container-build/cerc-mobymask-snap/build.sh deleted file mode 100755 index c82f96ca..00000000 --- a/app/data/container-build/cerc-mobymask-snap/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/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 diff --git a/app/data/container-build/cerc-nitro-contracts/Dockerfile b/app/data/container-build/cerc-nitro-contracts/Dockerfile deleted file mode 100644 index 23c95886..00000000 --- a/app/data/container-build/cerc-nitro-contracts/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -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 diff --git a/app/data/container-build/cerc-nitro-contracts/build.sh b/app/data/container-build/cerc-nitro-contracts/build.sh deleted file mode 100755 index c0aa770f..00000000 --- a/app/data/container-build/cerc-nitro-contracts/build.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/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 diff --git a/app/data/container-build/cerc-ponder/Dockerfile b/app/data/container-build/cerc-ponder/Dockerfile deleted file mode 100644 index ff247101..00000000 --- a/app/data/container-build/cerc-ponder/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -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 diff --git a/app/data/container-build/cerc-ponder/build.sh b/app/data/container-build/cerc-ponder/build.sh deleted file mode 100755 index fa3e44c0..00000000 --- a/app/data/container-build/cerc-ponder/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/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 diff --git a/app/data/container-build/cerc-test-container/run.sh b/app/data/container-build/cerc-test-container/run.sh index 205c231a..da0af7d5 100755 --- a/app/data/container-build/cerc-test-container/run.sh +++ b/app/data/container-build/cerc-test-container/run.sh @@ -14,6 +14,8 @@ else echo "Filesystem is fresh" echo `date` > $EXISTSFILENAME fi - +if [ -n "$CERC_TEST_PARAM_1" ]; then + echo "Test-param-1: ${CERC_TEST_PARAM_1}" +fi # Run nginx which will block here forever /usr/sbin/nginx -g "daemon off;" diff --git a/app/data/container-image-list.txt b/app/data/container-image-list.txt index 780bda53..ab8bc3ce 100644 --- a/app/data/container-image-list.txt +++ b/app/data/container-image-list.txt @@ -51,7 +51,3 @@ cerc/graph-node cerc/sushiswap-subgraphs cerc/webapp-base cerc/watcher-mobymask-v3 -cerc/go-nitro -cerc/nitro-contracts -cerc/mobymask-snap -cerc/ponder diff --git a/app/data/pod-list.txt b/app/data/pod-list.txt index ed7f17d5..ee3fc53b 100644 --- a/app/data/pod-list.txt +++ b/app/data/pod-list.txt @@ -37,8 +37,3 @@ sushiswap-subgraph-v3 fixturenet-sushiswap-subgraph-v3 watcher-mobymask-v3 mobymask-app-v3 -go-nitro -nitro-contracts -nitro-reverse-payment-proxy -mobymask-snap -ponder diff --git a/app/data/repository-list.txt b/app/data/repository-list.txt index d41074c1..d85b5895 100644 --- a/app/data/repository-list.txt +++ b/app/data/repository-list.txt @@ -43,7 +43,3 @@ github.com/cerc-io/sushiswap-v3-core github.com/cerc-io/sushiswap-v3-periphery github.com/graphprotocol/graph-node 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 diff --git a/app/data/stacks/fixturenet-payments/.env.fixturenet b/app/data/stacks/fixturenet-payments/.env.fixturenet deleted file mode 100644 index 3ebaa13f..00000000 --- a/app/data/stacks/fixturenet-payments/.env.fixturenet +++ /dev/null @@ -1,25 +0,0 @@ -# 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 diff --git a/app/data/stacks/fixturenet-payments/README.md b/app/data/stacks/fixturenet-payments/README.md deleted file mode 100644 index 2525b6d6..00000000 --- a/app/data/stacks/fixturenet-payments/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# 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") -``` diff --git a/app/data/stacks/fixturenet-payments/stack.yml b/app/data/stacks/fixturenet-payments/stack.yml deleted file mode 100644 index 98b26928..00000000 --- a/app/data/stacks/fixturenet-payments/stack.yml +++ /dev/null @@ -1,53 +0,0 @@ -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 diff --git a/app/data/stacks/mainnet-laconic/deploy/commands.py b/app/data/stacks/mainnet-laconic/deploy/commands.py index 16bf015a..3a62b42d 100644 --- a/app/data/stacks/mainnet-laconic/deploy/commands.py +++ b/app/data/stacks/mainnet-laconic/deploy/commands.py @@ -27,10 +27,7 @@ import sys import tomli import re -default_spec_file_content = """config: - node_moniker: my-node-name - chain_id: my-chain-id -""" +default_spec_file_content = "" class SetupPhase(Enum): diff --git a/app/data/stacks/mobymask-v3/stack.yml b/app/data/stacks/mobymask-v3/stack.yml index b07b3680..85af73ac 100644 --- a/app/data/stacks/mobymask-v3/stack.yml +++ b/app/data/stacks/mobymask-v3/stack.yml @@ -2,18 +2,15 @@ version: "1.0" description: "MobyMask v3 stack" name: mobymask-v3 repos: - - github.com/cerc-io/ts-nitrov0.1.12 - github.com/cerc-io/watcher-ts@v0.2.57 - - github.com/cerc-io/mobymask-v2-watcher-ts@v3 # TODO: Update after fixes + - github.com/cerc-io/mobymask-v2-watcher-ts@v3 - github.com/cerc-io/MobyMask@v0.1.3 - - github.com/cerc-io/mobymask-ui@v0.2.0 + - 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 diff --git a/app/data/stacks/mobymask-v3/watcher.md b/app/data/stacks/mobymask-v3/watcher.md index 1aa63c1d..9063b022 100644 --- a/app/data/stacks/mobymask-v3/watcher.md +++ b/app/data/stacks/mobymask-v3/watcher.md @@ -2,7 +2,7 @@ ## Setup -Prerequisite: L2 Optimism Geth RPC endpoint +Prerequisite: L2 Optimism Geth and Node RPC endpoints Clone required repositories: @@ -23,16 +23,21 @@ 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)): ```bash - # External ETH RPC endpoint (L2 Optimism geth) - CERC_ETH_RPC_ENDPOINT= + # External L2 endpoints + CERC_L2_GETH_RPC= - # External ETH RPC endpoint used for queries in the watcher - CERC_ETH_RPC_QUERY_ENDPOINT= + # Endpoints waited on before contract deployment + CERC_L2_GETH_HOST= + CERC_L2_GETH_PORT= - # External ETH RPC endpoint used for mutations in the watcher - CERC_ETH_RPC_MUTATION_ENDPOINT= + CERC_L2_NODE_HOST= + CERC_L2_NODE_PORT= - # Specify the an account PK for contract deployment + # URL (fixturenet-eth-bootnode-lighthouse) to get CSV with credentials for accounts on L1 to perform txs on L2 + CERC_L1_ACCOUNTS_CSV_URL= + + # OR + # Specify the required account credentials CERC_PRIVATE_KEY_DEPLOYER= # Base URI for mobymask-app @@ -66,14 +71,11 @@ Create and update an env file to be used in the next step ([defaults](../../conf CERC_PRIVATE_KEY_PEER= # Specify private key for the Nitro account - CERC_WATCHER_NITRO_PK= + CERC_PRIVATE_KEY_NITRO= # (Optional) Set a pre-existing peer id to be used (enables consensus) # Uses a generated peer id if not set (disables consensus) 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 @@ -81,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 --exclude mobymask-app-v3 --env-file up +laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mobymask-v3 --env-file up ``` * To list down and monitor the running containers: ```bash - laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-app-v3 ps + laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mobymask-v3 ps # With status docker ps -a @@ -104,18 +106,18 @@ laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-a docker logs -f $(docker ps -aq --filter name="mobymask-1") ``` -* Check logs of the Nitro contracts container to get the deployed Nitro contracts' addresses: +* Check the logs of the watcher server container to get the deployed Nitro contracts' addresses: - ```bash - docker exec -it $(docker ps -q --filter name="nitro-contracts") bash -c "cat /app/deployment/nitro-addresses.json" - ``` +```bash +docker exec -it $(docker ps -q --filter name="mobymask-watcher-server") bash -c "cat /nitro/nitro-addresses.json" +``` ## Clean up Stop all services running in the background: ```bash -laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-app-v3 down +laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mobymask-v3 down ``` Clear volumes created by this stack: diff --git a/app/data/stacks/mobymask-v3/web-app.md b/app/data/stacks/mobymask-v3/web-app.md index 12674cee..aef90e99 100644 --- a/app/data/stacks/mobymask-v3/web-app.md +++ b/app/data/stacks/mobymask-v3/web-app.md @@ -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 CERC_PAYMENT_NITRO_ADDRESS= - # (Optional) Endpoint for Mobymask snap installation + # Endpoint for Mobymask snap installation CERC_SNAP_URL= ``` diff --git a/app/data/stacks/test/deploy/commands.py b/app/data/stacks/test/deploy/commands.py index 0a836037..fbb9a8ea 100644 --- a/app/data/stacks/test/deploy/commands.py +++ b/app/data/stacks/test/deploy/commands.py @@ -20,7 +20,7 @@ from app.deploy_util import VolumeMapping, run_container_command from pathlib import Path default_spec_file_content = """config: - config_variable: test-value + test-variable-1: test-value-1 """ diff --git a/app/deployment.py b/app/deployment.py index 8c860e46..aeabf61c 100644 --- a/app/deployment.py +++ b/app/deployment.py @@ -25,6 +25,16 @@ from app.deploy import exec_operation, logs_operation, create_deploy_context class DeploymentContext: dir: Path + def get_stack_file(self): + return self.dir.joinpath("stack.yml") + + def get_env_file(self): + return self.dir.joinpath("config.env") + + # TODO: implement me + def get_cluster_name(self): + return None + @click.group() @click.option("--dir", required=True, help="path to deployment directory") @@ -49,10 +59,10 @@ def command(ctx, dir): def make_deploy_context(ctx): - # Get the stack config file name - stack_file_path = ctx.obj.dir.joinpath("stack.yml") - # TODO: add cluster name and env file here - return create_deploy_context(ctx.parent.parent.obj, stack_file_path, None, None, None, None) + stack_file_path = ctx.obj.get_stack_file() + env_file = ctx.obj.get_env_file() + cluster_name = ctx.obj.get_cluster_name() + return create_deploy_context(ctx.parent.parent.obj, stack_file_path, None, None, cluster_name, env_file) @command.command() diff --git a/app/deployment_create.py b/app/deployment_create.py index 837aaa61..76016262 100644 --- a/app/deployment_create.py +++ b/app/deployment_create.py @@ -204,22 +204,48 @@ def _get_mapped_ports(stack: str, map_recipe: str): return ports +def _parse_config_variables(variable_values: str): + result = None + if variable_values: + value_pairs = variable_values.split(",") + if len(value_pairs): + result_values = {} + for value_pair in value_pairs: + variable_value_pair = value_pair.split("=") + if len(variable_value_pair) != 2: + print(f"ERROR: config argument is not valid: {variable_values}") + sys.exit(1) + variable_name = variable_value_pair[0] + variable_value = variable_value_pair[1] + result_values[variable_name] = variable_value + result = {"config": result_values} + return result + + @click.command() +@click.option("--config", help="Provide config variables for the deployment") @click.option("--output", required=True, help="Write yaml spec file here") @click.option("--map-ports-to-host", required=False, help="Map ports to the host as one of: any-variable-random (default), " "localhost-same, any-same, localhost-fixed-random, any-fixed-random") @click.pass_context -def init(ctx, output, map_ports_to_host): +def init(ctx, config, output, map_ports_to_host): yaml = get_yaml() stack = global_options(ctx).stack - verbose = global_options(ctx).verbose + debug = global_options(ctx).debug default_spec_file_content = call_stack_deploy_init(ctx.obj) spec_file_content = {"stack": stack} if default_spec_file_content: spec_file_content.update(default_spec_file_content) - if verbose: - print(f"Creating spec file for stack: {stack}") + config_variables = _parse_config_variables(config) + if config_variables: + # Implement merge, since update() overwrites + orig_config = spec_file_content["config"] + new_config = config_variables["config"] + merged_config = {**new_config, **orig_config} + spec_file_content.update({"config": merged_config}) + if debug: + print(f"Creating spec file for stack: {stack} with content: {spec_file_content}") ports = _get_mapped_ports(stack, map_ports_to_host) spec_file_content["ports"] = ports @@ -235,6 +261,16 @@ def init(ctx, output, map_ports_to_host): yaml.dump(spec_file_content, output_file) +def _write_config_file(spec_file: Path, config_env_file: Path): + spec_content = get_parsed_deployment_spec(spec_file) + if spec_content["config"]: + config_vars = spec_content["config"] + if config_vars: + with open(config_env_file, "w") as output_file: + for variable_name, variable_value in config_vars.items(): + output_file.write(f"{variable_name}={variable_value}\n") + + @click.command() @click.option("--spec-file", required=True, help="Spec file to use to create this deployment") @click.option("--deployment-dir", help="Create deployment files in this directory") @@ -259,6 +295,8 @@ def create(ctx, spec_file, deployment_dir, network_dir, initial_peers): # Copy spec file and the stack file into the deployment dir copyfile(spec_file, os.path.join(deployment_dir, os.path.basename(spec_file))) copyfile(stack_file, os.path.join(deployment_dir, os.path.basename(stack_file))) + # Copy any config varibles from the spec file into an env file suitable for compose + _write_config_file(spec_file, os.path.join(deployment_dir, "config.env")) # Copy the pod files into the deployment dir, fixing up content pods = parsed_stack['pods'] destination_compose_dir = os.path.join(deployment_dir, "compose") diff --git a/tests/deploy/run-deploy-test.sh b/tests/deploy/run-deploy-test.sh index 0ebb215f..86f4b689 100755 --- a/tests/deploy/run-deploy-test.sh +++ b/tests/deploy/run-deploy-test.sh @@ -77,7 +77,7 @@ $TEST_TARGET_SO --stack test deploy down --delete-volumes # Basic test of creating a deployment test_deployment_dir=$CERC_REPO_BASE_DIR/test-deployment-dir test_deployment_spec=$CERC_REPO_BASE_DIR/test-deployment-spec.yml -$TEST_TARGET_SO --stack test deploy init --output $test_deployment_spec +$TEST_TARGET_SO --stack test deploy init --output $test_deployment_spec --config CERC_TEST_PARAM_1=PASSED # Check the file now exists if [ ! -f "$test_deployment_spec" ]; then echo "deploy init test: spec file not present" @@ -110,13 +110,20 @@ echo "deploy create output file test: passed" # Try to start the deployment $TEST_TARGET_SO deployment --dir $test_deployment_dir start # Check logs command works -log_output_2=$( $TEST_TARGET_SO deployment --dir $test_deployment_dir logs ) -if [[ "$log_output_2" == *"Filesystem is fresh"* ]]; then +log_output_3=$( $TEST_TARGET_SO deployment --dir $test_deployment_dir logs ) +if [[ "$log_output_3" == *"Filesystem is fresh"* ]]; then echo "deployment logs test: passed" else echo "deployment logs test: FAILED" exit 1 fi +# Check the config variable CERC_TEST_PARAM_1 was passed correctly +if [[ "$log_output_3" == *"Test-param-1: PASSED"* ]]; then + echo "deployment config test: passed" +else + echo "deployment config test: FAILED" + exit 1 +fi # Stop and clean up $TEST_TARGET_SO deployment --dir $test_deployment_dir stop --delete-volumes echo "Test passed"