Skip to content

Commit

Permalink
feat: setup cosmosvisor to run migalood
Browse files Browse the repository at this point in the history
  • Loading branch information
duvbell committed Jan 15, 2024
1 parent d752d0f commit 121c5b0
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 25 deletions.
5 changes: 1 addition & 4 deletions contrib/migalood-env/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ RUN apt-get update && \
apt-get -y upgrade && \
apt-get -y install curl jq file

ARG UID=1000
ARG GID=1000
ARG entrypoint=entrypoint.sh

USER ${UID}:${GID}
VOLUME /migalood
WORKDIR /migalood
EXPOSE 26656 26657
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
CMD ["start", "--log_format", "plain"]
CMD ["start", "--log_format", "plain", "--p2p.seeds", ""]
STOPSIGNAL SIGTERM

COPY ${entrypoint} /usr/bin/entrypoint.sh
2 changes: 1 addition & 1 deletion contrib/migalood-env/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
all: migalood-upgrade-env

migalood-upgrade-env:
docker build --platform linux/amd64 --no-cache --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --build-arg entrypoint=cosmovisor-entrypoint.sh --tag migaloo/migalood-upgrade-env .
docker build --platform linux/amd64 --no-cache --build-arg entrypoint=cosmovisor-entrypoint.sh --tag migaloo/migalood-upgrade-env .

.PHONY: all migalood-upgrade-env
68 changes: 68 additions & 0 deletions contrib/updates/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: '3'

services:
migaloodnode0:
container_name: migaloodnode0
platform: linux/amd64
image: "migaloo/migalood-upgrade-env"
ports:
- "9090:9090"
- "26656-26657:26656-26657"
environment:
- ID=0
- LOG=migalood.log
- DAEMON_HOME=/migalood/node0/migalood
- DAEMON_NAME=migalood
- DAEMON_RESTART_AFTER_UPGRADE=true
volumes:
- ../../build:/migalood:Z
networks:
localnet:
ipv4_address: 192.168.10.2

migaloodnode1:
container_name: migaloodnode1
platform: linux/amd64
image: "migaloo/migalood-upgrade-env"
ports:
- "9091:9090"
- "26659-26660:26656-26657"
environment:
- ID=1
- LOG=migalood.log
- DAEMON_HOME=/migalood/node1/migalood
- DAEMON_NAME=migalood
- DAEMON_RESTART_AFTER_UPGRADE=true
volumes:
- ../../build:/migalood:Z
networks:
localnet:
ipv4_address: 192.168.10.3

migaloodnode2:
container_name: migaloodnode2
platform: linux/amd64
image: "migaloo/migalood-upgrade-env"
environment:
- ID=2
- LOG=migalood.log
- DAEMON_HOME=/migalood/node2/migalood
- DAEMON_NAME=migalood
- DAEMON_RESTART_AFTER_UPGRADE=true
ports:
- "9092:9090"
- "26661-26662:26656-26657"
volumes:
- ../../build:/migalood:Z
networks:
localnet:
ipv4_address: 192.168.10.4

networks:
localnet:
driver: bridge
ipam:
driver: default
config:
-
subnet: 192.168.10.0/16
40 changes: 20 additions & 20 deletions contrib/updates/prepare_cosmovisor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,44 @@ 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
# 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
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
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 \
if [ ! -f "$BUILDDIR/node0/migalood/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; \
migaloo/migalood-upgrade-env testnet init-files --v $TESTNET_NVAL --chain-id $TESTNET_CHAINID -o . --starting-ip-address 192.168.10.2 --node-daemon-home migalood --keyring-backend=test --home=temp; \
fi


for (( i=0; i<$TESTNET_NVAL; i++ )); do
CURRENT=$BUILDDIR/node$i/simd
CURRENT=$BUILDDIR/node$i/migalood

# 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_HOME=/migalood/node$i/migalood \
-e DAEMON_NAME=migalood \
-e DAEMON_RESTART_AFTER_UPGRADE=true \
--entrypoint /migalood/cosmovisor \
Expand Down

0 comments on commit 121c5b0

Please sign in to comment.