-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added testnet upgrade handler for v1.0.4 (#625)
## Description This PR adds an on-chain upgrade handler for the upcoming version `1.0.4`. This will be used inside the Morpheus testnet to upgrade it to the same version of the current Desmos mainnet, so that we can later test future mainnet upgrades there as well. <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### 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... - [x] 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 - [x] targeted the correct branch (see [PR Targeting](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://docs.cosmos.network/v0.44/building-modules/intro.html) - [x] included the necessary unit and integration [tests](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] 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... - [x] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [x] 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
Showing
20 changed files
with
540 additions
and
32 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Test on chain upgrade | ||
# On chain upgrade workflow tests the on-chain upgrade procedure. | ||
# This workflow is run on pushes to master & every Pull Requests where a .go, .mod, .sum have been changed | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
Cleanup-runs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cleanup 🧹 | ||
uses: rokroskar/workflow-run-cleanup-action@master | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" | ||
|
||
Perform-upgrade: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
env: | ||
GENESIS_DESMOS_VERSION: "v0.17.7" | ||
GENESIS_URL: "https://raw.githubusercontent.com/RiccardoM/desmos-states/master/morpheus-apollo-22003141.json" | ||
UPGRADE_NAME: "v1.0.4" | ||
UPGRADE_HEIGHT: 50 | ||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Go 🧰 | ||
uses: actions/[email protected] | ||
with: | ||
go-version: 1.15 | ||
|
||
- name: Compute diff 📜 | ||
uses: technote-space/get-diff-action@v4 | ||
with: | ||
PATTERNS: | | ||
**/**.go | ||
go.mod | ||
go.sum | ||
- name: Install Desmos 🔧 | ||
run: make clean install | ||
if: env.GIT_DIFF | ||
|
||
- name: Start testnet ⛓ | ||
run: | | ||
make upgrade-testnet-start \ | ||
GENESIS_VERSION="$GENESIS_DESMOS_VERSION" \ | ||
GENESIS_URL="$GENESIS_URL" \ | ||
UPGRADE_NAME="$UPGRADE_NAME" | ||
if: env.GIT_DIFF | ||
|
||
- name: Submit upgrade ✅ | ||
run: | | ||
./contrib/upgrade_testnet/submit_upgrade_proposal.sh 4 $UPGRADE_NAME $UPGRADE_HEIGHT | ||
if: env.GIT_DIFF |
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 |
---|---|---|
|
@@ -324,3 +324,4 @@ jobs: | |
run: | | ||
./contrib/localnet_liveness.sh 100 5 50 localhost | ||
if: env.GIT_DIFF | ||
|
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
|
||
# Build | ||
vendor | ||
venv | ||
build | ||
tools/bin/* | ||
examples/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
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 |
---|---|---|
|
@@ -10,6 +10,8 @@ import ( | |
"os" | ||
"path/filepath" | ||
|
||
"github.com/desmos-labs/desmos/app" | ||
|
||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" | ||
"github.com/spf13/cobra" | ||
tmconfig "github.com/tendermint/tendermint/config" | ||
|
@@ -40,6 +42,7 @@ var ( | |
flagOutputDir = "output-dir" | ||
flagNodeDaemonHome = "node-daemon-home" | ||
flagStartingIPAddress = "starting-ip-address" | ||
flagGenTxCoinDenom = "gentx-coin-denom" | ||
) | ||
|
||
// get cmd to initialize all files for tendermint testnet and application | ||
|
@@ -56,7 +59,10 @@ Example: | |
desmos testnet --v 4 --output-dir ./output --starting-ip-address 192.168.10.2 | ||
`, | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
clientCtx := client.GetClientContextFromCmd(cmd) | ||
clientCtx, err := client.GetClientQueryContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
serverCtx := server.GetServerContextFromCmd(cmd) | ||
config := serverCtx.Config | ||
|
@@ -68,12 +74,13 @@ Example: | |
nodeDirPrefix, _ := cmd.Flags().GetString(flagNodeDirPrefix) | ||
nodeDaemonHome, _ := cmd.Flags().GetString(flagNodeDaemonHome) | ||
startingIPAddress, _ := cmd.Flags().GetString(flagStartingIPAddress) | ||
gentxCoinDenom, _ := cmd.Flags().GetString(flagGenTxCoinDenom) | ||
numValidators, _ := cmd.Flags().GetInt(flagNumValidators) | ||
algo, _ := cmd.Flags().GetString(flags.FlagKeyAlgorithm) | ||
|
||
return InitTestnet( | ||
clientCtx, cmd, config, mbm, genBalIterator, outputDir, chainID, minGasPrices, | ||
nodeDirPrefix, nodeDaemonHome, startingIPAddress, keyringBackend, algo, numValidators, | ||
nodeDirPrefix, nodeDaemonHome, startingIPAddress, gentxCoinDenom, keyringBackend, algo, numValidators, | ||
) | ||
}, | ||
} | ||
|
@@ -83,6 +90,7 @@ Example: | |
cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix the directory name for each node with (node results in node0, node1, ...)") | ||
cmd.Flags().String(flagNodeDaemonHome, "desmos", "Home directory of the node's daemon configuration") | ||
cmd.Flags().String(flagStartingIPAddress, "192.168.0.1", "Starting IP address (192.168.0.1 results in persistent peers list [email protected]:46656, [email protected]:46656, ...)") | ||
cmd.Flags().String(flagGenTxCoinDenom, sdk.DefaultBondDenom, "Denomination of the coin to be used when generating genesis transactions") | ||
cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") | ||
cmd.Flags().String(server.FlagMinGasPrices, fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)") | ||
cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") | ||
|
@@ -106,6 +114,7 @@ func InitTestnet( | |
nodeDirPrefix, | ||
nodeDaemonHome, | ||
startingIPAddress, | ||
gentxCoinDenom, | ||
keyringBackend, | ||
algoStr string, | ||
numValidators int, | ||
|
@@ -175,7 +184,7 @@ func InitTestnet( | |
return err | ||
} | ||
|
||
addr, secret, err := server.GenerateSaveCoinKey(kb, nodeDirName, true, algo) | ||
addr, secret, err := server.GenerateSaveCoinKeyFromPath(kb, nodeDirName, true, algo, app.FullFundraiserPath) | ||
if err != nil { | ||
_ = os.RemoveAll(outputDir) | ||
return err | ||
|
@@ -197,7 +206,7 @@ func InitTestnet( | |
accStakingTokens := sdk.TokensFromConsensusPower(500) | ||
coins := sdk.Coins{ | ||
sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), accTokens), | ||
sdk.NewCoin(sdk.DefaultBondDenom, accStakingTokens), | ||
sdk.NewCoin(gentxCoinDenom, accStakingTokens), | ||
} | ||
|
||
genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()}) | ||
|
@@ -207,7 +216,7 @@ func InitTestnet( | |
createValMsg, err := stakingtypes.NewMsgCreateValidator( | ||
sdk.ValAddress(addr), | ||
valPubKeys[i], | ||
sdk.NewCoin(sdk.DefaultBondDenom, valTokens), | ||
sdk.NewCoin(gentxCoinDenom, valTokens), | ||
stakingtypes.NewDescription(nodeDirName, "", "", "", ""), | ||
stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), | ||
sdk.OneInt(), | ||
|
@@ -230,7 +239,7 @@ func InitTestnet( | |
WithKeybase(kb). | ||
WithTxConfig(clientCtx.TxConfig) | ||
|
||
if err := tx.Sign(txFactory, nodeDirName, txBuilder, false); err != nil { | ||
if err := tx.Sign(txFactory, nodeDirName, txBuilder, true); err != nil { | ||
return err | ||
} | ||
|
||
|
@@ -286,7 +295,10 @@ func initGenFiles( | |
var bankGenState banktypes.GenesisState | ||
clientCtx.JSONMarshaler.MustUnmarshalJSON(appGenState[banktypes.ModuleName], &bankGenState) | ||
|
||
bankGenState.Balances = genBalances | ||
bankGenState.Balances = banktypes.SanitizeGenesisBalances(genBalances) | ||
for _, bal := range bankGenState.Balances { | ||
bankGenState.Supply = bankGenState.Supply.Add(bal.Coins...) | ||
} | ||
appGenState[banktypes.ModuleName] = clientCtx.JSONMarshaler.MustMarshalJSON(&bankGenState) | ||
|
||
appGenStateJSON, err := json.MarshalIndent(appGenState, "", " ") | ||
|
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 |
---|---|---|
@@ -1,6 +1,19 @@ | ||
all: desmos-env | ||
|
||
desmos-env: | ||
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag desmoslabs/desmos-env desmos-env | ||
|
||
.PHONY: all desmos-env | ||
desmos-build: | ||
docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag desmoslabs/desmos-build desmos-build | ||
|
||
desmos-python: | ||
docker build --tag desmoslabs/desmos-python desmos-python | ||
|
||
desmos-cosmovisor: | ||
docker build \ | ||
--build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) \ | ||
--build-arg DESMOS_VERSION=$(DESMOS_VERSION) \ | ||
--tag desmoslabs/desmos-cosmovisor:$(DESMOS_VERSION) \ | ||
desmos-cosmovisor | ||
|
||
all: desmos-env desmos-python desmos-cosmovisor desmos-build | ||
|
||
.PHONY: all desmos-env desmos-python desmos-cosmovisor desmos-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM golang:1.15-alpine | ||
|
||
# Set up dependencies | ||
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 | ||
RUN apk add --no-cache $PACKAGES | ||
|
||
ARG UID=1000 | ||
ARG GID=1000 | ||
USER ${UID}:${GID} | ||
|
||
# Fixes build errors. Required since Go 1.12 (https://github.com/golang/go/issues/26280#issuecomment-445294378) | ||
ENV GOPATH /tmp/go | ||
ENV GOCACHE /tmp/.cache | ||
|
||
VOLUME [ "/desmos" ] | ||
WORKDIR /desmos | ||
|
||
CMD ["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,30 @@ | ||
ARG DESMOS_VERSION="v0.17.2" | ||
FROM golang:1.15-alpine AS build-env | ||
|
||
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 | ||
RUN apk add --no-cache $PACKAGES | ||
|
||
ENV GOBIN /go/bin | ||
|
||
# Set working directory for the build | ||
WORKDIR /go/src/github.com/cosmos/cosmos-sdk | ||
RUN git clone https://github.com/cosmos/cosmos-sdk.git /go/src/github.com/cosmos/cosmos-sdk | ||
RUN cd /go/src/github.com/cosmos/cosmos-sdk | ||
RUN make cosmovisor | ||
|
||
# Final image | ||
FROM desmoslabs/desmos:$DESMOS_VERSION | ||
|
||
# Copy over binaries from the build-env | ||
COPY --from=build-env /go/src/github.com/cosmos/cosmos-sdk/cosmovisor/cosmovisor /usr/bin/cosmovisor | ||
|
||
ARG UID=1000 | ||
ARG GID=1000 | ||
USER ${UID}:${GID} | ||
|
||
COPY wrapper.sh /usr/bin/wrapper.sh | ||
ENTRYPOINT ["bash", "/usr/bin/wrapper.sh"] | ||
|
||
# Run cosmovisor by default, omit entrypoint to ease using container with Desmos | ||
CMD ["cosmovisor"] | ||
STOPSIGNAL SIGTERM |
Oops, something went wrong.