Update nitro-node stack to use public IP from config (#3)

* Rename nitro-node stack

* Add flag for setting public IP

* Log values in the nitro-node script

* Add command to install nitro-rpc-client

* Fix directory name

* Set default value for public IP
This commit is contained in:
Isha Venikar 2024-07-18 17:18:24 +05:30 committed by GitHub
parent c0fe155708
commit 192e6feee3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 46 additions and 22 deletions

View File

@ -1 +1 @@
# nitro-stack
# nitro-stack

View File

@ -15,6 +15,7 @@ services:
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

View File

@ -15,8 +15,7 @@ services:
CERC_OPTIMISM_DEPLOYER_PK: ${CERC_GETH_DEPLOYER_PK}
CERC_DISABLE_DETERMINISTIC_DEPLOYMENT: true
volumes:
- ../config/nitro-contracts/deploy.sh:/app/deploy.sh
- ../config/nitro-contracts/deploy.sh:/app/deploy.sh
command: ["bash", "-c", "/app/deploy.sh"]
extra_hosts:
- "host.docker.internal:host-gateway"

View File

@ -1,8 +1,8 @@
name: nitro-rpc-client
services:
nitro-rpc-client:
image: cerc/nitro-rpc-client:local
hostname: nitro-rpc-client
restart: on-failure
command: ["bash", "-c", "tail -f /dev/null"]
nitro-rpc-client:
image: cerc/nitro-rpc-client:local
hostname: nitro-rpc-client
restart: on-failure
command: ["bash", "-c", "tail -f /dev/null"]

View File

@ -5,4 +5,26 @@ if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
./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}
if [ -z "$CERC_NA_ADDRESS" ]; then
echo "Error: NA_ADDRESS is not present"
exit 1
fi
if [ -z "$CERC_VPA_ADDRESS" ]; then
echo "Error: VPA_ADDRESS is not present"
exit 1
fi
if [ -z "$CERC_CA_ADDRESS" ]; then
echo "Error: CA_ADDRESS is not present"
exit 1
fi
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}"
./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}

View File

@ -25,4 +25,4 @@ export OPTIMISM_DEPLOYER_PK=$GETH_DEPLOYER_PK
export DISABLE_DETERMINISTIC_DEPLOYMENT=true
yarn contracts:deploy-geth
yarn contracts:deploy-optimism
yarn contracts:deploy-optimism

View File

@ -9,4 +9,7 @@ COPY . .
RUN echo "Installing dependencies" && \
yarn & yarn build
RUN echo "Installing nitro-rpc-client package" && \
npm install -g /app/packages/nitro-rpc-client
WORKDIR /app/packages/nitro-rpc-client

View File

@ -11,14 +11,15 @@
- Clone required repositories
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stack/go-nitro setup-repositories
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node setup-repositories
```
Note: Replace path to nitro stack with actual path
- Build the container image
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stack/go-nitro build-containers
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node build-containers
```
## Create a deployment
@ -26,7 +27,7 @@
- Create a spec file
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stack/go-nitro deploy init --output go-nitro-spec.yml
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy init --output nitro-node-spec.yml
```
- TODO: Edit `network` in the spec file to map container ports to host ports as required:
@ -41,14 +42,14 @@
```
- Create deployment
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stack/go-nitro deploy create --spec-file go-nitro-spec.yml --deployment-dir go-nitro-deployment
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file nitro-node-spec.yml --deployment-dir nitro-node-deployment
```
## Configuration
* Inside the `go-nitro-deployment` deployment directory, open `config.env` file and set following env variables:
- Inside the `nitro-node-deployment` deployment directory, open `config.env` file and set following env variables:
```bash
# URL endpoint of the chain (Example: ws://host.docker.internal:8545)
@ -56,16 +57,16 @@
# Private key of account to be used by Nitro node (derived address is used as Nitro address)
CERC_NITRO_PK=
# Private key of the account on chain that is used for funding channels in Nitro node
CERC_NITRO_CHAIN_PK=
# Port to be used by P2P message service (Example: 3009)
CERC_NITRO_MSG_PORT=
# Port to be used by RPC server (Example: 4009)
CERC_NITRO_RPC_PORT=4009
# Optional
# Contract addresses of NitroAdjudicator, VirtualPaymentApp and ConsensusApp
# TODO: Contracts are deployed if addresses are not set
@ -77,5 +78,5 @@
## Start the deployment
```bash
laconic-so deployment --dir go-nitro-deployment start
laconic-so deployment --dir nitro-node-deployment start
```

View File

@ -4,10 +4,8 @@ description: "Stack to demonstrate payments between various services"
repos:
- github.com/cerc-io/go-nitro
containers:
- cerc/nitro-contracts
- cerc/go-nitro
# - cerc/nitro-rpc-client
pods:
- go-nitro
- nitro-contracts
# - nitro-rpc-client