diff --git a/Makefile b/Makefile index a97bde5c3a..b71c66dfb6 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 @@ -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 @@ -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 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 a297be595b..098eebd7ff 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="" @@ -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 @@ -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 @@ -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=$? @@ -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 @@ -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 diff --git a/contrib/localnet/scripts/start-zetaclientd.sh b/contrib/localnet/scripts/start-zetaclientd.sh index 01667df450..c29649b25c 100755 --- a/contrib/localnet/scripts/start-zetaclientd.sh +++ b/contrib/localnet/scripts/start-zetaclientd.sh @@ -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 @@ -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 diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index 8e16ffbc4a..0512c420d2 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -65,13 +65,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 - # create keys CHAINID="athens_101-1" KEYRING="test" @@ -93,7 +86,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