From d752d0f81557a2439307b43549cbe7d29fbc7731 Mon Sep 17 00:00:00 2001 From: kienn6034 Date: Mon, 15 Jan 2024 14:33:11 +0700 Subject: [PATCH] feat: init genesis with cosmovisor --- Makefile | 3 +- contrib/updates/prepare_cosmovisor.sh | 58 ++++++++++++++++++++------- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 08f8121c..ea0c1e84 100644 --- a/Makefile +++ b/Makefile @@ -302,7 +302,6 @@ localnet-stop: docker-compose down rm -rf build/node* rm -rf build/gentxs. - ############################################################################### ### Upgrade ### ############################################################################### @@ -312,6 +311,6 @@ build-cosmovisor-linux: build-migalood-env: $(MAKE) -C contrib/migalood-env migalood-upgrade-env - +## Should contain: build-comovisor-linux -> build-linux -> build-migalood-env upgrade-test: bash contrib/updates/prepare_cosmovisor.sh $(BUILDDIR) ${TESTNET_NVAL} ${TESTNET_CHAINID} \ No newline at end of file diff --git a/contrib/updates/prepare_cosmovisor.sh b/contrib/updates/prepare_cosmovisor.sh index b21cd3c8..4216dce9 100755 --- a/contrib/updates/prepare_cosmovisor.sh +++ b/contrib/updates/prepare_cosmovisor.sh @@ -18,20 +18,50 @@ if [ -z "$BUILDDIR" ]; then exit 1 fi -# install old binary if not exist -if [ ! -f "_build/$OLD_VERSION.zip" ] &> /dev/null -then - mkdir -p _build/old - wget -c "https://github.com/White-Whale-Defi-Platform/migaloo-chain/archive/refs/tags/${OLD_VERSION}.zip" -O _build/${OLD_VERSION}.zip - unzip _build/${OLD_VERSION}.zip -d _build +# # install old binary if not exist +# if [ ! -f "_build/$OLD_VERSION.zip" ] &> /dev/null +# then +# mkdir -p _build/old +# wget -c "https://github.com/White-Whale-Defi-Platform/migaloo-chain/archive/refs/tags/${OLD_VERSION}.zip" -O _build/${OLD_VERSION}.zip +# unzip _build/${OLD_VERSION}.zip -d _build +# fi + + +# if [ ! -f "$BUILDDIR/$OLD_VERSION.zip" ] &> /dev/null +# then +# mkdir -p BUILDDIR/old +# # docker build --platform linux/amd64 --no-cache --build-arg source=./_build/migaloo-chain-${OLD_VERSION:1}/ --tag migaloo/migalood.binary.old . +# docker create --platform linux/amd64 --name old-temp migaloo/migalood.binary.old:latest +# mkdir -p $BUILDDIR/old +# docker cp old-temp:/usr/bin/migalood $BUILDDIR/old/ +# docker rm old-temp +# fi + + +# prepare cosmovisor config in TESTNET_NVAL nodes +if [ ! -f "$BUILDDIR/node0/simd/config/genesis.json" ]; then docker run --rm \ + -v $BUILDDIR:/migalood:Z \ + --platform linux/amd64 \ + --entrypoint /migalood/old/migalood \ + migaloo/migalood-upgrade-env testnet init-files --v $TESTNET_NVAL --chain-id $TESTNET_CHAINID -o . --starting-ip-address 192.168.10.2 --keyring-backend=test --home=temp; \ fi -if [ ! -f "$BUILDDIR/$OLD_VERSION.zip" ] &> /dev/null -then - mkdir -p BUILDDIR/old - docker build --platform linux/amd64 --no-cache --build-arg source=./_build/migaloo-chain-${OLD_VERSION:1}/ --tag migaloo/migalood.binary.old . - docker create --platform linux/amd64 --name old-temp migaloo/migalood.binary.old:latest - docker cp old-temp:/usr/local/bin/migalood $BUILDDIR/old/ - docker rm old-temp -fi \ No newline at end of file +for (( i=0; i<$TESTNET_NVAL; i++ )); do + CURRENT=$BUILDDIR/node$i/simd + + # change gov params voting_period + jq '.app_state.gov.voting_params.voting_period = "50s"' $CURRENT/config/genesis.json > $CURRENT/config/genesis.json.tmp && mv $CURRENT/config/genesis.json.tmp $CURRENT/config/genesis.json + + docker run --rm \ + -v $BUILDDIR:/migalood:Z \ + -e DAEMON_HOME=/migalood/node$i/simd \ + -e DAEMON_NAME=migalood \ + -e DAEMON_RESTART_AFTER_UPGRADE=true \ + --entrypoint /migalood/cosmovisor \ + --platform linux/amd64 \ + migaloo/migalood-upgrade-env init /migalood/old/migalood + mkdir -p $CURRENT/cosmovisor/upgrades/$SOFTWARE_UPGRADE_NAME/bin + cp $BUILDDIR/migalood $CURRENT/cosmovisor/upgrades/$SOFTWARE_UPGRADE_NAME/bin + touch $CURRENT/cosmovisor/upgrades/$SOFTWARE_UPGRADE_NAME/upgrade-info.json +done \ No newline at end of file