diff --git a/Makefile b/Makefile index 1dcacfde35..b25a7bbd1f 100644 --- a/Makefile +++ b/Makefile @@ -197,24 +197,17 @@ start-e2etest: @echo "--> Starting e2e test" cd contrib/localnet/ && $(DOCKER) compose up -d -stop-e2etest: - @echo "--> Stopping e2e test" - cd contrib/localnet/ && $(DOCKER) compose down --remove-orphans - stress-test: zetanode - cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stresstest.yml up -d - -stop-stress-test: - cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stresstest.yml down --remove-orphans + cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-stresstest.yml up -d start-upgrade-test: @echo "--> Starting upgrade test" $(DOCKER) build --build-arg old_version=v12.2.1 -t zetanode -f ./Dockerfile-upgrade . $(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild . - cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-upgrade.yml up -d + cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d -stop-upgrade-test: - cd contrib/localnet/ && $(DOCKER) compose -f docker-compose-stateful.yml down --remove-orphans +stop-test: + cd contrib/localnet/ && $(DOCKER) compose down --remove-orphans ############################################################################### ### Monitoring ### diff --git a/contrib/localnet/docker-compose-stresstest.yml b/contrib/localnet/docker-compose-stresstest.yml index 043a181135..a17e394f00 100644 --- a/contrib/localnet/docker-compose-stresstest.yml +++ b/contrib/localnet/docker-compose-stresstest.yml @@ -1,12 +1,5 @@ version: "3" -networks: - mynetwork: - ipam: - config: - - subnet: 172.20.0.0/24 - - services: zetacore0: image: zetanode:latest @@ -23,7 +16,8 @@ services: mynetwork: ipv4_address: 172.20.0.11 entrypoint: ["/root/start-zetacored.sh", "4"] - + environment: + - HOTKEY_BACKEND=test zetacore1: image: zetanode:latest @@ -36,6 +30,8 @@ services: mynetwork: ipv4_address: 172.20.0.12 entrypoint: ["/root/start-zetacored.sh", "4"] + environment: + - HOTKEY_BACKEND=test zetacore2: image: zetanode:latest @@ -48,6 +44,8 @@ services: mynetwork: ipv4_address: 172.20.0.13 entrypoint: [ "/root/start-zetacored.sh", "4" ] + environment: + - HOTKEY_BACKEND=test zetacore3: image: zetanode:latest @@ -60,6 +58,8 @@ services: mynetwork: ipv4_address: 172.20.0.14 entrypoint: [ "/root/start-zetacored.sh", "4" ] + environment: + - HOTKEY_BACKEND=test zetaclient0: image: zetanode:latest @@ -73,10 +73,10 @@ services: ipv4_address: 172.20.0.21 ports: - "8123:8123" - entrypoint: /root/start-zetaclientd.sh environment: - ETHDEV_ENDPOINT=http://eth:8545 + - HOTKEY_BACKEND=test zetaclient1: image: zetanode:latest @@ -91,6 +91,7 @@ services: entrypoint: /root/start-zetaclientd.sh environment: - ETHDEV_ENDPOINT=http://eth:8545 + - HOTKEY_BACKEND=test zetaclient2: image: zetanode:latest @@ -105,6 +106,7 @@ services: entrypoint: /root/start-zetaclientd.sh environment: - ETHDEV_ENDPOINT=http://eth:8545 + - HOTKEY_BACKEND=test zetaclient3: image: zetanode:latest @@ -119,34 +121,7 @@ services: entrypoint: /root/start-zetaclientd.sh environment: - ETHDEV_ENDPOINT=http://eth:8545 - - eth: - image: ethereum/client-go:v1.10.26 - container_name: eth - hostname: eth - ports: - - "8545:8545" - networks: - mynetwork: - 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" ] - - 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 - hostname: bitcoin - networks: - mynetwork: - ipv4_address: 172.20.0.101 - ports: - - "18443:18443" - command: - -printtoconsole - -regtest=1 - -rpcallowip=172.20.0.0/16 - -rpcbind=0.0.0.0 - -rpcauth=e2e:63acf9b8dccecce914d85ff8c044b78b$5892f9bbc84f4364e79f0970039f88bdd823f168d4acc76099ab97b14a766a99 - -txindex=1 + - HOTKEY_BACKEND=test orchestrator: image: orchestrator:latest diff --git a/contrib/localnet/docker-compose-upgrade.yml b/contrib/localnet/docker-compose-upgrade.yml index a458a96f00..c55f847e43 100644 --- a/contrib/localnet/docker-compose-upgrade.yml +++ b/contrib/localnet/docker-compose-upgrade.yml @@ -1,11 +1,9 @@ version: "3" -networks: - mynetwork: - ipam: - config: - - subnet: 172.20.0.0/24 - +# 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 services: zetacore0: @@ -22,8 +20,9 @@ services: networks: mynetwork: ipv4_address: 172.20.0.11 - entrypoint: ["/root/start-zetacored.sh", "2", "upgrade"] # Need to specify that there are 2 nodes - + entrypoint: ["/root/start-zetacored.sh", "2", "upgrade"] + environment: + - HOTKEY_BACKEND=test zetacore1: image: zetanode:latest @@ -36,6 +35,8 @@ services: mynetwork: ipv4_address: 172.20.0.12 entrypoint: ["/root/start-zetacored.sh", "2", "upgrade"] + environment: + - HOTKEY_BACKEND=test zetaclient0: image: zetanode:latest @@ -49,6 +50,7 @@ services: ipv4_address: 172.20.0.21 entrypoint: ["/root/start-zetaclientd.sh", "background"] environment: + - HOTKEY_BACKEND=test - ETHDEV_ENDPOINT=http://eth:8545 zetaclient1: @@ -63,36 +65,9 @@ services: ipv4_address: 172.20.0.22 entrypoint: ["/root/start-zetaclientd.sh", "background"] environment: + - HOTKEY_BACKEND=test - ETHDEV_ENDPOINT=http://eth:8545 - 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 - hostname: bitcoin - networks: - mynetwork: - ipv4_address: 172.20.0.101 - ports: - - "18443:18443" - command: - -printtoconsole - -regtest=1 - -rpcallowip=172.20.0.0/16 - -rpcbind=0.0.0.0 - -rpcauth=e2e:63acf9b8dccecce914d85ff8c044b78b$$5892f9bbc84f4364e79f0970039f88bdd823f168d4acc76099ab97b14a766a99 - -txindex=1 - - eth: - image: ethereum/client-go:v1.10.26 - container_name: eth - hostname: eth - ports: - - "8545:8545" - networks: - mynetwork: - 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" ] - orchestrator: image: orchestrator:latest container_name: orchestrator @@ -106,4 +81,4 @@ services: networks: mynetwork: ipv4_address: 172.20.0.2 - entrypoint: [ "/work/start-upgrade.sh", "local"] + entrypoint: ["/work/start.sh", "local", "upgrade"] diff --git a/contrib/localnet/orchestrator/Dockerfile b/contrib/localnet/orchestrator/Dockerfile index c6557e6cd8..5e579916cc 100644 --- a/contrib/localnet/orchestrator/Dockerfile +++ b/contrib/localnet/orchestrator/Dockerfile @@ -12,7 +12,6 @@ COPY --from=zeta /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys COPY --from=zeta /root/.ssh/localtest.pem /root/.ssh/localtest.pem COPY contrib/localnet/orchestrator/start.sh /work/ -COPY contrib/localnet/orchestrator/start-upgrade.sh /work/ COPY contrib/localnet/orchestrator/restart-zetaclientd.sh /work/ RUN chmod +x /work/*.sh diff --git a/contrib/localnet/orchestrator/Dockerfile.fastbuild b/contrib/localnet/orchestrator/Dockerfile.fastbuild index 5cbccbc0a6..198205c000 100644 --- a/contrib/localnet/orchestrator/Dockerfile.fastbuild +++ b/contrib/localnet/orchestrator/Dockerfile.fastbuild @@ -12,7 +12,6 @@ COPY --from=zeta /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys COPY --from=zeta /root/.ssh/localtest.pem /root/.ssh/localtest.pem COPY contrib/localnet/orchestrator/start.sh /work/ -COPY contrib/localnet/orchestrator/start-upgrade.sh /work/ COPY contrib/localnet/orchestrator/restart-zetaclientd.sh /work/ RUN chmod +x /work/*.sh diff --git a/contrib/localnet/orchestrator/start-upgrade.sh b/contrib/localnet/orchestrator/start-upgrade.sh deleted file mode 100644 index f13666aa57..0000000000 --- a/contrib/localnet/orchestrator/start-upgrade.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -ZETAE2E_CMD=$1 - -echo "waiting for geth RPC to start..." -sleep 2 - -# unlock the deployer account -echo "funding deployer address 0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC with 100 Ether" -geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xE5C5367B8224807Ac2207d350E60e1b6F27a7ecC", value: web3.toWei(100,"ether")})' attach http://eth:8545 - -# unlock erc20 tester accounts -echo "funding deployer address 0x6F57D5E7c6DBb75e59F1524a3dE38Fc389ec5Fd6 with 100 Ether" -geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x6F57D5E7c6DBb75e59F1524a3dE38Fc389ec5Fd6", value: web3.toWei(100,"ether")})' attach http://eth:8545 - -# unlock zeta tester accounts -echo "funding deployer address 0x5cC2fBb200A929B372e3016F1925DcF988E081fd with 100 Ether" -geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x5cC2fBb200A929B372e3016F1925DcF988E081fd", value: web3.toWei(100,"ether")})' attach http://eth:8545 - -# unlock bitcoin tester accounts -echo "funding deployer address 0x283d810090EdF4043E75247eAeBcE848806237fD with 100 Ether" -geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x283d810090EdF4043E75247eAeBcE848806237fD", value: web3.toWei(100,"ether")})' attach http://eth:8545 - -# unlock ethers tester accounts -echo "funding deployer address 0x8D47Db7390AC4D3D449Cc20D799ce4748F97619A with 100 Ether" -geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x8D47Db7390AC4D3D449Cc20D799ce4748F97619A", value: web3.toWei(100,"ether")})' attach http://eth:8545 - -# unlock miscellaneous tests accounts -echo "funding deployer address 0x90126d02E41c9eB2a10cfc43aAb3BD3460523Cdf with 100 Ether" -geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0x90126d02E41c9eB2a10cfc43aAb3BD3460523Cdf", value: web3.toWei(100,"ether")})' attach http://eth:8545 - -# unlock advanced erc20 tests accounts -echo "funding deployer address 0xcC8487562AAc220ea4406196Ee902C7c076966af with 100 Ether" -geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xcC8487562AAc220ea4406196Ee902C7c076966af", value: web3.toWei(100,"ether")})' attach http://eth:8545 - - -echo "running E2E command to setup the networks and populate the state..." - -zetae2e "$ZETAE2E_CMD" --config-out deployed.yml - -ZETAE2E_EXIT_CODE=$? -if [ $ZETAE2E_EXIT_CODE -ne 0 ]; then - echo "E2E setup failed" - exit 1 -fi - -echo "E2E setup passed, waiting for upgrade height..." - -# Restart zetaclients at upgrade height -/work/restart-zetaclientd.sh -u 200 -n 2 - -echo "waiting 10 seconds for node to restart..." - -sleep 10 - -echo "running E2E command to test the network after upgrade..." - -zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml - -ZETAE2E_EXIT_CODE=$? -if [ $ZETAE2E_EXIT_CODE -eq 0 ]; then - echo "E2E passed after upgrade" - exit 0 -else - echo "E2E failed after upgrade" - exit 1 -fi \ No newline at end of file diff --git a/contrib/localnet/orchestrator/start.sh b/contrib/localnet/orchestrator/start.sh index 2c0901a2c2..2d947fb0eb 100644 --- a/contrib/localnet/orchestrator/start.sh +++ b/contrib/localnet/orchestrator/start.sh @@ -1,6 +1,12 @@ #!/bin/bash +# The script run the zetae2e CLI to run local end-to-end tests +# First argument is the command to run the local e2e +# 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 echo "waiting for geth RPC to start..." sleep 2 @@ -37,17 +43,57 @@ geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xcC8487562AAc220ea44 echo "funding TSS address 0xF421292cb0d3c97b90EEEADfcD660B893592c6A2 with 100 Ether" geth --exec 'eth.sendTransaction({from: eth.coinbase, to: "0xF421292cb0d3c97b90EEEADfcD660B893592c6A2", value: web3.toWei(100,"ether")})' attach http://eth:8545 -# run e2e tests -echo "running e2e tests..." -zetae2e "$ZETAE2E_CMD" -ZETAE2E_EXIT_CODE=$? +if [ "$OPTION" != "upgrade" ]; then + + # Run the e2e tests normally + + echo "running e2e tests..." + zetae2e "$ZETAE2E_CMD" + ZETAE2E_EXIT_CODE=$? + + # if e2e passed, exit with 0, otherwise exit with 1 + if [ $ZETAE2E_EXIT_CODE -eq 0 ]; then + cat /work/deployed.yml + echo "e2e passed" + exit 0 + else + echo "e2e failed" + exit 1 + fi -# if e2e passed, exit with 0, otherwise exit with 1 -if [ $ZETAE2E_EXIT_CODE -eq 0 ]; then - cat /work/deployed.yml - echo "e2e passed" - exit 0 else - echo "e2e failed" - exit 1 + + # Run the e2e tests, then restart zetaclientd at upgrade height and run the e2e tests again + + echo "running E2E command to setup the networks and populate the state..." + zetae2e "$ZETAE2E_CMD" --config-out deployed.yml + ZETAE2E_EXIT_CODE=$? + + if [ $ZETAE2E_EXIT_CODE -ne 0 ]; then + echo "E2E setup failed" + exit 1 + fi + + echo "E2E setup passed, waiting for upgrade height..." + + # Restart zetaclients at upgrade height + /work/restart-zetaclientd.sh -u 200 -n 2 + + echo "waiting 10 seconds for node to restart..." + + sleep 10 + + echo "running E2E command to test the network after upgrade..." + + zetae2e "$ZETAE2E_CMD" --skip-setup --config deployed.yml + + ZETAE2E_EXIT_CODE=$? + if [ $ZETAE2E_EXIT_CODE -eq 0 ]; then + echo "E2E passed after upgrade" + exit 0 + else + echo "E2E failed after upgrade" + exit 1 + fi + fi