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 <prathamesh.musale0@gmail.com>
Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
This commit is contained in:
Adwait Gharpure 2024-07-23 12:10:19 +05:30 committed by Nabarun
parent ce2258db07
commit e3a8b25850
17 changed files with 251 additions and 139 deletions

View File

@ -1 +1,6 @@
# nitro-stack # 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)

View File

@ -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"

View File

@ -1,4 +1,4 @@
name: bridge name: nitro-bridge
services: services:
nitro-bridge: nitro-bridge:
@ -6,22 +6,21 @@ services:
hostname: nitro-bridge hostname: nitro-bridge
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
# Wait for Nitro contracts to be deployed
nitro-contracts: nitro-contracts:
condition: service_completed_successfully condition: service_started
environment: environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_GETH_CHAIN_ID: ${CERC_GETH_CHAIN_ID:-1212} GETH_CHAIN_ID: ${GETH_CHAIN_ID:-1212}
CERC_OPTIMISM_CHAIN_ID: ${CERC_OPTIMISM_CHAIN_ID:-42069} OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID:-42069}
CERC_NITRO_L1_CHAIN_URL: ${CERC_NITRO_L1_CHAIN_URL} NITRO_L1_CHAIN_URL: ${NITRO_L1_CHAIN_URL}
CERC_NITRO_L2_CHAIN_URL: ${CERC_NITRO_L2_CHAIN_URL} NITRO_L2_CHAIN_URL: ${NITRO_L2_CHAIN_URL}
CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK} NITRO_CHAIN_PK: ${NITRO_CHAIN_PK}
CERC_NITRO_SC_PK: ${CERC_NITRO_SC_PK} NITRO_SC_PK: ${NITRO_SC_PK}
CERC_NITRO_L1_MSG_PORT: ${CERC_NITRO_L1_MSG_PORT:-3005} NITRO_L1_MSG_PORT: ${NITRO_L1_MSG_PORT:-3005}
CERC_NITRO_L2_MSG_PORT: ${CERC_NITRO_L2_MSG_PORT:-3006} NITRO_L2_MSG_PORT: ${NITRO_L2_MSG_PORT:-3006}
CERC_NITRO_RPC_PORT: ${CERC_NITRO_RPC_PORT:-4006} NITRO_RPC_PORT: ${NITRO_RPC_PORT:-4006}
CERC_NITRO_PUBLIC_P2P_HOST: ${CERC_NITRO_PUBLIC_P2P_HOST:-127.0.0.1} NITRO_PUBLIC_P2P_HOST: ${NITRO_PUBLIC_P2P_HOST:-127.0.0.1}
CERC_NITRO_PUBLIC_RPC_HOST: nitro-bridge NITRO_PUBLIC_RPC_HOST: nitro-bridge
entrypoint: ["bash", "-c", "/app/run-bridge.sh"] entrypoint: ["bash", "-c", "/app/run-bridge.sh"]
volumes: volumes:
- nitro_bridge_data:/app/data - nitro_bridge_data:/app/data

View File

@ -3,19 +3,20 @@ name: nitro-contracts
services: services:
# Optionally deploys the Nitro contracts # Optionally deploys the Nitro contracts
nitro-contracts: nitro-contracts:
image: cerc/nitro-contracts:local image: cerc/nitro-client:local
restart: on-failure restart: on-failure
environment: environment:
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
CERC_GETH_URL: ${CERC_GETH_URL} GETH_URL: ${GETH_URL}
CERC_OPTIMISM_URL: ${CERC_OPTIMISM_URL} OPTIMISM_URL: ${OPTIMISM_URL}
CERC_GETH_CHAIN_ID: ${CERC_GETH_CHAIN_ID:-1212} GETH_CHAIN_ID: ${GETH_CHAIN_ID:-1212}
CERC_OPTIMISM_CHAIN_ID: ${CERC_OPTIMISM_CHAIN_ID:-42069} OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID:-42069}
CERC_GETH_DEPLOYER_PK: ${CERC_GETH_DEPLOYER_PK} GETH_DEPLOYER_PK: ${GETH_DEPLOYER_PK}
CERC_OPTIMISM_DEPLOYER_PK: ${CERC_GETH_DEPLOYER_PK} OPTIMISM_DEPLOYER_PK: ${GETH_DEPLOYER_PK}
CERC_TOKEN_NAME: ${CERC_TOKEN_NAME} TOKEN_NAME: ${TOKEN_NAME}
CERC_TOKEN_SYMBOL: ${CERC_TOKEN_SYMBOL} TOKEN_SYMBOL: ${TOKEN_SYMBOL}
CERC_INITIAL_TOKEN_SUPPLY: ${CERC_INITIAL_TOKEN_SUPPLY} INITIAL_TOKEN_SUPPLY: ${INITIAL_TOKEN_SUPPLY}
DISABLE_DETERMINISTIC_DEPLOYMENT: ${DISABLE_DETERMINISTIC_DEPLOYMENT:-true}
volumes: volumes:
- nitro_deployment:/app/deployment - nitro_deployment:/app/deployment
- ../config/nitro-contracts/deploy.sh:/app/deploy.sh - ../config/nitro-contracts/deploy.sh:/app/deploy.sh

