From 70493ae753c190e94998943faba26d9d2fbc8e3a Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Thu, 20 Jun 2024 14:31:34 -0700 Subject: [PATCH 1/7] refactor(localnet): reduce number of docker compose files --- Makefile | 20 +++++++--- ...n.yml => docker-compose-additionalevm.yml} | 11 ++---- .../localnet/docker-compose-monitoring.yml | 2 - .../localnet/docker-compose-performance.yml | 9 ----- .../localnet/docker-compose-setup-only.yml | 9 ----- ...resstest.yml => docker-compose-stress.yml} | 39 ++++++------------- .../localnet/docker-compose-upgrade-light.yml | 11 ------ contrib/localnet/docker-compose-upgrade.yml | 12 ++---- contrib/localnet/docker-compose.yml | 12 ++++-- .../localnet/orchestrator/start-zetae2e.sh | 23 +++++------ contrib/localnet/scripts/start-zetaclientd.sh | 4 +- contrib/localnet/scripts/start-zetacored.sh | 10 +---- 12 files changed, 57 insertions(+), 105 deletions(-) rename contrib/localnet/{docker-compose-admin.yml => docker-compose-additionalevm.yml} (66%) delete mode 100644 contrib/localnet/docker-compose-performance.yml delete mode 100644 contrib/localnet/docker-compose-setup-only.yml rename contrib/localnet/{docker-compose-stresstest.yml => docker-compose-stress.yml} (70%) delete mode 100644 contrib/localnet/docker-compose-upgrade-light.yml diff --git a/Makefile b/Makefile index 360e071485..e351a55fb5 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -217,15 +221,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 @@ -236,17 +242,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: start-e2e-import-mainnet-test: zetanode diff --git a/contrib/localnet/docker-compose-admin.yml b/contrib/localnet/docker-compose-additionalevm.yml similarity index 66% rename from contrib/localnet/docker-compose-admin.yml rename to contrib/localnet/docker-compose-additionalevm.yml index 19a478100e..208a8e30e9 100644 --- a/contrib/localnet/docker-compose-admin.yml +++ b/contrib/localnet/docker-compose-additionalevm.yml @@ -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 @@ -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 diff --git a/contrib/localnet/docker-compose-monitoring.yml b/contrib/localnet/docker-compose-monitoring.yml index ad66f828ec..9f11bd5575 100644 --- a/contrib/localnet/docker-compose-monitoring.yml +++ b/contrib/localnet/docker-compose-monitoring.yml @@ -1,5 +1,3 @@ -version: '3' - services: grafana: image: grafana/grafana:latest diff --git a/contrib/localnet/docker-compose-performance.yml b/contrib/localnet/docker-compose-performance.yml deleted file mode 100644 index 0374d42030..0000000000 --- a/contrib/localnet/docker-compose-performance.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: "3" - -# This docker-compose file overrides the orchestrator service to specify the flag to test performance of cctxs -# and skip the regular tests - -services: - orchestrator: - entrypoint: ["/work/start-zetae2e.sh", "local --test-performance"] - diff --git a/contrib/localnet/docker-compose-setup-only.yml b/contrib/localnet/docker-compose-setup-only.yml deleted file mode 100644 index 11761ad817..0000000000 --- a/contrib/localnet/docker-compose-setup-only.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: "3" - -# This docker-compose file overrides the orcherstrator service to use the setup only option -# It is used to setup the localnet environment without running tests - -services: - orchestrator: - entrypoint: ["/work/start-zetae2e.sh", "local --setup-only"] - diff --git a/contrib/localnet/docker-compose-stresstest.yml b/contrib/localnet/docker-compose-stress.yml similarity index 70% rename from contrib/localnet/docker-compose-stresstest.yml rename to contrib/localnet/docker-compose-stress.yml index 38df1133f3..4f32b151ba 100644 --- a/contrib/localnet/docker-compose-stresstest.yml +++ b/contrib/localnet/docker-compose-stress.yml @@ -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: @@ -26,6 +22,7 @@ services: environment: - HOTKEY_BACKEND=file - HOTKEY_PASSWORD=password # test purposes only + - ZETACORED_REPLICAS=4 zetacore3: image: zetanode:latest @@ -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: @@ -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: @@ -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"] \ No newline at end of file + volumes: + - ssh:/root/.ssh + - preparams:/root/preparams \ No newline at end of file diff --git a/contrib/localnet/docker-compose-upgrade-light.yml b/contrib/localnet/docker-compose-upgrade-light.yml deleted file mode 100644 index 8e3cb098c1..0000000000 --- a/contrib/localnet/docker-compose-upgrade-light.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: "3" - -# This docker-compose is similar to the docker-compose-upgrade.yml, but it uses a smaller height option for the upgrade (90) -# By using 90, the orchestrator will automatically run setup only for the first e2e test execution. - -services: - orchestrator: - entrypoint: ["/work/start-zetae2e.sh", "local", "upgrade", "90"] - - upgrade-orchestrator: - entrypoint: ["/root/start-upgrade-orchestrator.sh", "90"] \ No newline at end of file diff --git a/contrib/localnet/docker-compose-upgrade.yml b/contrib/localnet/docker-compose-upgrade.yml index a7497db980..1febbbab59 100644 --- a/contrib/localnet/docker-compose-upgrade.yml +++ b/contrib/localnet/docker-compose-upgrade.yml @@ -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 @@ -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 @@ -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 \ No newline at end of file diff --git a/contrib/localnet/docker-compose.yml b/contrib/localnet/docker-compose.yml index f176c30f00..ceea25ba7f 100644 --- a/contrib/localnet/docker-compose.yml +++ b/contrib/localnet/docker-compose.yml @@ -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) @@ -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 @@ -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 @@ -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: diff --git a/contrib/localnet/orchestrator/start-zetae2e.sh b/contrib/localnet/orchestrator/start-zetae2e.sh index 8dcb4ea271..6f5f33f3a0 100644 --- a/contrib/localnet/orchestrator/start-zetae2e.sh +++ b/contrib/localnet/orchestrator/start-zetae2e.sh @@ -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="" @@ -78,12 +75,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 @@ -100,7 +97,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 @@ -142,9 +139,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=$? @@ -162,7 +159,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 @@ -171,9 +168,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 diff --git a/contrib/localnet/scripts/start-zetaclientd.sh b/contrib/localnet/scripts/start-zetaclientd.sh index 1b018de4ef..a849891275 100755 --- a/contrib/localnet/scripts/start-zetaclientd.sh +++ b/contrib/localnet/scripts/start-zetaclientd.sh @@ -63,7 +63,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 @@ -82,7 +82,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 diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index d390b99083..fb89c5b0fc 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -67,14 +67,6 @@ add_v17_message_authorizations() { ' $json_file > temp.json && mv temp.json $json_file } -if [ $# -lt 1 ] -then - echo "Usage: genesis.sh [option]" - exit 1 -fi -NUMOFNODES=$1 -OPTION=$2 - # create keys CHAINID="athens_101-1" KEYRING="test" @@ -96,7 +88,7 @@ export UNSAFE_SKIP_BACKUP=true # generate node list START=1 # shellcheck disable=SC2100 -END=$((NUMOFNODES - 1)) +END=$((ZETACORED_REPLICAS - 1)) NODELIST=() for i in $(eval echo "{$START..$END}") do From e3c13019f74c95b6d0a3169dd23c8b78988ebb40 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Thu, 20 Jun 2024 14:40:40 -0700 Subject: [PATCH 2/7] add ZETACORED_START_PERIOD and allow user to set E2E_ARGS --- Makefile | 7 ++++--- contrib/localnet/docker-compose.yml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e351a55fb5..fac3834c49 100644 --- a/Makefile +++ b/Makefile @@ -26,9 +26,10 @@ 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 := "" +export LOCALNET_MODE +export E2E_ARGS := $(E2E_ARGS) +export UPGRADE_HEIGHT +export ZETACORED_START_PERIOD := 30s clean: clean-binaries clean-dir clean-test-dir clean-coverage diff --git a/contrib/localnet/docker-compose.yml b/contrib/localnet/docker-compose.yml index ceea25ba7f..5474dd66a7 100644 --- a/contrib/localnet/docker-compose.yml +++ b/contrib/localnet/docker-compose.yml @@ -44,7 +44,7 @@ services: interval: 30s timeout: 10s retries: 3 - start_period: 30s + start_period: ${ZETACORED_START_PERIOD} start_interval: 1s networks: mynetwork: From 69a5e1779e01295250e47573dcf856aaf660baca Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Thu, 20 Jun 2024 15:53:16 -0700 Subject: [PATCH 3/7] fix upgrade tests --- contrib/localnet/orchestrator/start-zetae2e.sh | 4 ++-- contrib/localnet/scripts/start-upgrade-orchestrator.sh | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/contrib/localnet/orchestrator/start-zetae2e.sh b/contrib/localnet/orchestrator/start-zetae2e.sh index 6f5f33f3a0..791f0a6074 100644 --- a/contrib/localnet/orchestrator/start-zetae2e.sh +++ b/contrib/localnet/orchestrator/start-zetae2e.sh @@ -83,7 +83,7 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; then UPGRADE_HEIGHT=${UPGRADE_HEIGHT:=225} if [[ ! -f deployed.yml ]]; then - zetae2e "$ZETAE2E_CMD" --setup-only --config-out deployed.yml --skip-header-proof + zetae2e local $E2E_ARGS --setup-only --config-out deployed.yml --skip-header-proof if [ $? -ne 0 ]; then echo "e2e setup failed" exit 1 @@ -97,7 +97,7 @@ if [ "$LOCALNET_MODE" == "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 $E2E_ARGS --skip-setup --config deployed.yml --light --skip-header-proof + zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --light --skip-header-proof if [ $? -ne 0 ]; then echo "first e2e failed" exit 1 diff --git a/contrib/localnet/scripts/start-upgrade-orchestrator.sh b/contrib/localnet/scripts/start-upgrade-orchestrator.sh index a2e8ec68fd..f68009db9a 100755 --- a/contrib/localnet/scripts/start-upgrade-orchestrator.sh +++ b/contrib/localnet/scripts/start-upgrade-orchestrator.sh @@ -1,7 +1,5 @@ #!/bin/bash -UPGRADE_HEIGHT=$1 - CHAINID="athens_101-1" UPGRADE_AUTHORITY_ACCOUNT="zeta10d07y265gmmuvt4z0w9aw880jnsr700jvxasvr" From 43b19ad54efdbcf6596d544734f97e5c878b5871 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Thu, 20 Jun 2024 17:59:45 -0700 Subject: [PATCH 4/7] fix upgrade-test height --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index fac3834c49..9803615d38 100644 --- a/Makefile +++ b/Makefile @@ -244,6 +244,7 @@ zetanode-upgrade: zetanode 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 start-upgrade-test-light: zetanode-upgrade From 335b9df2edbdf7464933f8fa1fb08e4a07586cdb Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Fri, 21 Jun 2024 09:34:41 -0700 Subject: [PATCH 5/7] rebase for start-e2e-import-mainnet-test --- Makefile | 8 +++-- .../localnet/docker-compose-import-data.yml | 30 ------------------- contrib/localnet/docker-compose.yml | 2 ++ contrib/localnet/scripts/import-data.sh | 6 ++-- contrib/localnet/scripts/start-zetacored.sh | 2 +- 5 files changed, 11 insertions(+), 37 deletions(-) delete mode 100644 contrib/localnet/docker-compose-import-data.yml diff --git a/Makefile b/Makefile index 9803615d38..fa99e6f80f 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,7 @@ export DOCKER_BUILDKIT := 1 export LOCALNET_MODE export E2E_ARGS := $(E2E_ARGS) export UPGRADE_HEIGHT +export ZETACORED_IMPORT_GENESIS_DATA export ZETACORED_START_PERIOD := 30s clean: clean-binaries clean-dir clean-test-dir clean-coverage @@ -260,12 +261,13 @@ start-localnet-skip-build: export LOCALNET_MODE=setup-only && \ cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml up -d -stop-localnet: start-e2e-import-mainnet-test: zetanode @echo "--> Starting e2e import-data test" - cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER) compose -f docker-compose.yml -f docker-compose-import-data.yml up -d + export ZETACORED_IMPORT_GENESIS_DATA=true && \ + export ZETACORED_START_PERIOD=10m && \ + cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER) compose -f docker-compose.yml up -d -stop-test: +stop-localnet: cd contrib/localnet/ && $(DOCKER) compose down --remove-orphans ############################################################################### diff --git a/contrib/localnet/docker-compose-import-data.yml b/contrib/localnet/docker-compose-import-data.yml deleted file mode 100644 index 19f4068ad5..0000000000 --- a/contrib/localnet/docker-compose-import-data.yml +++ /dev/null @@ -1,30 +0,0 @@ -version: "3" - -# 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) -# - An Ethereum node (eth) -# - A Bitcoin node (bitcoin) -# - A Rosetta API (rosetta) -# - An orchestrator to manage interaction with the localnet (orchestrator) -services: - rosetta: - entrypoint: ["/root/start-rosetta.sh"] - - zetacore0: - entrypoint: ["/root/start-zetacored.sh", "2","import-data"] - volumes: - - ~/genesis_export/:/root/genesis_data - - zetacore1: - entrypoint: ["/root/start-zetacored.sh", "2","import-data"] - - zetaclient0: - entrypoint: ["/root/start-zetaclientd.sh"] - - zetaclient1: - entrypoint: ["/root/start-zetaclientd.sh"] - - orchestrator: - entrypoint: ["/work/start-zetae2e.sh", "local"] \ No newline at end of file diff --git a/contrib/localnet/docker-compose.yml b/contrib/localnet/docker-compose.yml index 5474dd66a7..1a59202d0d 100644 --- a/contrib/localnet/docker-compose.yml +++ b/contrib/localnet/docker-compose.yml @@ -54,8 +54,10 @@ services: - HOTKEY_BACKEND=file - HOTKEY_PASSWORD=password # test purposes only - ZETACORED_REPLICAS=2 + - ZETACORED_IMPORT_GENESIS_DATA=${ZETACORED_IMPORT_GENESIS_DATA} volumes: - ssh:/root/.ssh + - ~/.zetacored/genesis_data:/root/genesis_data zetacore1: image: zetanode:latest diff --git a/contrib/localnet/scripts/import-data.sh b/contrib/localnet/scripts/import-data.sh index d71d5c3656..3d53077d63 100644 --- a/contrib/localnet/scripts/import-data.sh +++ b/contrib/localnet/scripts/import-data.sh @@ -7,9 +7,9 @@ fi NETWORK=$1 echo "NETWORK: ${NETWORK}" -rm -rf ~/genesis_export/ -mkdir ~/genesis_export/ +rm -rf ~/.zetacored/genesis_data +mkdir ~/.zetacored/genesis_data echo "Download Latest State Export" LATEST_EXPORT_URL=$(curl https://snapshots.zetachain.com/latest-state-export | jq -r ."${NETWORK}") echo "LATEST EXPORT URL: ${LATEST_EXPORT_URL}" -wget -q ${LATEST_EXPORT_URL} -O ~/genesis_export/exported-genesis.json \ No newline at end of file +wget -q ${LATEST_EXPORT_URL} -O ~/.zetacored/genesis_data/exported-genesis.json \ No newline at end of file diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index fb89c5b0fc..dd8509847f 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -249,7 +249,7 @@ then scp $NODE:~/.zetacored/config/gentx/* ~/.zetacored/config/gentx/z2gentx/ done - if [[ "$OPTION" == "import-data" || "$OPTION" == "import-data-upgrade" ]]; then + if [[ -n "$ZETACORED_IMPORT_GENESIS_DATA" ]]; then echo "Importing data" zetacored parse-genesis-file /root/genesis_data/exported-genesis.json fi From 5f6935f811e4b30a628ffd32871978184ff8882c Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Fri, 21 Jun 2024 10:07:51 -0700 Subject: [PATCH 6/7] always use make stop-localnet --- .github/workflows/build.yml | 6 ++---- .github/workflows/execute_advanced_tests.yaml | 12 ++++-------- .github/workflows/publish-release.yml | 3 +-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fdd5c2149..fc58eb6c56 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -152,8 +152,7 @@ jobs: - name: Full Log Dump On Failure if: failure() run: | - cd contrib/localnet - docker compose logs + make stop-localnet - name: Notify Slack on Failure if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/develop' @@ -167,8 +166,7 @@ jobs: - name: Stop Private Network if: always() run: | - cd contrib/localnet/ - docker compose down + make stop-localnet - name: Clean Up Workspace if: always() diff --git a/.github/workflows/execute_advanced_tests.yaml b/.github/workflows/execute_advanced_tests.yaml index e42d08e9d6..8d286fbdf0 100644 --- a/.github/workflows/execute_advanced_tests.yaml +++ b/.github/workflows/execute_advanced_tests.yaml @@ -50,8 +50,7 @@ jobs: - name: Full Log Dump On Failure if: failure() run: | - cd contrib/localnet - docker compose logs + make stop-localnet - name: Notify Slack on Failure if: failure() && github.event_name == 'schedule' @@ -82,8 +81,7 @@ jobs: - name: Full Log Dump On Failure if: failure() run: | - cd contrib/localnet - docker compose logs + make stop-localnet - name: Notify Slack on Failure if: failure() && github.event_name == 'schedule' @@ -114,8 +112,7 @@ jobs: - name: Full Log Dump On Failure if: failure() run: | - cd contrib/localnet - docker compose logs + make stop-localnet e2e-performance-test: if: ${{ github.event.inputs.e2e-performance-test == 'true' }} @@ -137,5 +134,4 @@ jobs: - name: Full Log Dump On Failure if: failure() run: | - cd contrib/localnet - docker compose logs \ No newline at end of file + make stop-localnet \ No newline at end of file diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index e96bb39e46..89a4b1f688 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -339,8 +339,7 @@ jobs: - name: Stop Private Network if: ${{ always() && github.event.inputs.skip_checks != 'true' }} run: | - cd contrib/localnet/ - docker compose down + make stop-localnet - name: Clean Up Workspace if: always() From 1f4987cbc7e2fa597b8b243a6f621c924eada68d Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Mon, 24 Jun 2024 09:39:08 -0700 Subject: [PATCH 7/7] newlines and readme --- .github/workflows/execute_advanced_tests.yaml | 2 +- Makefile | 2 ++ contrib/localnet/docker-compose-stress.yml | 2 +- contrib/localnet/docker-compose-upgrade.yml | 2 +- contrib/localnet/scripts/import-data.sh | 2 +- docs/development/LOCAL_TESTING.md | 19 ++++++++++++------- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/execute_advanced_tests.yaml b/.github/workflows/execute_advanced_tests.yaml index 8d286fbdf0..0af6d13a48 100644 --- a/.github/workflows/execute_advanced_tests.yaml +++ b/.github/workflows/execute_advanced_tests.yaml @@ -134,4 +134,4 @@ jobs: - name: Full Log Dump On Failure if: failure() run: | - make stop-localnet \ No newline at end of file + make stop-localnet diff --git a/Makefile b/Makefile index fa99e6f80f..75834d690d 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,8 @@ TEST_BUILD_FLAGS := -tags pebbledb,ledger HSM_BUILD_FLAGS := -tags pebbledb,ledger,hsm_test export DOCKER_BUILDKIT := 1 + +# parameters for localnet docker compose files # set defaults to empty to prevent docker warning export LOCALNET_MODE export E2E_ARGS := $(E2E_ARGS) diff --git a/contrib/localnet/docker-compose-stress.yml b/contrib/localnet/docker-compose-stress.yml index 4f32b151ba..fb11f01b5c 100644 --- a/contrib/localnet/docker-compose-stress.yml +++ b/contrib/localnet/docker-compose-stress.yml @@ -70,4 +70,4 @@ services: - HOTKEY_PASSWORD=password # test purposes only volumes: - ssh:/root/.ssh - - preparams:/root/preparams \ No newline at end of file + - preparams:/root/preparams diff --git a/contrib/localnet/docker-compose-upgrade.yml b/contrib/localnet/docker-compose-upgrade.yml index 1febbbab59..c6ae72941a 100644 --- a/contrib/localnet/docker-compose-upgrade.yml +++ b/contrib/localnet/docker-compose-upgrade.yml @@ -42,4 +42,4 @@ services: environment: - UPGRADE_HEIGHT=${UPGRADE_HEIGHT} volumes: - - ssh:/root/.ssh \ No newline at end of file + - ssh:/root/.ssh diff --git a/contrib/localnet/scripts/import-data.sh b/contrib/localnet/scripts/import-data.sh index 3d53077d63..5236bfe166 100644 --- a/contrib/localnet/scripts/import-data.sh +++ b/contrib/localnet/scripts/import-data.sh @@ -12,4 +12,4 @@ mkdir ~/.zetacored/genesis_data echo "Download Latest State Export" LATEST_EXPORT_URL=$(curl https://snapshots.zetachain.com/latest-state-export | jq -r ."${NETWORK}") echo "LATEST EXPORT URL: ${LATEST_EXPORT_URL}" -wget -q ${LATEST_EXPORT_URL} -O ~/.zetacored/genesis_data/exported-genesis.json \ No newline at end of file +wget -q ${LATEST_EXPORT_URL} -O ~/.zetacored/genesis_data/exported-genesis.json diff --git a/docs/development/LOCAL_TESTING.md b/docs/development/LOCAL_TESTING.md index d28c44638e..3472daca89 100644 --- a/docs/development/LOCAL_TESTING.md +++ b/docs/development/LOCAL_TESTING.md @@ -27,6 +27,17 @@ Now we have built all the docker images, we can run the e2e test with make comma make start-e2e-test ``` +This uses `docker compose` to start the localnet and run standard e2e tests inside the orchestrator container. There are several parameters that the `Makefile` can provide to `docker compose` via environment variables: + +- `LOCALNET_MODE` + - `setup-only`: only setup the localnet, do not run the e2e tests + - `upgrade`: run the upgrade tests + - unset: run the e2e tests +- `E2E_ARGS`: arguments to provide to the `zetae2e local` command +- `UPGRADE_HEIGHT`: block height to upgrade at when `LOCALNET_MODE=upgrade` +- `ZETACORED_IMPORT_GENESIS_DATA`: path to genesis data to import before starting zetacored +- `ZETACORED_START_PERIOD`: duration to tolerate `zetacored` health check failures during startup + #### Run admin functions e2e tests We define e2e tests allowing to test admin functionalities (emergency network pause for example). @@ -42,13 +53,7 @@ make start-e2e-admin-test Upgrade tests run the E2E tests with an older version, upgrade the nodes to the new version, and run the E2E tests again. This allows testing the upgrade process with a populated state. -Before running the upgrade tests, the versions must be specified in `Dockefile-upgrade`: - -```dockerfile -ARG OLD_VERSION=v{old_major_version}.{old_minor_version}.{old_patch_version} -ENV NEW_VERSION=v{new_major_version} -``` -The new version must match the version specified in `app/setup_handlers.go` +Before running the upgrade tests, the old version must be specified the Makefile. NOTE: We only specify the major version for `NEW_VERSION` since we use major version only for chain upgrade. Semver is needed for `OLD_VERSION` because we use this value to fetch the release tag from the GitHub repository.