diff --git a/Dockerfile-localnet b/Dockerfile-localnet index 1ed82c6b98..f9ff74d48a 100644 --- a/Dockerfile-localnet +++ b/Dockerfile-localnet @@ -28,7 +28,7 @@ RUN go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.5.0 FROM golang:1.20.14-bookworm AS base-runtime RUN apt update && \ - apt install -yq jq yq curl tmux python3 openssh-server iputils-ping iproute2 && \ + apt install -yq jq yq curl tmux python3 openssh-server iputils-ping iproute2 bind9-host && \ rm -rf /var/lib/apt/lists/* RUN ssh-keygen -A && \ diff --git a/Makefile b/Makefile index 509cb40fd7..6fd58f0484 100644 --- a/Makefile +++ b/Makefile @@ -215,8 +215,9 @@ start-localnet-skip-build: export LOCALNET_MODE=setup-only && \ cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml up -d +# stop-localnet should include all profiles so other containers are also removed stop-localnet: - cd contrib/localnet/ && $(DOCKER) compose down --remove-orphans + cd contrib/localnet/ && $(DOCKER) compose --profile eth2 --profile stress --profile upgrade down --remove-orphans ############################################################################### ### E2E tests ### @@ -240,7 +241,7 @@ start-e2e-test: zetanode start-e2e-admin-test: zetanode @echo "--> Starting e2e admin test" export E2E_ARGS="--skip-regular --test-admin" && \ - cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-additionalevm.yml up -d + cd contrib/localnet/ && $(DOCKER) compose --profile eth2 -f docker-compose.yml up -d start-e2e-performance-test: zetanode @echo "--> Starting e2e performance test" @@ -255,7 +256,7 @@ start-e2e-import-mainnet-test: zetanode start-stress-test: zetanode @echo "--> Starting stress test" - cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-stress.yml up -d + cd contrib/localnet/ && $(DOCKER) compose --profile stress -f docker-compose.yml up -d ############################################################################### ### Upgrade Tests ### @@ -272,13 +273,13 @@ start-upgrade-test: zetanode-upgrade @echo "--> Starting upgrade test" export LOCALNET_MODE=upgrade && \ export UPGRADE_HEIGHT=225 && \ - cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d + cd contrib/localnet/ && $(DOCKER) compose --profile upgrade -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)" export LOCALNET_MODE=upgrade && \ export UPGRADE_HEIGHT=90 && \ - cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d + cd contrib/localnet/ && $(DOCKER) compose --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d start-upgrade-import-mainnet-test: zetanode-upgrade @echo "--> Starting import-data upgrade test" @@ -286,7 +287,8 @@ start-upgrade-import-mainnet-test: zetanode-upgrade export ZETACORED_IMPORT_GENESIS_DATA=true && \ export ZETACORED_START_PERIOD=15m && \ export UPGRADE_HEIGHT=225 && \ - cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d + cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER) compose --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d + ############################################################################### ### Monitoring ### ############################################################################### diff --git a/contrib/localnet/docker-compose-additionalevm.yml b/contrib/localnet/docker-compose-additionalevm.yml deleted file mode 100644 index 208a8e30e9..0000000000 --- a/contrib/localnet/docker-compose-additionalevm.yml +++ /dev/null @@ -1,24 +0,0 @@ -# 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: - eth2: - build: - context: ./anvil - container_name: eth2 - hostname: eth2 - platform: linux/amd64 - ports: - - "8546:8545" - networks: - mynetwork: - ipv4_address: 172.20.0.102 - - zetaclient0: - environment: - - ADDITIONAL_EVM=true - - zetaclient1: - environment: - - ADDITIONAL_EVM=true diff --git a/contrib/localnet/docker-compose-stress.yml b/contrib/localnet/docker-compose-stress.yml deleted file mode 100644 index fb11f01b5c..0000000000 --- a/contrib/localnet/docker-compose-stress.yml +++ /dev/null @@ -1,73 +0,0 @@ -# This docker-compose redefine the services: -# - ZetaChain with 4 nodes to test performance -# - ZetaChain observer set with 4 clients to test performance - -services: - zetacore0: - environment: - - ZETACORED_REPLICAS=4 - - zetacore1: - environment: - - ZETACORED_REPLICAS=4 - - zetacore2: - image: zetanode:latest - container_name: zetacore2 - hostname: zetacore2 - networks: - mynetwork: - ipv4_address: 172.20.0.13 - entrypoint: [ "/root/start-zetacored.sh", "4" ] - environment: - - HOTKEY_BACKEND=file - - HOTKEY_PASSWORD=password # test purposes only - - ZETACORED_REPLICAS=4 - - zetacore3: - image: zetanode:latest - container_name: zetacore3 - build: - context: ../../. - dockerfile: Dockerfile-localnet - hostname: zetacore3 - networks: - mynetwork: - ipv4_address: 172.20.0.14 - entrypoint: [ "/root/start-zetacored.sh", "4" ] - environment: - - HOTKEY_BACKEND=file - - HOTKEY_PASSWORD=password # test purposes only - - ZETACORED_REPLICAS=4 - - zetaclient2: - image: zetanode:latest - container_name: zetaclient2 - hostname: zetaclient2 - networks: - mynetwork: - ipv4_address: 172.20.0.23 - entrypoint: /root/start-zetaclientd.sh - environment: - - 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 - hostname: zetaclient3 - networks: - mynetwork: - ipv4_address: 172.20.0.24 - entrypoint: /root/start-zetaclientd.sh - environment: - - ETHDEV_ENDPOINT=http://eth:8545 - - HOTKEY_BACKEND=file - - HOTKEY_PASSWORD=password # test purposes only - volumes: - - ssh:/root/.ssh - - preparams:/root/preparams diff --git a/contrib/localnet/docker-compose-upgrade.yml b/contrib/localnet/docker-compose-upgrade.yml index badd7db8e5..7bcfb9a4fa 100644 --- a/contrib/localnet/docker-compose-upgrade.yml +++ b/contrib/localnet/docker-compose-upgrade.yml @@ -1,8 +1,5 @@ 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 -# - Orchestrator with upgrade option +# This docker-compose updates the services to use the old version of the zetanode image services: zetacore0: @@ -11,36 +8,20 @@ services: zetacore1: image: zetanode:old + zetacore2: + image: zetanode:old + + zetacore3: + image: zetanode:old + zetaclient0: image: zetanode:old zetaclient1: image: zetanode:old - upgrade-host: - image: zetanode:latest - container_name: upgrade-host - hostname: upgrade-host - entrypoint: ["/root/start-upgrade-host.sh"] - networks: - mynetwork: - ipv4_address: 172.20.0.250 - volumes: - - ssh:/root/.ssh - - upgrade-orchestrator: - # must run from old node for api compatibility - image: zetanode:old - container_name: upgrade-orchestrator - hostname: upgrade-orchestrator - 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 + zetaclient2: + image: zetanode:old + + zetaclient3: + image: zetanode:old diff --git a/contrib/localnet/docker-compose.yml b/contrib/localnet/docker-compose.yml index e73a946c04..b9e5f12372 100644 --- a/contrib/localnet/docker-compose.yml +++ b/contrib/localnet/docker-compose.yml @@ -1,11 +1,14 @@ # This docker-compose file configures the localnet environment # it contains the following services: -# - ZetaChain with 2 nodes (zetacore0, zetacore1) -# - A observer set with 2 clients (zetaclient0, zetaclient1) +# - ZetaChain with 2 nodes (zetacore0, zetacore1). When profile set to stress, 4 nodes will be created. +# - A observer set with 2 clients (zetaclient0, zetaclient1). When profile set to stress, 4 clients will be created. # - An Ethereum node (eth) +# - A secondary optional Ethereum node (eth2) enabled when profile is set to eth2 # - A Bitcoin node (bitcoin) # - A Rosetta API (rosetta) # - An orchestrator to manage interaction with the localnet (orchestrator) +# - An upgrade host to serve binaries for the upgrade tests (upgrade-host). Only enabled when profile is set to upgrade. +# - An upgrade orchestrator to send the upgrade governance proposal (upgrade-orchestrator). Only enabled when profile is set to upgrade. networks: mynetwork: @@ -56,7 +59,6 @@ services: environment: - HOTKEY_BACKEND=file - HOTKEY_PASSWORD=password # test purposes only - - ZETACORED_REPLICAS=2 - ZETACORED_IMPORT_GENESIS_DATA=${ZETACORED_IMPORT_GENESIS_DATA} volumes: - ssh:/root/.ssh @@ -73,7 +75,38 @@ services: environment: - HOTKEY_BACKEND=file - HOTKEY_PASSWORD=password # test purposes only - - ZETACORED_REPLICAS=2 + volumes: + - ssh:/root/.ssh + + zetacore2: + image: zetanode:latest + container_name: zetacore2 + hostname: zetacore2 + profiles: + - stress + networks: + mynetwork: + ipv4_address: 172.20.0.13 + entrypoint: [ "/root/start-zetacored.sh", "4" ] + environment: + - HOTKEY_BACKEND=file + - HOTKEY_PASSWORD=password # test purposes only + volumes: + - ssh:/root/.ssh + + zetacore3: + image: zetanode:latest + container_name: zetacore3 + hostname: zetacore3 + profiles: + - stress + networks: + mynetwork: + ipv4_address: 172.20.0.14 + entrypoint: [ "/root/start-zetacored.sh", "4" ] + environment: + - HOTKEY_BACKEND=file + - HOTKEY_PASSWORD=password # test purposes only volumes: - ssh:/root/.ssh @@ -109,6 +142,40 @@ services: - ssh:/root/.ssh - preparams:/root/preparams + zetaclient2: + image: zetanode:latest + container_name: zetaclient2 + hostname: zetaclient2 + profiles: + - stress + networks: + mynetwork: + ipv4_address: 172.20.0.23 + entrypoint: /root/start-zetaclientd.sh + environment: + - HOTKEY_BACKEND=file + - HOTKEY_PASSWORD=password # test purposes only + volumes: + - ssh:/root/.ssh + - preparams:/root/preparams + + zetaclient3: + image: zetanode:latest + container_name: zetaclient3 + hostname: zetaclient3 + profiles: + - stress + networks: + mynetwork: + ipv4_address: 172.20.0.24 + entrypoint: /root/start-zetaclientd.sh + environment: + - HOTKEY_BACKEND=file + - HOTKEY_PASSWORD=password # test purposes only + volumes: + - ssh:/root/.ssh + - preparams:/root/preparams + eth: image: ethereum/client-go:v1.10.26 container_name: eth @@ -120,6 +187,20 @@ services: ipv4_address: 172.20.0.100 entrypoint: ["geth", "--dev", "--http", "--http.addr", "172.20.0.100", "--http.vhosts", "*", "--http.api", "eth,web3,net", "--http.corsdomain", "https://remix.ethereum.org", "--dev.period", "2"] + eth2: + build: + context: ./anvil + container_name: eth2 + hostname: eth2 + profiles: + - eth2 + platform: linux/amd64 + ports: + - "8546:8545" + networks: + mynetwork: + ipv4_address: 172.20.0.102 + bitcoin: image: ruimarinho/bitcoin-core:22 # version 23 is not working with btcd 0.22.0 due to change in createwallet rpc container_name: bitcoin @@ -157,6 +238,38 @@ services: - UPGRADE_HEIGHT=${UPGRADE_HEIGHT} volumes: - ssh:/root/.ssh + + upgrade-host: + image: zetanode:latest + container_name: upgrade-host + hostname: upgrade-host + profiles: + - upgrade + entrypoint: ["/root/start-upgrade-host.sh"] + networks: + mynetwork: + ipv4_address: 172.20.0.250 + volumes: + - ssh:/root/.ssh + + upgrade-orchestrator: + # must run from old node for api compatibility + image: zetanode:old + container_name: upgrade-orchestrator + hostname: upgrade-orchestrator + profiles: + - upgrade + 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 volumes: ssh: preparams: \ No newline at end of file diff --git a/contrib/localnet/scripts/start-zetaclientd.sh b/contrib/localnet/scripts/start-zetaclientd.sh index a849891275..fea6b69779 100755 --- a/contrib/localnet/scripts/start-zetaclientd.sh +++ b/contrib/localnet/scripts/start-zetaclientd.sh @@ -7,7 +7,6 @@ /usr/sbin/sshd HOSTNAME=$(hostname) -OPTION=$1 export ZETACLIENTD_SUPERVISOR_ENABLE_AUTO_DOWNLOAD=true # sepolia is used in chain migration tests, this functions set the sepolia endpoint in the zetaclient_config.json @@ -28,15 +27,12 @@ while [ ! -f ~/.ssh/authorized_keys ]; do sleep 1 done - - # need to wait for zetacore0 to be up while ! curl -s -o /dev/null zetacore0:26657/status ; do echo "Waiting for zetacore0 rpc" sleep 10 done - # read HOTKEY_BACKEND env var for hotkey keyring backend and set default to test BACKEND="test" if [ "$HOTKEY_BACKEND" == "file" ]; then @@ -60,10 +56,11 @@ then MYIP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) zetaclientd init --zetacore-url zetacore0 --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --keyring-backend "$BACKEND" --pre-params "$PREPARAMS_PATH" - # check if the option is additional-evm + # if eth2 is enabled, set the endpoint in the zetaclient_config.json # 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 [[ -n $ADDITIONAL_EVM ]]; then + if host eth2 ; then + echo "enabling additional evm (eth2)" set_sepolia_endpoint fi fi diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index aba9538c5e..64779d2a39 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -85,16 +85,6 @@ export CLIENT_SKIP_UPGRADE=true export CLIENT_START_PROCESS=false export UNSAFE_SKIP_BACKUP=true -# generate node list -START=1 -# shellcheck disable=SC2100 -END=$((ZETACORED_REPLICAS - 1)) -NODELIST=() -for i in $(eval echo "{$START..$END}") -do - NODELIST+=("zetacore$i") -done - echo "HOSTNAME: $HOSTNAME" # init ssh keys @@ -162,6 +152,21 @@ fi # Skip genesis if it has already been completed (marked by presence of ~/.zetacored/init_complete file) if [[ $HOSTNAME == "zetacore0" && ! -f ~/.zetacored/init_complete ]] then + ZETACORED_REPLICAS=2 + if host zetacore3 ; then + echo "zetacore3 exists, setting ZETACORED_REPLICAS to 4" + ZETACORED_REPLICAS=4 + fi + # generate node list + START=1 + # shellcheck disable=SC2100 + END=$((ZETACORED_REPLICAS - 1)) + NODELIST=() + for i in $(eval echo "{$START..$END}") + do + NODELIST+=("zetacore$i") + done + # Misc : Copying the keyring to the client nodes so that they can sign the transactions ssh zetaclient0 mkdir -p ~/.zetacored/keyring-test/ scp ~/.zetacored/keyring-test/* zetaclient0:~/.zetacored/keyring-test/