Skip to content

Commit

Permalink
Oip6upgrade2 (#143)
Browse files Browse the repository at this point in the history
* update to onomy-sdk v0.44.8-onomy

* add missing module names

* Changed upgrade version

* Fixed errors with upgrade

* Remove onomyd

* Fix linting error in comment

* Add back v1.0.1 upgrade

* Set upgrade version name to v1.0.3

* Add undelegation logic to DAO

* Add VoteAbstain and err handling

* Add in v1.0.3.1 upgrade

* Add InflateDao function to EndBlocker

* Add upgrade v1.0.3.2

* Change nom to anom and comment out tests

* Update comments

* Fixing linter

* Fix lint issues

* Add nolint

* Change nestif lint rule to 5

* Dao treasury tests now pass

* Add v1.0.3.4 upgrade

* Add v1.0.3.5 upgrade and update Onomy-SDK import

* Address redirect

* Add error handling

* Add comments for CI

* register BeginBlocker

* Update export.go

* gofumpt

---------

Co-authored-by: Aaron Kutch <[email protected]>
  • Loading branch information
cgdusek and AaronKutch authored Jun 7, 2023
1 parent 71a6190 commit d0cb6f2
Show file tree
Hide file tree
Showing 19 changed files with 364 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ linters-settings:

nestif:
# minimal complexity of if statements to report, 5 by default
min-complexity: 3
min-complexity: 5

goconst:
# minimal length of string constant, 3 by default
Expand Down
55 changes: 51 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -93,6 +94,9 @@ import (
gravitykeeper "github.com/onomyprotocol/cosmos-gravity-bridge/module/x/gravity/keeper"
gravitytypes "github.com/onomyprotocol/cosmos-gravity-bridge/module/x/gravity/types"
v1_0_1 "github.com/onomyprotocol/onomy/app/upgrades/v1.0.1"
v1_0_3 "github.com/onomyprotocol/onomy/app/upgrades/v1.0.3"
v1_0_3_4 "github.com/onomyprotocol/onomy/app/upgrades/v1.0.3.4"
v1_0_3_5 "github.com/onomyprotocol/onomy/app/upgrades/v1.0.3.5"
"github.com/onomyprotocol/onomy/docs"
"github.com/onomyprotocol/onomy/x/dao"
daoclient "github.com/onomyprotocol/onomy/x/dao/client"
Expand Down Expand Up @@ -326,6 +330,9 @@ func New( // nolint:funlen // app new cosmos func
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)

app.UpgradeKeeper.SetUpgradeHandler(v1_0_1.Name, v1_0_1.UpgradeHandler)
app.UpgradeKeeper.SetUpgradeHandler(v1_0_3.Name, v1_0_3.UpgradeHandler)
app.UpgradeKeeper.SetUpgradeHandler(v1_0_3_4.Name, v1_0_3_4.UpgradeHandler)
app.UpgradeKeeper.SetUpgradeHandler(v1_0_3_5.Name, v1_0_3_5.UpgradeHandler)

// Create IBC Keeper
app.IBCKeeper = ibckeeper.NewKeeper(
Expand Down Expand Up @@ -373,6 +380,7 @@ func New( // nolint:funlen // app new cosmos func
&app.AccountKeeper,
&app.DistrKeeper,
&app.GovKeeper,
&app.MintKeeper,
&app.StakingKeeper,
)

Expand Down Expand Up @@ -447,11 +455,46 @@ func New( // nolint:funlen // app new cosmos func
// CanWithdrawInvariant invariant.
// NOTE: staking module is required if HistoricalEntries param > 0
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, feegrant.ModuleName,
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
ibchost.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
ibctransfertypes.ModuleName,
gravitytypes.ModuleName,
crisistypes.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
feegrant.ModuleName,
daotypes.ModuleName,
)
app.mm.SetOrderEndBlockers(
crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, gravitytypes.ModuleName, daotypes.ModuleName,
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
ibchost.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
ibctransfertypes.ModuleName,
gravitytypes.ModuleName,
crisistypes.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
feegrant.ModuleName,
daotypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand All @@ -460,6 +503,7 @@ func New( // nolint:funlen // app new cosmos func
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
app.mm.SetOrderInitGenesis(
upgradetypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
Expand All @@ -468,12 +512,15 @@ func New( // nolint:funlen // app new cosmos func
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
crisistypes.ModuleName,
ibchost.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
ibctransfertypes.ModuleName,
gravitytypes.ModuleName,
crisistypes.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
feegrant.ModuleName,
daotypes.ModuleName,
)

Expand Down
3 changes: 2 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func (app *OnomyApp) ExportAppStateAndValidators(

// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
// in favor of export at a block height
//
// in favor of export at a block height
func (app *OnomyApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { // nolint:cyclop,gocyclo,gocognit // generated by cosmos
applyAllowedAddrs := false

Expand Down
4 changes: 3 additions & 1 deletion app/upgrades/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ This folder contains sub-folders for every chain upgrade.
## Version History

- v1.0.1 - IBC integration fix

- v1.0.3 - Hyperinflation fix
- v1.0.3.4 - OIP 6 Undelegate DAO from all validators
- v1.0.3.5 - OIP 6 Patch Subtract DAO Treasury from Staking Supply
16 changes: 16 additions & 0 deletions app/upgrades/v1.0.3.4/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Package v1_0_3_4 is contains chain upgrade of the corresponding version.
package v1_0_3_4 //nolint:revive,stylecheck // app version

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

// Name is migration name.
const Name = "v1.0.3.4"

// UpgradeHandler is an x/upgrade handler.
func UpgradeHandler(_ sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return vm, nil
}
16 changes: 16 additions & 0 deletions app/upgrades/v1.0.3.5/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Package v1_0_3_5 is contains chain upgrade of the corresponding version.
package v1_0_3_5 //nolint:revive,stylecheck // app version

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

// Name is migration name.
const Name = "v1.0.3.5"

// UpgradeHandler is an x/upgrade handler.
func UpgradeHandler(_ sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return vm, nil
}
16 changes: 16 additions & 0 deletions app/upgrades/v1.0.3/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Package v1_0_3 is contains chain upgrade of the corresponding version.
package v1_0_3 //nolint:revive,stylecheck // app version

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

// Name is migration name.
const Name = "v1.0.3"

// UpgradeHandler is an x/upgrade handler.
func UpgradeHandler(_ sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return vm, nil
}
13 changes: 8 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/onomyprotocol/onomy
go 1.16

require (
github.com/cosmos/cosmos-sdk v0.44.5
github.com/cosmos/cosmos-sdk v0.44.8
github.com/cosmos/ibc-go/v2 v2.0.4
github.com/ethereum/go-ethereum v1.10.10
github.com/gogo/protobuf v1.3.3
Expand All @@ -14,12 +14,12 @@ require (
github.com/onomyprotocol/cosmos-gravity-bridge/module v0.0.0-20220606130009-db180e048abe
github.com/onomyprotocol/tm-load-test v0.9.1-0.20211101093435-b38e68e11c01
github.com/spf13/cast v1.4.1
github.com/spf13/cobra v1.2.1
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.0
github.com/tendermint/starport v0.19.3
github.com/tendermint/tendermint v0.34.14
github.com/tendermint/tm-db v0.6.4
github.com/tendermint/tendermint v0.34.19
github.com/tendermint/tm-db v0.6.6
github.com/testcontainers/testcontainers-go v0.12.0
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e
Expand All @@ -29,8 +29,11 @@ require (

replace (
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/onomyprotocol/onomy-sdk v0.44.6-0.20221103153534-77ffa1c3fab2
// v0.44.8-onomy
github.com/cosmos/cosmos-sdk => github.com/onomyprotocol/onomy-sdk v0.44.6-0.20230527201514-b355cbab8616
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4

google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
Loading

0 comments on commit d0cb6f2

Please sign in to comment.