Add a fixturenet-payments stack #540

Merged
prathamesh0 merged 20 commits from pm-payments-stack into main 2023-10-03 12:10:35 +00:00
36 changed files with 836 additions and 212 deletions

View File

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

View File

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

View File

@ -15,18 +15,19 @@ services:
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
CERC_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}
CERC_PAYMENT_NITRO_ADDRESS: ${CERC_PAYMENT_NITRO_ADDRESS:-0xBBB676f9cFF8D242e9eaC39D063848807d3D1D94}
CERC_SNAP_URL: ${CERC_SNAP_URL}
working_dir: /scripts
command: ["sh", "mobymask-app-start.sh"]
working_dir: /app
command: ["bash", "/scripts/mobymask-app-start.sh"]
volumes:
- ../config/watcher-mobymask-v3/mobymask-app-start.sh:/scripts/mobymask-app-start.sh
- ../config/watcher-mobymask-v2/mobymask-app-config.json:/app/src/mobymask-app-config.json
- peers_ids:/peers
- mobymask_deployment:/server
- nitro_deployment:/nitro
ports:
- "127.0.0.1:3004:80"
healthcheck:
@ -37,3 +38,8 @@ services:
start_period: 10s
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
peers_ids:
mobymask_deployment:
nitro_deployment:

View File

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

View File

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

View File

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

View File

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

View File

@ -32,20 +32,13 @@ services:
environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
ENV: "PROD"
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_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT}
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER:-0x888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218}
CERC_MOBYMASK_APP_BASE_URI: ${CERC_MOBYMASK_APP_BASE_URI}
CERC_DEPLOYED_CONTRACT: ${CERC_DEPLOYED_CONTRACT}
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"]
command: ["bash", "-c", "./deploy-and-generate-invite.sh"]
volumes:
- ../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
- ../config/watcher-mobymask-v3/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"
@ -62,7 +55,6 @@ 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
@ -74,13 +66,14 @@ 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_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_ETH_RPC_QUERY_ENDPOINT: ${CERC_ETH_RPC_QUERY_ENDPOINT}
CERC_ETH_RPC_MUTATION_ENDPOINT: ${CERC_ETH_RPC_MUTATION_ENDPOINT}
CERC_RELAY_PEERS: ${CERC_RELAY_PEERS}
CERC_DENY_MULTIADDRS: ${CERC_DENY_MULTIADDRS}
CERC_PUBSUB: ${CERC_PUBSUB}
@ -90,21 +83,22 @@ 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}
CERC_PRIVATE_KEY_NITRO: ${CERC_PRIVATE_KEY_NITRO}
CERC_PRIVATE_KEY_PEER: ${CERC_PRIVATE_KEY_PEER:-111b7500bdce494d6f4bcfe8c2a0dde2ef92f751d9070fac6475dbd6d8021b3f}
CERC_WATCHER_NITRO_PK: ${CERC_WATCHER_NITRO_PK:-0279651921cd800ac560c21ceea27aab0107b67daf436cdd25ce84cad30159b4}
CERC_PEER_ID: ${CERC_PEER_ID}
entrypoint: ["bash", "-c"]
command: ["./deploy-nitro-contracts.sh && ./start-server.sh"]
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"]
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
- nitro_data:/app/out/nitro-db
- watcher_nitro_data:/app/out/nitro-db
- peers_ids:/app/peers
- nitro_addresses:/nitro
- nitro_deployment:/nitro
- mobymask_deployment:/server
# Expose GQL, metrics and relay node ports
ports:
@ -124,5 +118,5 @@ volumes:
mobymask_watcher_db_data:
peers_ids:
mobymask_deployment:
nitro_addresses:
nitro_data:
nitro_deployment:
watcher_nitro_data:

View File

