Skip to content

Commit

Permalink
fix: fix the github workflow for upgrade (#1444)
Browse files Browse the repository at this point in the history
## Description

closes: #XXXX

---

### Author Checklist

_All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues._

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] added appropriate labels to the PR
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/umee-network/umee/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

_All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items._

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
gsk967 authored Sep 24, 2022
1 parent ae43ccb commit 8b54dd0
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 26 deletions.
61 changes: 48 additions & 13 deletions contrib/scripts/download-mainnet-umeed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,58 @@

# USAGE: ./download-mainnet-umeed.sh

is_macos() {
[[ "$OSTYPE" == "darwin"* ]]
}

architecture=$(uname -m)

CWD="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
UMEED_BIN_MAINNET_URL_TARBALL=${UMEED_BIN_MAINNET_URL_TARBALL:-"https://github.com/umee-network/umee/releases/download/v1.1.2/umeed-v1.1.2-linux-amd64.tar.gz"}
UMEED_BIN_MAINNET=${UMEED_BIN_MAINNET:-"$CWD/umeed-releases/umeed-v1.1.2-linux-amd64/umeed"}
MAINNET_VERSION=${MAINNET_VERSION:-"v1.1.2"}

download_mainnet_binary(){
# Checks for the umeed v1 file
if [ ! -f "$UMEED_BIN_MAINNET" ]; then
echo "$UMEED_BIN_MAINNET doesn't exist"

if [ -z $UMEED_BIN_MAINNET_URL_TARBALL ]; then
echo You need to set the UMEED_BIN_MAINNET_URL_TARBALL variable
exit 1
fi

# Checks for the umeed v1 file
if [ ! -f "$UMEED_BIN_MAINNET" ]; then
echo "$UMEED_BIN_MAINNET doesn't exist"
UMEED_RELEASES_PATH=$CWD/umeed-releases
mkdir -p $UMEED_RELEASES_PATH
wget -c $UMEED_BIN_MAINNET_URL_TARBALL -O - | tar -xz -C $UMEED_RELEASES_PATH

if [ -z $UMEED_BIN_MAINNET_URL_TARBALL ]; then
echo You need to set the UMEED_BIN_MAINNET_URL_TARBALL variable
exit 1
UMEED_BIN_MAINNET_BASENAME=$(basename $UMEED_BIN_MAINNET_URL_TARBALL .tar.gz)
UMEED_BIN_MAINNET=$UMEED_RELEASES_PATH/$UMEED_BIN_MAINNET_BASENAME/umeed
fi
}

UMEED_RELEASES_PATH=$CWD/umeed-releases
mkdir -p $UMEED_RELEASES_PATH
wget -c $UMEED_BIN_MAINNET_URL_TARBALL -O - | tar -xz -C $UMEED_RELEASES_PATH
mac_mainnet() {
if [[ "$architecture" == "arm64" ]];then
UMEED_BIN_MAINNET_URL_TARBALL=${UMEED_BIN_MAINNET_URL_TARBALL:-"https://github.com/umee-network/umee/releases/download/${MAINNET_VERSION}/umeed-${MAINNET_VERSION}-darwin-arm64.tar.gz"}
UMEED_BIN_MAINNET=${UMEED_BIN_MAINNET:-"$CWD/umeed-releases/umeed-${MAINNET_VERSION}-darwin-arm64/umeed"}
else
UMEED_BIN_MAINNET_URL_TARBALL=${UMEED_BIN_MAINNET_URL_TARBALL:-"https://github.com/umee-network/umee/releases/download/${MAINNET_VERSION}/umeed-${MAINNET_VERSION}-darwin-amd64.tar.gz"}
UMEED_BIN_MAINNET=${UMEED_BIN_MAINNET:-"$CWD/umeed-releases/umeed-${MAINNET_VERSION}-darwin-amd64/umeed"}
fi
}

linux_mainnet(){
if [[ "$architecture" == "arm64" ]];then
UMEED_BIN_MAINNET_URL_TARBALL=${UMEED_BIN_MAINNET_URL_TARBALL:-"https://github.com/umee-network/umee/releases/download/${MAINNET_VERSION}/umeed-${MAINNET_VERSION}-linux-arm64.tar.gz"}
UMEED_BIN_MAINNET=${UMEED_BIN_MAINNET:-"$CWD/umeed-releases/umeed-${MAINNET_VERSION}-linux-arm64/umeed"}
else
UMEED_BIN_MAINNET_URL_TARBALL=${UMEED_BIN_MAINNET_URL_TARBALL:-"https://github.com/umee-network/umee/releases/download/${MAINNET_VERSION}/umeed-${MAINNET_VERSION}-linux-amd64.tar.gz"}
UMEED_BIN_MAINNET=${UMEED_BIN_MAINNET:-"$CWD/umeed-releases/umeed-${MAINNET_VERSION}-linux-amd64/umeed"}
fi
}

