From e3a8b25850cccf3350e07c2a455cf22acefadb0d Mon Sep 17 00:00:00 2001 From: Adwait Gharpure <69599306+Adw8@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:10:19 +0530 Subject: [PATCH] Update nitro-node stack setup (#5) * Rename service for nitro node * Update nitro node setup * Rename nitro-contracts image to nitro-client * Fix nitro node config setup * Add env variable for deterministic deployment * Keep nitro-contracts service running * Start nitro-bridge service after asset file is ready * Update environment variables for all services * Use quotes for bridge address * Update nitro-node and bridge stack readme * Fix nitro-node readme --------- Co-authored-by: Prathamesh Musale Co-authored-by: IshaVenikar --- README.md | 5 ++ .../compose/docker-compose-go-nitro.yml | 27 -------- ...ge.yml => docker-compose-nitro-bridge.yml} | 27 ++++---- .../docker-compose-nitro-contracts.yml | 21 +++--- .../compose/docker-compose-nitro-node.yml | 45 +++++++++++++ .../docker-compose-nitro-rpc-client.yml | 2 +- .../config/go-nitro/create-certs.sh | 2 +- .../config/go-nitro/run-bridge.sh | 49 ++++++++------ .../config/go-nitro/run-nitro-node.sh | 58 +++++++++++------ .../config/nitro-contracts/deploy.sh | 34 ++++------ .../container-build/cerc-go-nitro/Dockerfile | 2 +- .../Dockerfile | 0 .../build.sh | 4 +- stack-orchestrator/stacks/bridge/README.md | 65 +++++++++++++++++++ stack-orchestrator/stacks/bridge/stack.yml | 6 +- .../stacks/nitro-node/README.md | 35 +++++----- .../stacks/nitro-node/stack.yml | 8 +-- 17 files changed, 251 insertions(+), 139 deletions(-) delete mode 100644 stack-orchestrator/compose/docker-compose-go-nitro.yml rename stack-orchestrator/compose/{docker-compose-bridge.yml => docker-compose-nitro-bridge.yml} (55%) create mode 100644 stack-orchestrator/compose/docker-compose-nitro-node.yml rename stack-orchestrator/container-build/{cerc-nitro-contracts => cerc-nitro-client}/Dockerfile (100%) rename stack-orchestrator/container-build/{cerc-nitro-contracts => cerc-nitro-client}/build.sh (56%) diff --git a/README.md b/README.md index 305267f..7d9563a 100644 --- a/README.md +++ b/README.md @@ -1 +1,6 @@ # nitro-stack + +Stacks to run nitro-node and bridge + +- [bridge stack documentation](stack-orchestrator/stacks/bridge/README.md) +- [nitro-node stack documentation](stack-orchestrator/stacks/nitro-node/README.md) diff --git a/stack-orchestrator/compose/docker-compose-go-nitro.yml b/stack-orchestrator/compose/docker-compose-go-nitro.yml deleted file mode 100644 index 7c20600..0000000 --- a/stack-orchestrator/compose/docker-compose-go-nitro.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: go-nitro - -services: - go-nitro: - image: cerc/go-nitro:local - hostname: go-nitro - restart: on-failure - environment: - CERC_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL} - CERC_NITRO_PK: ${CERC_NITRO_PK} - CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK} - CERC_NITRO_MSG_PORT: ${CERC_NITRO_MSG_PORT} - CERC_NITRO_RPC_PORT: ${CERC_NITRO_RPC_PORT} - CERC_NA_ADDRESS: ${CERC_NA_ADDRESS} - CERC_VPA_ADDRESS: ${CERC_VPA_ADDRESS} - CERC_CA_ADDRESS: ${CERC_CA_ADDRESS} - CERC_BOOT_PEERS: ${CERC_BOOT_PEERS} - CERC_PUBLIC_IP: ${CERC_PUBLIC_IP:-127.0.0.1} - entrypoint: ["bash", "-c", "/app/run-nitro-node.sh"] - volumes: - - ../config/go-nitro/run-nitro-node.sh:/app/run-nitro-node.sh - ports: - - 3006:3006 - - 4006:4006 - - 5006:5006 - extra_hosts: - - "host.docker.internal:host-gateway" diff --git a/stack-orchestrator/compose/docker-compose-bridge.yml b/stack-orchestrator/compose/docker-compose-nitro-bridge.yml similarity index 55% rename from stack-orchestrator/compose/docker-compose-bridge.yml rename to stack-orchestrator/compose/docker-compose-nitro-bridge.yml index 8ae8663..caae62e 100644 --- a/stack-orchestrator/compose/docker-compose-bridge.yml +++ b/stack-orchestrator/compose/docker-compose-nitro-bridge.yml @@ -1,4 +1,4 @@ -name: bridge +name: nitro-bridge services: nitro-bridge: @@ -6,22 +6,21 @@ services: hostname: nitro-bridge restart: unless-stopped depends_on: - # Wait for Nitro contracts to be deployed nitro-contracts: - condition: service_completed_successfully + condition: service_started environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} - CERC_GETH_CHAIN_ID: ${CERC_GETH_CHAIN_ID:-1212} - CERC_OPTIMISM_CHAIN_ID: ${CERC_OPTIMISM_CHAIN_ID:-42069} - CERC_NITRO_L1_CHAIN_URL: ${CERC_NITRO_L1_CHAIN_URL} - CERC_NITRO_L2_CHAIN_URL: ${CERC_NITRO_L2_CHAIN_URL} - CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK} - CERC_NITRO_SC_PK: ${CERC_NITRO_SC_PK} - CERC_NITRO_L1_MSG_PORT: ${CERC_NITRO_L1_MSG_PORT:-3005} - CERC_NITRO_L2_MSG_PORT: ${CERC_NITRO_L2_MSG_PORT:-3006} - CERC_NITRO_RPC_PORT: ${CERC_NITRO_RPC_PORT:-4006} - CERC_NITRO_PUBLIC_P2P_HOST: ${CERC_NITRO_PUBLIC_P2P_HOST:-127.0.0.1} - CERC_NITRO_PUBLIC_RPC_HOST: nitro-bridge + GETH_CHAIN_ID: ${GETH_CHAIN_ID:-1212} + OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID:-42069} + NITRO_L1_CHAIN_URL: ${NITRO_L1_CHAIN_URL} + NITRO_L2_CHAIN_URL: ${NITRO_L2_CHAIN_URL} + NITRO_CHAIN_PK: ${NITRO_CHAIN_PK} + NITRO_SC_PK: ${NITRO_SC_PK} + NITRO_L1_MSG_PORT: ${NITRO_L1_MSG_PORT:-3005} + NITRO_L2_MSG_PORT: ${NITRO_L2_MSG_PORT:-3006} + NITRO_RPC_PORT: ${NITRO_RPC_PORT:-4006} + NITRO_PUBLIC_P2P_HOST: ${NITRO_PUBLIC_P2P_HOST:-127.0.0.1} + NITRO_PUBLIC_RPC_HOST: nitro-bridge entrypoint: ["bash", "-c", "/app/run-bridge.sh"] volumes: - nitro_bridge_data:/app/data diff --git a/stack-orchestrator/compose/docker-compose-nitro-contracts.yml b/stack-orchestrator/compose/docker-compose-nitro-contracts.yml index 17593f3..51cf2e7 100644 --- a/stack-orchestrator/compose/docker-compose-nitro-contracts.yml +++ b/stack-orchestrator/compose/docker-compose-nitro-contracts.yml @@ -3,19 +3,20 @@ name: nitro-contracts services: # Optionally deploys the Nitro contracts nitro-contracts: - image: cerc/nitro-contracts:local + image: cerc/nitro-client:local restart: on-failure environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} - CERC_GETH_URL: ${CERC_GETH_URL} - CERC_OPTIMISM_URL: ${CERC_OPTIMISM_URL} - CERC_GETH_CHAIN_ID: ${CERC_GETH_CHAIN_ID:-1212} - CERC_OPTIMISM_CHAIN_ID: ${CERC_OPTIMISM_CHAIN_ID:-42069} - CERC_GETH_DEPLOYER_PK: ${CERC_GETH_DEPLOYER_PK} - CERC_OPTIMISM_DEPLOYER_PK: ${CERC_GETH_DEPLOYER_PK} - CERC_TOKEN_NAME: ${CERC_TOKEN_NAME} - CERC_TOKEN_SYMBOL: ${CERC_TOKEN_SYMBOL} - CERC_INITIAL_TOKEN_SUPPLY: ${CERC_INITIAL_TOKEN_SUPPLY} + GETH_URL: ${GETH_URL} + OPTIMISM_URL: ${OPTIMISM_URL} + GETH_CHAIN_ID: ${GETH_CHAIN_ID:-1212} + OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID:-42069} + GETH_DEPLOYER_PK: ${GETH_DEPLOYER_PK} + OPTIMISM_DEPLOYER_PK: ${GETH_DEPLOYER_PK} + TOKEN_NAME: ${TOKEN_NAME} + TOKEN_SYMBOL: ${TOKEN_SYMBOL} + INITIAL_TOKEN_SUPPLY: ${INITIAL_TOKEN_SUPPLY} + DISABLE_DETERMINISTIC_DEPLOYMENT: ${DISABLE_DETERMINISTIC_DEPLOYMENT:-true} volumes: - nitro_deployment:/app/deployment - ../config/nitro-contracts/deploy.sh:/app/deploy.sh diff --git a/stack-orchestrator/compose/docker-compose-nitro-node.yml b/stack-orchestrator/compose/docker-compose-nitro-node.yml new file mode 100644 index 0000000..0ddd1ee --- /dev/null +++ b/stack-orchestrator/compose/docker-compose-nitro-node.yml @@ -0,0 +1,45 @@ +name: nitro-node + +services: + nitro-node: + image: cerc/go-nitro:local + hostname: nitro-node + restart: on-failure + environment: + NITRO_USE_DURABLE_STORE: true + NITRO_MSG_PORT: ${NITRO_MSG_PORT:-3005} + NITRO_RPC_PORT: ${NITRO_RPC_PORT:-4005} + NITRO_SC_PK: ${NITRO_SC_PK} + NITRO_CHAIN_PK: ${NITRO_CHAIN_PK} + NITRO_CHAIN_URL: ${NITRO_CHAIN_URL} + NITRO_BOOTPEERS: ${NITRO_BOOTPEERS} + NITRO_PUBLIC_P2P_HOST: ${NITRO_PUBLIC_P2P_HOST:-127.0.0.1} + NITRO_L2: ${NITRO_L2:-false} + NA_ADDRESS: ${NA_ADDRESS} + CA_ADDRESS: ${CA_ADDRESS} + VPA_ADDRESS: ${VPA_ADDRESS} + BRIDGE_ADDRESS: ${BRIDGE_ADDRESS} + NITRO_PUBLIC_RPC_HOST: nitro-node + entrypoint: ["bash", "-c", "/app/run-nitro-node.sh"] + volumes: + - nitro_node_data:/app/data + - nitro_node_tls:/app/tls + - nitro_node_caroot:/app/mkcert-caroot + - ../config/go-nitro/run-nitro-node.sh:/app/run-nitro-node.sh + - ../config/go-nitro/create-certs.sh:/app/create-certs.sh + ports: + - 3005 + - 4005 + healthcheck: + test: ["CMD", "nc", "-vz", "localhost", "4005"] + interval: 30s + timeout: 5s + retries: 10 + start_period: 10s + extra_hosts: + - "host.docker.internal:host-gateway" + +volumes: + nitro_node_data: + nitro_node_tls: + nitro_node_caroot: diff --git a/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml b/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml index 06e0983..438e52c 100644 --- a/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml +++ b/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml @@ -2,7 +2,7 @@ name: nitro-rpc-client services: nitro-rpc-client: - image: cerc/nitro-contracts:local + image: cerc/nitro-client:local hostname: nitro-rpc-client restart: on-failure environment: diff --git a/stack-orchestrator/config/go-nitro/create-certs.sh b/stack-orchestrator/config/go-nitro/create-certs.sh index 5eda7a4..8f6cc25 100755 --- a/stack-orchestrator/config/go-nitro/create-certs.sh +++ b/stack-orchestrator/config/go-nitro/create-certs.sh @@ -13,7 +13,7 @@ if [ -f "$cert_file" ] ; then echo "Cert file ${cert_file} already exists" else echo "Creating certs" - mkcert -cert-file $cert_file -key-file $key_file statechannels.org localhost 127.0.0.1 $CERC_NITRO_PUBLIC_RPC_HOST ::1 + mkcert -cert-file $cert_file -key-file $key_file statechannels.org localhost 127.0.0.1 $NITRO_PUBLIC_RPC_HOST ::1 # Copy over the rootCA cert so that it can be used by the client cp -r $(mkcert -CAROOT)/* /app/mkcert-caroot diff --git a/stack-orchestrator/config/go-nitro/run-bridge.sh b/stack-orchestrator/config/go-nitro/run-bridge.sh index 7989d3e..a30bb2e 100755 --- a/stack-orchestrator/config/go-nitro/run-bridge.sh +++ b/stack-orchestrator/config/go-nitro/run-bridge.sh @@ -10,36 +10,45 @@ bridge_assets_map_file="/app/deployment/bridge-assets-map.toml" bridge_config_file="/app/bridge.toml" echo "Using the following environment variables:" -echo "CERC_NITRO_L1_CHAIN_URL: ${CERC_NITRO_L1_CHAIN_URL}" -echo "CERC_NITRO_L2_CHAIN_URL: ${CERC_NITRO_L2_CHAIN_URL}" -echo "CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK}" -echo "CERC_NITRO_SC_PK: ${CERC_NITRO_SC_PK}" -echo "CERC_NITRO_L1_MSG_PORT: ${CERC_NITRO_L1_MSG_PORT}" -echo "CERC_NITRO_L2_MSG_PORT: ${CERC_NITRO_L2_MSG_PORT}" -echo "CERC_NITRO_RPC_PORT: ${CERC_NITRO_RPC_PORT}" -echo "CERC_NITRO_PUBLIC_P2P_HOST: ${CERC_NITRO_PUBLIC_P2P_HOST}" +echo "NITRO_L1_CHAIN_URL: ${NITRO_L1_CHAIN_URL}" +echo "NITRO_L2_CHAIN_URL: ${NITRO_L2_CHAIN_URL}" +echo "NITRO_CHAIN_PK: ${NITRO_CHAIN_PK}" +echo "NITRO_SC_PK: ${NITRO_SC_PK}" +echo "NITRO_L1_MSG_PORT: ${NITRO_L1_MSG_PORT}" +echo "NITRO_L2_MSG_PORT: ${NITRO_L2_MSG_PORT}" +echo "NITRO_RPC_PORT: ${NITRO_RPC_PORT}" +echo "NITRO_PUBLIC_P2P_HOST: ${NITRO_PUBLIC_P2P_HOST}" + +echo "Waiting for $bridge_assets_map_file to be ready" + +while [ ! -e "$bridge_assets_map_file" ]; do + sleep 3 +done + +echo "File $bridge_assets_map_file found" # Create required certs ./create-certs.sh # Create the bridge config file cat < "$bridge_config_file" -chainpk = "$CERC_NITRO_CHAIN_PK" -statechannelpk = "$CERC_NITRO_SC_PK" -l1chainurl = "$CERC_NITRO_L1_CHAIN_URL" -l2chainurl = "$CERC_NITRO_L2_CHAIN_URL" -nodel1msgport = $CERC_NITRO_L1_MSG_PORT -nodel2msgport = $CERC_NITRO_L2_MSG_PORT -rpcport = $CERC_NITRO_RPC_PORT -bridgepublicip = "$CERC_NITRO_PUBLIC_P2P_HOST" +chainpk = "$NITRO_CHAIN_PK" +statechannelpk = "$NITRO_SC_PK" +l1chainurl = "$NITRO_L1_CHAIN_URL" +l2chainurl = "$NITRO_L2_CHAIN_URL" +nodel1msgport = $NITRO_L1_MSG_PORT +nodel2msgport = $NITRO_L2_MSG_PORT +rpcport = $NITRO_RPC_PORT +bridgepublicip = "$NITRO_PUBLIC_P2P_HOST" assetmapfilepath = "$bridge_assets_map_file" EOF # Export contract addresses -export NA_ADDRESS=$(jq -r ".\"$CERC_GETH_CHAIN_ID\"[0].contracts.NitroAdjudicator.address" ${nitro_addresses_file}) -export CA_ADDRESS=$(jq -r ".\"$CERC_GETH_CHAIN_ID\"[0].contracts.ConsensusApp.address" ${nitro_addresses_file}) -export VPA_ADDRESS=$(jq -r ".\"$CERC_GETH_CHAIN_ID\"[0].contracts.VirtualPaymentApp.address" ${nitro_addresses_file}) -export BRIDGE_ADDRESS=$(jq -r ".\"$CERC_OPTIMISM_CHAIN_ID\"[0].contracts.Bridge.address" ${nitro_addresses_file}) +export NA_ADDRESS=$(jq -r ".\"$GETH_CHAIN_ID\"[0].contracts.NitroAdjudicator.address" ${nitro_addresses_file}) +export CA_ADDRESS=$(jq -r ".\"$GETH_CHAIN_ID\"[0].contracts.ConsensusApp.address" ${nitro_addresses_file}) +export VPA_ADDRESS=$(jq -r ".\"$GETH_CHAIN_ID\"[0].contracts.VirtualPaymentApp.address" ${nitro_addresses_file}) +export BRIDGE_ADDRESS=$(jq -r ".\"$OPTIMISM_CHAIN_ID\"[0].contracts.Bridge.address" ${nitro_addresses_file}) # Start bridge +echo "Starting nitro-bridge" ./nitro-bridge -config $bridge_config_file diff --git a/stack-orchestrator/config/go-nitro/run-nitro-node.sh b/stack-orchestrator/config/go-nitro/run-nitro-node.sh index ab98e52..99c1174 100755 --- a/stack-orchestrator/config/go-nitro/run-nitro-node.sh +++ b/stack-orchestrator/config/go-nitro/run-nitro-node.sh @@ -1,30 +1,48 @@ #!/bin/bash -# TODO: Support running node on L2 if [ -n "$CERC_SCRIPT_DEBUG" ]; then set -x fi -if [ -z "$CERC_NA_ADDRESS" ]; then - echo "Error: NA_ADDRESS is not present" - exit 1 -fi +node_config_file="/app/config.toml" -if [ -z "$CERC_VPA_ADDRESS" ]; then - echo "Error: VPA_ADDRESS is not present" - exit 1 -fi +echo "Using the following environment variables:" +echo "NITRO_USE_DURABLE_STORE: ${NITRO_USE_DURABLE_STORE}" +echo "NITRO_MSG_PORT: ${NITRO_MSG_PORT}" +echo "NITRO_RPC_PORT: ${NITRO_RPC_PORT}" +echo "NITRO_SC_PK: ${NITRO_SC_PK}" +echo "NITRO_CHAIN_PK: ${NITRO_CHAIN_PK}" +echo "NITRO_CHAIN_URL: ${NITRO_CHAIN_URL}" +echo "NITRO_BOOTPEERS: ${NITRO_BOOTPEERS}" +echo "NITRO_PUBLIC_P2P_HOST: ${NITRO_PUBLIC_P2P_HOST}" +echo "NITRO_L2: ${NITRO_L2}" -if [ -z "$CERC_CA_ADDRESS" ]; then - echo "Error: CA_ADDRESS is not present" - exit 1 -fi +echo "Using Nitro contract addresses:" +echo "NA_ADDRESS: ${NA_ADDRESS}" +echo "CA_ADDRESS: ${CA_ADDRESS}" +echo "VPA_ADDRESS: ${VPA_ADDRESS}" +echo "BRIDGE_ADDRESS: ${BRIDGE_ADDRESS}" -echo "CERC_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL}" -echo "CERC_NITRO_MSG_PORT: ${CERC_NITRO_MSG_PORT}" -echo "CERC_NITRO_RPC_PORT: ${CERC_NITRO_RPC_PORT}" -echo "CERC_NITRO_PK: ${CERC_NITRO_PK}" -echo "CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK}" -echo "CERC_PUBLIC_IP: ${CERC_PUBLIC_IP}" +# Create required certs +./create-certs.sh -./nitro -chainurl ${CERC_NITRO_CHAIN_URL} -msgport ${CERC_NITRO_MSG_PORT} -rpcport ${CERC_NITRO_RPC_PORT} -pk ${CERC_NITRO_PK} -chainpk ${CERC_NITRO_CHAIN_PK} -naaddress ${CERC_NA_ADDRESS} -vpaaddress ${CERC_VPA_ADDRESS} -caaddress ${CERC_CA_ADDRESS} -publicip ${CERC_PUBLIC_IP} +# Create the required config file +cat < "$node_config_file" +usedurablestore = ${NITRO_USE_DURABLE_STORE} +msgport = ${NITRO_MSG_PORT} +rpcport = ${NITRO_RPC_PORT} +pk = "${NITRO_SC_PK}" +chainpk = "${NITRO_CHAIN_PK}" +chainurl = "${NITRO_CHAIN_URL}" +bootpeers = "${NITRO_BOOTPEERS}" +bridgepublicip = "${NITRO_PUBLIC_P2P_HOST}" +l2 = ${NITRO_L2} + +naaddress = "${NA_ADDRESS}" +vpaaddress = "${CA_ADDRESS}" +caaddress = "${VPA_ADDRESS}" +bridgeaddress = "${BRIDGE_ADDRESS}" +EOF + +# Start the node +./nitro -config $node_config_file diff --git a/stack-orchestrator/config/nitro-contracts/deploy.sh b/stack-orchestrator/config/nitro-contracts/deploy.sh index 5bb88ee..19f981d 100755 --- a/stack-orchestrator/config/nitro-contracts/deploy.sh +++ b/stack-orchestrator/config/nitro-contracts/deploy.sh @@ -10,27 +10,16 @@ nitro_addresses_file="/app/deployment/nitro-addresses.json" bridge_assets_map_file="/app/deployment/bridge-assets-map.toml" echo "Using the following environment variables:" -echo "CERC_GETH_URL: ${CERC_GETH_URL}" -echo "CERC_OPTIMISM_URL: ${CERC_OPTIMISM_URL}" -echo "CERC_GETH_CHAIN_ID: ${CERC_GETH_CHAIN_ID}" -echo "CERC_OPTIMISM_CHAIN_ID: ${CERC_OPTIMISM_CHAIN_ID}" -echo "CERC_GETH_DEPLOYER_PK: ${CERC_GETH_DEPLOYER_PK}" -echo "CERC_OPTIMISM_DEPLOYER_PK: ${CERC_OPTIMISM_DEPLOYER_PK}" -echo "CERC_TOKEN_NAME: ${CERC_TOKEN_NAME}" -echo "CERC_TOKEN_SYMBOL: ${CERC_TOKEN_SYMBOL}" -echo "CERC_INITIAL_TOKEN_SUPPLY: ${CERC_INITIAL_TOKEN_SUPPLY}" - -export GETH_URL=$CERC_GETH_URL -export GETH_CHAIN_ID=$CERC_GETH_CHAIN_ID -export OPTIMISM_CHAIN_ID=$CERC_OPTIMISM_CHAIN_ID -export OPTIMISM_URL=$CERC_OPTIMISM_URL -export GETH_DEPLOYER_PK=$CERC_GETH_DEPLOYER_PK -export OPTIMISM_DEPLOYER_PK=$GETH_DEPLOYER_PK -export DISABLE_DETERMINISTIC_DEPLOYMENT=true - -export TOKEN_NAME=$CERC_TOKEN_NAME -export TOKEN_SYMBOL=$CERC_TOKEN_SYMBOL -export INITIAL_TOKEN_SUPPLY=$CERC_INITIAL_TOKEN_SUPPLY +echo "GETH_URL: ${GETH_URL}" +echo "OPTIMISM_URL: ${OPTIMISM_URL}" +echo "GETH_CHAIN_ID: ${GETH_CHAIN_ID}" +echo "OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID}" +echo "GETH_DEPLOYER_PK: ${GETH_DEPLOYER_PK}" +echo "OPTIMISM_DEPLOYER_PK: ${OPTIMISM_DEPLOYER_PK}" +echo "TOKEN_NAME: ${TOKEN_NAME}" +echo "TOKEN_SYMBOL: ${TOKEN_SYMBOL}" +echo "INITIAL_TOKEN_SUPPLY: ${INITIAL_TOKEN_SUPPLY}" +echo "DISABLE_DETERMINISTIC_DEPLOYMENT: ${DISABLE_DETERMINISTIC_DEPLOYMENT}" # Check if L1 chain id key is present for L1 deployment if [ -f "$nitro_addresses_file" ] && jq -e "has(\"$GETH_CHAIN_ID\")" ${nitro_addresses_file} > /dev/null; then @@ -69,3 +58,6 @@ l2AssetAddress = "$L2_ASSET_ADDRESS" EOF echo "Done" + +# Keep the container running for future asset transfers +tail -f /dev/null diff --git a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile index 0067a0a..3e792ac 100644 --- a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile +++ b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile @@ -15,7 +15,7 @@ RUN go mod tidy RUN go build -v -o nitro . RUN go build -o nitro-bridge cmd/start-bridge/main.go -# TODO: Update steps to build go-nitro image + # Reduce image size FROM debian:bullseye-slim RUN apt-get update diff --git a/stack-orchestrator/container-build/cerc-nitro-contracts/Dockerfile b/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile similarity index 100% rename from stack-orchestrator/container-build/cerc-nitro-contracts/Dockerfile rename to stack-orchestrator/container-build/cerc-nitro-client/Dockerfile diff --git a/stack-orchestrator/container-build/cerc-nitro-contracts/build.sh b/stack-orchestrator/container-build/cerc-nitro-client/build.sh similarity index 56% rename from stack-orchestrator/container-build/cerc-nitro-contracts/build.sh rename to stack-orchestrator/container-build/cerc-nitro-client/build.sh index e70c7d0..dda05c8 100755 --- a/stack-orchestrator/container-build/cerc-nitro-contracts/build.sh +++ b/stack-orchestrator/container-build/cerc-nitro-client/build.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash -# Build cerc/nitro-contracts +# Build cerc/nitro-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-contracts:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/go-nitro +docker build -t cerc/nitro-client:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/go-nitro diff --git a/stack-orchestrator/stacks/bridge/README.md b/stack-orchestrator/stacks/bridge/README.md index d053a4a..2b57d63 100644 --- a/stack-orchestrator/stacks/bridge/README.md +++ b/stack-orchestrator/stacks/bridge/README.md @@ -19,3 +19,68 @@ ```bash laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge build-containers ``` + +## Create a deployment + +- Create a spec file + + ```bash + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge deploy init --output bridge-spec.yml + ``` + +- TODO: Edit `network` in the spec file to map container ports to host ports as required: + + ```bash + network: + ports: + go-nitro: + - 3005:3005 + - 3006:3006 + - 4006:4006 + ``` + +- Create deployment + + ```bash + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge deploy create --spec-file bridge-spec.yml --deployment-dir bridge-deployment + ``` + +## Configuration + +- Inside the `bridge-deployment` deployment directory, open `config.env` file and set following env variables: + + ```bash + GETH_CHAIN_ID=1212 + + OPTIMISM_CHAIN_ID=42069 + + # URL endpoint of the L1 chain (Example: ws://host.docker.internal:8545) + NITRO_L1_CHAIN_URL= + + # URL endpoint of the L2 chain (Example: ws://host.docker.internal:8546) + NITRO_L2_CHAIN_URL= + + # Private key of the account on chain that is used for funding channels + NITRO_CHAIN_PK: ${NITRO_CHAIN_PK} + + NITRO_SC_PK: ${NITRO_SC_PK} + + # Port to be used by P2P message service for L1 + NITRO_L1_MSG_PORT=3005 + + # Port to be used by P2P message service for L2 + NITRO_L2_MSG_PORT=3006 + + # Port to be used by RPC server + NITRO_RPC_PORT=4006 + + NITRO_PUBLIC_P2P_HOST=127.0.0.1 + + NITRO_PUBLIC_RPC_HOST=nitro-bridge + ``` + +## Start the deployment + +```bash +laconic-so deployment --dir bridge-deployment start +``` diff --git a/stack-orchestrator/stacks/bridge/stack.yml b/stack-orchestrator/stacks/bridge/stack.yml index 9d453d2..63be604 100644 --- a/stack-orchestrator/stacks/bridge/stack.yml +++ b/stack-orchestrator/stacks/bridge/stack.yml @@ -1,12 +1,12 @@ version: "1.0" name: bridge -description: "Nitro bridge node" +description: "Nitro bridge with contracts deployment and nitro-rpc-client" repos: - github.com/cerc-io/go-nitro containers: - - cerc/nitro-contracts + - cerc/nitro-client - cerc/go-nitro pods: - nitro-contracts - - bridge + - nitro-bridge - nitro-rpc-client diff --git a/stack-orchestrator/stacks/nitro-node/README.md b/stack-orchestrator/stacks/nitro-node/README.md index 7843a10..f813c07 100644 --- a/stack-orchestrator/stacks/nitro-node/README.md +++ b/stack-orchestrator/stacks/nitro-node/README.md @@ -1,4 +1,4 @@ -# Go-nitro +# nitro-node ## Setup @@ -36,9 +36,8 @@ network: ports: go-nitro: - - 3006:3006 - - 4006:4006 - - 5006:5006 + - 3005:3005 + - 4005:4005 ``` - Create deployment @@ -53,26 +52,31 @@ ```bash # URL endpoint of the chain (Example: ws://host.docker.internal:8545) - CERC_NITRO_CHAIN_URL= + NITRO_CHAIN_URL= # Private key of account to be used by Nitro node (derived address is used as Nitro address) - CERC_NITRO_PK= + NITRO_PK= # Private key of the account on chain that is used for funding channels in Nitro node - CERC_NITRO_CHAIN_PK= + NITRO_CHAIN_PK= # Port to be used by P2P message service (Example: 3009) - CERC_NITRO_MSG_PORT= + NITRO_MSG_PORT= # Port to be used by RPC server (Example: 4009) - CERC_NITRO_RPC_PORT=4009 + NITRO_RPC_PORT=4009 - # Optional - # Contract addresses of NitroAdjudicator, VirtualPaymentApp and ConsensusApp - # TODO: Contracts are deployed if addresses are not set - CERC_NA_ADDRESS= - CERC_VPA_ADDRESS= - CERC_CA_ADDRESS= + # Contract address of NitroAdjudicator + NA_ADDRESS= + + # Contract address of VirtualPaymentApp + VPA_ADDRESS= + + # Contract address of ConsensusApp + CA_ADDRESS= + + # Address of the bridge node + BRIDGE_ADDRESS= ``` ## Start the deployment @@ -80,3 +84,4 @@ ```bash laconic-so deployment --dir nitro-node-deployment start ``` + diff --git a/stack-orchestrator/stacks/nitro-node/stack.yml b/stack-orchestrator/stacks/nitro-node/stack.yml index 4cf4d7e..2b1fb80 100644 --- a/stack-orchestrator/stacks/nitro-node/stack.yml +++ b/stack-orchestrator/stacks/nitro-node/stack.yml @@ -1,11 +1,11 @@ version: "1.0" -name: go-nitro -description: "Stack to demonstrate payments between various services" +name: nitro-node +description: "Nitro node with nitro-rpc-client" repos: - github.com/cerc-io/go-nitro containers: - cerc/go-nitro - - cerc/nitro-contracts + - cerc/nitro-client pods: - - go-nitro + - nitro-node - nitro-rpc-client