@ -0,0 +1,35 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
nitro_addresses_file="/app/deployment/nitro-addresses.json"
# Check if CERC_NA_ADDRESS environment variable is set
if [ -n "$CERC_NA_ADDRESS" ]; then
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
echo "CERC_CA_ADDRESS is set to '$CERC_CA_ADDRESS'"
echo "Using the above Nitro addresses"
NA_ADDRESS=${CERC_NA_ADDRESS}
VPA_ADDRESS=${CERC_VPA_ADDRESS}
CA_ADDRESS=${CERC_CA_ADDRESS}
elif [ -f ${nitro_addresses_file} ]; then
echo "Reading Nitro addresses from ${nitro_addresses_file}"
NA_ADDRESS=$(jq -r '.nitroAdjudicatorAddress' ${nitro_addresses_file})
VPA_ADDRESS=$(jq -r '.virtualPaymentAppAddress' ${nitro_addresses_file})
CA_ADDRESS=$(jq -r '.consensusAppAddress' ${nitro_addresses_file})
else
echo "File ${nitro_addresses_file} not found"
exit 1
fi
echo "Running Nitro node"
# TODO Wait for RPC endpoint to come up
./nitro -chainurl ${NITRO_CHAIN_URL} -msgport 3005 -rpcport 4005 -wsmsgport 5005 -pk ${NITRO_PK} -chainpk ${NITRO_CHAIN_PK} -naaddress ${NA_ADDRESS} -vpaaddress ${VPA_ADDRESS} -caaddress ${CA_ADDRESS} -usedurablestore ${NITRO_USE_DURABLE_STORE} -durablestorefolder ${NITRO_DURABLE_STORE_FOLDER}

View File

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

View File

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

View File

@ -0,0 +1,69 @@
#!/bin/bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
# Wait till RPC endpoint is available
retry_interval=5
while true; do
rpc_response=$(curl -s -o /dev/null -w '%{http_code}' ${PONDER_RPC_URL_1})
if [ ${rpc_response} = 200 ]; then
echo "RPC endpoint is available"
break
fi
echo "RPC endpoint not yet available, retrying in $retry_interval seconds..."
sleep $retry_interval
done
nitro_addresses_file="/nitro/nitro-addresses.json"
nitro_addresses_destination_file="/app/examples/token-erc20/nitro-addresses.json"
# Check if CERC_NA_ADDRESS environment variable is set
if [ -n "$CERC_NA_ADDRESS" ]; then
echo "CERC_NA_ADDRESS is set to '$CERC_NA_ADDRESS'"
echo "CERC_VPA_ADDRESS is set to '$CERC_VPA_ADDRESS'"
echo "CERC_CA_ADDRESS is set to '$CERC_CA_ADDRESS'"
echo "Using the above Nitro addresses"
# Create the required JSON and write it to a file
nitro_addresses_json=$(jq -n \
--arg na "$CERC_NA_ADDRESS" \
--arg vpa "$CERC_VPA_ADDRESS" \
--arg ca "$CERC_CA_ADDRESS" \
'.nitroAdjudicatorAddress = $na | .virtualPaymentAppAddress = $vpa | .consensusAppAddress = $ca')
echo "$nitro_addresses_json" > "${nitro_addresses_destination_file}"
elif [ -f ${nitro_addresses_file} ]; then
echo "Using Nitro addresses from ${nitro_addresses_file}:"
cat "$nitro_addresses_file"
cat "$nitro_addresses_file" > "$nitro_addresses_destination_file"
else
echo "Nitro addresses not available"
exit 1
fi
echo "Using CERC_PONDER_NITRO_PK from env for Nitro account"
echo "Using CERC_PONDER_NITRO_CHAIN_PK (account with funds) from env for sending Nitro txs"
echo "Using ${CERC_PONDER_NITRO_CHAIN_URL} as the RPC endpoint for Nitro txs"
# If not set, check the mounted volume for relay peer id
if [ -z "$CERC_RELAY_MULTIADDR" ]; then
echo "CERC_RELAY_MULTIADDR not provided, taking from the mounted volume"
CERC_RELAY_MULTIADDR="/dns4/mobymask-watcher-server/tcp/9090/ws/p2p/$(jq -r '.id' /peers/relay-id.json)"
fi
env_file='.env.local'
echo "PONDER_CHAIN_ID=\"$PONDER_CHAIN_ID\"" > "$env_file"
echo "PONDER_RPC_URL_1=\"$PONDER_RPC_URL_1\"" >> "$env_file"
echo "CERC_PONDER_NITRO_PK=\"$CERC_PONDER_NITRO_PK\"" >> "$env_file"
echo "CERC_PONDER_NITRO_CHAIN_PK=\"$CERC_PONDER_NITRO_CHAIN_PK\"" >> "$env_file"
echo "CERC_PONDER_NITRO_CHAIN_URL=\"$CERC_PONDER_NITRO_CHAIN_URL\"" >> "$env_file"
echo "CERC_RELAY_MULTIADDR=\"$CERC_RELAY_MULTIADDR\"" >> "$env_file"
echo "CERC_UPSTREAM_NITRO_ADDRESS=\"$CERC_UPSTREAM_NITRO_ADDRESS\"" >> "$env_file"
echo "CERC_UPSTREAM_NITRO_MULTIADDR=\"$CERC_UPSTREAM_NITRO_MULTIADDR\"" >> "$env_file"
echo "CERC_UPSTREAM_NITRO_PAY_AMOUNT=\"$CERC_UPSTREAM_NITRO_PAY_AMOUNT\"" >> "$env_file"
# Keep the container running
tail -f

