diff --git a/app/data/compose/docker-compose-go-nitro.yml b/app/data/compose/docker-compose-go-nitro.yml index fc051f19..5d28179b 100644 --- a/app/data/compose/docker-compose-go-nitro.yml +++ b/app/data/compose/docker-compose-go-nitro.yml @@ -10,11 +10,11 @@ services: 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_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL:-ws://fixturenet-eth-geth-1:8546} + CERC_NITRO_PK: ${CERC_NITRO_PK:-2d999770f7b5d49b694080f987b82bbc9fc9ac2b4dcc10b0f8aba7d700f69c6d} + CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK:-570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597} + CERC_NITRO_USE_DURABLE_STORE: ${CERC_NITRO_USE_DURABLE_STORE:-true} + CERC_NITRO_DURABLE_STORE_FOLDER: ${CERC_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} @@ -34,6 +34,17 @@ services: - "4005:4005" - "5005:5005" + nitro-rpc-client: + image: cerc/nitro-rpc-client:local + hostname: nitro-rpc-client + restart: on-failure + depends_on: + # Wait for the go-nitro node to start + go-nitro: + condition: service_healthy + command: ["bash", "-c", "tail -f /dev/null"] + + volumes: go_nitro_data: 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 index 37f49407..bf7461a0 100644 --- a/app/data/compose/docker-compose-nitro-reverse-payment-proxy.yml +++ b/app/data/compose/docker-compose-nitro-reverse-payment-proxy.yml @@ -10,10 +10,10 @@ services: 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} + CERC_PROXY_ADDRESS: 0.0.0.0:8081 + CERC_PROXY_NITRO_ENDPOINT: ${CERC_PROXY_NITRO_ENDPOINT:-go-nitro:4005/api/v1} + CERC_PROXY_DESTINATION_URL: ${CERC_PROXY_DESTINATION_URL:-http://ipld-eth-server:8081} + CERC_PROXY_COST_PER_BYTE: ${CERC_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 diff --git a/app/data/compose/docker-compose-ponder.yml b/app/data/compose/docker-compose-ponder.yml index 62d46b47..d0ea29e6 100644 --- a/app/data/compose/docker-compose-ponder.yml +++ b/app/data/compose/docker-compose-ponder.yml @@ -6,11 +6,11 @@ services: 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_CHAIN_ID: ${PONDER_CHAIN_ID:-99} + CERC_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_PONDER_NITRO_CHAIN_URL: ${CERC_PONDER_NITRO_CHAIN_URL:-http://fixturenet-eth-geth-1:8546} 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} diff --git a/app/data/compose/docker-compose-watcher-mobymask-v3.yml b/app/data/compose/docker-compose-watcher-mobymask-v3.yml index 107c9bba..bd07d7ef 100644 --- a/app/data/compose/docker-compose-watcher-mobymask-v3.yml +++ b/app/data/compose/docker-compose-watcher-mobymask-v3.yml @@ -74,6 +74,7 @@ services: 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_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL} CERC_RELAY_PEERS: ${CERC_RELAY_PEERS} CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS} CERC_PUBSUB: ${CERC_PUBSUB} diff --git a/app/data/config/go-nitro/run-nitro-node.sh b/app/data/config/go-nitro/run-nitro-node.sh index 3131a826..9cc9fccf 100755 --- a/app/data/config/go-nitro/run-nitro-node.sh +++ b/app/data/config/go-nitro/run-nitro-node.sh @@ -30,6 +30,6 @@ fi echo "Running Nitro node" -# TODO Wait for RPC endpoint to come up +# TODO Wait for chain endpoint to come up -./nitro -chainurl ${NITRO_CHAIN_URL} -msgport 3005 -rpcport 4005 -wsmsgport 5005 -pk ${NITRO_PK} -chainpk ${NITRO_CHAIN_PK} -naaddress ${NA_ADDRESS} -vpaaddress ${VPA_ADDRESS} -caaddress ${CA_ADDRESS} -usedurablestore ${NITRO_USE_DURABLE_STORE} -durablestorefolder ${NITRO_DURABLE_STORE_FOLDER} +./nitro -chainurl ${CERC_NITRO_CHAIN_URL} -msgport 3005 -rpcport 4005 -wsmsgport 5005 -pk ${CERC_NITRO_PK} -chainpk ${CERC_NITRO_CHAIN_PK} -naaddress ${NA_ADDRESS} -vpaaddress ${VPA_ADDRESS} -caaddress ${CA_ADDRESS} -usedurablestore ${CERC_NITRO_USE_DURABLE_STORE} -durablestorefolder ${CERC_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 index f884f20a..4aa07fbe 100755 --- a/app/data/config/go-nitro/run-reverse-payment-proxy.sh +++ b/app/data/config/go-nitro/run-reverse-payment-proxy.sh @@ -6,9 +6,9 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then 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}" +echo "Using CERC_PROXY_ADDRESS ${CERC_PROXY_ADDRESS}" +echo "Using CERC_PROXY_NITRO_ENDPOINT ${CERC_PROXY_NITRO_ENDPOINT}" +echo "Using CERC_PROXY_DESTINATION_URL ${CERC_PROXY_DESTINATION_URL}" +echo "Using CERC_PROXY_COST_PER_BYTE ${CERC_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 +./proxy -proxyaddress ${CERC_PROXY_ADDRESS} -nitroendpoint=${CERC_PROXY_NITRO_ENDPOINT} -destinationurl=${CERC_PROXY_DESTINATION_URL} -costperbyte ${CERC_PROXY_COST_PER_BYTE} -enablepaidrpcmethods diff --git a/app/data/config/nitro-contracts/deploy.sh b/app/data/config/nitro-contracts/deploy.sh index f4c896f7..758837b8 100755 --- a/app/data/config/nitro-contracts/deploy.sh +++ b/app/data/config/nitro-contracts/deploy.sh @@ -53,5 +53,5 @@ 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} +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 index 5fa5c491..51d2447b 100755 --- a/app/data/config/ponder/ponder-start.sh +++ b/app/data/config/ponder/ponder-start.sh @@ -5,19 +5,6 @@ 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" @@ -55,15 +42,19 @@ if [ -z "$CERC_RELAY_MULTIADDR" ]; then 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" +echo "PONDER_TELEMETRY_DISABLED=true" > "$env_file" +echo "PONDER_LOG_LEVEL=debug" >> "$env_file" +echo "PONDER_CHAIN_ID=\"$CERC_PONDER_CHAIN_ID\"" >> "$env_file" +echo "PONDER_RPC_URL_1=\"$CERC_PONDER_RPC_URL_1\"" >> "$env_file" +echo "PONDER_NITRO_PK=\"$CERC_PONDER_NITRO_PK\"" >> "$env_file" +echo "PONDER_NITRO_CHAIN_PK=\"$CERC_PONDER_NITRO_CHAIN_PK\"" >> "$env_file" +echo "PONDER_NITRO_CHAIN_URL=\"$CERC_PONDER_NITRO_CHAIN_URL\"" >> "$env_file" +echo "RELAY_MULTIADDR=\"$CERC_RELAY_MULTIADDR\"" >> "$env_file" +echo "UPSTREAM_NITRO_ADDRESS=\"$CERC_UPSTREAM_NITRO_ADDRESS\"" >> "$env_file" +echo "UPSTREAM_NITRO_MULTIADDR=\"$CERC_UPSTREAM_NITRO_MULTIADDR\"" >> "$env_file" +echo "UPSTREAM_NITRO_PAY_AMOUNT=\"$CERC_UPSTREAM_NITRO_PAY_AMOUNT\"" >> "$env_file" + +cat "$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 index c3a80830..be73af9a 100644 --- a/app/data/config/ponder/ponder.config.ts +++ b/app/data/config/ponder/ponder.config.ts @@ -9,6 +9,24 @@ export const config: Config = { chainId: Number(process.env.PONDER_CHAIN_ID), rpcUrl: process.env.PONDER_RPC_URL_1, maxRpcRequestConcurrency: 1, + pollingInterval: 5000, + payments: { + nitro: { + address: process.env.UPSTREAM_NITRO_ADDRESS!, + multiAddr: process.env.UPSTREAM_NITRO_MULTIADDR!, + fundingAmounts: { + // TODO: Pass amounts from env + directFund: "1000000000000", + virtualFund: "1000000000", + }, + }, + paidRPCMethods: [ + "eth_getLogs", + "eth_getBlockByNumber", + "eth_getBlockByHash", + ], + amount: process.env.UPSTREAM_NITRO_PAY_AMOUNT!, + }, }, ], contracts: [ @@ -22,16 +40,11 @@ export const config: Config = { }, ], nitro: { - privateKey: process.env.CERC_PONDER_NITRO_PK!, - chainPrivateKey: process.env.CERC_PONDER_NITRO_CHAIN_PK!, - chainURL: process.env.CERC_PONDER_NITRO_CHAIN_URL!, + privateKey: process.env.PONDER_NITRO_PK!, + chainPrivateKey: process.env.PONDER_NITRO_CHAIN_PK!, + chainUrl: process.env.PONDER_NITRO_CHAIN_URL!, contractAddresses, - relayMultiAddr: process.env.CERC_RELAY_MULTIADDR!, + relayMultiAddr: process.env.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/mobymask-params.env b/app/data/config/watcher-mobymask-v3/mobymask-params.env index f96aae31..1d843597 100644 --- a/app/data/config/watcher-mobymask-v3/mobymask-params.env +++ b/app/data/config/watcher-mobymask-v3/mobymask-params.env @@ -9,6 +9,9 @@ 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" +# ETH endpoint used by watcher's Nitro node +DEFAULT_CERC_NITRO_CHAIN_URL="http://fixturenet-eth-geth-1:8546" + # Set of relay peers to connect to from the relay node DEFAULT_CERC_RELAY_PEERS=[] diff --git a/app/data/config/watcher-mobymask-v3/start-server.sh b/app/data/config/watcher-mobymask-v3/start-server.sh index b3546e81..e2d005c4 100755 --- a/app/data/config/watcher-mobymask-v3/start-server.sh +++ b/app/data/config/watcher-mobymask-v3/start-server.sh @@ -7,6 +7,7 @@ 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_NITRO_CHAIN_URL="${CERC_NITRO_CHAIN_URL:-${DEFAULT_CERC_NITRO_CHAIN_URL}}" 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}}" @@ -19,6 +20,7 @@ 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 Nitro chain URL ${CERC_NITRO_CHAIN_URL}" # Use public domain for relay multiaddr in peer config if specified # Otherwise, use the docker container's host IP @@ -146,6 +148,7 @@ WATCHER_CONFIG=$(echo "$WATCHER_CONFIG_TEMPLATE" | \ 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_CERC_NITRO_CHAIN_URL|${CERC_NITRO_CHAIN_URL}|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; \ 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..052fcd63 100644 --- a/app/data/config/watcher-mobymask-v3/watcher-config-template.toml +++ b/app/data/config/watcher-mobymask-v3/watcher-config-template.toml @@ -53,6 +53,7 @@ contractAddress = 'REPLACE_WITH_CONTRACT_ADDRESS' [server.p2p.nitro] + chainUrl = 'REPLACE_WITH_CERC_NITRO_CHAIN_URL' store = './out/nitro-db' privateKey = 'REPLACE_WITH_CERC_WATCHER_NITRO_PK' chainPrivateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER' @@ -93,15 +94,22 @@ [upstream] [upstream.ethServer] - gqlApiEndpoint = 'http://ipld-eth-server:8083/graphql' + 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' + [upstream.ethServer.payments] + paidRPCMethods = ["eth_getBlockByHash", "eth_getBlockByNumber", "eth_getStorageAt"] amount = 'REPLACE_WITH_UPSTREAM_NITRO_PAY_AMOUNT' + [upstream.ethServer.payments.nitro] + address = 'REPLACE_WITH_UPSTREAM_NITRO_ADDRESS' + multiAddr = 'REPLACE_WITH_UPSTREAM_NITRO_MULTIADDR' + + [upstream.ethServer.payments.nitro.fundingAmounts] + directFund = "1000000000000" + virtualFund = "1000000000" + [upstream.cache] name = "requests" enabled = false diff --git a/app/data/container-build/cerc-nitro-contracts/Dockerfile b/app/data/container-build/cerc-nitro-contracts/Dockerfile index 23c95886..4ed5192d 100644 --- a/app/data/container-build/cerc-nitro-contracts/Dockerfile +++ b/app/data/container-build/cerc-nitro-contracts/Dockerfile @@ -7,6 +7,6 @@ WORKDIR /app COPY . . RUN echo "Installing dependencies" && \ - yarn + yarn && yarn build:node -WORKDIR /app/packages/nitro-util +WORKDIR /app/packages/nitro-node diff --git a/app/data/container-build/cerc-nitro-rpc-client/Dockerfile b/app/data/container-build/cerc-nitro-rpc-client/Dockerfile new file mode 100644 index 00000000..2c0d636a --- /dev/null +++ b/app/data/container-build/cerc-nitro-rpc-client/Dockerfile @@ -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 + +RUN cd packages/nitro-rpc-client diff --git a/app/data/container-build/cerc-nitro-rpc-client/build.sh b/app/data/container-build/cerc-nitro-rpc-client/build.sh new file mode 100755 index 00000000..1a80583b --- /dev/null +++ b/app/data/container-build/cerc-nitro-rpc-client/build.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Build cerc/nitro-rpc-client + +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-rpc-client:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/go-nitro diff --git a/app/data/container-build/cerc-watcher-ts/Dockerfile b/app/data/container-build/cerc-watcher-ts/Dockerfile index 75ba2efa..ec6c00f8 100644 --- a/app/data/container-build/cerc-watcher-ts/Dockerfile +++ b/app/data/container-build/cerc-watcher-ts/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16.17.1-alpine3.16 +FROM node:18.17.1-alpine3.18 RUN apk --update --no-cache add git python3 alpine-sdk jq diff --git a/app/data/stacks/fixturenet-payments/demo.md b/app/data/stacks/fixturenet-payments/demo.md index 1bdf87bb..0b5e658d 100644 --- a/app/data/stacks/fixturenet-payments/demo.md +++ b/app/data/stacks/fixturenet-payments/demo.md @@ -13,6 +13,7 @@ # ts-nitro:util:nitro Ledger channel created with id 0x65703ccdfacab09ac35367bdbe6c5a337e7a6651aad526807607b1c59b28bc1e # ... # ts-nitro:util:nitro Virtual payment channel created with id 0x29ff1335d73391a50e8fde3e9b34f00c3d81c39ddc7f89187f44dd51df96140e + # vulcanize:server Starting server... +0ms ``` * Export the payment channel id to a variable: @@ -21,39 +22,21 @@ export WATCHER_UPSTREAM_PAYMENT_CHANNEL= ``` -* Generate an auth token required to query the go-nitro node's RPC endpoint: - - ```bash - export AUTH_TOKEN=$(curl -s -X POST -H "Content-Type: application/json" --data '{ - "jsonrpc": "2.0", "id": 1, - "method": "get_auth_token", - "params": {} - }' http://127.0.0.1:4005/api/v1 | jq -r '.result') - ``` - * Check the payment channel status: ```bash - curl -X POST -H "Content-Type: application/json" --data "{ - \"jsonrpc\": \"2.0\", \"id\": 1, - \"method\": \"get_payment_channel\", - \"params\": { \"authtoken\": \"$AUTH_TOKEN\", \"payload\": { \"Id\": \"$WATCHER_UPSTREAM_PAYMENT_CHANNEL\" } } - }" http://127.0.0.1:4005/api/v1 | jq + docker exec payments-nitro-rpc-client-1 npm exec -c "nitro-rpc-client get-payment-channel $WATCHER_UPSTREAM_PAYMENT_CHANNEL -h go-nitro -p 4005" # Expected output: # { - # "jsonrpc": "2.0", - # "id": 1, - # "result": { - # "ID": "0xfe1231722d6c2cd7af8606afe039582ebc438ee5ca2b956f8284cb497597583f", - # "Status": "Open", - # "Balance": { - # "AssetAddress": "0x0000000000000000000000000000000000000000", - # "Payee": "0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce", - # "Payer": "0xbbb676f9cff8d242e9eac39d063848807d3d1d94", - # "PaidSoFar": "0x0", - # "RemainingFunds": "0x3b9aca00" - # } + # ID: '0x8c0d17639bd2ba07dbcd248304a8f3c6c7276bfe25c2b87fe41f461e20f33f01', + # Status: 'Open', + # Balance: { + # AssetAddress: '0x0000000000000000000000000000000000000000', + # Payee: '0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce', + # Payer: '0xbbb676f9cff8d242e9eac39d063848807d3d1d94', + # PaidSoFar: 0n, + # RemainingFunds: 1000000000n # } # } ``` @@ -127,7 +110,7 @@ * Perform phisher status check queries now that a payment channel is created: * Check the watcher logs for received payments - * Check the payment proxy server logs for charged RPC requests (`eth_getBlockByHash`, `eth_getStorageAt`) made from watcher to upstream ETH server + * Check the payment proxy server logs for charged RPC requests (`eth_getBlockByHash`, `eth_getBlockByNumber`, `eth_getStorageAt`) made from watcher to upstream ETH server * Change the amount besides `PAY` button to `>=100` for phisher reports next @@ -136,26 +119,18 @@ * Check the watcher - eth-server payment channel status after a few requests: ```bash - curl -X POST -H "Content-Type: application/json" --data "{ - \"jsonrpc\": \"2.0\", \"id\": 1, - \"method\": \"get_payment_channel\", - \"params\": { \"authtoken\": \"$AUTH_TOKEN\", \"payload\": { \"Id\": \"$WATCHER_UPSTREAM_PAYMENT_CHANNEL\" } } - }" http://127.0.0.1:4005/api/v1 | jq + docker exec payments-nitro-rpc-client-1 npm exec -c "nitro-rpc-client get-payment-channel $WATCHER_UPSTREAM_PAYMENT_CHANNEL -h go-nitro -p 4005" # Expected output ('PaidSoFar' should be non zero): # { - # "jsonrpc": "2.0", - # "id": 1, - # "result": { - # "ID": "0xfe1231722d6c2cd7af8606afe039582ebc438ee5ca2b956f8284cb497597583f", - # "Status": "Open", - # "Balance": { - # "AssetAddress": "0x0000000000000000000000000000000000000000", - # "Payee": "0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce", - # "Payer": "0xbbb676f9cff8d242e9eac39d063848807d3d1d94", - # "PaidSoFar": "0x2710", - # "RemainingFunds": "0x3b9aa2f0" - # } + # ID: '0x8c0d17639bd2ba07dbcd248304a8f3c6c7276bfe25c2b87fe41f461e20f33f01', + # Status: 'Open', + # Balance: { + # AssetAddress: '0x0000000000000000000000000000000000000000', + # Payee: '0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce', + # Payer: '0xbbb676f9cff8d242e9eac39d063848807d3d1d94', + # PaidSoFar: 30000n, + # RemainingFunds: 999970000n # } # } ``` @@ -184,14 +159,20 @@ * Check the ponder - eth-server payment channel status: ```bash - curl -X POST -H "Content-Type: application/json" --data "{ - \"jsonrpc\": \"2.0\", \"id\": 1, - \"method\": \"get_payment_channel\", - \"params\": { \"authtoken\": \"$AUTH_TOKEN\", \"payload\": { \"Id\": \"$PONDER_UPSTREAM_PAYMENT_CHANNEL\" } } - }" http://127.0.0.1:4005/api/v1 | jq + docker exec payments-nitro-rpc-client-1 npm exec -c "nitro-rpc-client get-payment-channel $PONDER_UPSTREAM_PAYMENT_CHANNEL -h go-nitro -p 4005" - # Expected output: - # TODO + # Expected output ('PaidSoFar' is non zero): + # { + # ID: '0x1178ac0f2a43e54a122216fa6afdd30333b590e49e50317a1f9274a591da0f96', + # Status: 'Open', + # Balance: { + # AssetAddress: '0x0000000000000000000000000000000000000000', + # Payee: '0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce', + # Payer: '0x67d5b55604d1af90074fcb69b8c51838fff84f8d', + # PaidSoFar: 215000n, + # RemainingFunds: 999785000n + # } + # } ``` * Check reverse payment proxy server logs for charged RPC requests made from ponder app to upstream ETH server: diff --git a/app/data/stacks/fixturenet-payments/stack.yml b/app/data/stacks/fixturenet-payments/stack.yml index 7e5be82b..485aeea0 100644 --- a/app/data/stacks/fixturenet-payments/stack.yml +++ b/app/data/stacks/fixturenet-payments/stack.yml @@ -8,11 +8,11 @@ repos: - git.vdb.to/cerc-io/ipld-eth-db@v5 - git.vdb.to/cerc-io/ipld-eth-server@v1.11.6-statediff-v5 # 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 + - github.com/cerc-io/ts-nitro@v0.1.13 + - github.com/cerc-io/go-nitro@ts-interop # 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/watcher-ts@v0.2.63 + - github.com/cerc-io/mobymask-v2-watcher-ts@v0.2.2 - github.com/cerc-io/MobyMask@v0.1.3 # mobymask app repos - github.com/cerc-io/mobymask-snap @@ -31,6 +31,7 @@ containers: - cerc/ipld-eth-server - cerc/nitro-contracts - cerc/go-nitro + - cerc/nitro-rpc-client # mobymask watcher images - cerc/watcher-ts - cerc/watcher-mobymask-v3