diff --git a/Dockerfile-upgrade b/Dockerfile-upgrade index e53b766256..42e9834bf6 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,32 +21,35 @@ WORKDIR /go/delivery/zeta-node RUN mkdir -p $GOPATH/bin/old RUN mkdir -p $GOPATH/bin/new -ARG OLD_VERSION=v14.0.0 -ENV NEW_VERSION=v15 - -# Build new release from the current source -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/ +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 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 -RUN cp $GOPATH/bin/zetacored $GOPATH/bin/old/ -RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/old/ -RUN ssh-keygen -A -WORKDIR /root +# Build new release from the current source +FROM base +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 +COPY . /go/delivery/zeta-node/ +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 cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys +COPY --from=oldbuild $GOPATH/bin/zetacored $GOPATH/bin/zetaclientd $GOPATH/bin/ +COPY --from=oldbuild $GOPATH/bin/zetacored $GOPATH/bin/zetaclientd $GOPATH/bin/old + +WORKDIR /root RUN cp /go/bin/zetaclientd /usr/local/bin RUN cp /go/bin/zetacored /usr/local/bin 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 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