View File

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

View File

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

View File

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

View File

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

View File

@ -11,21 +11,36 @@ CERC_RELAY_NODES="${CERC_RELAY_NODES:-${DEFAULT_CERC_RELAY_NODES}}"
CERC_DENY_MULTIADDRS="${CERC_DENY_MULTIADDRS:-${DEFAULT_CERC_DENY_MULTIADDRS}}"
CERC_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
echo "CERC_DEPLOYED_CONTRACT not set"
exit 1
# 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)
else
echo "Using CERC_DEPLOYED_CONTRACT ${CERC_DEPLOYED_CONTRACT} from env as the MobyMask contract address"
fi
# Checkout to the required release/branch
cd /app
git checkout $CERC_RELEASE
nitro_addresses_file="/nitro/nitro-addresses.json"
nitro_addresses_destination_file="/app/src/utils/nitro-addresses.json"
# Check if CERC_NA_ADDRESS is set
# 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'"
@ -38,24 +53,31 @@ 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" > /app/src/utils/nitro-addresses.json
echo "$nitro_addresses_json" > "${nitro_addresses_destination_file}"
elif [ -f ${nitro_addresses_file} ]; then
echo "Using Nitro addresses from ${nitro_addresses_file}:"
cat "$nitro_addresses_file"
cat "$nitro_addresses_file" > "$nitro_addresses_destination_file"
else
echo "Nitro addresses not provided"
echo "Nitro addresses not available"
exit 1
fi
# Export config values in a json file
jq --arg address "$CERC_DEPLOYED_CONTRACT" \
app_config_file="/app/src/utils/config.json"
app_config_json=$(jq -n \
--arg name "MobyMask" \
--argjson enableDebugInfo true \
--arg address "$CERC_DEPLOYED_CONTRACT" \
--argjson chainId "$CERC_CHAIN_ID" \
--argjson relayNodes "$CERC_RELAY_NODES" \
--argjson denyMultiaddrs "$CERC_DENY_MULTIADDRS" \
--arg pubsub "$CERC_PUBSUB" \
--argjson directPeers "$CERC_GOSSIPSUB_DIRECT_PEERS" \
'.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
'.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}"
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" \

View File

@ -1,5 +1,14 @@
# 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=[]
@ -17,7 +26,13 @@ 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=42069
DEFAULT_CERC_CHAIN_ID=1212
# Watcher endpoint used by the web-app
DEFAULT_CERC_APP_WATCHER_URL="http://localhost:3001"
# MobyMask snap URL to be used by the web-app
DEFAULT_CERC_SNAP_URL=http://localhost:8080
# Set of relay nodes to be used by web-apps
DEFAULT_CERC_RELAY_NODES=[]
@ -31,7 +46,5 @@ DEFAULT_CERC_PUBSUB=""
# Set of direct peers to be used when pubsub is set to gossipsub
DEFAULT_CERC_GOSSIPSUB_DIRECT_PEERS=[]
# Set deployed Nitro addresses to avoid deploying them in the stack
DEFAULT_CERC_NA_ADDRESS=
DEFAULT_CERC_VPA_ADDRESS=
DEFAULT_CERC_CA_ADDRESS=
# Whether to enable payments to upstream ETH server
DEFAULT_CERC_ENABLE_UPSTREAM_PAYMENTS=true

View File

@ -5,21 +5,20 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
CERC_L2_GETH_RPC="${CERC_L2_GETH_RPC:-${DEFAULT_CERC_L2_GETH_RPC}}"
CERC_ETH_RPC_QUERY_ENDPOINT="${CERC_ETH_RPC_QUERY_ENDPOINT:-${DEFAULT_CERC_ETH_RPC_QUERY_ENDPOINT}}"
CERC_ETH_RPC_MUTATION_ENDPOINT="${CERC_ETH_RPC_MUTATION_ENDPOINT:-${DEFAULT_CERC_ETH_RPC_MUTATION_ENDPOINT}}"
CERC_RELAY_PEERS="${CERC_RELAY_PEERS:-${DEFAULT_CERC_RELAY_PEERS}}"
CERC_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}}"
nitro_addresses_file="/nitro/nitro-addresses.json"
nitro_addresses_destination_file="./src/nitro-addresses.json"
CERC_ENABLE_UPSTREAM_PAYMENTS="${CERC_ENABLE_UPSTREAM_PAYMENTS:-${DEFAULT_CERC_ENABLE_UPSTREAM_PAYMENTS}}"
watcher_keys_dir="./keys"
echo "Using L2 RPC endpoint ${CERC_L2_GETH_RPC}"
echo "Using RPC query endpoint ${CERC_ETH_RPC_QUERY_ENDPOINT}"
echo "Using RPC mutation endpoint ${CERC_ETH_RPC_MUTATION_ENDPOINT}"
# Use public domain for relay multiaddr in peer config if specified
# Otherwise, use the docker container's host IP
@ -37,20 +36,37 @@ else
CONTRACT_ADDRESS=$(jq -r '.address' /server/config.json | tr -d '"')
fi
# 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}"
nitro_addresses_file="/nitro/nitro-addresses.json"
nitro_addresses_destination_file="./src/nitro-addresses.json"
# Build after setting the Nitro addresses
yarn build
# 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 "File ${nitro_addresses_file} does not exist"
echo "Nitro addresses not available"
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_PRIVATE_KEY_NITRO from env for Nitro account"
echo "Using CERC_WATCHER_NITRO_PK from env for Nitro account"
if [ -n "$CERC_PEER_ID" ]; then
echo "Using CERC_PEER_ID ${CERC_PEER_ID} from env for watcher fixture"
@ -107,24 +123,38 @@ 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_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}| ")
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}/ ")
# Write the modified content to a new file
echo "$WATCHER_CONFIG" > environments/local.toml

