From 9b53a5bd656f87b18e6d1239897f24eff9889135 Mon Sep 17 00:00:00 2001 From: Adw8 Date: Wed, 9 Oct 2024 19:03:12 +0530 Subject: [PATCH 1/6] Remove go-nitro repo from stack.yml --- stack-orchestrator/stacks/bridge/stack.yml | 2 -- stack-orchestrator/stacks/nitro-node/stack.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/stack-orchestrator/stacks/bridge/stack.yml b/stack-orchestrator/stacks/bridge/stack.yml index a162378..e84f1ff 100644 --- a/stack-orchestrator/stacks/bridge/stack.yml +++ b/stack-orchestrator/stacks/bridge/stack.yml @@ -2,10 +2,8 @@ version: "1.0" name: bridge description: "Nitro bridge with contracts deployment and nitro-rpc-client" repos: - - github.com/cerc-io/go-nitro containers: - cerc/nitro-client - - cerc/go-nitro pods: - nitro-bridge - nitro-rpc-client diff --git a/stack-orchestrator/stacks/nitro-node/stack.yml b/stack-orchestrator/stacks/nitro-node/stack.yml index 2b1fb80..aacacd9 100644 --- a/stack-orchestrator/stacks/nitro-node/stack.yml +++ b/stack-orchestrator/stacks/nitro-node/stack.yml @@ -2,9 +2,7 @@ version: "1.0" name: nitro-node description: "Nitro node with nitro-rpc-client" repos: - - github.com/cerc-io/go-nitro containers: - - cerc/go-nitro - cerc/nitro-client pods: - nitro-node -- 2.45.2 From 61695df4c315ea129d0c77a217179f438e8f570b Mon Sep 17 00:00:00 2001 From: Adw8 Date: Wed, 9 Oct 2024 19:04:05 +0530 Subject: [PATCH 2/6] Update dockerfile to fetch binaries from release --- .../config/go-nitro/run-bridge.sh | 2 +- .../container-build/cerc-go-nitro/Dockerfile | 30 +++++++------------ .../cerc-nitro-client/Dockerfile | 7 ++--- stack-orchestrator/stacks/bridge/stack.yml | 1 + .../stacks/nitro-node/stack.yml | 1 + 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/stack-orchestrator/config/go-nitro/run-bridge.sh b/stack-orchestrator/config/go-nitro/run-bridge.sh index 06dea26..c9dac33 100755 --- a/stack-orchestrator/config/go-nitro/run-bridge.sh +++ b/stack-orchestrator/config/go-nitro/run-bridge.sh @@ -43,4 +43,4 @@ EOF # Start bridge echo "Starting nitro-bridge" -./nitro-bridge -config $bridge_config_file +./bridge -config $bridge_config_file diff --git a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile index af75157..96b0b9d 100644 --- a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile +++ b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile @@ -1,29 +1,21 @@ -FROM golang:1.22-bullseye AS builder +FROM debian:bullseye-slim + +RUN apt-get update +RUN apt-get install -y jq netcat ca-certificates curl +RUN rm -rf /var/lib/apt/lists/* # Copy files into image WORKDIR /app -COPY . . # Install mkcert RUN curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64" RUN chmod +x mkcert-v*-linux-amd64 RUN cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert -RUN go mod tidy +# Download binaries +RUN curl -LO https://3a54-14-140-185-65.ngrok-free.app/cerc-io/nitro/releases/download/latest/nitro +RUN curl -LO https://3a54-14-140-185-65.ngrok-free.app/cerc-io/nitro/releases/download/latest/bridge -# Build the binary -RUN go build -v -o nitro . -RUN go build -o nitro-bridge cmd/start-bridge/main.go - - -# Reduce image size -FROM debian:bullseye-slim -RUN apt-get update -RUN apt-get install -y jq netcat ca-certificates -RUN rm -rf /var/lib/apt/lists/* - -WORKDIR /app - -COPY --from=builder /app/nitro . -COPY --from=builder /app/nitro-bridge . -COPY --from=builder /usr/local/bin/mkcert /usr/local/bin/mkcert +# Make binaries executable +RUN chmod +x ./nitro +RUN chmod +x ./bridge diff --git a/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile b/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile index 77bc6c8..ef0f957 100644 --- a/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile +++ b/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile @@ -4,10 +4,7 @@ RUN apk --update --no-cache add python3 alpine-sdk bash curl jq WORKDIR /app -COPY . . - -RUN echo "Installing dependencies" && \ - yarn && yarn build +RUN npm config set @cerc-io:registry https://3a54-14-140-185-65.ngrok-free.app/api/packages/cerc-io/npm/ RUN echo "Installing nitro-rpc-client" && \ - npm install -g ./packages/nitro-rpc-client + npm install -g @cerc-io/nitro-rpc-client diff --git a/stack-orchestrator/stacks/bridge/stack.yml b/stack-orchestrator/stacks/bridge/stack.yml index e84f1ff..008c1b0 100644 --- a/stack-orchestrator/stacks/bridge/stack.yml +++ b/stack-orchestrator/stacks/bridge/stack.yml @@ -3,6 +3,7 @@ name: bridge description: "Nitro bridge with contracts deployment and nitro-rpc-client" repos: containers: + - cerc/go-nitro - cerc/nitro-client pods: - nitro-bridge diff --git a/stack-orchestrator/stacks/nitro-node/stack.yml b/stack-orchestrator/stacks/nitro-node/stack.yml index aacacd9..ed078b0 100644 --- a/stack-orchestrator/stacks/nitro-node/stack.yml +++ b/stack-orchestrator/stacks/nitro-node/stack.yml @@ -3,6 +3,7 @@ name: nitro-node description: "Nitro node with nitro-rpc-client" repos: containers: + - cerc/go-nitro - cerc/nitro-client pods: - nitro-node -- 2.45.2 From 36cdb196ecc79bf3ed40b78efc1ca4d8c0329e3e Mon Sep 17 00:00:00 2001 From: Adw8 Date: Fri, 11 Oct 2024 10:08:30 +0530 Subject: [PATCH 3/6] Add image for nitro-contracts --- .../compose/docker-compose-nitro-contracts.yml | 2 +- .../compose/docker-compose-nitro-rpc-client.yml | 2 +- .../container-build/cerc-go-nitro/Dockerfile | 8 ++++---- .../container-build/cerc-nitro-client/Dockerfile | 2 +- .../container-build/cerc-nitro-contracts/Dockerfile | 10 ++++++++++ .../container-build/cerc-nitro-contracts/build.sh | 9 +++++++++ stack-orchestrator/stacks/nitro-contracts/stack.yml | 2 +- 7 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 stack-orchestrator/container-build/cerc-nitro-contracts/Dockerfile create mode 100755 stack-orchestrator/container-build/cerc-nitro-contracts/build.sh diff --git a/stack-orchestrator/compose/docker-compose-nitro-contracts.yml b/stack-orchestrator/compose/docker-compose-nitro-contracts.yml index 796357f..bab3d8a 100644 --- a/stack-orchestrator/compose/docker-compose-nitro-contracts.yml +++ b/stack-orchestrator/compose/docker-compose-nitro-contracts.yml @@ -3,7 +3,7 @@ name: nitro-contracts services: # Optionally deploys the Nitro contracts nitro-contracts: - image: cerc/nitro-client:local + image: cerc/nitro-contracts:local restart: on-failure environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} diff --git a/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml b/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml index df4d118..4e64070 100644 --- a/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml +++ b/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml @@ -9,7 +9,7 @@ services: NODE_EXTRA_CA_CERTS: "/app/mkcert-caroot/rootCA.pem" command: ["bash", "-c", "tail -f /dev/null"] healthcheck: - test: ["CMD-SHELL", "nitro-rpc-client --version -p 4005"] + test: ["CMD-SHELL", "nitro-cli --version -p 4005"] interval: 30s timeout: 5s retries: 10 diff --git a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile index 96b0b9d..a695373 100644 --- a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile +++ b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile @@ -1,7 +1,7 @@ -FROM debian:bullseye-slim +FROM ubuntu:latest RUN apt-get update -RUN apt-get install -y jq netcat ca-certificates curl +RUN apt-get install -y jq netcat-traditional ca-certificates curl RUN rm -rf /var/lib/apt/lists/* # Copy files into image @@ -13,8 +13,8 @@ RUN chmod +x mkcert-v*-linux-amd64 RUN cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert # Download binaries -RUN curl -LO https://3a54-14-140-185-65.ngrok-free.app/cerc-io/nitro/releases/download/latest/nitro -RUN curl -LO https://3a54-14-140-185-65.ngrok-free.app/cerc-io/nitro/releases/download/latest/bridge +RUN curl -LO https://git.vdb.to/cerc-io/nitro/releases/download/latest/nitro +RUN curl -LO https://git.vdb.to/cerc-io/nitro/releases/download/latest/bridge # Make binaries executable RUN chmod +x ./nitro diff --git a/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile b/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile index ef0f957..50bca80 100644 --- a/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile +++ b/stack-orchestrator/container-build/cerc-nitro-client/Dockerfile @@ -4,7 +4,7 @@ RUN apk --update --no-cache add python3 alpine-sdk bash curl jq WORKDIR /app -RUN npm config set @cerc-io:registry https://3a54-14-140-185-65.ngrok-free.app/api/packages/cerc-io/npm/ +RUN npm config set @cerc-io:registry https://git.vdb.to/api/packages/cerc-io/npm/ RUN echo "Installing nitro-rpc-client" && \ npm install -g @cerc-io/nitro-rpc-client diff --git a/stack-orchestrator/container-build/cerc-nitro-contracts/Dockerfile b/stack-orchestrator/container-build/cerc-nitro-contracts/Dockerfile new file mode 100644 index 0000000..5fe2df7 --- /dev/null +++ b/stack-orchestrator/container-build/cerc-nitro-contracts/Dockerfile @@ -0,0 +1,10 @@ +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 && yarn build diff --git a/stack-orchestrator/container-build/cerc-nitro-contracts/build.sh b/stack-orchestrator/container-build/cerc-nitro-contracts/build.sh new file mode 100755 index 0000000..e70c7d0 --- /dev/null +++ b/stack-orchestrator/container-build/cerc-nitro-contracts/build.sh @@ -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}/go-nitro diff --git a/stack-orchestrator/stacks/nitro-contracts/stack.yml b/stack-orchestrator/stacks/nitro-contracts/stack.yml index ece621d..4938465 100644 --- a/stack-orchestrator/stacks/nitro-contracts/stack.yml +++ b/stack-orchestrator/stacks/nitro-contracts/stack.yml @@ -4,6 +4,6 @@ description: "Deploy nitro contracts" repos: - github.com/cerc-io/go-nitro containers: - - cerc/nitro-client + - cerc/nitro-contracts pods: - nitro-contracts -- 2.45.2 From dd9d51d047ba04979b11571e37ce5c37a75ac3eb Mon Sep 17 00:00:00 2001 From: Adw8 Date: Fri, 11 Oct 2024 12:24:02 +0530 Subject: [PATCH 4/6] Update README --- nitro-bridge-demo.md | 6 +++--- .../compose/docker-compose-nitro-rpc-client.yml | 2 +- .../container-build/cerc-go-nitro/Dockerfile | 6 +++++- stack-orchestrator/stacks/bridge/README.md | 6 ------ stack-orchestrator/stacks/nitro-contracts/README.md | 3 ++- stack-orchestrator/stacks/nitro-node/README.md | 8 -------- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/nitro-bridge-demo.md b/nitro-bridge-demo.md index 7bddb26..b09a84e 100644 --- a/nitro-bridge-demo.md +++ b/nitro-bridge-demo.md @@ -264,7 +264,7 @@ ```bash export GETH_CHAIN_ID="1212" - export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json") + export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.TestToken.address' /app/deployment/nitro-addresses.json") export A_CHAIN_ADDRESS="0xe22AD83A0dE117bA0d03d5E94Eb4E0d80a69C62a" export C_CHAIN_ADDRESS="0xf1ac8Dd1f6D6F5c0dA99097c57ebF50CD99Ce293" @@ -276,7 +276,7 @@ # Send tokens to Alice laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $ASSET_ADDRESS --to $A_CHAIN_ADDRESS --amount 1000 --network geth" - #Send tokens to Charlie + # Send tokens to Charlie laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $ASSET_ADDRESS --to $C_CHAIN_ADDRESS --amount 1000 --network geth" ``` @@ -438,7 +438,7 @@ ```bash export BRIDGE_NITRO_ADDRESS=0xBBB676f9cFF8D242e9eaC39D063848807d3D1D94 export GETH_CHAIN_ID="1212" - export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json") + export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.TestToken.address' /app/deployment/nitro-addresses.json") ``` - Create ledger channel between A and Bridge with custom token diff --git a/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml b/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml index 4e64070..df4d118 100644 --- a/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml +++ b/stack-orchestrator/compose/docker-compose-nitro-rpc-client.yml @@ -9,7 +9,7 @@ services: NODE_EXTRA_CA_CERTS: "/app/mkcert-caroot/rootCA.pem" command: ["bash", "-c", "tail -f /dev/null"] healthcheck: - test: ["CMD-SHELL", "nitro-cli --version -p 4005"] + test: ["CMD-SHELL", "nitro-rpc-client --version -p 4005"] interval: 30s timeout: 5s retries: 10 diff --git a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile index a695373..4bac47e 100644 --- a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile +++ b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:latest +FROM debian:bookworm-slim RUN apt-get update RUN apt-get install -y jq netcat-traditional ca-certificates curl @@ -19,3 +19,7 @@ RUN curl -LO https://git.vdb.to/cerc-io/nitro/releases/download/latest/bridge # Make binaries executable RUN chmod +x ./nitro RUN chmod +x ./bridge + +# Verify that binaries are correctly setup +RUN ./nitro help +RUN ./bridge help diff --git a/stack-orchestrator/stacks/bridge/README.md b/stack-orchestrator/stacks/bridge/README.md index c46d0c2..1baa9ba 100644 --- a/stack-orchestrator/stacks/bridge/README.md +++ b/stack-orchestrator/stacks/bridge/README.md @@ -8,12 +8,6 @@ laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack ``` -- Clone required repositories: - - ```bash - laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge setup-repositories - ``` - - Build container images: ```bash diff --git a/stack-orchestrator/stacks/nitro-contracts/README.md b/stack-orchestrator/stacks/nitro-contracts/README.md index 8dc0e92..352b0f2 100644 --- a/stack-orchestrator/stacks/nitro-contracts/README.md +++ b/stack-orchestrator/stacks/nitro-contracts/README.md @@ -11,8 +11,9 @@ - Clone required repositories: ```bash - laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts setup-repositories + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts setup-repositories --git-ssh --pull ``` + Make sure you have access to the `go-nitro` repository - Build container images: diff --git a/stack-orchestrator/stacks/nitro-node/README.md b/stack-orchestrator/stacks/nitro-node/README.md index f813c07..5d71018 100644 --- a/stack-orchestrator/stacks/nitro-node/README.md +++ b/stack-orchestrator/stacks/nitro-node/README.md @@ -8,14 +8,6 @@ laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack ``` -- Clone required repositories - - ```bash - 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 -- 2.45.2 From c7acf17bd068012d48e3ae892b6e046a7c267771 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Wed, 16 Oct 2024 19:37:33 +0530 Subject: [PATCH 5/6] Use ubuntu latest for building nitro node containers --- stack-orchestrator/compose/docker-compose-nitro-contracts.yml | 1 + stack-orchestrator/container-build/cerc-go-nitro/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/stack-orchestrator/compose/docker-compose-nitro-contracts.yml b/stack-orchestrator/compose/docker-compose-nitro-contracts.yml index bab3d8a..b7826a4 100644 --- a/stack-orchestrator/compose/docker-compose-nitro-contracts.yml +++ b/stack-orchestrator/compose/docker-compose-nitro-contracts.yml @@ -4,6 +4,7 @@ services: # Optionally deploys the Nitro contracts nitro-contracts: image: cerc/nitro-contracts:local + working_dir: /app restart: on-failure environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} diff --git a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile index 4bac47e..46c8179 100644 --- a/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile +++ b/stack-orchestrator/container-build/cerc-go-nitro/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bookworm-slim +FROM ubuntu:latest RUN apt-get update RUN apt-get install -y jq netcat-traditional ca-certificates curl -- 2.45.2 From 012164d6c0ca2ee8021684483446faea164caba0 Mon Sep 17 00:00:00 2001 From: Shreerang Kale Date: Wed, 16 Oct 2024 19:47:52 +0530 Subject: [PATCH 6/6] Add step to build nitro contracts container --- nitro-bridge-demo.md | 3 +++ nitro-node-demo.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/nitro-bridge-demo.md b/nitro-bridge-demo.md index b09a84e..ad7a89b 100644 --- a/nitro-bridge-demo.md +++ b/nitro-bridge-demo.md @@ -99,6 +99,9 @@ ```bash laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node build-containers --force-rebuild + + # Build nitro-contracts container image + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts build-containers --force-rebuild ``` - Create a deployment spec-file for Alice's L1 nitro-node: diff --git a/nitro-node-demo.md b/nitro-node-demo.md index fcbc205..29e81e8 100644 --- a/nitro-node-demo.md +++ b/nitro-node-demo.md @@ -96,6 +96,9 @@ ```bash laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node build-containers --force-rebuild + + # Build nitro-contracts container image + laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts build-containers --force-rebuild ``` ## Run -- 2.45.2