From c8fe72b3925d073363f5e65b57e263dfbaaf4eb5 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 3 Oct 2023 12:09:51 +0530 Subject: [PATCH] Fix ponder setup and update instructions --- app/data/compose/docker-compose-ponder.yml | 13 ++++--- .../{ponder-app-start.sh => ponder-start.sh} | 32 +++++++++-------- .../fixturenet-payments/.env.fixturenet | 25 +++++++++++++ app/data/stacks/fixturenet-payments/README.md | 35 +++++++++++++++++-- app/data/stacks/fixturenet-payments/stack.yml | 6 ++-- 5 files changed, 84 insertions(+), 27 deletions(-) rename app/data/config/ponder/{ponder-app-start.sh => ponder-start.sh} (90%) create mode 100644 app/data/stacks/fixturenet-payments/.env.fixturenet diff --git a/app/data/compose/docker-compose-ponder.yml b/app/data/compose/docker-compose-ponder.yml index a633a178..4a6602e4 100644 --- a/app/data/compose/docker-compose-ponder.yml +++ b/app/data/compose/docker-compose-ponder.yml @@ -4,7 +4,7 @@ services: ponder-app: restart: unless-stopped image: cerc/ponder:local - workdir: /app/examples/token-erc20 + 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} @@ -14,15 +14,14 @@ services: CERC_RELAY_MULTIADDR: ${CERC_RELAY_MULTIADDR} CERC_UPSTREAM_NITRO_ADDRESS: ${CERC_UPSTREAM_NITRO_ADDRESS} CERC_UPSTREAM_NITRO_MULTIADDR: ${CERC_UPSTREAM_NITRO_MULTIADDR} - CERC_UPSTREAM_NITRO_PAY_AMOUNT: ${CERC_UPSTREAM_NITRO_PAY_AMOUNT} - command: ["bash", "ponder-app-start.sh"] + CERC_UPSTREAM_NITRO_PAY_AMOUNT: ${CERC_UPSTREAM_NITRO_PAY_AMOUNT:-5000} + command: ["bash", "./ponder-start.sh"] volumes: - - ../config/ponder/ponder-app-start.sh:/app/ponder-app-start.sh - - ../config/ponder/ponder.config.ts:/app/ponder.config.ts - - ../config/ponder/.env.local:/app/.env.local + - ../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/.ponder/nitro-db + - ponder_nitro_data:/app/examples/token-erc20/.ponder/nitro-db extra_hosts: - "host.docker.internal:host-gateway" diff --git a/app/data/config/ponder/ponder-app-start.sh b/app/data/config/ponder/ponder-start.sh similarity index 90% rename from app/data/config/ponder/ponder-app-start.sh rename to app/data/config/ponder/ponder-start.sh index 830c0b31..5fa5c491 100755 --- a/app/data/config/ponder/ponder-app-start.sh +++ b/app/data/config/ponder/ponder-start.sh @@ -5,8 +5,21 @@ 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/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 @@ -38,21 +51,9 @@ 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="[\"/ip4/127.0.0.1/tcp/9090/ws/p2p/$(jq -r '.id' /peers/relay-id.json)\"]" + CERC_RELAY_MULTIADDR="/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/$(jq -r '.id' /peers/relay-id.json)" 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 - break - fi - - echo "RPC endpoint not yet available, retrying in $retry_interval seconds..." - sleep $retry_interval -done - env_file='.env.local' echo "PONDER_CHAIN_ID=\"$PONDER_CHAIN_ID\"" > "$env_file" echo "PONDER_RPC_URL_1=\"$PONDER_RPC_URL_1\"" >> "$env_file" @@ -64,4 +65,5 @@ echo "CERC_UPSTREAM_NITRO_ADDRESS=\"$CERC_UPSTREAM_NITRO_ADDRESS\"" >> "$env_fil echo "CERC_UPSTREAM_NITRO_MULTIADDR=\"$CERC_UPSTREAM_NITRO_MULTIADDR\"" >> "$env_file" echo "CERC_UPSTREAM_NITRO_PAY_AMOUNT=\"$CERC_UPSTREAM_NITRO_PAY_AMOUNT\"" >> "$env_file" -pnpm start +# Keep the container running +tail -f diff --git a/app/data/stacks/fixturenet-payments/.env.fixturenet b/app/data/stacks/fixturenet-payments/.env.fixturenet new file mode 100644 index 00000000..3ebaa13f --- /dev/null +++ b/app/data/stacks/fixturenet-payments/.env.fixturenet @@ -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 diff --git a/app/data/stacks/fixturenet-payments/README.md b/app/data/stacks/fixturenet-payments/README.md index 26e0f479..0dfdf360 100644 --- a/app/data/stacks/fixturenet-payments/README.md +++ b/app/data/stacks/fixturenet-payments/README.md @@ -16,12 +16,43 @@ laconic-so --stack fixturenet-payments build-containers ## Deploy -Deploy the stack: +### Configuration + +Create an env file with contents from [.env.fixturenet](./.env.fixturenet) to be used in the next step + +### Deploy the stack: ```bash -laconic-so --stack fixturenet-payments deploy --cluster [CLUSTER_NAME] up +laconic-so --stack fixturenet-payments deploy --cluster [CLUSTER_NAME] --env-file 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: diff --git a/app/data/stacks/fixturenet-payments/stack.yml b/app/data/stacks/fixturenet-payments/stack.yml index 31b55601..8de0baf7 100644 --- a/app/data/stacks/fixturenet-payments/stack.yml +++ b/app/data/stacks/fixturenet-payments/stack.yml @@ -8,17 +8,17 @@ repos: - github.com/cerc-io/ipld-eth-db - github.com/cerc-io/ipld-eth-server # nitro repos - - github.com/cerc-io/ts-nitro + - github.com/cerc-io/ts-nitro@v0.1.12 - github.com/cerc-io/go-nitro@pm-disable-compression # TODO: Update # mobymask watcher repos - github.com/cerc-io/watcher-ts@v0.2.61 - - github.com/cerc-io/mobymask-v2-watcher-ts@pm-upstream-payments # TODO: Update + - github.com/cerc-io/mobymask-v2-watcher-ts@v3 # TODO: Update - 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@paid-eth-rpc # TODO: Update + - github.com/cerc-io/ponder@laconic containers: # fixturenet images - cerc/go-ethereum