Skip to content

Commit

Permalink
ci: split testnet and release CI workflows (#1094)
Browse files Browse the repository at this point in the history
* Revert "fixing version upgrades (#1090)"

This reverts commit 2fc6e9a.

* chore: minor

* ci: split release and deploy to testnet

* fix: introduce upgrade version

* test: fix tests

* ci: use upgrade version

* ci: update localnet version
  • Loading branch information
cosmic-vagabond authored Jan 2, 2025
1 parent 0267787 commit ce37d90
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 40 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Create release

on:
push:
tags:
- v*

permissions:
contents: write

jobs:
release:
name: Create release
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.release_tag }}

- name: Make release
run: |
sudo rm -rf dist
make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 8 additions & 2 deletions .github/workflows/mainnet-deploy-2h.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,19 @@ jobs:
# query and upgrade height
height=$(${ELYSD} status --node $NODE | extract_and_calc_upgrade_height)
# generate upgrade version
upgrade_version=$(echo ${ELYS_VERSION} | cut -d'.' -f1)
echo "current version: ${ELYS_VERSION}"
echo "upgrade_version: $upgrade_version"
# create proposal
# create proposal
txhash=$(
${ELYSD} software-upgrade-tx \
${ELYS_VERSION} \
$upgrade_version \
$height \
5000000000uelys \
"Elys Network ${ELYS_VERSION} released. Focuses on enhancements and codebase improvements." \
"Elys Network ${upgrade_version} released. Focuses on enhancements and codebase improvements." \
"{\"binaries\":{\"linux/amd64\":\"https://github.com/elys-network/elys/releases/download/${ELYS_VERSION}/elysd-${ELYS_VERSION}-linux-amd64.tar.gz?checksum=$checksum\"}}" \
true \
--from=proposer \
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/mainnet-deploy-48h.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,18 @@ jobs:
# query and upgrade height
height=$(${ELYSD} status --node $NODE | extract_and_calc_upgrade_height)
# generate upgrade version
upgrade_version=$(echo ${ELYS_VERSION} | cut -d'.' -f1)
echo "current version: ${ELYS_VERSION}"
echo "upgrade_version: $upgrade_version"
# create proposal
txhash=$(
${ELYSD} software-upgrade-tx \
${ELYS_VERSION} \
$upgrade_version \
$height \
1000000000uelys \
"Elys Network ${ELYS_VERSION} released. Focuses on enhancements and codebase improvements." \
"Elys Network ${upgrade_version} released. Focuses on enhancements and codebase improvements." \
"{\"binaries\":{\"linux/amd64\":\"https://github.com/elys-network/elys/releases/download/${ELYS_VERSION}/elysd-${ELYS_VERSION}-linux-amd64.tar.gz?checksum=$checksum\"}}" \
false \
--from=proposer \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
- name: Build new binary
run: |
# create new git tag
git tag -f v999.999.999
git tag -f v999999.999999.999999
# build new elys binary
make build
NEW_BINARY_PATH=./build/elysd
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/testnet-deploy-2h.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: TestNet deploy in 2 hours

on:
workflow_dispatch:

permissions:
contents: write

jobs:
release:
name: Deploy to TestNet in 2 hours
runs-on: ubuntu-latest
steps:
- name: Create software upgrade proposal
run: |
# Get latest release version using GitHub API
ELYS_VERSION=$(curl -s https://api.github.com/repos/elys-network/elys/releases/latest | grep -Po '"tag_name": "\K.*?(?=")')
echo "Latest elys version: $ELYS_VERSION"
# Download latest binary
DOWNLOAD_BINARY_URL=https://github.com/elys-network/elys/releases/download/${ELYS_VERSION}/elysd-${ELYS_VERSION}-linux-amd64
DOWNLOAD_SHA256_URL=https://github.com/elys-network/elys/releases/download/${ELYS_VERSION}/sha256sum.txt
ELYSD=/tmp/elysd-${ELYS_VERSION}
SHA256SUM=/tmp/sha256sum.txt
curl -L $DOWNLOAD_BINARY_URL -o $ELYSD && chmod +x $ELYSD
curl -L $DOWNLOAD_SHA256_URL -o $SHA256SUM
# helper functions
extract_txhash() { awk -F 'txhash: ' '/txhash:/{print $2; exit}'; }
extract_proposal_id() { awk -F 'key: proposal_id|value: ' '/key: proposal_id/ { getline; gsub(/"/, "", $2); print $2; exit }'; }
extract_and_calc_upgrade_height() { awk -F'"latest_block_height":"' '{ split($2,a,"\""); print a[1]+2600; exit }'; }
extract_checksum() { awk "/elysd-${ELYS_VERSION}-linux-amd64.tar.gz/ {print \$1; exit}"; }
# environment variables
NODE=https://rpc.testnet.elys.network:443
OPTIONS="--node $NODE --chain-id elysicstestnet-1 --keyring-backend=test -b=sync --fees=20000uelys --gas=300000 -y"
# import proposers key
${ELYSD} keys import-hex proposer1 ${{ secrets.TESTNET_PROPOSER_PRIVATE_KEY_1 }} --keyring-backend=test
${ELYSD} keys import-hex proposer2 ${{ secrets.TESTNET_PROPOSER_PRIVATE_KEY_2 }} --keyring-backend=test
${ELYSD} keys import-hex proposer3 ${{ secrets.TESTNET_PROPOSER_PRIVATE_KEY_3 }} --keyring-backend=test
${ELYSD} keys import-hex proposer4 ${{ secrets.TESTNET_PROPOSER_PRIVATE_KEY_4 }} --keyring-backend=test
# get checksum
checksum=$(cat $SHA256SUM | extract_checksum)
# query and upgrade height
height=$(${ELYSD} status --node $NODE | extract_and_calc_upgrade_height)
# generate upgrade version
upgrade_version=$(echo ${ELYS_VERSION} | cut -d'.' -f1)
echo "current version: ${ELYS_VERSION}"
echo "upgrade_version: $upgrade_version"
# create proposal
txhash=$(
${ELYSD} software-upgrade-tx \
$upgrade_version \
$height \
10000000uelys \
"Elys Network ${upgrade_version} released. Focuses on enhancements and codebase improvements." \
"{\"binaries\":{\"linux/amd64\":\"https://github.com/elys-network/elys/releases/download/${ELYS_VERSION}/elysd-${ELYS_VERSION}-linux-amd64.tar.gz?checksum=$checksum\"}}" \
true \
--from=proposer1 \
$OPTIONS | extract_txhash
)
sleep 10
proposalid=$(${ELYSD} q tx $txhash --node $NODE | extract_proposal_id)
# vote on proposal
${ELYSD} tx gov vote $proposalid yes --from=proposer1 $OPTIONS
${ELYSD} tx gov vote $proposalid yes --from=proposer2 $OPTIONS
${ELYSD} tx gov vote $proposalid yes --from=proposer3 $OPTIONS
${ELYSD} tx gov vote $proposalid yes --from=proposer4 $OPTIONS
sleep 10
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
name: Create release and TestNet deploy
name: TestNet deploy in 48 hours

on:
push:
tags:
- v*
workflow_dispatch:

permissions:
contents: write

jobs:
release:
name: Create release and TestNet deploy
name: Deploy to TestNet in 48 hours
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.release_tag }}

- name: Make release
run: |
sudo rm -rf dist
make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create software upgrade proposal
run: |
# Get latest release version using GitHub API
Expand Down Expand Up @@ -62,13 +47,18 @@ jobs:
# query and upgrade height
height=$(${ELYSD} status --node $NODE | extract_and_calc_upgrade_height)
# generate upgrade version
upgrade_version=$(echo ${ELYS_VERSION} | cut -d'.' -f1)
echo "current version: ${ELYS_VERSION}"
echo "upgrade_version: $upgrade_version"
# create proposal
txhash=$(
${ELYSD} software-upgrade-tx \
$ELYS_VERSION \
$upgrade_version \
$height \
10000000uelys \
"Elys Network $ELYS_VERSION released. Focuses on enhancements and codebase improvements." \
"Elys Network ${upgrade_version} released. Focuses on enhancements and codebase improvements." \
"{\"binaries\":{\"linux/amd64\":\"https://github.com/elys-network/elys/releases/download/${ELYS_VERSION}/elysd-${ELYS_VERSION}-linux-amd64.tar.gz?checksum=$checksum\"}}" \
false \
--from=proposer1 \
Expand Down
39 changes: 27 additions & 12 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"context"
"fmt"
"strings"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
Expand All @@ -14,30 +15,41 @@ import (
)

const (
LocalNetVersion = "v999.999.999"
LocalNetVersion = "v999999"
NewMaxBytes = 5 * 1024 * 1024 // 5MB
)

// make sure to update these when you upgrade the version
var UpgradeName = "v1.6"
var RunPreMigrations = true
var NextVersion = "vNEXT"

func (app *ElysApp) setUpgradeHandler() {
if version.Version == LocalNetVersion {
UpgradeName = LocalNetVersion
// generate upgrade version from the current version (v999999.999999.999999 => v999999)
func generateUpgradeVersion(currentVersion string) string {
// if current version empty then override it with localnet version
if currentVersion == "v" {
currentVersion = "v999999.999999.999999"
}
parts := strings.Split(currentVersion, ".")
if len(parts) != 3 {
panic(fmt.Sprintf("Invalid version format: %s. Expected format: vX.Y.Z", currentVersion))
}
majorVersion := strings.TrimPrefix(parts[0], "v")
return fmt.Sprintf("v%s", majorVersion)
}

func (app *ElysApp) setUpgradeHandler() {
upgradeVersion := generateUpgradeVersion(version.Version)
app.Logger().Info("Current version", "version", version.Version)
app.Logger().Info("Upgrade version", "version", upgradeVersion)
app.UpgradeKeeper.SetUpgradeHandler(
UpgradeName,
upgradeVersion,
func(goCtx context.Context, plan upgradetypes.Plan, vm m.VersionMap) (m.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
app.Logger().Info("Running upgrade handler for " + UpgradeName)

if RunPreMigrations {
app.Logger().Info("Running upgrade handler for " + upgradeVersion)

// Set RunPreMigrations to false if not needed in mainnet
if upgradeVersion == NextVersion || upgradeVersion == LocalNetVersion {

// Add any logic here to run when the chain is upgraded to the new version

}

return app.mm.RunMigrations(ctx, app.configurator, vm)
Expand Down Expand Up @@ -77,5 +89,8 @@ func (app *ElysApp) setUpgradeStore() {
func shouldLoadUpgradeStore(app *ElysApp, upgradeInfo upgradetypes.Plan) bool {
currentHeight := app.LastBlockHeight()
app.Logger().Debug(fmt.Sprintf("Current block height: %d, Upgrade height: %d\n", currentHeight, upgradeInfo.Height))
return !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height)
upgradeVersion := generateUpgradeVersion(version.Version)
app.Logger().Debug("Current version", "version", version.Version)
app.Logger().Debug("Upgrade version", "version", upgradeVersion)
return upgradeInfo.Name == upgradeVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height)
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This guide provides instructions on how to spin up a new localnet using the Elys
Navigate into the cloned repository and build the binary using:

```bash
git tag -f v999.999.999 && make install
git tag -f v999999.999999.999999 && make install
```

This command will install the `elysd` daemon.
Expand Down
5 changes: 3 additions & 2 deletions x/amm/client/cli/query_denom_liquidity_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package cli_test

import (
"cosmossdk.io/math"
"fmt"
assetprofilemoduletypes "github.com/elys-network/elys/x/assetprofile/types"
"strconv"
"testing"

"cosmossdk.io/math"
assetprofilemoduletypes "github.com/elys-network/elys/x/assetprofile/types"

tmcli "github.com/cometbft/cometbft/libs/cli"
"github.com/cosmos/cosmos-sdk/client/flags"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
Expand Down

0 comments on commit ce37d90

Please sign in to comment.