From 0116dc77cb802017bd2f381464f14401ac639869 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Tue, 7 May 2024 00:13:49 -0400 Subject: [PATCH] add latest genesis data to make command --- Makefile | 5 + .../localnet/docker-compose-import-data.yml | 145 ++++++++++++++++++ contrib/localnet/docker-compose.yml | 2 - .../localnet/orchestrator/start-zetae2e.sh | 6 +- contrib/localnet/scripts/import-data.sh | 6 + contrib/localnet/scripts/start-zetaclientd.sh | 8 +- contrib/localnet/scripts/start-zetacored.sh | 6 +- 7 files changed, 173 insertions(+), 5 deletions(-) create mode 100644 contrib/localnet/docker-compose-import-data.yml create mode 100755 contrib/localnet/scripts/import-data.sh diff --git a/Makefile b/Makefile index 2cc2bf1d80..aa5c82a2ae 100644 --- a/Makefile +++ b/Makefile @@ -206,10 +206,15 @@ 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 +start-e2e-import-test: zetanode + @echo "--> Starting e2e import-data test" + cd contrib/localnet/ && chmod +x scripts/import-data.sh && ./scripts/import-data.sh && $(DOCKER) compose -f docker-compose.yml -f docker-compose-import-data.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 + start-stress-test: zetanode @echo "--> Starting stress test" cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-stresstest.yml up -d diff --git a/contrib/localnet/docker-compose-import-data.yml b/contrib/localnet/docker-compose-import-data.yml new file mode 100644 index 0000000000..779ae68592 --- /dev/null +++ b/contrib/localnet/docker-compose-import-data.yml @@ -0,0 +1,145 @@ +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) + +networks: + mynetwork: + ipam: + config: + - subnet: 172.20.0.0/24 + +services: + rosetta: + image: zetanode:latest + container_name: rosetta + hostname: rosetta + ports: + - "8080:8080" + networks: + mynetwork: + ipv4_address: 172.20.0.200 + entrypoint: ["zetacored", "rosetta", "--tendermint", "zetacore0:26657", "--grpc", "zetacore0:9090", "--network", "athens_101-1", "--blockchain", "zetacore" ,"--retries", "500"] + + zetacore0: + image: zetanode:latest + container_name: zetacore0 + build: + context: .. + dockerfile: Dockerfile-localnet + hostname: zetacore0 + ports: + - "1317:1317" + - "9545:8545" + - "9546:8546" + - "26657:26657" + - "6060:6060" + - "9090:9090" + networks: + mynetwork: + ipv4_address: 172.20.0.11 + entrypoint: ["/root/start-zetacored.sh", "2","import-data"] + environment: + - HOTKEY_BACKEND=file + - HOTKEY_PASSWORD=password # test purposes only + volumes: + - ~/genesis_export/:/root/genesis_data + + zetacore1: + image: zetanode:latest + container_name: zetacore1 + build: + context: .. + dockerfile: Dockerfile-localnet + hostname: zetacore1 + networks: + mynetwork: + ipv4_address: 172.20.0.12 + entrypoint: ["/root/start-zetacored.sh", "2","import-data"] + environment: + - HOTKEY_BACKEND=file + - HOTKEY_PASSWORD=password # test purposes only + + + zetaclient0: + image: zetanode:latest + container_name: zetaclient0 + build: + context: .. + dockerfile: Dockerfile-localnet + hostname: zetaclient0 + networks: + mynetwork: + ipv4_address: 172.20.0.21 + entrypoint: ["/root/start-zetaclientd.sh", "import-data"] + environment: + - ETHDEV_ENDPOINT=http://eth:8545 + - HOTKEY_BACKEND=file + - HOTKEY_PASSWORD=password # test purposes only + + zetaclient1: + image: zetanode:latest + container_name: zetaclient1 + build: + context: .. + dockerfile: Dockerfile-localnet + hostname: zetaclient1 + networks: + mynetwork: + ipv4_address: 172.20.0.22 + entrypoint: ["/root/start-zetaclientd.sh", "import-data"] + environment: + - ETHDEV_ENDPOINT=http://eth:8545 + - HOTKEY_BACKEND=file + - HOTKEY_PASSWORD=password # test purposes only + + 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=0.0.0.0/0 + -rpcbind=0.0.0.0 + -rpcauth=smoketest:63acf9b8dccecce914d85ff8c044b78b$$5892f9bbc84f4364e79f0970039f88bdd823f168d4acc76099ab97b14a766a99 + -txindex=1 + + orchestrator: + image: orchestrator:latest + tty: true + container_name: orchestrator + build: + context: .. + dockerfile: contrib/localnet/orchestrator/Dockerfile + depends_on: + - zetacore0 + - eth + hostname: orchestrator + networks: + mynetwork: + ipv4_address: 172.20.0.2 + entrypoint: ["/work/start-zetae2e.sh", "local","import-data"] + diff --git a/contrib/localnet/docker-compose.yml b/contrib/localnet/docker-compose.yml index 29ce7dc27b..17a9583cbe 100644 --- a/contrib/localnet/docker-compose.yml +++ b/contrib/localnet/docker-compose.yml @@ -48,8 +48,6 @@ services: environment: - HOTKEY_BACKEND=file - HOTKEY_PASSWORD=password # test purposes only - volumes: - - /Users/tanmay/IdeaProjects/kingpinXD/genesis_export/:/root/genesis_data zetacore1: image: zetanode:latest diff --git a/contrib/localnet/orchestrator/start-zetae2e.sh b/contrib/localnet/orchestrator/start-zetae2e.sh index 25980e3f20..404af28fb5 100644 --- a/contrib/localnet/orchestrator/start-zetae2e.sh +++ b/contrib/localnet/orchestrator/start-zetae2e.sh @@ -9,7 +9,11 @@ ZETAE2E_CMD=$1 OPTION=$2 echo "waiting for geth RPC to start..." -sleep 420 + if [ "$OPTION" != "import-data" ]; then + sleep 2 + else + sleep 420 + fi ### Create the accounts and fund them with Ether on local Ethereum network diff --git a/contrib/localnet/scripts/import-data.sh b/contrib/localnet/scripts/import-data.sh new file mode 100755 index 0000000000..e0db8f8a62 --- /dev/null +++ b/contrib/localnet/scripts/import-data.sh @@ -0,0 +1,6 @@ +#!/bin/bash +mkdir ~/genesis_export/ +echo "Download Latest State Export" +LATEST_EXPORT_URL=$(curl https://snapshots.zetachain.com/latest-state-export | jq -r .mainnet) +echo "LATEST EXPORT URL: ${LATEST_EXPORT_URL}" +wget -q ${LATEST_EXPORT_URL} -O ~/genesis_export/exported-genesis.json \ No newline at end of file diff --git a/contrib/localnet/scripts/start-zetaclientd.sh b/contrib/localnet/scripts/start-zetaclientd.sh index daa8dae46a..09fb1c8ccc 100755 --- a/contrib/localnet/scripts/start-zetaclientd.sh +++ b/contrib/localnet/scripts/start-zetaclientd.sh @@ -25,7 +25,13 @@ num=$(echo $HOSTNAME | tr -dc '0-9') node="zetacore$num" echo "Wait for zetacore to exchange genesis file" -sleep 410 + +if [ "$OPTION" != "import-data" ]; then + sleep 40 +else + sleep 410 +fi + operator=$(cat $HOME/.zetacored/os.json | jq '.ObserverAddress' ) operatorAddress=$(echo "$operator" | tr -d '"') echo "operatorAddress: $operatorAddress" diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index 9f12a43099..2ddc4f9663 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -70,7 +70,11 @@ source ~/add-keys.sh if [ $HOSTNAME != "zetacore0" ] then echo "Waiting for zetacore0 to create genesis.json" - sleep 400 + if [ "$OPTION" != "import-data" ]; then + sleep 10 + else + sleep 400 + fi echo "genesis.json created" fi