Skip to content

Commit

Permalink
docs(cosmovisor): update simapp migration example (#17583)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency authored Aug 30, 2023
1 parent 47309fa commit 914a8b6
Showing 1 changed file with 23 additions and 35 deletions.
58 changes: 23 additions & 35 deletions tools/cosmovisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,25 +268,25 @@ The following instructions provide a demonstration of `cosmovisor` using the sim

### Chain Setup

Let's create a new chain using the `v0.44` version of simapp (the Cosmos SDK demo app):
Let's create a new chain using the `v0.47.4` version of simapp (the Cosmos SDK demo app):

```shell
git checkout v0.44.6
git checkout v0.47.4
make build
```

Clean `~/.simapp` (never do this in a production environment):

```shell
./build/simd unsafe-reset-all
./build/simd tendermint unsafe-reset-all
```

Set up app config:

```shell
./build/simd config set client chain-id test
./build/simd config set client keyring-backend test
./build/simd config set client broadcast-mode sync
./build/simd config chain-id test
./build/simd config keyring-backend test
./build/simd config broadcast-mode sync
```

Initialize the node and overwrite any previous genesis file (never do this in a production environment):
Expand All @@ -297,16 +297,10 @@ Initialize the node and overwrite any previous genesis file (never do this in a
./build/simd init test --chain-id test --overwrite
```

Set the minimum gas price to `0stake` in `~/.simapp/config/app.toml`:

```shell
minimum-gas-prices = "0stake"
```

For the sake of this demonstration, amend `voting_period` in `genesis.json` to a reduced time of 20 seconds (`20s`):

```shell
cat <<< $(jq '.app_state.gov.voting_params.voting_period = "20s"' $HOME/.simapp/config/genesis.json) > $HOME/.simapp/config/genesis.json
cat <<< $(jq '.app_state.gov.params.voting_period = "20s"' $HOME/.simapp/config/genesis.json) > $HOME/.simapp/config/genesis.json
```

Create a validator, and setup genesis transaction:
Expand Down Expand Up @@ -339,17 +333,23 @@ Initialize cosmovisor with the current binary:
cosmovisor init ./build/simd
```

Now you can run cosmovisor with simapp v0.44:
Now you can run cosmovisor with simapp v0.47.4:

```shell
cosmovisor run start
```

#### Update App
### Update App

Update app to the latest version (e.g. v0.50.0).

:::note

Update app to the latest version (e.g. v0.45).
Migration plans are defined using the `x/upgrade` module and described in [In-Place Store Migrations](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/core/15-upgrade.md). Migrations can perform any deterministic state change.

Next, we can add a migration - which is defined using `x/upgrade` [upgrade plan](https://github.com/cosmos/cosmos-sdk/blob/main/docs/core/upgrade.md) (you may refer to a past version if you are using an older Cosmos SDK release). In a migration we can do any deterministic state change.
The migration plan to upgrade the simapp from v0.47 to v0.50 is defined in `simapp/upgrade.go`.

:::

Build the new version `simd` binary:

Expand All @@ -359,32 +359,20 @@ make build

Add the new `simd` binary and the upgrade name:

```shell
cosmovisor add-upgrade test1 ./build/simd
```

Open a new terminal window and submit an upgrade proposal along with a deposit and a vote (these commands must be run within 20 seconds of each other):
:::warning

**<= v0.45**:
The migration name must match the one defined in the migration plan.

```shell
./build/simd tx gov submit-proposal software-upgrade test1 --title upgrade --description upgrade --upgrade-height 200 --from validator --yes
./build/simd tx gov deposit 1 10000000stake --from validator --yes
./build/simd tx gov vote 1 yes --from validator --yes
```

**v0.46, v0.47**:
:::

```shell
./build/simd tx gov submit-legacy-proposal software-upgrade test1 --title upgrade --description upgrade --upgrade-height 200 --no-validate --from validator --yes
./build/simd tx gov deposit 1 10000000stake --from validator --yes
./build/simd tx gov vote 1 yes --from validator --yes
cosmovisor add-upgrade v047-to-v050 ./build/simd
```

**>= v0.50+**:
Open a new terminal window and submit an upgrade proposal along with a deposit and a vote (these commands must be run within 20 seconds of each other):

```shell
./build/simd tx upgrade software-upgrade test1 --title upgrade --summary upgrade --upgrade-height 200 --upgrade-info "{}" --no-validate --from validator --yes
./build/simd tx upgrade software-upgrade v047-to-v050 --title upgrade --summary upgrade --upgrade-height 200 --upgrade-info "{}" --no-validate --from validator --yes
./build/simd tx gov deposit 1 10000000stake --from validator --yes
./build/simd tx gov vote 1 yes --from validator --yes
```
Expand Down

0 comments on commit 914a8b6

Please sign in to comment.