# Chain Upgrade Guide to v0.44
This document provides guidelines for a chain upgrade from v0.42 to v0.44 and an example of the upgrade process using simapp
.
You must upgrade to Stargate v0.42 before upgrading to v0.44. If you have not done so, please see Chain Upgrade Guide to v0.42. Please note, v0.43 was discontinued shortly after being released and all chains should upgrade directly to v0.44 from v0.42.
# Prerequisite Readings
Cosmos SDK v0.44 introduces a new way of handling chain upgrades that no longer requires exporting state to JSON, making the necessary changes, and then creating a new chain with the modified JSON as the new genesis file.
The IBC module for the Cosmos SDK has moved to its own repository (opens new window) for v0.42 and later versions. If you are using IBC, make sure to also go through the IBC migration docs (opens new window).
Instead of starting a new chain, the upgrade binary will read the existing database and perform in-place store migrations. This new way of handling chain upgrades can be used alongside Cosmovisor to make the upgrade process seamless.
# In-Place Store Migrations
We recommend using In-Place Store Migrations to upgrade your chain from v0.42 to v0.44. The first step is to make sure all your modules follow the Module Upgrade Guide. The second step is to add an upgrade handler to app.go
.
In this document, we'll provide an example of what the upgrade handler looks like for a chain upgrading module versions for the first time. It's critical to note that the initial version of each module must be set to 1
rather than 0
or else the upgrade handler will re-initialize each module.
In addition to migrating existing modules, the upgrade handler also performs store upgrades for new modules. In the example below, we'll be adding store migrations for two new modules made available in v0.44: x/authz
and x/feegrant
.
# Using Cosmovisor
We recommend validators use Cosmovisor, which is a process manager for running application binaries. For security reasons, we recommend validators build their own upgrade binaries rather than enabling the auto-download option. Validators may still choose to use the auto-download option if the necessary security guarantees are in place (i.e. the URL provided in the upgrade proposal for the downloadable upgrade binary includes a proper checksum).
Validators can use the auto-restart option to prevent unecessary downtime during the upgrade process. The auto-restart option will automatically restart the chain with the upgrade binary once the chain has halted at the proposed upgrade height. With the auto-restart option, validators can prepare the upgrade binary in advance and then relax at the time of the upgrade.
# Migrating app.toml
With the update to v0.44
, new server configuration options have been added to app.toml
. The updates include new configuration sections for Rosetta and gRPC Web as well as a new configuration option for State Sync. Check out the default app.toml
(opens new window) file in the latest version of v0.44
for more information.
# Example: Simapp Upgrade
The following example will walk through the upgrade process using simapp
as our blockchain application. We will be upgrading simapp
from v0.42 to v0.44. We will be building the upgrade binary ourselves and enabling the auto-restart option.
Note: In this example, we will be starting a new chain from v0.42
. The binary for this version will be the genesis binary. For validators using Cosmovisor for the first time, the binary for the current version of the chain should be used as the genesis binary (i.e. the starting binary). For more information, see Cosmovisor.
# Initial Setup
From within the cosmos-sdk
repository, check out the latest v0.42.x
release:
Build the simd
binary for the latest v0.42.x
release (the genesis binary):
Reset ~/.simapp
(never do this in a production environment):
Configure the simd
binary for testing:
Initialize the node and overwrite any previous genesis file (never do this in a production environment):
Set the minimum gas price to 0stake
in ~/.simapp/config/app.toml
:
For the purpose of this demonstration, change voting_period
in genesis.json
to a reduced time of 20 seconds (20s
):
Create a new key for the validator, then add a genesis account and transaction:
Now that our node is initialized and we are ready to start a new simapp
chain, let's set up cosmovisor
and the genesis binary.
# Cosmovisor Setup
First, install or update cosmovisor
:
Set the required environment variables:
Set the optional environment variable to trigger an automatic restart:
Create the folder for the genesis binary and copy the v0.42.x
binary:
Now that cosmovisor
is installed and the genesis binary has been added, let's add the upgrade handler to simapp/app.go
and prepare the upgrade binary.
# Chain Upgrade
Check out release/v0.44.x
:
Add the following to simapp/app.go
inside NewSimApp
and after app.UpgradeKeeper
:
Add the following to simapp/app.go
after NewSimApp
(to learn more about the upgrade handler, see the In-Place Store Migrations):
Add storetypes
to imports:
Build the simd
binary for v0.44.x
(the upgrade binary):
Create the folder for the upgrade binary and copy the v0.44.x
binary:
Now that we have added the upgrade handler and prepared the upgrade binary, we are ready to start cosmovisor
and simulate the upgrade proposal process.
# Upgrade Proposal
Start the node using cosmovisor
:
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):
Confirm the chain automatically upgrades at height 20.