UMEED_BIN_MAINNET_BASENAME=$(basename $UMEED_BIN_MAINNET_URL_TARBALL .tar.gz)
UMEED_BIN_MAINNET=$UMEED_RELEASES_PATH/$UMEED_BIN_MAINNET_BASENAME/umeed
if is_macos ; then
mac_mainnet
download_mainnet_binary
else
linux_mainnet
download_mainnet_binary
fi
31 changes: 22 additions & 9 deletions contrib/scripts/umeemainnet_fork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,23 @@ CHAIN_ID="${CHAIN_ID:-umeemain-local-testnet}"
FORK_DIR="${FORK_DIR:-$CWD}"
CHAIN_DIR="${CHAIN_DIR:-$FORK_DIR/node-data}"
LOG_LEVEL="${LOG_LEVEL:-debug}"
BLOCK_TIME="${BLOCK_TIME:-6}"
BLOCK_TIME="${BLOCK_TIME:-1}"
UPGRADE_TITLE="${UPGRADE_TITLE:-"v1.1-v3.0"}"
UMEED_BIN_CURRENT="${UMEED_BIN_CURRENT:-$FORK_DIR/../../build/umeed}"
UMEED_BIN_MAINNET="${UMEED_BIN_MAINNET:-$FORK_DIR/umeed-releases/umeed-v1.1.2-linux-amd64/umeed}"
UMEEMAINNET_GENESIS_PATH="${UMEEMAINNET_GENESIS_PATH:-$CWD/mainnet_tinkered_genesis.json}"
NODE_PRIV_KEY="${NODE_PRIV_KEY:-$FORK_DIR/priv_validator_key.json}"
SEC_AWAIT_NODE_START="${SEC_AWAIT_NODE_START:-80}"
MAINNET_VERSION="${MAINNET_VERSION:-"v1.1.2"}"

UMEED_BIN_CURRENT="${UMEED_BIN_CURRENT:-$FORK_DIR/../../build/umeed}"
# UMEED_BIN_MAINNET="${UMEED_BIN_MAINNET:-$FORK_DIR/umeed-releases/umeed-v1.1.2-linux-amd64/umeed}"

# Loads another sources
# Loads another sources ,
# It will download the mainnet binaries
. $CWD/download-mainnet-umeed.sh

# It will download the mainnet genesis
UMEEMAINNET_GENESIS_PATH=$UMEEMAINNET_GENESIS_PATH . $CWD/tinker-mainnet-genesis.sh

. $CWD/blocks.sh

nodeHome="$CHAIN_DIR/$CHAIN_ID"
Expand Down Expand Up @@ -90,13 +96,19 @@ rm $nodeDir/$genesisConfigPath

cp $UMEEMAINNET_GENESIS_PATH $nodeDir/$genesisConfigPath

## Updating the gov proposal voting perioid to 20seconds
jq '.app_state.gov.voting_params.voting_period = "20s"' $nodeDir/$genesisConfigPath > $nodeDir/new-genesis.json
## Copy the new updated genesis
cp $nodeDir/new-genesis.json $nodeDir/$genesisConfigPath


perl -i -pe 's|fast_sync = true|fast_sync = false|g' $nodeCfg
perl -i -pe 's|addr_book_strict = true|addr_book_strict = false|g' $nodeCfg
perl -i -pe 's|external_address = ""|external_address = "tcp://127.0.0.1:26657"|g' $nodeCfg
perl -i -pe 's|"tcp://127.0.0.1:26657"|"tcp://0.0.0.0:26657"|g' $nodeCfg
perl -i -pe 's|allow_duplicate_ip = false|allow_duplicate_ip = true|g' $nodeCfg
perl -i -pe 's|log_level = "info"|log_level = "'$LOG_LEVEL'"|g' $nodeCfg
perl -i -pe 's|timeout_commit = ".*?"|timeout_commit = "5s"|g' $nodeCfg
perl -i -pe 's|timeout_commit = ".*?"|timeout_commit = "1s"|g' $nodeCfg
perl -i -pe 's|minimum-gas-prices = ""|minimum-gas-prices = "0.05uumee"|g' $nodeApp

