Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: added local development testing node sync docker compose #2070

Merged
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ 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}" && \
echo -n "${expected_major_version}" > /go/delivery/zeta-node/expected_major_version

# Run Stage
FROM alpine:3.18
Expand All @@ -46,6 +48,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
Expand Down
66 changes: 60 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,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 ###
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@

### 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.
lumtis marked this conversation as resolved.
Show resolved Hide resolved
* [1958](https://github.com/zeta-chain/node/pull/1958) - Fix e2e advanced test debug checkbox.
* [1945](https://github.com/zeta-chain/node/pull/1945) - update advanced testing pipeline to not execute tests that weren't selected so they show skipped instead of skipping steps.
* [1940](https://github.com/zeta-chain/node/pull/1940) - adjust release pipeline to be created as pre-release instead of latest
Expand Down
42 changes: 0 additions & 42 deletions contrib/athens3/zetacored/docker-compose.yml

This file was deleted.

28 changes: 27 additions & 1 deletion contrib/docker-scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,33 @@ 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
fi
expected_major_version=$(cat /scripts/expected_major_version)
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_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} \
Expand Down
45 changes: 0 additions & 45 deletions contrib/mainnet/zetacored/docker-compose.yml

This file was deleted.

8 changes: 8 additions & 0 deletions contrib/rpc/ethereum/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
38 changes: 38 additions & 0 deletions contrib/rpc/ethereum/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
- "8545:8545" # JSON-RPC
- "8546:8546" # 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:
36 changes: 36 additions & 0 deletions contrib/rpc/zetacored/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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=-:
62 changes: 62 additions & 0 deletions contrib/rpc/zetacored/init_docker_compose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/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 "================"

# Run Docker Compose
docker-compose -f ${FILE_PATH} up
14 changes: 14 additions & 0 deletions contrib/rpc/zetacored/kill_docker_compose.sh
Original file line number Diff line number Diff line change
@@ -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

Loading
Loading