Skip to content

Commit

Permalink
added zetaclient restart script
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinssgh committed Sep 19, 2023
1 parent 94dffa8 commit fc06c34
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 17 deletions.
14 changes: 8 additions & 6 deletions Dockerfile-versioned
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ RUN mkdir -p $GOPATH/bin/new

ENV NEW_VERSION=${new_version}

# Checkout and build base binary
# Checkout and build new binary
RUN git clone https://github.com/zeta-chain/node.git
RUN cd node && git fetch
RUN cd node && git checkout ${old_version}
RUN cd node && git checkout ${new_version}
RUN cd node && go mod download
RUN cd node && make install
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/old/
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/new/
RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/new/

# Checkout and build new binary
RUN cd node && git checkout ${new_version}
# Checkout and build old binary
RUN cd node && git checkout ${old_version}
RUN cd node && go mod download
RUN cd node && make install
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/new/
RUN cp $GOPATH/bin/zetacored $GOPATH/bin/old/
RUN cp $GOPATH/bin/zetaclientd $GOPATH/bin/old/

RUN cd node && git checkout stateful-upgrade
RUN cd node && git pull
Expand Down
4 changes: 2 additions & 2 deletions contrib/localnet/docker-compose-stateful.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ services:
networks:
mynetwork:
ipv4_address: 172.20.0.21
entrypoint: /root/start-zetaclientd-genesis.sh
entrypoint: /root/start-zetaclientd-background.sh
environment:
- ETHDEV_ENDPOINT=http://eth:8545

Expand All @@ -61,7 +61,7 @@ services:
networks:
mynetwork:
ipv4_address: 172.20.0.22
entrypoint: /root/start-zetaclientd-genesis.sh
entrypoint: /root/start-zetaclientd-background.sh
environment:
- ETHDEV_ENDPOINT=http://eth:8545

Expand Down
3 changes: 2 additions & 1 deletion contrib/localnet/orchestrator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM zetanode:latest as zeta
FROM ethereum/client-go:v1.10.26 as geth
FROM golang:1.20-alpine as orchestrator

RUN apk --no-cache add jq curl bash make git build-base
RUN apk --no-cache add jq curl bash make git build-base openssh

COPY --from=zeta /usr/local/bin/zetacored /usr/local/bin/
COPY --from=zeta /usr/local/bin/zetaclientd /usr/local/bin/
Expand All @@ -13,6 +13,7 @@ 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

ENV GOPATH /go
Expand Down
3 changes: 2 additions & 1 deletion contrib/localnet/orchestrator/Dockerfile.fastbuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM zetanode:latest as zeta
FROM ethereum/client-go:v1.10.26 as geth
FROM golang:1.20-alpine as orchestrator

RUN apk --no-cache add jq curl bash make git build-base
RUN apk --no-cache add jq curl bash make git build-base openssh

COPY --from=zeta /usr/local/bin/zetacored /usr/local/bin/
COPY --from=zeta /usr/local/bin/zetaclientd /usr/local/bin/
Expand All @@ -13,6 +13,7 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,29 @@ do
esac
done

# generate node list
START=1
END=$((NUM_OF_NODES - 1))

CLIENT_LIST=()
for i in $(eval echo "{$START..$END}")
do
CLIENT_LIST+=("zetaclient$i")
done

echo "$UPGRADE_HEIGHT"

CURRENT_HEIGHT=0

while [ $CURRENT_HEIGHT -lt "$UPGRADE_HEIGHT" ]
while [[ $CURRENT_HEIGHT -lt $UPGRADE_HEIGHT ]]
do
CURRENT_HEIGHT=$(curl localhost:26657/status | jq '.result.sync_info.latest_block_height' )
CURRENT_HEIGHT=$(curl zetacore0:26657/status | jq '.result.sync_info.latest_block_height' | tr -d '"')
sleep 5
done

for i in {$NUM_OF_NODES}
do
ssh "zetaclient$i" "killall zetaclientd; zetaclientd start > $HOME/zetaclient.log 2>&1 &"
echo current height is "$CURRENT_HEIGHT", restarting zetaclients
for NODE in "${NODELIST[@]}"; do
ssh $NODE "killall zetaclientd; $GOPATH/bin/new/zetaclientd start > $HOME/zetaclient.log 2>&1 &"
done


Expand Down
5 changes: 4 additions & 1 deletion contrib/localnet/orchestrator/start-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ if [ $SMOKETEST_EXIT_CODE -ne 0 ]; then
exit 1
fi

smoketest "$SMOKETEST_CMD" --deployed --wait-for 325
# Restart zetaclients at upgrade height
/work/restart-zetaclientd.sh -u 330 -n 2

smoketest "$SMOKETEST_CMD" --deployed --wait-for 335

if [ $SMOKETEST_EXIT_CODE -eq 0 ]; then
echo "smoketest passed"
Expand Down
2 changes: 1 addition & 1 deletion contrib/localnet/scripts/genesis-stateful.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ chmod +x $DAEMON_HOME/zetavisor/upgrades/$UpgradeName/bin/zetacored

# 7 Start the nodes
zetavisor start --pruning=nothing --minimum-gas-prices=0.0001azeta --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --home /root/.zetacored >> zetanode.log 2>&1 &
sleep 10
sleep 20
echo

if [ $HOSTNAME = "zetacore0" ]
Expand Down
1 change: 1 addition & 0 deletions contrib/localnet/scripts/start-zetaclientd-background.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ else
zetaclientd start > $HOME/zetaclient.log 2>&1 &
fi

sleep 3
tail -f $HOME/zetaclient.log

0 comments on commit fc06c34

Please sign in to comment.