-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #316 from White-Whale-Defi-Platform/fix/wasmvm-sec…
…urity-patch Fix/wasmvm security patch
- Loading branch information
Showing
17 changed files
with
702 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ mytestnet | |
data | ||
screenlog.0 | ||
_build | ||
.idea | ||
.idea | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<number> | ||
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 |
Oops, something went wrong.