From 97e650fcd522b917c40d5893e423d661a0606949 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Tue, 30 Apr 2024 09:51:34 -0700 Subject: [PATCH 1/3] test: optimize upgrade test image build (#2096) * test: optimize upgrade test build * versions build-arg --- Dockerfile-upgrade | 40 +++++++++++---------- Makefile | 14 ++++---- contrib/localnet/scripts/start-zetacored.sh | 4 +-- 3 files changed, 32 insertions(+), 26 deletions(-) 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 From 0e91dcf49c0c0b7571aa601d5dcbd68d093387eb Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Tue, 30 Apr 2024 10:27:43 -0700 Subject: [PATCH 2/3] docs: update release flow/docs (#2081) * docs: update release flow/docs * add note about RC from develop --- readme.md | 55 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/readme.md b/readme.md index b4ba24455f..eb1438682a 100644 --- a/readme.md +++ b/readme.md @@ -81,27 +81,56 @@ to [run the E2E test](./LOCAL_TESTING.md). [Discord](https://discord.com/invite/zetachain) | [Telegram](https://t.me/zetachainofficial) | [Website](https://zetachain.com) +## Releases -## Creating a Release Candidate -Creating a release candidate for testing is a straightforward process. Here are the steps to follow: +To start a new major release, begin by creating and pushing a `release/` branch based on `develop`. -### Steps - - Step 1. Create the release candidate tag with the following format (e.g., vx.x.x-rc) ex. v11.0.0-rc. - - Step 2. Once a RC branch is created the automation will kickoff to build and upload the release and its binaries. +
+Example Commands + +```bash +git fetch +git checkout -b release/v15 origin/develop +git push origin release/v15 +``` + +
+ +Most changes should first be merged into `develop` then backported to the release branch via a PR. + +
+Example Commands to Backport a Change + +```bash +git fetch +git checkout -b my-backport-branch origin/release/v15 +git cherry-pick +git push origin my-backport-branch +``` + +
+ +### Creating a Release Candidate +You can use github actions to create a release candidate: +1) Create the release candidate tag with the following format (e.g., vx.x.x-rc) ex. v11.0.0-rc. +2) Push the tag and the automation will take care of the rest + +You may create the RC tag directly off `develop` if a release branch has not been created yet. You should use the release branch if it exists and has diverged from develop. By following these steps, you can efficiently create a release candidate for QA and validation. In the future we will make this automatically deploy to a testnet when a -rc branch is created. Currently, raising the proposal to deploy to testnet is a manual process via GovOps repo. -## Creating a Release / Hotfix Release +### Creating a Release / Hotfix Release -To create a release simply execute the publish-release workflow and follow the steps below. +To create a release simply execute the publish-release workflow and follow these steps: -### Steps - - Step 1. Go to this pipeline: https://github.com/zeta-chain/node/actions/workflows/publish-release.yml - - Step 2. Select the dropdown branch / tag you want to create the release with. - - Step 3. In the version input, include the version of your release. Note. The major version must match what is in the upgrade handler. - - Step 4. Select if you want to skip the tests by checking the checkbox for skip tests. - - Step 5. Once the testing steps pass it will create a Github Issue. This Github Issue needes to be approved by one of the approvers: kingpinXD,lumtis,brewmaster012 +1) Go to this pipeline: https://github.com/zeta-chain/node/actions/workflows/publish-release.yml +2) Select the release branch. +3) In the version input, include the version of your release. + - The major version must match what is in the upgrade handler + - The version should look like this: `v15.0.0` +4) Select if you want to skip the tests by checking the checkbox for skip tests. +5) Once the testing steps pass it will create a Github Issue. This Github Issue needes to be approved by one of the approvers: kingpinXD,lumtis,brewmaster012 Once the release is approved the pipeline will continue and will publish the releases with the title / version you specified in the user input. From e5f48e4fbf8f441ec3df53ec4df5e6ad0f578d8d Mon Sep 17 00:00:00 2001 From: Grant Zukel <80433392+gzukel@users.noreply.github.com> Date: Wed, 1 May 2024 10:46:15 -0600 Subject: [PATCH 3/3] ci: added local development testing node sync docker compose (#2070) * ci: re-organizaed the folder structure for docker compose, made the docker commposes dynamic, added new make commands for building working branches to test non-governance upgrades against a full node fully synced against testnet or mainnet. Updated readme as well. --- Dockerfile | 6 +- Makefile | 66 ++++- changelog.md | 3 + contrib/athens3/zetacored/docker-compose.yml | 42 ---- contrib/docker-scripts/start.sh | 30 ++- contrib/mainnet/zetacored/docker-compose.yml | 45 ---- .../bitcoind-mainnet}/docker-compose.yml | 0 contrib/rpc/ethereum/Dockerfile | 8 + contrib/rpc/ethereum/docker-compose.yml | 38 +++ contrib/rpc/zetacored/docker-compose.yml | 36 +++ contrib/rpc/zetacored/init_docker_compose.sh | 65 +++++ contrib/rpc/zetacored/kill_docker_compose.sh | 14 ++ contrib/rpc/zetacored/networks/.athens3 | 14 ++ .../zetacored/networks/.athens3-localbuild | 14 ++ contrib/rpc/zetacored/networks/.mainnet | 14 ++ .../zetacored/networks/.mainnet-localbuild | 14 ++ readme.md | 231 +++++------------- 17 files changed, 372 insertions(+), 268 deletions(-) delete mode 100644 contrib/athens3/zetacored/docker-compose.yml delete mode 100644 contrib/mainnet/zetacored/docker-compose.yml rename contrib/{mainnet/bitcoind => rpc/bitcoind-mainnet}/docker-compose.yml (100%) create mode 100644 contrib/rpc/ethereum/Dockerfile create mode 100644 contrib/rpc/ethereum/docker-compose.yml create mode 100644 contrib/rpc/zetacored/docker-compose.yml create mode 100644 contrib/rpc/zetacored/init_docker_compose.sh create mode 100644 contrib/rpc/zetacored/kill_docker_compose.sh create mode 100644 contrib/rpc/zetacored/networks/.athens3 create mode 100644 contrib/rpc/zetacored/networks/.athens3-localbuild create mode 100644 contrib/rpc/zetacored/networks/.mainnet create mode 100644 contrib/rpc/zetacored/networks/.mainnet-localbuild diff --git a/Dockerfile b/Dockerfile index b43c2ca501..570a08ec4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,7 +20,10 @@ RUN go mod download # Copy the rest of the source code and build the application COPY . . -RUN make install +RUN expected_major_version=$(grep 'const releaseVersion = ' app/setup_handlers.go | awk -F'"' '{print $2}') && \ + make install VERSION="${expected_major_version}" && \ + git_hash=$(git rev-parse --short HEAD) && \ + echo -n "${expected_major_version}-${git_hash}" > /go/delivery/zeta-node/expected_major_version # Run Stage FROM alpine:3.18 @@ -46,6 +49,7 @@ RUN apk --no-cache add git jq bash curl nano vim tmux python3 libusb-dev linux-h # Copy the binaries from the build stage COPY --from=builder /go/bin/zetaclientd /usr/local/bin/zetaclientd COPY --from=builder /go/bin/zetacored /usr/local/bin/zetacored +COPY --from=builder /go/delivery/zeta-node/expected_major_version /scripts/expected_major_version # Set the working directory WORKDIR /usr/local/bin diff --git a/Makefile b/Makefile index b679c488d3..14f911e420 100644 --- a/Makefile +++ b/Makefile @@ -287,14 +287,68 @@ release: ### Local Mainnet Development ### ############################################################################### -mainnet-zetarpc-node: - cd contrib/mainnet/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose up +#BTC +start-bitcoin-node-mainnet: + cd contrib/rpc/bitcoind-mainnet && DOCKER_TAG=$(DOCKER_TAG) docker-compose up -mainnet-bitcoind-node: - cd contrib/mainnet/bitcoind && DOCKER_TAG=$(DOCKER_TAG) docker-compose up +stop-bitcoin-node-mainnet: + cd contrib/rpc/bitcoind-mainnet && DOCKER_TAG=$(DOCKER_TAG) docker-compose down + +clean-bitcoin-node-mainnet: + cd contrib/rpc/bitcoind-mainnet && DOCKER_TAG=$(DOCKER_TAG) docker-compose down -v + +#ETHEREUM +start-eth-node-mainnet: + cd contrib/rpc/ethereum && DOCKER_TAG=$(DOCKER_TAG) docker-compose up + +stop-eth-node-mainnet: + cd contrib/rpc/ethereum && DOCKER_TAG=$(DOCKER_TAG) docker-compose down + +clean-eth-node-mainnet: + cd contrib/rpc/ethereum && DOCKER_TAG=$(DOCKER_TAG) docker-compose down -v + +#ZETA + +#FULL-NODE-RPC-FROM-BUILT-IMAGE +start-zetacored-rpc-mainnet: + cd contrib/rpc/zetacored && bash init_docker_compose.sh mainnet image $(DOCKER_TAG) + +stop-zetacored-rpc-mainnet: + cd contrib/rpc/zetacored && bash kill_docker_compose.sh mainnet false + +clean-zetacored-rpc-mainnet: + cd contrib/rpc/zetacored && bash kill_docker_compose.sh mainnet true + +#FULL-NODE-RPC-FROM-BUILT-IMAGE +start-zetacored-rpc-testnet: + cd contrib/rpc/zetacored && bash init_docker_compose.sh athens3 image $(DOCKER_TAG) + +stop-zetacored-rpc-testnet: + cd contrib/rpc/zetacored && bash kill_docker_compose.sh athens3 false + +clean-zetacored-rpc-testnet: + cd contrib/rpc/zetacored && bash kill_docker_compose.sh athens3 true + +#FULL-NODE-RPC-FROM-LOCAL-BUILD +start-zetacored-rpc-mainnet-localbuild: + cd contrib/rpc/zetacored && bash init_docker_compose.sh mainnet localbuild $(DOCKER_TAG) + +stop-zetacored-rpc-mainnet-localbuild: + cd contrib/rpc/zetacored && bash kill_docker_compose.sh mainnet false + +clean-zetacored-rpc-mainnet-localbuild: + cd contrib/rpc/zetacored && bash kill_docker_compose.sh mainnet true + +#FULL-NODE-RPC-FROM-LOCAL-BUILD +start-zetacored-rpc-testnet-localbuild: + cd contrib/rpc/zetacored && bash init_docker_compose.sh athens3 localbuild $(DOCKER_TAG) + +stop-zetacored-rpc-testnet-localbuild: + cd contrib/rpc/zetacored && bash kill_docker_compose.sh athens3 false + +clean-zetacored-rpc-testnet-localbuild: + cd contrib/rpc/zetacored && bash kill_docker_compose.sh athens3 true -athens3-zetarpc-node: - cd contrib/athens3/zetacored && DOCKER_TAG=$(DOCKER_TAG) docker-compose up ############################################################################### ### Debug Tools ### diff --git a/changelog.md b/changelog.md index 3688b1f89c..bb2f5e881c 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,9 @@ ## Unreleased +### CI +* [2070](https://github.com/zeta-chain/node/pull/2070) - Added commands to build binaries from the working branch as a live full node rpc to test non-governance changes. + ### Refactor * [2032](https://github.com/zeta-chain/node/pull/2032) - improve some general structure of the ZetaClient codebase diff --git a/contrib/athens3/zetacored/docker-compose.yml b/contrib/athens3/zetacored/docker-compose.yml deleted file mode 100644 index cee5b695bc..0000000000 --- a/contrib/athens3/zetacored/docker-compose.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: '3.8' -services: - zetachain_mainnet_rpc: - platform: linux/amd64 - #This will build the binary from the GIT_REF you are locally on. -# build: -# context: ../../.. -# dockerfile: Dockerfile - image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14.0.1} - environment: - DAEMON_HOME: "/root/.zetacored" - NETWORK: athens3 - #RESTORE_TYPE=snapshot/snapshot-archive/statesync - RESTORE_TYPE: "snapshot" - SNAPSHOT_API: https://snapshots.zetachain.com - TRUST_HEIGHT_DIFFERENCE_STATE_SYNC: 40000 - CHAIN_ID: "athens_7001-1" - VISOR_NAME: "cosmovisor" - DAEMON_NAME: "zetacored" - DAEMON_ALLOW_DOWNLOAD_BINARIES: "false" - DAEMON_RESTART_AFTER_UPGRADE: "true" - UNSAFE_SKIP_BACKUP: "true" - CLIENT_DAEMON_NAME: "zetaclientd" - CLIENT_DAEMON_ARGS: "" - CLIENT_SKIP_UPGRADE: "true" - CLIENT_START_PROCESS: "false" - MONIKER: local-test - RE_DO_START_SEQUENCE: "false" - ports: - - "26656:26656" - - "1317:1317" - - "8545:8545" - - "8546:8546" - - "26657:26657" - - "9090:9090" - - "9091:9091" - volumes: - - zetacored_data_athens3:/root/.zetacored/ - entrypoint: bash /scripts/start.sh - -volumes: - zetacored_data_athens3: diff --git a/contrib/docker-scripts/start.sh b/contrib/docker-scripts/start.sh index d60f131c2c..6e2cebaf1f 100644 --- a/contrib/docker-scripts/start.sh +++ b/contrib/docker-scripts/start.sh @@ -236,7 +236,35 @@ function move_zetacored_binaries { } function start_network { - ${VISOR_NAME} version + if [ "${IS_LOCAL_DEVELOPMENT}" == "true" ]; then + cp /usr/local/bin/zetacored ${DAEMON_HOME}/cosmovisor/genesis/bin/zetacored + find /root/.zetacored/cosmovisor/upgrades/ -type f -path "*/bin/zetacored" -exec cp /usr/local/bin/zetacored {} \; + fi + expected_major_version=$(cat /scripts/expected_major_version | cut -d '-' -f 1) + VISOR_VERSION=v$(${VISOR_NAME} version | tail -n 1 | tr -d '(devel)' | tr -d '\n') + DAEMON_VERSION=$(${DAEMON_NAME} version) + VISOR_MAJOR_VERSION=$(echo $VISOR_VERSION | grep -o '^v[0-9]*') + DAEMON_MAJOR_VERSION=$(echo $DAEMON_VERSION | grep -o '^v[0-9]*') + + logt "EXPECTED_VERSION_WITH_HASH: $(cat /scripts/expected_major_version | cut -d '-' -f 1)" + logt "EXPECTED_MAJOR_VERSION: ${expected_major_version}" + logt "VISOR_VERSION: ${VISOR_VERSION}" + logt "DAEMON_VERSION: ${DAEMON_VERSION}" + logt "VISOR_MAJOR_VERSION: ${VISOR_MAJOR_VERSION}" + logt "DAEMON_MAJOR_VERSION: ${DAEMON_MAJOR_VERSION}" + + if [ "$VISOR_MAJOR_VERSION" != "$expected_major_version" ] || [ "$DAEMON_MAJOR_VERSION" != "$expected_major_version" ]; then + logt "One or both versions don't match the expected major release version: $expected_major_version" + else + logt "Both versions match the expected major release version: $expected_major_version" + fi + + if [ "$VISOR_VERSION" != "$DAEMON_VERSION" ]; then + logt "cosmovisor version doesn't appear to match your daemon version. Start ${DAEMON_NAME}" + else + logt "cosmovisor version match your daemon version. Start ${VISOR_NAME}" + fi + ${VISOR_NAME} run start --home ${DAEMON_HOME} \ --log_level info \ --moniker ${MONIKER} \ diff --git a/contrib/mainnet/zetacored/docker-compose.yml b/contrib/mainnet/zetacored/docker-compose.yml deleted file mode 100644 index ed75d0254c..0000000000 --- a/contrib/mainnet/zetacored/docker-compose.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: '3.8' -services: - zetachain_mainnet_rpc: - platform: linux/amd64 - #This will build the binary from the GIT_REF you are locally on. - # build: - # context: ../../.. - # dockerfile: Dockerfile - image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14.0.1} - container_name: zetachain_mainnet_rpc - environment: - DAEMON_HOME: "/root/.zetacored" - NETWORK: mainnet - #RESTORE_TYPE=snapshot/snapshot-archive/statesync - RESTORE_TYPE: "snapshot" - SNAPSHOT_API: https://snapshots.zetachain.com - TRUST_HEIGHT_DIFFERENCE_STATE_SYNC: 40000 - CHAIN_ID: "zetachain_7000-1" - VISOR_NAME: "cosmovisor" - DAEMON_NAME: "zetacored" - DAEMON_ALLOW_DOWNLOAD_BINARIES: "false" - DAEMON_RESTART_AFTER_UPGRADE: "true" - UNSAFE_SKIP_BACKUP: "true" - CLIENT_DAEMON_NAME: "zetaclientd" - CLIENT_DAEMON_ARGS: "" - CLIENT_SKIP_UPGRADE: "true" - CLIENT_START_PROCESS: "false" - MONIKER: local-test - RE_DO_START_SEQUENCE: "false" - ports: - - "26656:26656" - - "1317:1317" - - "8545:8545" - - "8546:8546" - - "26657:26657" - - "9090:9090" - - "9091:9091" - volumes: - - zetacored_data_mainnet:/root/.zetacored/ - entrypoint: bash /scripts/start.sh - #for debugging - #entrypoint: ["/bin/sh", "-c"] - #command: ["while true; do sleep 86400; done"] -volumes: - zetacored_data_mainnet: diff --git a/contrib/mainnet/bitcoind/docker-compose.yml b/contrib/rpc/bitcoind-mainnet/docker-compose.yml similarity index 100% rename from contrib/mainnet/bitcoind/docker-compose.yml rename to contrib/rpc/bitcoind-mainnet/docker-compose.yml diff --git a/contrib/rpc/ethereum/Dockerfile b/contrib/rpc/ethereum/Dockerfile new file mode 100644 index 0000000000..25451ea475 --- /dev/null +++ b/contrib/rpc/ethereum/Dockerfile @@ -0,0 +1,8 @@ +# Use the official Go Ethereum image +FROM ethereum/client-go:latest + +# Expose the ports (8545 for JSON-RPC, 8546 for WebSocket, 30303 for P2P) +EXPOSE 8545 8546 30303 + +# Set the entrypoint to start Geth +ENTRYPOINT ["geth"] diff --git a/contrib/rpc/ethereum/docker-compose.yml b/contrib/rpc/ethereum/docker-compose.yml new file mode 100644 index 0000000000..c2e433d22e --- /dev/null +++ b/contrib/rpc/ethereum/docker-compose.yml @@ -0,0 +1,38 @@ +version: '3.8' +services: + lighthouse: + image: sigp/lighthouse:latest + command: lighthouse --network mainnet beacon --http --checkpoint-sync-url https://sync.invis.tools + ports: + - "5052:5052" + volumes: + - type: volume + source: lighthouse_data + target: /root/.lighthouse + geth: + build: . + ports: + - "18545:18545" # JSON-RPC + - "18546:18546" # WebSocket + - "30303:30303" # P2P Network + volumes: + - type: volume + source: ethereum_data + target: /root/.ethereum + command: + - "--http" + - "--http.addr" + - "0.0.0.0" + - "--http.vhosts=*" + - "--http.api=admin,eth,debug,miner,net,txpool,personal,web3" + - "--ws" + - "--ws.addr" + - "0.0.0.0" + - "--ws.api=admin,eth,debug,miner,net,txpool,personal,web3" + - "--ws.origins=*" + - "--maxpeers=50" + - "--syncmode=snap" + +volumes: + ethereum_data: + lighthouse_data: diff --git a/contrib/rpc/zetacored/docker-compose.yml b/contrib/rpc/zetacored/docker-compose.yml new file mode 100644 index 0000000000..fa0f8caacb --- /dev/null +++ b/contrib/rpc/zetacored/docker-compose.yml @@ -0,0 +1,36 @@ +version: '3.8' +services: + -=name=-: + platform: linux/amd64 + -=image_block=- + container_name: "zetachain_${NETWORK:-mainnet}_rpc" + environment: + DAEMON_HOME: "${DAEMON_HOME:-/root/.zetacored}" + NETWORK: ${NETWORK:-mainnet} + RESTORE_TYPE: "${RESTORE_TYPE:-snapshot}" + SNAPSHOT_API: ${SNAPSHOT_API:-https://snapshots.zetachain.com} + TRUST_HEIGHT_DIFFERENCE_STATE_SYNC: ${TRUST_HEIGHT_DIFFERENCE_STATE_SYNC:-40000} + CHAIN_ID: "${CHAIN_ID:-zetachain_7000-1}" + VISOR_NAME: "${VISOR_NAME:-cosmovisor}" + DAEMON_NAME: "${DAEMON_NAME:-zetacored}" + DAEMON_ALLOW_DOWNLOAD_BINARIES: "${DAEMON_ALLOW_DOWNLOAD_BINARIES:-false}" + DAEMON_RESTART_AFTER_UPGRADE: "${DAEMON_RESTART_AFTER_UPGRADE:-true}" + UNSAFE_SKIP_BACKUP: "${UNSAFE_SKIP_BACKUP:-true}" + MONIKER: ${MONIKER:-mainnet-docker-rpc} + #If this is true it will erase everything and start over from scratch. + RE_DO_START_SEQUENCE: "${RE_DO_START_SEQUENCE:-false}" + #If this is true it will build the dockerfile and use binary from built docker file instead of remote docker image for local development testing on non-governance upgrades. + IS_LOCAL_DEVELOPMENT: "${IS_LOCAL_DEVELOPMENT:-false}" + ports: + - "26656:26656" + - "1317:1317" + - "8545:8545" + - "8546:8546" + - "26657:26657" + - "9090:9090" + - "9091:9091" + volumes: + - -=name=-:/root/.zetacored/ + entrypoint: bash /scripts/start.sh +volumes: + -=name=-: diff --git a/contrib/rpc/zetacored/init_docker_compose.sh b/contrib/rpc/zetacored/init_docker_compose.sh new file mode 100644 index 0000000000..04e9f6857c --- /dev/null +++ b/contrib/rpc/zetacored/init_docker_compose.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +NETWORK=${1} +TYPE=${2} +DOCKER_TAG=${3} + +if [ "$TYPE" == "image" ]; then + echo "Source Environment File." + SOURCE_FILE_NAME="networks/.${NETWORK}" + if [ ! -f "$SOURCE_FILE_NAME" ]; then + echo "Environment file $SOURCE_FILE_NAME does not exist." + exit 1 + fi + source ${SOURCE_FILE_NAME} +elif [ "$TYPE" == "localbuild" ]; then + echo "Source Environment File." + SOURCE_FILE_NAME="networks/.${NETWORK}-localbuild" + if [ ! -f "$SOURCE_FILE_NAME" ]; then + echo "Environment file $SOURCE_FILE_NAME does not exist." + exit 1 + fi + source ${SOURCE_FILE_NAME} +fi + +# Define the path to the Docker Compose file +FILE_PATH="${NETWORK}-docker-compose.yml" +cp docker-compose.yml ${FILE_PATH} + +# Determine the appropriate Docker Compose configuration based on TYPE +if [ "$TYPE" == "image" ]; then + IMAGE_BLOCK="image: zetachain/zetacored:\${DOCKER_TAG:-ubuntu-v14.0.1.0}" + NAME="zetacored-rpc-${NETWORK}" +elif [ "$TYPE" == "localbuild" ]; then + IMAGE_BLOCK=$(cat << 'EOF' +build: + context: ../../.. + dockerfile: Dockerfile +EOF +) + NAME="zetacored-rpc-${NETWORK}-localbuild" +else + echo "Invalid TYPE. Please specify 'image' or 'localbuild'." + exit 1 +fi + +IMAGE_BLOCK_ESCAPED=$(echo "$IMAGE_BLOCK" | sed 's/[&/]/\\&/g; s/$/\\/') +IMAGE_BLOCK_ESCAPED=${IMAGE_BLOCK_ESCAPED%?} + +# Replace placeholders in the Docker Compose file +sed -i '' "s|-=name=-|$NAME|g" $FILE_PATH +sed -i '' "s|-=image_block=-|$IMAGE_BLOCK_ESCAPED|g" $FILE_PATH + +echo "DEBUG ENV VARS" +printenv +echo "================" + +echo "Placeholders have been replaced in $FILE_PATH." +cat $FILE_PATH +echo "================" + +if [ "$TYPE" == "image" ]; then + docker-compose -f ${FILE_PATH} up +elif [ "$TYPE" == "localbuild" ]; then + docker-compose -f ${FILE_PATH} up --build +fi diff --git a/contrib/rpc/zetacored/kill_docker_compose.sh b/contrib/rpc/zetacored/kill_docker_compose.sh new file mode 100644 index 0000000000..5d6a2c192d --- /dev/null +++ b/contrib/rpc/zetacored/kill_docker_compose.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +NETWORK=${1} +CLEAN=${2} +FILE_PATH="${NETWORK}-docker-compose.yml" + +if [ "${CLEAN}" == "true" ]; then + docker-compose -f ${FILE_PATH} down -v + rm -rf ${FILE_PATH} +else + docker-compose -f ${FILE_PATH} down + rm -rf ${FILE_PATH} +fi + diff --git a/contrib/rpc/zetacored/networks/.athens3 b/contrib/rpc/zetacored/networks/.athens3 new file mode 100644 index 0000000000..d89a99033d --- /dev/null +++ b/contrib/rpc/zetacored/networks/.athens3 @@ -0,0 +1,14 @@ +export DAEMON_HOME="/root/.zetacored" +export NETWORK=athens3 +export RESTORE_TYPE="snapshot" +export SNAPSHOT_API=https://snapshots.zetachain.com +export TRUST_HEIGHT_DIFFERENCE_STATE_SYNC=40000 +export CHAIN_ID="athens_7001-1" +export VISOR_NAME="cosmovisor" +export DAEMON_NAME="zetacored" +export DAEMON_ALLOW_DOWNLOAD_BINARIES="false" +export DAEMON_RESTART_AFTER_UPGRADE="true" +export UNSAFE_SKIP_BACKUP="true" +export MONIKER=testnet-docker-rpc +export RE_DO_START_SEQUENCE="false" +export IS_LOCAL_DEVELOPMENT="false" \ No newline at end of file diff --git a/contrib/rpc/zetacored/networks/.athens3-localbuild b/contrib/rpc/zetacored/networks/.athens3-localbuild new file mode 100644 index 0000000000..b8e0acb6ad --- /dev/null +++ b/contrib/rpc/zetacored/networks/.athens3-localbuild @@ -0,0 +1,14 @@ +export DAEMON_HOME="/root/.zetacored" +export NETWORK=athens3 +export RESTORE_TYPE="snapshot" +export SNAPSHOT_API=https://snapshots.zetachain.com +export TRUST_HEIGHT_DIFFERENCE_STATE_SYNC=40000 +export CHAIN_ID="athens_7001-1" +export VISOR_NAME="cosmovisor" +export DAEMON_NAME="zetacored" +export DAEMON_ALLOW_DOWNLOAD_BINARIES="false" +export DAEMON_RESTART_AFTER_UPGRADE="false" +export UNSAFE_SKIP_BACKUP="true" +export MONIKER=testnet-docker-rpc +export RE_DO_START_SEQUENCE="false" +export IS_LOCAL_DEVELOPMENT="true" \ No newline at end of file diff --git a/contrib/rpc/zetacored/networks/.mainnet b/contrib/rpc/zetacored/networks/.mainnet new file mode 100644 index 0000000000..4b7420b539 --- /dev/null +++ b/contrib/rpc/zetacored/networks/.mainnet @@ -0,0 +1,14 @@ +export DAEMON_HOME="/root/.zetacored" +export NETWORK=mainnet +export RESTORE_TYPE="snapshot" +export SNAPSHOT_API=https://snapshots.zetachain.com +export TRUST_HEIGHT_DIFFERENCE_STATE_SYNC=40000 +export CHAIN_ID="zetachain_7000-1" +export VISOR_NAME="cosmovisor" +export DAEMON_NAME="zetacored" +export DAEMON_ALLOW_DOWNLOAD_BINARIES="false" +export DAEMON_RESTART_AFTER_UPGRADE="true" +export UNSAFE_SKIP_BACKUP="true" +export MONIKER=mainnet-docker-rpc +export RE_DO_START_SEQUENCE="false" +export IS_LOCAL_DEVELOPMENT="false" diff --git a/contrib/rpc/zetacored/networks/.mainnet-localbuild b/contrib/rpc/zetacored/networks/.mainnet-localbuild new file mode 100644 index 0000000000..371e6fe215 --- /dev/null +++ b/contrib/rpc/zetacored/networks/.mainnet-localbuild @@ -0,0 +1,14 @@ +export DAEMON_HOME="/root/.zetacored" +export NETWORK=mainnet +export RESTORE_TYPE="snapshot" +export SNAPSHOT_API=https://snapshots.zetachain.com +export TRUST_HEIGHT_DIFFERENCE_STATE_SYNC=40000 +export CHAIN_ID="zetachain_7000-1" +export VISOR_NAME="cosmovisor" +export DAEMON_NAME="zetacored" +export DAEMON_ALLOW_DOWNLOAD_BINARIES="false" +export DAEMON_RESTART_AFTER_UPGRADE="false" +export UNSAFE_SKIP_BACKUP="true" +export MONIKER=mainnet-docker-rpc +export RE_DO_START_SEQUENCE="false" +export IS_LOCAL_DEVELOPMENT="true" diff --git a/readme.md b/readme.md index eb1438682a..c20c2aa54e 100644 --- a/readme.md +++ b/readme.md @@ -139,182 +139,67 @@ Once the release is approved the pipeline will continue and will publish the rel This guide details deploying Zetacored nodes on both ZetaChain mainnet and Athens3 (testnet), alongside setting up a Bitcoin node for mainnet. The setup utilizes Docker Compose with environment variables for a streamlined deployment process. -### Deploying Zetacored Nodes - -#### Launching a Node - -**For Mainnet:** -- Use the `make` command with a specified Docker tag to initiate a mainnet Zetacored node. - ```shell - make mainnet-zetarpc-node DOCKER_TAG=ubuntu-v14.0.1 - ``` - -**For Athens3 (Testnet):** -- Similar command structure for Athens3, ensuring the correct Docker tag is used. - ```shell - make testnet-zetarpc-node DOCKER_TAG=ubuntu-v14.0.1 - ``` - -#### Modifying the Sync Type - -**To change the sync type for your node:** -- Edit docker-compose.yml in contrib/{NETWORK}/zetacored/. -- Set RESTORE_TYPE to your desired method (snapshot, snapshot-archive, statesync). - -#### Zetacored Environment Variables - -| Variable | Description | -|----------|-------------| -| `DAEMON_HOME` | Daemon's home directory (`/root/.zetacored`). | -| `NETWORK` | Network identifier: `mainnet` or `athens3` (for testnet). | -| `RESTORE_TYPE` | Node restoration method: `snapshot`, `snapshot-archive`, `statesync`. | -| `SNAPSHOT_API` | API URL for fetching snapshots. | -| `TRUST_HEIGHT_DIFFERENCE_STATE_SYNC` | Trust height difference for state synchronization. | -| `CHAIN_ID` | Chain ID for the network. | -| `VISOR_NAME` | Visor software name, typically `cosmovisor`. | -| `DAEMON_NAME` | Daemon software name, `zetacored`. | -| `DAEMON_ALLOW_DOWNLOAD_BINARIES` | Enable daemon to download binaries. | -| `DAEMON_RESTART_AFTER_UPGRADE` | Restart daemon after software upgrade. | -| `UNSAFE_SKIP_BACKUP` | Skip backup during potentially unsafe operations. | -| `CLIENT_DAEMON_NAME` | Client daemon name, such as `zetaclientd`. | -| `CLIENT_DAEMON_ARGS` | Extra arguments for the client daemon. | -| `CLIENT_SKIP_UPGRADE` | Skip client software upgrade. | -| `CLIENT_START_PROCESS` | Begin client process start-up. | -| `MONIKER` | Node's moniker or nickname. | -| `RE_DO_START_SEQUENCE` | Restart node setup from scratch if necessary. | +Here's a comprehensive documentation using markdown tables to cover all the `make` commands for managing Zetacored and Bitcoin nodes, including where to modify the environment variables in Docker Compose configurations. + +### Zetacored / BTC Node Deployment and Management + +#### Commands Overview for Zetacored + +| Environment | Action | Command | Docker Compose Location | +|-------------------------------------|-----------------------------|---------------------------------------------------------------|------------------------------------------| +| **Mainnet** | Start Bitcoin Node | `make start-bitcoin-node-mainnet` | `contrib/rpc/bitcoind-mainnet` | +| **Mainnet** | Stop Bitcoin Node | `make stop-bitcoin-node-mainnet` | `contrib/rpc/bitcoind-mainnet` | +| **Mainnet** | Clean Bitcoin Node Data | `make clean-bitcoin-node-mainnet` | `contrib/rpc/bitcoind-mainnet` | +| **Mainnet** | Start Ethereum Node | `make start-eth-node-mainnet` | `contrib/rpc/ethereum` | +| **Mainnet** | Stop Ethereum Node | `make stop-eth-node-mainnet` | `contrib/rpc/ethereum` | +| **Mainnet** | Clean Ethereum Node Data | `make clean-eth-node-mainnet` | `contrib/rpc/ethereum` | +| **Mainnet** | Start Zetacored Node | `make start-mainnet-zetarpc-node DOCKER_TAG=ubuntu-v14.0.1` | `contrib/rpc/zetacored` | +| **Mainnet** | Stop Zetacored Node | `make stop-mainnet-zetarpc-node` | `contrib/rpc/zetacored` | +| **Mainnet** | Clean Zetacored Node Data | `make clean-mainnet-zetarpc-node` | `contrib/rpc/zetacored` | +| **Testnet (Athens3)** | Start Zetacored Node | `make start-testnet-zetarpc-node DOCKER_TAG=ubuntu-v14.0.1` | `contrib/rpc/zetacored` | +| **Testnet (Athens3)** | Stop Zetacored Node | `make stop-testnet-zetarpc-node` | `contrib/rpc/zetacored` | +| **Testnet (Athens3)** | Clean Zetacored Node Data | `make clean-testnet-zetarpc-node` | `contrib/rpc/zetacored` | +| **Mainnet Local Build** | Start Zetacored Node | `make start-zetacored-rpc-mainnet-localbuild` | `contrib/rpc/zetacored` | +| **Mainnet Local Build** | Stop Zetacored Node | `make stop-zetacored-rpc-mainnet-localbuild` | `contrib/rpc/zetacored` | +| **Mainnet Local Build** | Clean Zetacored Node Data | `make clean-zetacored-rpc-mainnet-localbuild` | `contrib/rpc/zetacored` | +| **Testnet Local Build (Athens3)** | Start Zetacored Node | `make start-zetacored-rpc-testnet-localbuild` | `contrib/rpc/zetacored` | +| **Testnet Local Build (Athens3)** | Stop Zetacored Node | `make stop-zetacored-rpc-testnet-localbuild` | `contrib/rpc/zetacored` | +| **Testnet Local Build (Athens3)** | Clean Zetacored Node Data | `make clean-zetacored-rpc-testnet-localbuild` | `contrib/rpc/zetacored` | + ### Bitcoin Node Setup for Mainnet -**Restoring a BTC Watcher Node:** -- To deploy a Bitcoin mainnet node, specify the `DOCKER_TAG` for your Docker image. - ```shell - make mainnet-bitcoind-node DOCKER_TAG=36-mainnet - ``` - -#### Bitcoin Node Environment Variables - -| Variable | Description | -|----------|-------------| -| `bitcoin_username` | Username for Bitcoin RPC. | -| `bitcoin_password` | Password for Bitcoin RPC. | -| `NETWORK_HEIGHT_URL` | URL to fetch the latest block height. | -| `WALLET_NAME` | Name of the Bitcoin wallet. | -| `WALLET_ADDRESS` | Bitcoin wallet address for transactions. | -| `SNAPSHOT_URL` | URL for downloading the blockchain snapshot. | -| `SNAPSHOT_RESTORE` | Enable restoration from snapshot. | -| `CLEAN_SNAPSHOT` | Clean existing data before restoring snapshot. | -| `DOWNLOAD_SNAPSHOT` | Download the snapshot if not present. | - -### Docker Compose Configurations - -#### Zetacored Mainnet - -```yaml -version: '3.8' -services: - zetachain_mainnet_rpc: - platform: linux/amd64 - image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14.0.1} - environment: - DAEMON_HOME: "/root/.zetacored" - NETWORK: mainnet - RESTORE_TYPE: "snapshot" - SNAPSHOT_API: https://snapshots.zetachain.com - TRUST_HEIGHT_DIFFERENCE_STATE_SYNC: 40000 - CHAIN_ID: "zetachain_7000-1" - VISOR_NAME: "cosmovisor" - DAEMON_NAME: "zetacored" - DAEMON_ALLOW_DOWNLOAD_BINARIES: "false" - DAEMON_RESTART_AFTER_UPGRADE: "true" - UNSAFE_SKIP_BACKUP: "true" - CLIENT_DAEMON_NAME: "zetaclientd" - CLIENT_DAEMON_ARGS: "" - CLIENT_SKIP_UPGRADE: "true" - CLIENT_START_PROCESS: "false" - MONIKER: local-test - RE_DO_START_SEQUENCE: "false" - ports: - - "26656:26656" - - "1317:1317" - - "8545:8545" - - "8546:8546" - - "26657:26657" - - "9090:9090" - - "9091:9091" - volumes: - - - - zetacored_data_mainnet:/root/.zetacored/ - entrypoint: bash /scripts/start.sh -volumes: - zetacored_data_mainnet: -``` +#### Commands Overview for Bitcoin -#### Zetacored Athens3/Testnet - -```yaml -version: '3.8' -services: - zetachain_testnet_rpc: - platform: linux/amd64 - image: zetachain/zetacored:${DOCKER_TAG:-ubuntu-v14-testnet} - environment: - DAEMON_HOME: "/root/.zetacored" - NETWORK: athens3 - RESTORE_TYPE: "snapshot" - SNAPSHOT_API: https://snapshots.zetachain.com - TRUST_HEIGHT_DIFFERENCE_STATE_SYNC: 40000 - CHAIN_ID: "athens_7001-1" - VISOR_NAME: "cosmovisor" - DAEMON_NAME: "zetacored" - DAEMON_ALLOW_DOWNLOAD_BINARIES: "false" - DAEMON_RESTART_AFTER_UPGRADE: "true" - UNSAFE_SKIP_BACKUP: "true" - CLIENT_DAEMON_NAME: "zetaclientd" - CLIENT_DAEMON_ARGS: "" - CLIENT_SKIP_UPGRADE: "true" - CLIENT_START_PROCESS: "false" - MONIKER: local-test - RE_DO_START_SEQUENCE: "false" - ports: - - "26656:26656" - - "1317:1317" - - "8545:8545" - - "8546:8546" - - "26657:26657" - - "9090:9090" - - "9091:9091" - volumes: - - zetacored_data_athens3:/root/.zetacored/ - entrypoint: bash /scripts/start.sh -volumes: - zetacored_data_athens3: -``` +| Action | Command | Docker Compose Location | +|--------|---------|-------------------------| +| Start Node | `make start-mainnet-bitcoind-node DOCKER_TAG=36-mainnet` | `contrib/mainnet/bitcoind` | +| Stop Node | `make stop-mainnet-bitcoind-node` | `contrib/mainnet/bitcoind` | +| Clean Node Data | `make clean-mainnet-bitcoind-node` | `contrib/mainnet/bitcoind` | -#### Bitcoin Mainnet Node - -```yaml -version: '3' -services: - bitcoin: - image: zetachain/bitcoin:${DOCKER_TAG:-36-mainnet} - platform: linux/amd64 - environment: - - bitcoin_username=test - - bitcoin_password=test - - NETWORK_HEIGHT_URL=https://blockstream.info/api/blocks/tip/height - - WALLET_NAME=tssMainnet - - WALLET_ADDRESS=bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y - - SNAPSHOT_URL=https://storage.googleapis.com/bitcoin-rpc-snapshots-prod/bitcoind-mainnet-2024-02-20-00-22-06.tar.gz - - SNAPSHOT_RESTORE=true - - CLEAN_SNAPSHOT=true - - DOWNLOAD_SNAPSHOT=true - volumes: - - bitcoin_data:/root/ - ports: - - 8332:8332 -volumes: - bitcoin_data: -``` +### Configuration Options + +#### Where to Modify Environment Variables + +The environment variables for both Zetacored and Bitcoin nodes are defined in the `docker-compose.yml` files located in the respective directories mentioned above. These variables control various operational aspects like the sync type, networking details, and client behavior. + +#### Example Environment Variables for Zetacored + +| Variable | Description | Example | +|----------|-------------|---------| +| `DAEMON_HOME` | Daemon's home directory | `/root/.zetacored` | +| `NETWORK` | Network identifier | `mainnet`, `athens3` | +| `CHAIN_ID` | Chain ID for the network | `zetachain_7000-1`, `athens_7001-1` | +| `RESTORE_TYPE` | Node restoration method | `snapshot`, `statesync` | +| `SNAPSHOT_API` | API URL for fetching snapshots | `https://snapshots.zetachain.com` | + +#### Example Environment Variables for Bitcoin + +| Variable | Description | Example | +|----------|-------------|---------| +| `bitcoin_username` | Username for Bitcoin RPC | `user` | +| `bitcoin_password` | Password for Bitcoin RPC | `pass` | +| `WALLET_NAME` | Name of the Bitcoin wallet | `tssMainnet` | +| `WALLET_ADDRESS` | Bitcoin wallet address for transactions | `bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y` | -Replace placeholders in Docker Compose files and `make` commands with actual values appropriate for your deployment scenario. This complete setup guide is designed to facilitate the deployment and management of Zetacored and Bitcoin nodes in various environments. \ No newline at end of file +This detailed tabulation ensures all necessary commands and configurations are neatly organized, providing clarity on where to manage the settings and how to execute different operations for Zetacored and Bitcoin nodes across different environments.