From 4559a5fb0eb9ff797c5c78f6d53266d15a17c5c5 Mon Sep 17 00:00:00 2001 From: Vladislav Mikitich Date: Fri, 10 Nov 2023 00:48:30 +0300 Subject: [PATCH] Fix update proposal upgrade --- app/app.go | 10 ++- app/upgrade/v163/handler.go | 18 ++++ app/upgrade/v163/upgrade.md | 86 +++++++++++++++++++ .../core/02-client/client/proposal_handler.go | 25 ++++++ vendor/modules.txt | 3 +- 5 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 app/upgrade/v163/handler.go create mode 100644 app/upgrade/v163/upgrade.md create mode 100644 vendor/github.com/cosmos/ibc-go/modules/core/02-client/client/proposal_handler.go diff --git a/app/app.go b/app/app.go index c513608d..14ed1dff 100644 --- a/app/app.go +++ b/app/app.go @@ -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" @@ -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" @@ -120,6 +123,8 @@ func getGovProposalHandlers() []govclient.ProposalHandler { distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler, + ibcclientcli.UpgradeProposalHandler, + ibcclientcli.UpdateClientProposalHandler, ) return govProposalHandlers @@ -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( @@ -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 { diff --git a/app/upgrade/v163/handler.go b/app/upgrade/v163/handler.go new file mode 100644 index 00000000..36a67b07 --- /dev/null +++ b/app/upgrade/v163/handler.go @@ -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) + } +} diff --git a/app/upgrade/v163/upgrade.md b/app/upgrade/v163/upgrade.md new file mode 100644 index 00000000..d55371ca --- /dev/null +++ b/app/upgrade/v163/upgrade.md @@ -0,0 +1,86 @@ +## Decentr-1.6.3 Upgrade Instructions + +### Software Version and Key Dates + +We will be upgrading node from v1.6.2 to v1.6.3.
+The network will be shutdown with a SoftwareUpgradeProposal that activates at block height **11619000**, which is approximately **Mon Nov 20 2022 17:00:00 UTC**.
+The version of cosmos-sdk is still v0.45.9
+The version of tendermint is still v0.34.21
+The recommended version of golang is **1.19**

+ +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 11619000` to as decentr node start parameter. + +### Upgrade Procedure + +#### Before the upgrade + +Decentr has submitted a SoftwareUpgradeProposal that specifies block height 11619000 as the final block height for v1.6.2. This height corresponds to approximately Mon Nov 20 2022 17:00:00 UTC. Once the proposal passes, the chain will shut down 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 11619000, at approximately Mon Nov 20 2022 17:00:00 UTC, and restart with new software after an hour at Mon Nov 20 2022 18:00:00 UTC. Do not stop your node and begin the upgrade before Mon Nov 20 2022 17:00:00 UTC, 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 Mon Nov 20 2022 20:00:00 UTC, 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. diff --git a/vendor/github.com/cosmos/ibc-go/modules/core/02-client/client/proposal_handler.go b/vendor/github.com/cosmos/ibc-go/modules/core/02-client/client/proposal_handler.go new file mode 100644 index 00000000..8f773dd4 --- /dev/null +++ b/vendor/github.com/cosmos/ibc-go/modules/core/02-client/client/proposal_handler.go @@ -0,0 +1,25 @@ +package client + +import ( + "net/http" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/types/rest" + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" + govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" + "github.com/cosmos/ibc-go/modules/core/02-client/client/cli" +) + +var ( + UpdateClientProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpdateClientProposal, emptyRestHandler) + UpgradeProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpgradeProposal, emptyRestHandler) +) + +func emptyRestHandler(client.Context) govrest.ProposalRESTHandler { + return govrest.ProposalRESTHandler{ + SubRoute: "unsupported-ibc-client", + Handler: func(w http.ResponseWriter, r *http.Request) { + rest.WriteErrorResponse(w, http.StatusBadRequest, "Legacy REST Routes are not supported for IBC proposals") + }, + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 22440090..3439b5bb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -296,6 +296,7 @@ github.com/cosmos/ibc-go/modules/apps/transfer/simulation github.com/cosmos/ibc-go/modules/apps/transfer/types github.com/cosmos/ibc-go/modules/core github.com/cosmos/ibc-go/modules/core/02-client +github.com/cosmos/ibc-go/modules/core/02-client/client github.com/cosmos/ibc-go/modules/core/02-client/client/cli github.com/cosmos/ibc-go/modules/core/02-client/client/utils github.com/cosmos/ibc-go/modules/core/02-client/keeper @@ -921,6 +922,6 @@ nhooyr.io/websocket/internal/errd nhooyr.io/websocket/internal/wsjs nhooyr.io/websocket/internal/xsync # github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 +# github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 # github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 # google.golang.org/grpc => google.golang.org/grpc v1.33.2 -# github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0