Skip to content

Commit

Permalink
refactor(localnet): reduce number of docker compose files
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Jun 20, 2024
1 parent 2bb6f7b commit 4deeafe
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 104 deletions.
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ TEST_BUILD_FLAGS := -tags pebbledb,ledger
HSM_BUILD_FLAGS := -tags pebbledb,ledger,hsm_test

export DOCKER_BUILDKIT := 1
# set defaults to empty to prevent docker warning
export LOCALNET_MODE := ""
export E2E_ARGS := ""
export UPGRADE_HEIGHT := ""

clean: clean-binaries clean-dir clean-test-dir clean-coverage

Expand Down Expand Up @@ -223,15 +227,17 @@ start-e2e-test: zetanode

start-e2e-admin-test: zetanode
@echo "--> Starting e2e admin test"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-admin.yml up -d
export E2E_ARGS="--skip-regular --test-admin" && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-additionalevm.yml up -d

start-e2e-performance-test: zetanode
@echo "--> Starting e2e performance test"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-performance.yml up -d
export E2E_ARGS="--test-performance" && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml up -d

start-stress-test: zetanode
@echo "--> Starting stress test"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-stresstest.yml up -d
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-stress.yml up -d

#TODO: replace OLD_VERSION with v16 tag once its available
zetanode-upgrade: zetanode
Expand All @@ -242,17 +248,21 @@ zetanode-upgrade: zetanode

start-upgrade-test: zetanode-upgrade
@echo "--> Starting upgrade test"
export LOCALNET_MODE=upgrade && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d

start-upgrade-test-light: zetanode-upgrade
@echo "--> Starting light upgrade test (no ZetaChain state populating before upgrade)"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml -f docker-compose-upgrade-light.yml up -d
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=90 && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d

start-localnet: zetanode start-localnet-skip-build

start-localnet-skip-build:
@echo "--> Starting localnet"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-setup-only.yml up -d
export LOCALNET_MODE=setup-only && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml up -d

stop-localnet:
cd contrib/localnet/ && $(DOCKER) compose down --remove-orphans
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
version: "3"

# This docker-compose file overrides the orchestrator service to specify the flag to test the admin functions
# and skip the regular tests
# it also adds another local Ethereum network to test EVM chain migration and use the additional-evm flag

services:
orchestrator:
entrypoint: ["/work/start-zetae2e.sh", "local --skip-regular --test-admin"]

eth2:
build:
context: ./anvil
Expand All @@ -21,7 +16,9 @@ services:
ipv4_address: 172.20.0.102

zetaclient0:
entrypoint: [ "/root/start-zetaclientd.sh", "additional-evm" ]
environment:
- ADDITIONAL_EVM=true

zetaclient1:
entrypoint: [ "/root/start-zetaclientd.sh", "additional-evm" ]
environment:
- ADDITIONAL_EVM=true
2 changes: 0 additions & 2 deletions contrib/localnet/docker-compose-monitoring.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
grafana:
image: grafana/grafana:latest
Expand Down
9 changes: 0 additions & 9 deletions contrib/localnet/docker-compose-performance.yml

This file was deleted.

9 changes: 0 additions & 9 deletions contrib/localnet/docker-compose-setup-only.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
version: "3"

# This docker-compose redefine the services:
# - ZetaChain with 4 nodes to test performance
# - ZetaChain observer set with 4 clients to test performance
# - Orchestrator call stress commands

services:
zetacore0:
entrypoint: ["/root/start-zetacored.sh", "4"]
environment:
- ZETACORED_REPLICAS=4

zetacore1:
entrypoint: ["/root/start-zetacored.sh", "4"]
environment:
- ZETACORED_REPLICAS=4

zetacore2:
image: zetanode:latest
container_name: zetacore2
build:
context: ../../.
dockerfile: Dockerfile-localnet
hostname: zetacore2
networks:
mynetwork:
Expand All @@ -26,6 +22,7 @@ services:
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
- ZETACORED_REPLICAS=4

