Skip to content

Commit

Permalink
Fix update proposal upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
mikluke committed Nov 9, 2023
1 parent 7739912 commit 95ebf95
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package app

import (
"fmt"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"path/filepath"

v160 "github.com/Decentr-net/decentr/app/upgrade/v160"
v163 "github.com/Decentr-net/decentr/app/upgrade/v163"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
Expand Down Expand Up @@ -82,6 +83,8 @@ import (
ibctransfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/modules/core"
ibcclient "github.com/cosmos/ibc-go/modules/core/02-client"
ibcclientcli "github.com/cosmos/ibc-go/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
ibcporttypes "github.com/cosmos/ibc-go/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/modules/core/keeper"
Expand Down Expand Up @@ -120,6 +123,8 @@ func getGovProposalHandlers() []govclient.ProposalHandler {
distrclient.ProposalHandler,
upgradeclient.ProposalHandler,
upgradeclient.CancelProposalHandler,
ibcclientcli.UpgradeProposalHandler,
ibcclientcli.UpdateClientProposalHandler,
)

return govProposalHandlers
Expand Down Expand Up @@ -347,7 +352,7 @@ func New(
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
Expand Down Expand Up @@ -549,6 +554,7 @@ func New(
app.SetEndBlocker(app.EndBlocker)

app.UpgradeKeeper.SetUpgradeHandler(v160.Name, v160.Handler(app.configurator, app.mm))
app.UpgradeKeeper.SetUpgradeHandler(v163.Name, v160.Handler(app.configurator, app.mm))

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
Expand Down
18 changes: 18 additions & 0 deletions app/upgrade/v163/handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v160

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

const Name = "v163"

func Handler(
cfg module.Configurator,
mm *module.Manager,
) func(ctx sdk.Context, _ upgrade.Plan, _ module.VersionMap) (module.VersionMap, error) {
return func(ctx sdk.Context, _ upgrade.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, cfg, fromVM)
}
}
86 changes: 86 additions & 0 deletions app/upgrade/v163/upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
## Decentr-1.6 Upgrade Instructions

### Software Version and Key Dates

We will be upgrading node from v1.6.2 to v1.6.3. <br />
The network will be shutdown with a SoftwareUpgradeProposal that activates at block height **<block>**, which is approximately **<date>**.<br />
The version of cosmos-sdk is still v0.45.9 <br />
The version of tendermint is still v0.34.21 <br />
The recommended version of golang is **1.19** <br /> <br />

To update golang to **1.19** use the following command:
```shell
sudo snap refresh go --channel=1.19/stable --classic
```

### Risks

As a validator, performing the upgrade procedure on your consensus nodes carries a risk of being slashed in case of not running the node in time.
If you discover a mistake in the process, the best thing to do is to seek advice from a Decentr developer before resetting your validator.

### Recovery

Prior to the upgrading procedure, validators are encouraged to take a full data snapshot at the export height before proceeding. Snap-shotting depends heavily on infrastructure, but generally this can be done by backing up the .decentr directory.

In the event that the upgrade does not succeed, validators and operators must restore their nodes from backup with v1.6.2 of the decentr software. Before starting the node validators should add `--unsafe-skip-upgrades <block>` to as decentr node start parameter.

### Upgrade Procedure

#### Before the upgrade

Decentr has submitted a SoftwareUpgradeProposal that specifies block height <block> as the final block height for <date>. This height corresponds to approximately <date template>. Once the proposal passes, the chain will shutdown automatically at the specified height and does not require manual intervention by validators.

#### On the day of the upgrade

The decentr chain is expected to halt at block height <block>, at approximately <date>, and restart with new software after an hour at <date>. Do not stop your node and begin the upgrade before <date>, or you may go offline and be unable to recover until after the upgrade!

Make sure the decentrd process is stopped before proceeding and that you have backed up your validator. Failure to backup your validator could make it impossible to restart your node if the upgrade fails.

#### Guide

1. Stop the service that's running the node
```shell
sudo systemctl stop decentr_node
```

2. Backup .decentr
```shell
cp -rf $HOME/.decentr $HOME/.decentr.bak
```

3. Check if you have proper go version
```shell
go version
```
It has to be `1.19` or higher. If it's not you should [install go with appropriate version](https://go.dev/doc/install).

4. Clone Decentr from the latest release
```shell
git clone -b v1.6.3 https://github.com/Decentr-net/decentr
cd decentr
```

5. Compile and install new version of Decentr
```shell
make install
```
and check version

```shell
decentrd version
```
It has to be `1.6.3`

6. Start your node back
```shell
sudo systemctl start decentr_node
```

7. Validate your node is up
```shell
sudo journalctl -u decentr_node.service -f
```

## Coordination

If the network does not launch by <date + 3 hours>, the launch should be considered a failure and validators should refer to the rollback instructions to restart the previous version of software. In the event of launch failure, coordination will occur in the Decentr discord.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/modules.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 95ebf95

Please sign in to comment.