Skip to content

Commit

Permalink
simplify docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Feb 17, 2024
1 parent d0a3a87 commit 1850e8d
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 165 deletions.
15 changes: 4 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down
49 changes: 12 additions & 37 deletions contrib/localnet/docker-compose-stresstest.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
version: "3"

networks:
mynetwork:
ipam:
config:
- subnet: 172.20.0.0/24


services:
zetacore0:
image: zetanode:latest
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -91,6 +91,7 @@ services:
entrypoint: /root/start-zetaclientd.sh
environment:
- ETHDEV_ENDPOINT=http://eth:8545
- HOTKEY_BACKEND=test

zetaclient2:
image: zetanode:latest
Expand All @@ -105,6 +106,7 @@ services:
entrypoint: /root/start-zetaclientd.sh
environment:
- ETHDEV_ENDPOINT=http://eth:8545
- HOTKEY_BACKEND=test

zetaclient3:
image: zetanode:latest
Expand All @@ -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
Expand Down
49 changes: 12 additions & 37 deletions contrib/localnet/docker-compose-upgrade.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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"]
1 change: 0 additions & 1 deletion contrib/localnet/orchestrator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion contrib/localnet/orchestrator/Dockerfile.fastbuild
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
67 changes: 0 additions & 67 deletions contrib/localnet/orchestrator/start-upgrade.sh

This file was deleted.

68 changes: 57 additions & 11 deletions contrib/localnet/orchestrator/start.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

0 comments on commit 1850e8d

Please sign in to comment.