From 5081321f51721eda094698b9ca949989937e2e71 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Mon, 29 Apr 2024 13:22:16 -0700 Subject: [PATCH 1/2] test: optimize upgrade test build --- Dockerfile-upgrade | 37 +++++++++++---------- contrib/localnet/scripts/start-zetacored.sh | 4 +-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Dockerfile-upgrade b/Dockerfile-upgrade index e53b766256..c9963d2ea1 100644 --- a/Dockerfile-upgrade +++ b/Dockerfile-upgrade @@ -1,4 +1,4 @@ -FROM golang:1.20-alpine3.18 +FROM golang:1.20-alpine3.18 as base # Purpose: This Dockerfile creates an environment for performing an upgrade test on ZetaChain # It contains the ZetaChain and ZetaClient binaries for two different versions of ZetaChain @@ -8,6 +8,7 @@ FROM golang:1.20-alpine3.18 ENV GOPATH /go ENV GOOS=linux ENV CGO_ENABLED=1 +ENV GOCACHE=/root/.cache/go-build RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl tmux RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N "" @@ -20,33 +21,35 @@ WORKDIR /go/delivery/zeta-node RUN mkdir -p $GOPATH/bin/old RUN mkdir -p $GOPATH/bin/new +RUN ssh-keygen -A +RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys + +# Checkout and build old binary +FROM base as oldbuild ARG OLD_VERSION=v14.0.0 -ENV NEW_VERSION=v15 +RUN git clone https://github.com/zeta-chain/node.git +RUN cd node && git fetch + +RUN cd node && git checkout ${OLD_VERSION} +RUN cd node && make install # Build new release from the current source +FROM base +ENV NEW_VERSION=v15 COPY go.mod /go/delivery/zeta-node/ COPY go.sum /go/delivery/zeta-node/ RUN cd /go/delivery/zeta-node/ && go mod download COPY . /go/delivery/zeta-node/ -RUN cd /go/delivery/zeta-node/ && make install -RUN cd /go/delivery/zeta-node/ && make install-zetae2e -RUN cp $GOPATH/bin/zetacored $GOPATH/bin/new/ -RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/new/ - -# Checkout and build old binary -RUN git clone https://github.com/zeta-chain/node.git -RUN cd node && git fetch +RUN --mount=type=cache,target="/root/.cache/go-build" cd /go/delivery/zeta-node/ && make install +RUN --mount=type=cache,target="/root/.cache/go-build" cd /go/delivery/zeta-node/ && make install-zetae2e +RUN cp $GOPATH/bin/zetacored $GOPATH/bin/new/ && \ + cp $GOPATH/bin/zetaclientd $GOPATH/bin/new/ -RUN cd node && git checkout ${OLD_VERSION} -RUN cd node && make install -RUN cp $GOPATH/bin/zetacored $GOPATH/bin/old/ -RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/old/ +COPY --from=oldbuild $GOPATH/bin/zetacored $GOPATH/bin/zetaclientd $GOPATH/bin/ +COPY --from=oldbuild $GOPATH/bin/zetacored $GOPATH/bin/zetaclientd $GOPATH/bin/old -RUN ssh-keygen -A WORKDIR /root -RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys - RUN cp /go/bin/zetaclientd /usr/local/bin RUN cp /go/bin/zetacored /usr/local/bin RUN cp /go/bin/zetae2e /usr/local/bin diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index d28f6ae446..4a83f7cb79 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -226,8 +226,8 @@ else sleep 7 /root/.zetacored/cosmovisor/genesis/bin/zetacored query gov proposal 1 - # We use tail -f to keep the container running - tail -f zetanode.log + # We use tail -f to keep the container running. Use -n999999 to ensure we get all the context. + tail -n999999 -f zetanode.log fi From 55050ace815f5730f58b57ce6daaf2245da5450e Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Mon, 29 Apr 2024 14:25:21 -0700 Subject: [PATCH 2/2] versions build-arg --- Dockerfile-upgrade | 5 +++-- Makefile | 14 ++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Dockerfile-upgrade b/Dockerfile-upgrade index c9963d2ea1..42e9834bf6 100644 --- a/Dockerfile-upgrade +++ b/Dockerfile-upgrade @@ -26,7 +26,7 @@ RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys # Checkout and build old binary FROM base as oldbuild -ARG OLD_VERSION=v14.0.0 +ARG OLD_VERSION RUN git clone https://github.com/zeta-chain/node.git RUN cd node && git fetch @@ -35,7 +35,8 @@ RUN cd node && make install # Build new release from the current source FROM base -ENV NEW_VERSION=v15 +ARG NEW_VERSION +ENV NEW_VERSION=${NEW_VERSION} COPY go.mod /go/delivery/zeta-node/ COPY go.sum /go/delivery/zeta-node/ RUN cd /go/delivery/zeta-node/ && go mod download diff --git a/Makefile b/Makefile index 2cc2bf1d80..b679c488d3 100644 --- a/Makefile +++ b/Makefile @@ -214,16 +214,18 @@ start-stress-test: zetanode @echo "--> Starting stress test" cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-stresstest.yml up -d -start-upgrade-test: - @echo "--> Starting upgrade test" - $(DOCKER) build -t zetanode -f ./Dockerfile-upgrade . +zetanode-upgrade: + @echo "Building zetanode-upgrade" + $(DOCKER) build -t zetanode -f ./Dockerfile-upgrade --build-arg OLD_VERSION=v14.0.0 --build-arg NEW_VERSION=v15 . $(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild . +.PHONY: zetanode-upgrade + +start-upgrade-test: zetanode-upgrade + @echo "--> Starting upgrade test" cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d -start-upgrade-test-light: +start-upgrade-test-light: zetanode-upgrade @echo "--> Starting light upgrade test (no ZetaChain state populating before upgrade)" - $(DOCKER) build -t zetanode -f ./Dockerfile-upgrade . - $(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild . cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade-light.yml up -d start-localnet: zetanode