View File

@ -19,6 +19,9 @@
# 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
@ -41,6 +44,9 @@
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'
@ -48,7 +54,7 @@
[server.p2p.nitro]
store = './out/nitro-db'
privateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_NITRO'
privateKey = 'REPLACE_WITH_CERC_WATCHER_NITRO_PK'
chainPrivateKey = 'REPLACE_WITH_CERC_PRIVATE_KEY_PEER'
[server.p2p.nitro.payments]
@ -67,7 +73,7 @@
enabled = REPLACE_WITH_CONSENSUS_ENABLED
publicKey = 'REPLACE_WITH_CONSENSUS_PUBLIC_KEY'
privateKey = 'REPLACE_WITH_CONSENSUS_PRIVATE_KEY'
watcherPartyFile = 'REPLACE_WITH_WATCHER_PARTY_PEERS_FILE'
watcherPartyPeersFile = 'REPLACE_WITH_WATCHER_PARTY_PEERS_FILE'
[metrics]
host = "0.0.0.0"
@ -87,9 +93,14 @@
[upstream]
[upstream.ethServer]
gqlApiEndpoint = "http://ipld-eth-server:8083/graphql"
rpcProviderEndpoint = "REPLACE_WITH_CERC_L2_GETH_RPC_ENDPOINT"
blockDelayInMilliSecs = 60000
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'
[upstream.cache]
name = "requests"
@ -101,3 +112,4 @@
maxCompletionLagInSecs = 300
jobDelayInMilliSecs = 100
eventsInBatch = 50
blockDelayInMilliSecs = 60000

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,3 +43,7 @@ github.com/cerc-io/sushiswap-v3-core
github.com/cerc-io/sushiswap-v3-periphery
github.com/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

