Skip to content

Commit

Permalink
feat: init genesis with cosmovisor
Browse files Browse the repository at this point in the history
  • Loading branch information
duvbell committed Jan 15, 2024
1 parent 690e6b4 commit d752d0f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ localnet-stop:
docker-compose down
rm -rf build/node*
rm -rf build/gentxs.

###############################################################################
### Upgrade ###
###############################################################################
Expand All @@ -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}
58 changes: 44 additions & 14 deletions contrib/updates/prepare_cosmovisor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
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

0 comments on commit d752d0f

Please sign in to comment.