nodeLogPath=$hdir.umeed-main.log
Expand Down Expand Up @@ -126,17 +138,18 @@ CURRENT_BLOCK_HEIGHT=$(CHAIN_ID=$CHAIN_ID UMEED_BIN=$UMEED_BIN_CURRENT get_block
echo "Current Block: $CURRENT_BLOCK_HEIGHT >= $WAIT_UNTIL_HEIGHT"

# we should produce at least 20 blocks with the new version
((WAIT_UNTIL_HEIGHT=CURRENT_BLOCK_HEIGHT+20))
((WAIT_UNTIL_HEIGHT=CURRENT_BLOCK_HEIGHT+40))

UMEED_V1_PID_FILE=$pid_path CHAIN_DIR=$CHAIN_DIR CHAIN_ID=$CHAIN_ID LOG_LEVEL=$LOG_LEVEL NODE_NAME=node UPGRADE_TITLE=$UPGRADE_TITLE UMEED_BIN_V1=$UMEED_BIN_MAINNET UMEED_BIN_V2=$UMEED_BIN_CURRENT $CWD/upgrade-test-single-node.sh

echo "UPGRADE FINISH, going to wait to produce 20 blocks from: $CURRENT_BLOCK_HEIGHT to $WAIT_UNTIL_HEIGHT"
sleep $SEC_AWAIT_NODE_START
echo "UPGRADE FINISH, going to wait to produce blocks from upgrade height to $WAIT_UNTIL_HEIGHT"
echo "Sleep for 50s, wait for upgrade binary to produce blocks for sometime"
sleep 50

CHAIN_ID=$CHAIN_ID UMEED_BIN=$UMEED_BIN_CURRENT wait_until_block $WAIT_UNTIL_HEIGHT

echo
echo Upgrade Process Finish
echo "👍 Upgrade Process Finish to $UMEED_BIN_CURRENT"
echo

pid_value=$(cat $pid_path)
Expand Down
11 changes: 7 additions & 4 deletions contrib/scripts/upgrade-test-single-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,20 @@ cid="--chain-id $CHAIN_ID"
CURRENT_HEIGHT=$(CHAIN_ID=$CHAIN_ID UMEED_BIN=$UMEED_BIN_V1 get_block_current_height)
echo blockchain CURRENT_HEIGHT is $CURRENT_HEIGHT

UPGRADE_HEIGHT=$(($CURRENT_HEIGHT + 10))
UPGRADE_HEIGHT=$(($CURRENT_HEIGHT + 30))
echo blockchain UPGRADE_HEIGHT is $UPGRADE_HEIGHT

echo "Submitting the software-upgrade proposal..."
$UMEED_BIN_V1 tx gov submit-proposal software-upgrade $UPGRADE_TITLE --deposit 1000000000uumee \
--upgrade-height $UPGRADE_HEIGHT --upgrade-info '{"binaries":{"linux/amd64":"https://github.com/cosmos/gaia/releases/download/v6.0.0-rc1/gaiad-v6.0.0-rc1-linux-amd64","linux/arm64":"https://github.com/cosmos/gaia/releases/download/v6.0.0-rc1/gaiad-v6.0.0-rc1-linux-arm64","darwin/amd64":"https://github.com/cosmos/gaia/releases/download/v6.0.0-rc1/gaiad-v6.0.0-rc1-darwin-amd64"}}' \
-b block $nodeHomeFlag --from admin $nodeUrlFlag $kbt --title yeet --description megayeet $cid --yes --fees 10000uumee
--upgrade-height $UPGRADE_HEIGHT \
-b block $nodeHomeFlag --from admin $nodeUrlFlag $kbt --title yeet --description megayeet $cid --yes --fees 100000uumee

##
PROPOSAL_ID=$($UMEED_BIN_V1 q gov $nodeUrlFlag proposals -o json | jq ".proposals[-1].proposal_id" -r)
echo proposal ID is $PROPOSAL_ID

$UMEED_BIN_V1 tx gov vote -b async --from admin $nodeUrlFlag $kbt $PROPOSAL_ID yes $nodeHomeFlag $cid --yes --fees 10000uumee
echo "Voting on proposaal : $PROPOSAL_ID"
$UMEED_BIN_V1 tx gov vote $PROPOSAL_ID yes -b block --from admin $nodeHomeFlag $cid $nodeUrlFlag $kbt --yes --fees 100000uumee

echo "..."
echo "Finished voting on the proposal"
Expand Down

0 comments on commit 8b54dd0

Please sign in to comment.