diff --git a/contrib/localnet/docker-compose-upgrade.yml b/contrib/localnet/docker-compose-upgrade.yml index 43af2c6768..a7497db980 100644 --- a/contrib/localnet/docker-compose-upgrade.yml +++ b/contrib/localnet/docker-compose-upgrade.yml @@ -13,11 +13,11 @@ services: image: zetanode:old zetaclient0: - entrypoint: ["/root/start-zetaclientd.sh", "background"] + entrypoint: ["/root/start-zetaclientd.sh"] image: zetanode:old zetaclient1: - entrypoint: ["/root/start-zetaclientd.sh", "background"] + entrypoint: ["/root/start-zetaclientd.sh"] image: zetanode:old orchestrator: diff --git a/contrib/localnet/scripts/start-zetaclientd.sh b/contrib/localnet/scripts/start-zetaclientd.sh index 5a364aeb9a..32271a30b5 100755 --- a/contrib/localnet/scripts/start-zetaclientd.sh +++ b/contrib/localnet/scripts/start-zetaclientd.sh @@ -39,21 +39,22 @@ operator=$(cat $HOME/.zetacored/os.json | jq '.ObserverAddress' ) operatorAddress=$(echo "$operator" | tr -d '"') echo "operatorAddress: $operatorAddress" echo "Start zetaclientd" -if [ $HOSTNAME == "zetaclient0" ] +# skip initialization if the config file already exists (zetaclientd init has already been run) +if [[ $HOSTNAME == "zetaclient0" && ! -f ~/.zetacored/config/zetaclient_config.json ]] then rm ~/.tss/* MYIP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) zetaclientd init --zetacore-url zetacore0 --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --keyring-backend "$BACKEND" # check if the option is additional-evm - # in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545) + # in this case, the additional evm is represented with the sepolia chain, we set manually the eth2 endpoint to the sepolia chain (11155111 -> http://eth2:8545) # in /root/.zetacored/config/zetaclient_config.json if [ "$OPTION" == "additional-evm" ]; then set_sepolia_endpoint fi - - zetaclientd-supervisor start < /root/password.file -else +fi +if [[ $HOSTNAME != "zetaclient0" && ! -f ~/.zetacored/config/zetaclient_config.json ]] +then num=$(echo $HOSTNAME | tr -dc '0-9') node="zetacore$num" MYIP=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) @@ -71,13 +72,6 @@ else if [ "$OPTION" == "additional-evm" ]; then set_sepolia_endpoint fi - - zetaclientd-supervisor start < /root/password.file fi -# check if the option is background -# in this case, we tail the zetaclientd log file -if [ "$OPTION" == "background" ]; then - sleep 3 - tail -f $HOME/zetaclient.log -fi +zetaclientd-supervisor start < /root/password.file \ No newline at end of file diff --git a/contrib/localnet/scripts/start-zetacored.sh b/contrib/localnet/scripts/start-zetacored.sh index 08e8b0ef01..278ecd778b 100755 --- a/contrib/localnet/scripts/start-zetacored.sh +++ b/contrib/localnet/scripts/start-zetacored.sh @@ -121,20 +121,24 @@ while [ ! -f ~/.ssh/authorized_keys ]; do sleep 1 done -# Init a new node to generate genesis file . -# Copy config files from existing folders which get copied via Docker Copy when building images -mkdir -p ~/.backup/config -zetacored init Zetanode-Localnet --chain-id=$CHAINID -rm -rf ~/.zetacored/config/app.toml -rm -rf ~/.zetacored/config/client.toml -rm -rf ~/.zetacored/config/config.toml -cp -r ~/zetacored/common/app.toml ~/.zetacored/config/ -cp -r ~/zetacored/common/client.toml ~/.zetacored/config/ -cp -r ~/zetacored/common/config.toml ~/.zetacored/config/ -sed -i -e "/moniker =/s/=.*/= \"$HOSTNAME\"/" "$HOME"/.zetacored/config/config.toml +# Skip init if it has already been completed (marked by presence of ~/.zetacored/init_complete file) +if [[ ! -f ~/.zetacored/init_complete ]] +then + # Init a new node to generate genesis file . + # Copy config files from existing folders which get copied via Docker Copy when building images + mkdir -p ~/.backup/config + zetacored init Zetanode-Localnet --chain-id=$CHAINID + rm -rf ~/.zetacored/config/app.toml + rm -rf ~/.zetacored/config/client.toml + rm -rf ~/.zetacored/config/config.toml + cp -r ~/zetacored/common/app.toml ~/.zetacored/config/ + cp -r ~/zetacored/common/client.toml ~/.zetacored/config/ + cp -r ~/zetacored/common/config.toml ~/.zetacored/config/ + sed -i -e "/moniker =/s/=.*/= \"$HOSTNAME\"/" "$HOME"/.zetacored/config/config.toml -# Add two new keys for operator and hotkey and create the required json structure for os_info -source ~/add-keys.sh + # Add two new keys for operator and hotkey and create the required json structure for os_info + source ~/add-keys.sh +fi # Pause other nodes so that the primary can node can do the genesis creation if [ $HOSTNAME != "zetacore0" ] @@ -143,8 +147,7 @@ then echo "Waiting for genesis.json file to exist..." sleep 1 done - # need to wait for zetacore0 to be up otherwise you get - # + # need to wait for zetacore0 to be up while ! curl -s -o /dev/null zetacore0:26657/status ; do echo "Waiting for zetacore0 rpc" sleep 1 @@ -160,8 +163,9 @@ fi # 6. Update Config in zetacore0 so that it has the correct persistent peer list # 7. Start the nodes -# Start of genesis creation . This is done only on zetacore0 -if [ $HOSTNAME == "zetacore0" ] +# Start of genesis creation . This is done only on zetacore0. +# Skip genesis if it has already been completed (marked by presence of ~/.zetacored/init_complete file) +if [[ $HOSTNAME == "zetacore0" && ! -f ~/.zetacored/init_complete ]] then # Misc : Copying the keyring to the client nodes so that they can sign the transactions ssh zetaclient0 mkdir -p ~/.zetacored/keyring-test/ @@ -266,7 +270,7 @@ fi # End of genesis creation steps . The steps below are common to all the nodes # Update persistent peers -if [ $HOSTNAME != "zetacore0" ] +if [[ $HOSTNAME != "zetacore0" && ! -f ~/.zetacored/init_complete ]] then # Misc : Copying the keyring to the client nodes so that they can sign the transactions ssh zetaclient"$INDEX" mkdir -p ~/.zetacored/keyring-test/ @@ -279,4 +283,7 @@ then sed -i -e "/persistent_peers =/s/=.*/= \"$pps\"/" "$HOME"/.zetacored/config/config.toml fi +# mark init completed so we skip it if container is restarted +touch ~/.zetacored/init_complete + cosmovisor run start --pruning=nothing --minimum-gas-prices=0.0001azeta --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --home /root/.zetacored \ No newline at end of file