diff --git a/.gitignore b/.gitignore index d64b583d..de70f44d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ mytestnet data screenlog.0 _build -.idea \ No newline at end of file +.idea +build \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6b3d5621..240d4701 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19-alpine AS go-builder +FROM golang:1.21-alpine AS go-builder # this comes from standard alpine nightly file # https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile @@ -14,11 +14,13 @@ RUN apk add --no-cache ca-certificates build-base git WORKDIR /code COPY . /code/ -# See https://github.com/CosmWasm/wasmvm/releases -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.2.1/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a -ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.2.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a -RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 86bc5fdc0f01201481c36e17cd3dfed6e9650d22e1c5c8983a5b78c231789ee0 -RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep a00700aa19f5bfe0f46290ddf69bf51eb03a6dfcd88b905e1081af2e42dbbafc +# See https://github.com/CosmWasm/wasmvm/releases +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.5.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.5.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a + +# TODO: add checksums later +# RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 86bc5fdc0f01201481c36e17cd3dfed6e9650d22e1c5c8983a5b78c231789ee0 +# RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep a00700aa19f5bfe0f46290ddf69bf51eb03a6dfcd88b905e1081af2e42dbbafc # Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc` RUN cp "/lib/libwasmvm_muslc.$(uname -m).a" /lib/libwasmvm_muslc.a diff --git a/Makefile b/Makefile index bcf6f841..b4c6d803 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ APP_DIR = ./app BINDIR ?= ~/go/bin RUNSIM = $(BINDIR)/runsim BINARY ?= migalood +MIGALOO_ENV_V3 ?= $(CURDIR)/contrib/v3 +BUILDDIR ?= $(CURDIR)/build + ifeq (,$(VERSION)) VERSION := $(shell git describe --tags) @@ -26,6 +29,10 @@ HTTPS_GIT := https://github.com/White-Whale-Defi-Platform/migaloo-chain.git export GO111MODULE = on +TESTNET_NVAL := $(if $(TESTNET_NVAL),$(TESTNET_NVAL),6) +TESTNET_CHAINID := $(if $(TESTNET_CHAINID),$(TESTNET_CHAINID),migaloo-1) + + # process build tags build_tags = netgo @@ -240,3 +247,53 @@ proto-format: @echo "Formatting Protobuf files" @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \ find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi + + + + +############################################################################### +### Localnet ### +############################################################################### + +build-linux: + mkdir -p $(BUILDDIR) + @if [ -z "$(docker images -q migalood 2> /dev/null)" ]; then \ + docker build --platform linux/amd64 --tag migalood ./; \ + fi + docker create --platform limux/amd64 --name temp migalood:latest + docker cp temp:/usr/bin/migalood $(BUILDDIR)/ + docker rm temp + + +localnet-start: localnet-stop + @if ! [ -f build/node0/$(BINARY)/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/migaloo:Z migalood testnet init-files --chain-id ${TESTNET_CHAINID} --v ${TESTNET_NVAL} -o /migaloo --keyring-backend=test --starting-ip-address 192.168.10.2; fi + + +localnet-stop: + docker-compose down + rm -rf build/node* + rm -rf build/gentxs. +############################################################################### +### Upgrade ### +############################################################################### +build-cosmovisor-linux: + @if [ -z "$(docker images -q migaloo/migaloo.cosmovisor-binary 2> /dev/null)" ]; then \ + $(MAKE) -C contrib/updates build-cosmovisor-linux BUILDDIR=$(BUILDDIR); \ + fi + +build-migalood-env: + @if [ -z "$(docker images -q migaloo/migalood-upgrade-env 2> /dev/null)" ]; then \ + $(MAKE) -C contrib/migalood-env migalood-upgrade-env; \ + fi + +## Presiquites: build-cosmovisor-linux build-linux build-migalood-env +localnet-start-upgrade: localnet-upgrade-stop build-linux build-cosmovisor-linux build-migalood-env + bash contrib/updates/prepare_cosmovisor.sh $(BUILDDIR) ${TESTNET_NVAL} ${TESTNET_CHAINID} + docker-compose -f ./contrib/updates/docker-compose.yml up + @./contrib/updates/upgrade-test.sh + $(MAKE) localnet-upgrade-stop + +localnet-upgrade-stop: + docker-compose -f contrib/updates/docker-compose.yml down + rm -rf build/node* + rm -rf build/gentxs. \ No newline at end of file diff --git a/contrib/migalood-env/Dockerfile b/contrib/migalood-env/Dockerfile new file mode 100644 index 00000000..018dc558 --- /dev/null +++ b/contrib/migalood-env/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:18.04 + +RUN apt-get update && \ + apt-get -y upgrade && \ + apt-get -y install curl jq file + +ARG entrypoint=entrypoint.sh + +VOLUME /migalood +WORKDIR /migalood +EXPOSE 26656 26657 +ENTRYPOINT ["/usr/bin/entrypoint.sh"] +CMD ["start", "--log_format", "plain", "--p2p.seeds", ""] +STOPSIGNAL SIGTERM + +COPY ${entrypoint} /usr/bin/entrypoint.sh diff --git a/contrib/migalood-env/Makefile b/contrib/migalood-env/Makefile new file mode 100644 index 00000000..d7da0843 --- /dev/null +++ b/contrib/migalood-env/Makefile @@ -0,0 +1,6 @@ +all: migalood-upgrade-env + +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 diff --git a/contrib/migalood-env/cosmovisor-entrypoint.sh b/contrib/migalood-env/cosmovisor-entrypoint.sh new file mode 100755 index 00000000..194c3092 --- /dev/null +++ b/contrib/migalood-env/cosmovisor-entrypoint.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +BINARY=/migalood/${BINARY:-cosmovisor} +ID=${ID:-0} +LOG=${LOG:-migalood.log} + +if ! [ -f "${BINARY}" ]; then + echo "The binary $(basename "${BINARY}") cannot be found. Please add the binary to the shared folder. Please use the BINARY environment variable if the name of the binary is not 'migalood'" + exit 1 +fi + +BINARY_CHECK="$(file "$BINARY" | grep 'ELF 64-bit LSB executable, x86-64')" + +if [ -z "${BINARY_CHECK}" ]; then + echo "Binary needs to be OS linux, ARCH amd64" + exit 1 +fi + +export MIGALOOD_HOME="/migalood/node${ID}/migalood" + +if [ -d "$(dirname "${MIGALOOD_HOME}"/"${LOG}")" ]; then + "${BINARY}" run "$@" --home "${MIGALOOD_HOME}" | tee "${MIGALOOD_HOME}/${LOG}" +else + "${BINARY}" run "$@" --home "${MIGALOOD_HOME}" +fi \ No newline at end of file diff --git a/contrib/updates/Dockerfile.cosmovisor b/contrib/updates/Dockerfile.cosmovisor new file mode 100644 index 00000000..6f7f2949 --- /dev/null +++ b/contrib/updates/Dockerfile.cosmovisor @@ -0,0 +1,8 @@ +FROM golang:1.20-alpine + +RUN set -eux; apk add --no-cache ca-certificates build-base; + +# make cosmovisor statically linked +RUN go install -ldflags '-w -s -linkmode=external -extldflags "-Wl,-z,muldefs -static"' -trimpath cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest + +ENTRYPOINT [ "/bin/sh" ] \ No newline at end of file diff --git a/contrib/updates/Makefile b/contrib/updates/Makefile new file mode 100644 index 00000000..9c731a02 --- /dev/null +++ b/contrib/updates/Makefile @@ -0,0 +1,10 @@ +all: build-cosmovisor-linux + +build-cosmovisor-linux: + mkdir -p $(BUILDDIR) + docker build --platform linux/amd64 --no-cache --tag migaloo/migaloo.cosmovisor-binary --file Dockerfile.cosmovisor . + docker create --platform linux/amd64 --name temp migaloo/migaloo.cosmovisor-binary:latest + docker cp temp:/go/bin/cosmovisor $(BUILDDIR)/ + docker rm temp + +.PHONY: all build-cosmovisor-linux \ No newline at end of file diff --git a/contrib/updates/docker-compose.yml b/contrib/updates/docker-compose.yml new file mode 100644 index 00000000..da8d22fa --- /dev/null +++ b/contrib/updates/docker-compose.yml @@ -0,0 +1,125 @@ +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 + + migaloodnode3: + container_name: migaloodnode3 + platform: linux/amd64 + image: "migaloo/migalood-upgrade-env" + environment: + - ID=3 + - LOG=migalood.log + - DAEMON_HOME=/migalood/node3/migalood + - DAEMON_NAME=migalood + - DAEMON_RESTART_AFTER_UPGRADE=true + ports: + - "9093:9090" + - "26663-26664:26656-26657" + volumes: + - ../../build:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.5 + + migaloodnode4: + container_name: migaloodnode4 + platform: linux/amd64 + image: "migaloo/migalood-upgrade-env" + environment: + - ID=4 + - LOG=migalood.log + - DAEMON_HOME=/migalood/node4/migalood + - DAEMON_NAME=migalood + - DAEMON_RESTART_AFTER_UPGRADE=true + ports: + - "9094:9090" + - "26665-26666:26656-26657" + volumes: + - ../../build:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.6 + + migaloodnode5: + container_name: migaloodnode5 + platform: linux/amd64 + image: "migaloo/migalood-upgrade-env" + environment: + - ID=5 + - LOG=migalood.log + - DAEMON_HOME=/migalood/node5/migalood + - DAEMON_NAME=migalood + - DAEMON_RESTART_AFTER_UPGRADE=true + ports: + - "9095:9090" + - "26667-26668:26656-26657" + volumes: + - ../../build:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.7 + +networks: + localnet: + driver: bridge + ipam: + driver: default + config: + - + subnet: 192.168.10.0/16 \ No newline at end of file diff --git a/contrib/updates/prepare_cosmovisor.sh b/contrib/updates/prepare_cosmovisor.sh new file mode 100755 index 00000000..4a1447c4 --- /dev/null +++ b/contrib/updates/prepare_cosmovisor.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +# this bash will prepare cosmosvisor to the build folder so that it can perform upgrade +# this script is supposed to be run by Makefile + +# These fields should be fetched automatically in the future +# Need to do more upgrade to see upgrade patterns +OLD_VERSION=v3.0.4 +# this command will retrieve the folder with the largest number in format v +SOFTWARE_UPGRADE_NAME="v4.1.0" +BUILDDIR=$1 +TESTNET_NVAL=$2 +TESTNET_CHAINID=$3 + +# check if BUILDDIR is set +if [ -z "$BUILDDIR" ]; then + echo "BUILDDIR is not set" + 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 + + +if [ ! -f "$BUILDDIR/old/migalood" ] &> /dev/null +then + mkdir -p BUILDDIR/old + if [ ! "$(docker images -q migaloo/migalood.binary.old 2> /dev/null)" ]; then + docker build --platform linux/amd64 --no-cache --build-arg source=./_build/migaloo-chain-${OLD_VERSION:1}/ --tag migaloo/migalood.binary.old ./_build/migaloo-chain-${OLD_VERSION:1} + fi + 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/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 --minimum-gas-prices "0stake" --node-daemon-home migalood --keyring-backend=test --home=temp; \ +fi + +for (( i=0; i<$TESTNET_NVAL; i++ )); do + 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/migalood \ + -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 diff --git a/contrib/updates/upgrade-test.sh b/contrib/updates/upgrade-test.sh new file mode 100755 index 00000000..0d029c3f --- /dev/null +++ b/contrib/updates/upgrade-test.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +# should make this auto fetch upgrade name from app upgrades once many upgrades have been done +# this command will retrieve the folder with the largest number in format v +SOFTWARE_UPGRADE_NAME="v4.1.0" +NODE1_HOME=node1/migalood +SELECTED_CONTAINER=migaloodnode1 +BINARY_OLD="docker exec $SELECTED_CONTAINER ./old/migalood" +TESTNET_NVAL=${1:-3} +UPGRADE_CLIFF_HEIGHT=20 + +# sleep to wait for localnet to come up +echo "Wait for localnet to come up" +sleep 5 + +# 20 block from now +$BINARY_OLD status --home $NODE1_HOME +STATUS_INFO=($($BINARY_OLD status --home $NODE1_HOME | jq -r '.NodeInfo.network,.SyncInfo.latest_block_height')) +echo "Current status info: $STATUS_INFO" +CHAIN_ID=${STATUS_INFO[0]} +UPGRADE_HEIGHT=$((STATUS_INFO[1] + UPGRADE_CLIFF_HEIGHT)) +echo "Upgrade should happens at: $UPGRADE_HEIGHT" + + +docker exec $SELECTED_CONTAINER tar -cf ./migalood.tar -C . migalood +SUM=$(docker exec $SELECTED_CONTAINER sha256sum ./migalood.tar | cut -d ' ' -f1) +DOCKER_BASE_PATH=$(docker exec $SELECTED_CONTAINER pwd) +echo $SUM +UPGRADE_INFO=$(jq -n ' +{ + "binaries": { + "linux/amd64": "file://'$DOCKER_BASE_PATH'/migalood.tar?checksum=sha256:'"$SUM"'", + } +}') + +echo $UPGRADE_INFO + +echo "Submitting software upgrade proposal..." +$BINARY_OLD tx gov submit-legacy-proposal software-upgrade "$SOFTWARE_UPGRADE_NAME" --upgrade-height $UPGRADE_HEIGHT --upgrade-info "$UPGRADE_INFO" --title "upgrade" --description "upgrade" --from node1 --keyring-backend test --chain-id $CHAIN_ID --home $NODE1_HOME -y > /dev/null 2>&1 + + +echo "upgrade name: $SOFTWARE_UPGRADE_NAME" + +sleep 5 + +echo "Depositing to software upgrade proposal..." +$BINARY_OLD tx gov deposit 1 "20000000stake" --from node1 --keyring-backend test --chain-id $CHAIN_ID --home $NODE1_HOME -y > /dev/null 2>&1 + +sleep 5 + +# loop from 0 to TESTNET_NVAL +for (( i=0; i<$TESTNET_NVAL; i++ )); do + # check if docker for node i is running + if [[ $(docker ps -a | grep migaloodnode$i | wc -l) -eq 1 ]]; then + $BINARY_OLD tx gov vote 1 yes --from node$i --keyring-backend test --chain-id $CHAIN_ID --home "node$i/migalood" -y > /dev/null 2>&1 + echo -e "---> Node $i voted yes" + fi +done + +# keep track of block_height +NIL_BLOCK=0 +LAST_BLOCK=0 +SAME_BLOCK=0 +while true; do + BLOCK_HEIGHT=$($BINARY_OLD status --home $NODE1_HOME | jq '.SyncInfo.latest_block_height' -r) + # if BLOCK_HEIGHT is empty + if [[ -z $BLOCK_HEIGHT ]]; then + # if 5 nil blocks in a row, exit + if [[ $NIL_BLOCK -ge 5 ]]; then + echo "ERROR: 5 nil blocks in a row" + break + fi + NIL_BLOCK=$((NIL_BLOCK + 1)) + fi + + # if block height is not nil + # if block height is same as last block height + if [[ $BLOCK_HEIGHT -eq $LAST_BLOCK ]]; then + # if 5 same blocks in a row, exit + if [[ $SAME_BLOCK -ge 5 ]]; then + echo "ERROR: 5 same blocks in a row" + break + fi + SAME_BLOCK=$((SAME_BLOCK + 1)) + else + # update LAST_BLOCK and reset SAME_BLOCK + LAST_BLOCK=$BLOCK_HEIGHT + SAME_BLOCK=0 + fi + + if [[ $BLOCK_HEIGHT -ge $UPGRADE_HEIGHT ]]; then + # assuming running only 1 migalood + echo "UPGRADE REACHED, CONTINUING NEW CHAIN" + break + else + $BINARY_OLD q gov proposal 1 --output=json --home $NODE1_HOME | jq ".status" + echo "BLOCK_HEIGHT = $BLOCK_HEIGHT" + sleep 10 + fi +done + +if [[ $SAME_BLOCK -ge 5 ]]; then + docker logs migaloodnode0 + exit 1 +fi + +sleep 40 + +# check all nodes are online after upgrade +for (( i=0; i<$TESTNET_NVAL; i++ )); do + if [[ $(docker ps -a | grep migaloodnode$i | wc -l) -eq 1 ]]; then + docker exec migaloodnode$i ./migalood status --home "node$i/migalood" + if [[ "${PIPESTATUS[0]}" != "0" ]]; then + echo "node$i is not online" + docker logs migaloodnode$i + exit 1 + fi + else + echo "migaloodnode$i is not running" + docker logs migaloodnode$i + exit 1 + fi +done \ No newline at end of file diff --git a/contrib/v3/Dockerfile b/contrib/v3/Dockerfile new file mode 100644 index 00000000..58af1b0b --- /dev/null +++ b/contrib/v3/Dockerfile @@ -0,0 +1,55 @@ +# Start from a base image with Go installed +FROM golang:1.19-alpine AS builder + +# Install dependency for container +SHELL ["/bin/sh", "-ecuxo", "pipefail"] +RUN apk add --no-cache ca-certificates build-base git +RUN apk update && apk add unzip + +# Set the Current Working Directory inside the container +WORKDIR /code +ENV OLD_VERSION v3.0.4 +ENV ROOT /code + +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.2.6/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a +ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.2.6/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a + + +# Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc` +RUN cp "/lib/libwasmvm_muslc.$(uname -m).a" /lib/libwasmvm_muslc.a + +# Download and unzip the old version +RUN wget -c "https://github.com/White-Whale-Defi-Platform/migaloo-chain/archive/refs/tags/${OLD_VERSION}.zip" -O /code/${OLD_VERSION}.zip && \ + unzip /code/${OLD_VERSION}.zip -d /code + +# Install the binary file +RUN OLD_VERSION_SUBSTRING=`echo $OLD_VERSION | cut -c 2-` && \ + cd /code/migaloo-chain-$OLD_VERSION_SUBSTRING && \ + LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build && \ + file /code/migaloo-chain-$OLD_VERSION_SUBSTRING/bin/migalood && \ + echo "Ensuring binary is statically linked ..." && \ + (file /code/migaloo-chain-$OLD_VERSION_SUBSTRING/bin/migalood | grep "statically linked") && \ + mkdir -p /code/bin && \ + cp /code/migaloo-chain-$OLD_VERSION_SUBSTRING/bin/migalood /code/bin + + +# Start a new stage from scratch +FROM alpine:3.16 +ENV HOME /.migalood +WORKDIR $HOME + + +# Copy the migalood binary from the builder stage to the final image +COPY --from=builder /code/bin/migalood /usr/bin/migalood + +# rest server +EXPOSE 1317 +# tendermint p2p +EXPOSE 26656 +# tendermint rpc +EXPOSE 26657 +#grpc +EXPOSE 9090 + +# Run the binary program +ENTRYPOINT ["migalood"] \ No newline at end of file diff --git a/contrib/v3/docker-compose.yml b/contrib/v3/docker-compose.yml new file mode 100644 index 00000000..66c5ba26 --- /dev/null +++ b/contrib/v3/docker-compose.yml @@ -0,0 +1,97 @@ +version: '3.8' + +services: + migaloo0: + container_name: migaloo0 + image: migaloodv3 + command: start --home /migalood + environment: + - ID=0 + - LOG=migalood.log + ports: + - "1317:1317" + - "9090:9090" + - "26656-26657:26656-26657" + volumes: + - ./build/node0/simd:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.2 + + migaloo1: + container_name: migaloo1 + image: migaloodv3 + command: start --home /migalood + ports: + - "1318:1317" + - "9091:9090" + - "26659-26660:26656-26657" + environment: + - ID=1 + - LOG=migalood.log + volumes: + - ./build/node1/simd:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.3 + + migaloo2: + container_name: migaloo2 + image: migaloodv3 + command: start --home /migalood + environment: + - ID=2 + - LOG=migalood.log + ports: + - "1319:1317" + - "9092:9090" + - "26661-26662:26656-26657" + volumes: + - ./build/node2/simd:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.4 + + # migaloo3: + # container_name: migaloo3 + # image: migaloodv3 + # command: start --home /migalood + # environment: + # - ID=3 + # - LOG=migalood.log + # ports: + # - "1320:1317" + # - "9093:9090" + # - "26663-26664:26656-26657" + # volumes: + # - ./build/node3/simd:/migalood:Z + # networks: + # localnet: + # ipv4_address: 192.168.10.5 + + # migaloo4: + # container_name: migaloo4 + # image: migaloodv3 + # command: start --home /migalood + # environment: + # - ID=4 + # - LOG=migalood.log + # ports: + # - "1321:1317" + # - "9094:9090" + # - "26665-26666:26656-26657" + # volumes: + # - ./build/node4/simd:/migalood:Z + # networks: + # localnet: + # ipv4_address: 192.168.10.6 + + +networks: + localnet: + driver: bridge + ipam: + driver: default + config: + - + subnet: 192.168.10.0/24 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..65447e76 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,97 @@ +version: '3.8' + +services: + migaloo0: + container_name: migaloo0 + image: migalood + command: start --home /migalood + environment: + - ID=0 + - LOG=migalood.log + ports: + - "1317:1317" + - "9090:9090" + - "26656-26657:26656-26657" + volumes: + - ./build/node0/simd:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.2 + + migaloo1: + container_name: migaloo1 + image: migalood + command: start --home /migalood + ports: + - "1318:1317" + - "9091:9090" + - "26659-26660:26656-26657" + environment: + - ID=1 + - LOG=migalood.log + volumes: + - ./build/node1/simd:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.3 + + migaloo2: + container_name: migaloo2 + image: migalood + command: start --home /migalood + environment: + - ID=2 + - LOG=migalood.log + ports: + - "1319:1317" + - "9092:9090" + - "26661-26662:26656-26657" + volumes: + - ./build/node2/simd:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.4 + + migaloo3: + container_name: migaloo3 + image: migalood + command: start --home /migalood + environment: + - ID=3 + - LOG=migalood.log + ports: + - "1320:1317" + - "9093:9090" + - "26663-26664:26656-26657" + volumes: + - ./build/node3/simd:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.5 + + migaloo4: + container_name: migaloo4 + image: migalood + command: start --home /migalood + environment: + - ID=4 + - LOG=migalood.log + ports: + - "1321:1317" + - "9094:9090" + - "26665-26666:26656-26657" + volumes: + - ./build/node4/simd:/migalood:Z + networks: + localnet: + ipv4_address: 192.168.10.6 + + +networks: + localnet: + driver: bridge + ipam: + driver: default + config: + - + subnet: 192.168.10.0/24 diff --git a/go.mod b/go.mod index 95260792..b4b341c2 100644 --- a/go.mod +++ b/go.mod @@ -68,7 +68,7 @@ require ( github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.2 // indirect github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect - github.com/CosmWasm/wasmvm v1.5.0 // indirect + github.com/CosmWasm/wasmvm v1.5.1 // indirect github.com/armon/go-metrics v0.4.1 // indirect github.com/aws/aws-sdk-go v1.44.203 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/go.sum b/go.sum index e93b667a..87a5153c 100644 --- a/go.sum +++ b/go.sum @@ -216,8 +216,8 @@ github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRr github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4= github.com/CosmWasm/wasmd v0.45.0 h1:9zBqrturKJwC2kVsfHvbrA++EN0PS7UTXCffCGbg6JI= github.com/CosmWasm/wasmd v0.45.0/go.mod h1:RnSAiqbNIZu4QhO+0pd7qGZgnYAMBPGmXpzTADag944= -github.com/CosmWasm/wasmvm v1.5.0 h1:3hKeT9SfwfLhxTGKH3vXaKFzBz1yuvP8SlfwfQXbQfw= -github.com/CosmWasm/wasmvm v1.5.0/go.mod h1:fXB+m2gyh4v9839zlIXdMZGeLAxqUdYdFQqYsTha2hc= +github.com/CosmWasm/wasmvm v1.5.1 h1:2MHN9uFyHP6pxfvpBJ0JW6ujvAIBk9kQk283zyri0Ro= +github.com/CosmWasm/wasmvm v1.5.1/go.mod h1:fXB+m2gyh4v9839zlIXdMZGeLAxqUdYdFQqYsTha2hc= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= diff --git a/scripts/upgrade_test.sh b/scripts/upgrade_test.sh index 14218f8a..f3d9c45e 100755 --- a/scripts/upgrade_test.sh +++ b/scripts/upgrade_test.sh @@ -3,7 +3,7 @@ # the upgrade is a fork, "true" otherwise FORK=${FORK:-"false"} -OLD_VERSION=v3.0.2 +OLD_VERSION=v3.0.4 UPGRADE_WAIT=${UPGRADE_WAIT:-20} HOME=mytestnet ROOT=$(pwd) @@ -45,7 +45,7 @@ fi # run old node if [[ "$OSTYPE" == "darwin"* ]]; then - screen -L -dmS node1 bash scripts/run-node.sh _build/old/migalood $DENOM + screen -L -dmS node1 bash scripts/run-node.sh _build/old/migalood $DENOM --Logfile $HOME/log-screen.txt else screen -L -Logfile $HOME/log-screen.txt -dmS node1 bash scripts/run-node.sh _build/old/migalood $DENOM fi @@ -123,7 +123,6 @@ run_upgrade () { if [ $BLOCK_HEIGHT = "$UPGRADE_HEIGHT" ]; then # assuming running only 1 migalood echo "BLOCK HEIGHT = $UPGRADE_HEIGHT REACHED, KILLING OLD ONE" - pkill migalood break else ./_build/old/migalood q gov proposal 1 --output=json | jq ".status"