zetacore3:
image: zetanode:latest
Expand All @@ -41,21 +38,11 @@ services:
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only

zetaclient0:
ports:
- "8123:8123"
entrypoint: /root/start-zetaclientd.sh

zetaclient1:
entrypoint: /root/start-zetaclientd.sh
- ZETACORED_REPLICAS=4

zetaclient2:
image: zetanode:latest
container_name: zetaclient2
build:
context: ../../.
dockerfile: Dockerfile-localnet
hostname: zetaclient2
networks:
mynetwork:
Expand All @@ -65,13 +52,13 @@ services:
- ETHDEV_ENDPOINT=http://eth:8545
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
volumes:
- ssh:/root/.ssh
- preparams:/root/preparams

zetaclient3:
image: zetanode:latest
container_name: zetaclient3
build:
context: ../../.
dockerfile: Dockerfile-localnet
hostname: zetaclient3
networks:
mynetwork:
Expand All @@ -81,8 +68,6 @@ services:
- ETHDEV_ENDPOINT=http://eth:8545
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only

orchestrator:
build:
dockerfile: contrib/localnet/orchestrator/Dockerfile.fastbuild
entrypoint: ["/work/start-zetae2e.sh", "stress"]
volumes:
- ssh:/root/.ssh
- preparams:/root/preparams
11 changes: 0 additions & 11 deletions contrib/localnet/docker-compose-upgrade-light.yml

This file was deleted.

12 changes: 3 additions & 9 deletions contrib/localnet/docker-compose-upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

# This docker-compose redefine the services:
# - ZetaChain with 2 nodes (zetacore0, zetacore1) using the upgrade option for cosmovisor
# - ZetaChain observer set with 2 clients (zetaclient0, zetaclient1) using the background option
Expand All @@ -13,17 +11,11 @@ services:
image: zetanode:old

zetaclient0:
entrypoint: ["/root/start-zetaclientd.sh"]
image: zetanode:old

zetaclient1:
entrypoint: ["/root/start-zetaclientd.sh"]
image: zetanode:old

orchestrator:
entrypoint: ["/work/start-zetae2e.sh", "local", "upgrade"]
image: orchestrator

upgrade-host:
image: zetanode:latest
container_name: upgrade-host
Expand All @@ -40,12 +32,14 @@ services:
image: zetanode:old
container_name: upgrade-orchestrator
hostname: upgrade-orchestrator
entrypoint: ["/root/start-upgrade-orchestrator.sh", "225"]
entrypoint: ["/root/start-upgrade-orchestrator.sh"]
networks:
mynetwork:
ipv4_address: 172.20.0.251
depends_on:
- zetacore0
- upgrade-host
environment:
- UPGRADE_HEIGHT=${UPGRADE_HEIGHT}
volumes:
- ssh:/root/.ssh
12 changes: 8 additions & 4 deletions contrib/localnet/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

# This docker-compose file configures the localnet environment
# it contains the following services:
# - ZetaChain with 2 nodes (zetacore0, zetacore1)
Expand Down Expand Up @@ -51,10 +49,11 @@ services:
networks:
mynetwork:
ipv4_address: 172.20.0.11
entrypoint: ["/root/start-zetacored.sh", "2"]
entrypoint: ["/root/start-zetacored.sh"]
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
- ZETACORED_REPLICAS=2
volumes:
- ssh:/root/.ssh

Expand All @@ -65,10 +64,11 @@ services:
networks:
mynetwork:
ipv4_address: 172.20.0.12
entrypoint: ["/root/start-zetacored.sh", "2"]
entrypoint: ["/root/start-zetacored.sh"]
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
- ZETACORED_REPLICAS=2
volumes:
- ssh:/root/.ssh