View File

@ -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:

View File

@ -2,7 +2,7 @@ name: nitro-rpc-client
services: services:
nitro-rpc-client: nitro-rpc-client:
image: cerc/nitro-contracts:local image: cerc/nitro-client:local
hostname: nitro-rpc-client hostname: nitro-rpc-client
restart: on-failure restart: on-failure
environment: environment:

View File

@ -13,7 +13,7 @@ if [ -f "$cert_file" ] ; then
echo "Cert file ${cert_file} already exists" echo "Cert file ${cert_file} already exists"
else else
echo "Creating certs" 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 # Copy over the rootCA cert so that it can be used by the client
cp -r $(mkcert -CAROOT)/* /app/mkcert-caroot cp -r $(mkcert -CAROOT)/* /app/mkcert-caroot

View File

@ -10,36 +10,45 @@ bridge_assets_map_file="/app/deployment/bridge-assets-map.toml"
bridge_config_file="/app/bridge.toml" bridge_config_file="/app/bridge.toml"
echo "Using the following environment variables:" echo "Using the following environment variables:"
echo "CERC_NITRO_L1_CHAIN_URL: ${CERC_NITRO_L1_CHAIN_URL}" echo "NITRO_L1_CHAIN_URL: ${NITRO_L1_CHAIN_URL}"
echo "CERC_NITRO_L2_CHAIN_URL: ${CERC_NITRO_L2_CHAIN_URL}" echo "NITRO_L2_CHAIN_URL: ${NITRO_L2_CHAIN_URL}"
echo "CERC_NITRO_CHAIN_PK: ${CERC_NITRO_CHAIN_PK}" echo "NITRO_CHAIN_PK: ${NITRO_CHAIN_PK}"
echo "CERC_NITRO_SC_PK: ${CERC_NITRO_SC_PK}" echo "NITRO_SC_PK: ${NITRO_SC_PK}"
echo "CERC_NITRO_L1_MSG_PORT: ${CERC_NITRO_L1_MSG_PORT}" echo "NITRO_L1_MSG_PORT: ${NITRO_L1_MSG_PORT}"
echo "CERC_NITRO_L2_MSG_PORT: ${CERC_NITRO_L2_MSG_PORT}" echo "NITRO_L2_MSG_PORT: ${NITRO_L2_MSG_PORT}"
echo "CERC_NITRO_RPC_PORT: ${CERC_NITRO_RPC_PORT}" echo "NITRO_RPC_PORT: ${NITRO_RPC_PORT}"
echo "CERC_NITRO_PUBLIC_P2P_HOST: ${CERC_NITRO_PUBLIC_P2P_HOST}" 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 required certs
./create-certs.sh ./create-certs.sh
# Create the bridge config file # Create the bridge config file
cat <<EOF > "$bridge_config_file" cat <<EOF > "$bridge_config_file"
chainpk = "$CERC_NITRO_CHAIN_PK" chainpk = "$NITRO_CHAIN_PK"
statechannelpk = "$CERC_NITRO_SC_PK" statechannelpk = "$NITRO_SC_PK"
l1chainurl = "$CERC_NITRO_L1_CHAIN_URL" l1chainurl = "$NITRO_L1_CHAIN_URL"
l2chainurl = "$CERC_NITRO_L2_CHAIN_URL" l2chainurl = "$NITRO_L2_CHAIN_URL"
nodel1msgport = $CERC_NITRO_L1_MSG_PORT nodel1msgport = $NITRO_L1_MSG_PORT
nodel2msgport = $CERC_NITRO_L2_MSG_PORT nodel2msgport = $NITRO_L2_MSG_PORT
rpcport = $CERC_NITRO_RPC_PORT rpcport = $NITRO_RPC_PORT
bridgepublicip = "$CERC_NITRO_PUBLIC_P2P_HOST" bridgepublicip = "$NITRO_PUBLIC_P2P_HOST"
assetmapfilepath = "$bridge_assets_map_file" assetmapfilepath = "$bridge_assets_map_file"
EOF EOF
# Export contract addresses # Export contract addresses
export NA_ADDRESS=$(jq -r ".\"$CERC_GETH_CHAIN_ID\"[0].contracts.NitroAdjudicator.address" ${nitro_addresses_file}) export NA_ADDRESS=$(jq -r ".\"$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 CA_ADDRESS=$(jq -r ".\"$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 VPA_ADDRESS=$(jq -r ".\"$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 BRIDGE_ADDRESS=$(jq -r ".\"$OPTIMISM_CHAIN_ID\"[0].contracts.Bridge.address" ${nitro_addresses_file})
# Start bridge # Start bridge
echo "Starting nitro-bridge"
./nitro-bridge -config $bridge_config_file ./nitro-bridge -config $bridge_config_file

View File

@ -1,30 +1,48 @@
#!/bin/bash #!/bin/bash
# TODO: Support running node on L2
if [ -n "$CERC_SCRIPT_DEBUG" ]; then if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x set -x
fi fi
if [ -z "$CERC_NA_ADDRESS" ]; then node_config_file="/app/config.toml"
echo "Error: NA_ADDRESS is not present"
exit 1
fi
if [ -z "$CERC_VPA_ADDRESS" ]; then echo "Using the following environment variables:"
echo "Error: VPA_ADDRESS is not present" echo "NITRO_USE_DURABLE_STORE: ${NITRO_USE_DURABLE_STORE}"
exit 1 echo "NITRO_MSG_PORT: ${NITRO_MSG_PORT}"
fi 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 "Using Nitro contract addresses:"
echo "Error: CA_ADDRESS is not present" echo "NA_ADDRESS: ${NA_ADDRESS}"
exit 1 echo "CA_ADDRESS: ${CA_ADDRESS}"
fi echo "VPA_ADDRESS: ${VPA_ADDRESS}"
echo "BRIDGE_ADDRESS: ${BRIDGE_ADDRESS}"
echo "CERC_NITRO_CHAIN_URL: ${CERC_NITRO_CHAIN_URL}" # Create required certs
echo "CERC_NITRO_MSG_PORT: ${CERC_NITRO_MSG_PORT}" ./create-certs.sh
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}"
./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 <<EOF > "$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

View File

@ -10,27 +10,16 @@ nitro_addresses_file="/app/deployment/nitro-addresses.json"
bridge_assets_map_file="/app/deployment/bridge-assets-map.toml" bridge_assets_map_file="/app/deployment/bridge-assets-map.toml"
echo "Using the following environment variables:" echo "Using the following environment variables:"
echo "CERC_GETH_URL: ${CERC_GETH_URL}" echo "GETH_URL: ${GETH_URL}"
echo "CERC_OPTIMISM_URL: ${CERC_OPTIMISM_URL}" echo "OPTIMISM_URL: ${OPTIMISM_URL}"
echo "CERC_GETH_CHAIN_ID: ${CERC_GETH_CHAIN_ID}" echo "GETH_CHAIN_ID: ${GETH_CHAIN_ID}"
echo "CERC_OPTIMISM_CHAIN_ID: ${CERC_OPTIMISM_CHAIN_ID}" echo "OPTIMISM_CHAIN_ID: ${OPTIMISM_CHAIN_ID}"
echo "CERC_GETH_DEPLOYER_PK: ${CERC_GETH_DEPLOYER_PK}" echo "GETH_DEPLOYER_PK: ${GETH_DEPLOYER_PK}"
echo "CERC_OPTIMISM_DEPLOYER_PK: ${CERC_OPTIMISM_DEPLOYER_PK}" echo "OPTIMISM_DEPLOYER_PK: ${OPTIMISM_DEPLOYER_PK}"
echo "CERC_TOKEN_NAME: ${CERC_TOKEN_NAME}" echo "TOKEN_NAME: ${TOKEN_NAME}"
echo "CERC_TOKEN_SYMBOL: ${CERC_TOKEN_SYMBOL}" echo "TOKEN_SYMBOL: ${TOKEN_SYMBOL}"
echo "CERC_INITIAL_TOKEN_SUPPLY: ${CERC_INITIAL_TOKEN_SUPPLY}" echo "INITIAL_TOKEN_SUPPLY: ${INITIAL_TOKEN_SUPPLY}"
echo "DISABLE_DETERMINISTIC_DEPLOYMENT: ${DISABLE_DETERMINISTIC_DEPLOYMENT}"
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
# Check if L1 chain id key is present for L1 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 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 EOF
echo "Done" echo "Done"
# Keep the container running for future asset transfers
tail -f /dev/null

View File

@ -15,7 +15,7 @@ RUN go mod tidy
RUN go build -v -o nitro . RUN go build -v -o nitro .
RUN go build -o nitro-bridge cmd/start-bridge/main.go RUN go build -o nitro-bridge cmd/start-bridge/main.go
# TODO: Update steps to build go-nitro image
# Reduce image size # Reduce image size
FROM debian:bullseye-slim FROM debian:bullseye-slim
RUN apt-get update RUN apt-get update

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Build cerc/nitro-contracts # Build cerc/nitro-client
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
# See: https://stackoverflow.com/a/246128/1701505 # See: https://stackoverflow.com/a/246128/1701505
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 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

View File

@ -19,3 +19,68 @@
```bash ```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge build-containers 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
```

View File

@ -1,12 +1,12 @@
version: "1.0" version: "1.0"
name: bridge name: bridge
description: "Nitro bridge node" description: "Nitro bridge with contracts deployment and nitro-rpc-client"
repos: repos:
- github.com/cerc-io/go-nitro - github.com/cerc-io/go-nitro
containers: containers:
- cerc/nitro-contracts - cerc/nitro-client
- cerc/go-nitro - cerc/go-nitro
pods: pods:
- nitro-contracts - nitro-contracts
- bridge - nitro-bridge
- nitro-rpc-client - nitro-rpc-client

View File

@ -1,4 +1,4 @@
# Go-nitro # nitro-node
## Setup ## Setup
@ -36,9 +36,8 @@
network: network:
ports: ports:
go-nitro: go-nitro:
- 3006:3006 - 3005:3005
- 4006:4006 - 4005:4005
- 5006:5006
``` ```
- Create deployment - Create deployment
@ -53,26 +52,31 @@
```bash ```bash
# URL endpoint of the chain (Example: ws://host.docker.internal:8545) # 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) # 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 # 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) # 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) # Port to be used by RPC server (Example: 4009)
CERC_NITRO_RPC_PORT=4009 NITRO_RPC_PORT=4009
# Optional # Contract address of NitroAdjudicator
# Contract addresses of NitroAdjudicator, VirtualPaymentApp and ConsensusApp NA_ADDRESS=
# TODO: Contracts are deployed if addresses are not set
CERC_NA_ADDRESS= # Contract address of VirtualPaymentApp
CERC_VPA_ADDRESS= VPA_ADDRESS=
CERC_CA_ADDRESS=
# Contract address of ConsensusApp
CA_ADDRESS=
# Address of the bridge node
BRIDGE_ADDRESS=
``` ```
## Start the deployment ## Start the deployment
@ -80,3 +84,4 @@
```bash ```bash
laconic-so deployment --dir nitro-node-deployment start laconic-so deployment --dir nitro-node-deployment start
``` ```
<!-- TODO: Implement -->

View File

@ -1,11 +1,11 @@
version: "1.0" version: "1.0"
name: go-nitro name: nitro-node
description: "Stack to demonstrate payments between various services" description: "Nitro node with nitro-rpc-client"
repos: repos:
- github.com/cerc-io/go-nitro - github.com/cerc-io/go-nitro
containers: containers:
- cerc/go-nitro - cerc/go-nitro
- cerc/nitro-contracts - cerc/nitro-client
pods: pods:
- go-nitro - nitro-node
- nitro-rpc-client - nitro-rpc-client