-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a fixturenet-payments stack (#540)
* Add a fixturenet-payments stack * Export the WebSocket port in fixturenet-eth-geth service * Add container to run a go-nitro node * Add container to deploy Nitro contracts * Read contract addresses from a volume when running the Nitro node * Add a service for Nitro reverse payment proxy * Expose payment proxy endpoint to be accessible from host * Map nitro node messaging and payment proxy ports to host * Use container to deploy Nitro contracts in mobymask-v3 stack * Use a common contract deployment script from mobymask-v3 stack * Add MobyMask contract deployment and watcher services * Fixes for contract deployment and watcher scripts * Add a container and service for mobymask-snap * Add MobyMask app service * Add container and service for a ponder app * Fix ponder setup and update instructions * Handle review comments * Use enablepaidrpcmethods flag in reverse payment proxy server * Update go-nitro branch * Fixes for mobymask-v3 stack --------- Co-authored-by: Nabarun <[email protected]>
- Loading branch information
1 parent
b485a3b
commit cf039d9
Showing
36 changed files
with
836 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ services: | |
- fixturenet-eth-bootnode-geth | ||
ports: | ||
- "8545" | ||
- "8546" | ||
- "40000" | ||
- "6060" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: |
27 changes: 27 additions & 0 deletions
27
app/data/compose/docker-compose-nitro-reverse-payment-proxy.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
Oops, something went wrong.