Skip to content

Commit

Permalink
add latest genesis data to make command
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed May 7, 2024
1 parent 6ff1578 commit 0116dc7
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
145 changes: 145 additions & 0 deletions contrib/localnet/docker-compose-import-data.yml
Original file line number Diff line number Diff line change
@@ -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"]

2 changes: 0 additions & 2 deletions contrib/localnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions contrib/localnet/scripts/import-data.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 0116dc7

Please sign in to comment.