Expand Down Expand Up @@ -146,6 +146,10 @@ services:
mynetwork:
ipv4_address: 172.20.0.2
entrypoint: ["/work/start-zetae2e.sh", "local"]
environment:
- LOCALNET_MODE=${LOCALNET_MODE}
- E2E_ARGS=${E2E_ARGS}
- UPGRADE_HEIGHT=${UPGRADE_HEIGHT}
volumes:
- ssh:/root/.ssh
volumes:
Expand Down
23 changes: 12 additions & 11 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
# A second optional argument can be passed and can have the following value:
# upgrade: run the local e2e once, then restart zetaclientd at upgrade height and run the local e2e again

ZETAE2E_CMD=$1
OPTION=$2

get_zetacored_version() {
retries=10
node_info=""
Expand Down Expand Up @@ -72,12 +69,12 @@ geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xF421292cb0d3c97b90E

### Run zetae2e command depending on the option passed

if [ "$OPTION" == "upgrade" ]; then
if [ "$LOCALNET_MODE" == "upgrade" ]; then

# Run the e2e tests, then restart zetaclientd at upgrade height and run the e2e tests again

# Fetch the height of the upgrade, default is 225, if arg3 is passed, use that value
UPGRADE_HEIGHT=${3:-225}
# set upgrade height to 225 by default
UPGRADE_HEIGHT=${UPGRADE_HEIGHT:=225}

if [[ ! -f deployed.yml ]]; then
zetae2e "$ZETAE2E_CMD" --setup-only --config-out deployed.yml --skip-header-proof
Expand All @@ -94,7 +91,7 @@ if [ "$OPTION" == "upgrade" ]; then
echo "running E2E command to setup the networks and populate the state..."

# Use light flag to ensure tests can complete before the upgrade height
zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml --light --skip-header-proof
zetae2e $E2E_ARGS --skip-setup --config deployed.yml --light --skip-header-proof
if [ $? -ne 0 ]; then
echo "first e2e failed"
exit 1
Expand Down Expand Up @@ -136,9 +133,9 @@ if [ "$OPTION" == "upgrade" ]; then
# When the upgrade height is greater than 100 for upgrade test, the Bitcoin tests have been run once, therefore the Bitcoin wallet is already set up
# Use light flag to skip advanced tests
if [ "$UPGRADE_HEIGHT" -lt 100 ]; then
zetae2e $ZETAE2E_CMD --skip-setup --config deployed.yml --light --skip-header-proof
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --light --skip-header-proof
else
zetae2e $ZETAE2E_CMD --skip-setup --config deployed.yml --skip-bitcoin-setup --light --skip-header-proof
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --skip-bitcoin-setup --light --skip-header-proof
fi

ZETAE2E_EXIT_CODE=$?
Expand All @@ -156,7 +153,7 @@ else
echo "running e2e setup..."

if [[ ! -f deployed.yml ]]; then
zetae2e $ZETAE2E_CMD --setup-only --config-out deployed.yml
zetae2e local $E2E_ARGS --setup-only --config-out deployed.yml
if [ $? -ne 0 ]; then
echo "e2e setup failed"
exit 1
Expand All @@ -165,9 +162,13 @@ else
echo "skipping e2e setup because it has already been completed"
fi

if [ "$LOCALNET_MODE" == "setup-only" ]; then
exit 0
fi

echo "running e2e tests..."

zetae2e $ZETAE2E_CMD --skip-setup --config deployed.yml
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml
ZETAE2E_EXIT_CODE=$?

# if e2e passed, exit with 0, otherwise exit with 1
Expand Down
4 changes: 2 additions & 2 deletions contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ then
# check if the option is additional-evm
# in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545)
# in /root/.zetacored/config/zetaclient_config.json
if [ "$OPTION" == "additional-evm" ]; then
if [[ -n $ADDITIONAL_EVM ]]; then
set_sepolia_endpoint
fi
fi
Expand All @@ -73,7 +73,7 @@ then
# check if the option is additional-evm
# in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545)
# in /root/.zetacored/config/zetaclient_config.json
if [ "$OPTION" == "additional-evm" ]; then
if [[ -n $ADDITIONAL_EVM ]]; then
set_sepolia_endpoint
fi
fi
Expand Down
Loading

0 comments on commit 4deeafe

Please sign in to comment.