View File

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

View File

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

View File

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

View File

@ -2,15 +2,18 @@ version: "1.0"
description: "MobyMask v3 stack"
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
- github.com/cerc-io/mobymask-v2-watcher-ts@v3 # TODO: Update after fixes
- github.com/cerc-io/MobyMask@v0.1.3
- github.com/cerc-io/mobymask-ui
- github.com/cerc-io/mobymask-ui@v0.2.0
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

View File

@ -2,7 +2,7 @@
## Setup
Prerequisite: L2 Optimism Geth and Node RPC endpoints
Prerequisite: L2 Optimism Geth RPC endpoint
Clone required repositories:
@ -23,21 +23,16 @@ laconic-so --stack mobymask-v3 build-containers --exclude cerc/mobymask-ui
Create and update an env file to be used in the next step ([defaults](../../config/watcher-mobymask-v3/mobymask-params.env)):
```bash
# External L2 endpoints
CERC_L2_GETH_RPC=
# External ETH RPC endpoint (L2 Optimism geth)
CERC_ETH_RPC_ENDPOINT=
# Endpoints waited on before contract deployment
CERC_L2_GETH_HOST=
CERC_L2_GETH_PORT=
# External ETH RPC endpoint used for queries in the watcher
CERC_ETH_RPC_QUERY_ENDPOINT=
CERC_L2_NODE_HOST=
CERC_L2_NODE_PORT=
# External ETH RPC endpoint used for mutations in the watcher
CERC_ETH_RPC_MUTATION_ENDPOINT=
# 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
# Specify the an account PK for contract deployment
CERC_PRIVATE_KEY_DEPLOYER=
# Base URI for mobymask-app
@ -71,11 +66,14 @@ Create and update an env file to be used in the next step ([defaults](../../conf
CERC_PRIVATE_KEY_PEER=
# Specify private key for the Nitro account
CERC_PRIVATE_KEY_NITRO=
CERC_WATCHER_NITRO_PK=
# (Optional) Set a pre-existing peer id to be used (enables consensus)
# 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
@ -83,13 +81,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 --include watcher-mobymask-v3 --env-file <PATH_TO_ENV_FILE> up
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-app-v3 --env-file <PATH_TO_ENV_FILE> up
```
* To list down and monitor the running containers:
```bash
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mobymask-v3 ps
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-app-v3 ps
# With status
docker ps -a
@ -106,18 +104,18 @@ laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mo
docker logs -f $(docker ps -aq --filter name="mobymask-1")
```
* Check the logs of the watcher server container to get the deployed Nitro contracts' addresses:
* Check logs of the Nitro contracts container to get the deployed Nitro contracts' addresses:
```bash
docker exec -it $(docker ps -q --filter name="mobymask-watcher-server") bash -c "cat /nitro/nitro-addresses.json"
```
```bash
docker exec -it $(docker ps -q --filter name="nitro-contracts") bash -c "cat /app/deployment/nitro-addresses.json"
```
## Clean up
Stop all services running in the background:
```bash
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --include watcher-mobymask-v3 down
laconic-so --stack mobymask-v3 deploy --cluster mobymask_v3 --exclude mobymask-app-v3 down
```
Clear volumes created by this stack:

View File

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