Skip to content

Commit

Permalink
Merge pull request #235 from scorpioborn/upgrade/cosmos-sdk-v0.46.4
Browse files Browse the repository at this point in the history
Upgrade / Upgrade Cosmos-SDK to `v0.46.14` and `IBC5`
  • Loading branch information
3eyedraga authored Aug 18, 2023
2 parents a4c4b78 + b1caac3 commit 2110d3f
Show file tree
Hide file tree
Showing 82 changed files with 801 additions and 656 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- uses: technote-space/[email protected]
with:
PATTERNS: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- name: Display go version
run: go version
- name: install tparse
Expand All @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
Expand All @@ -51,7 +51,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- uses: actions/checkout@v2
- name: Create a file with all the pkgs
run: go list ./... > pkgs.txt
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
Expand Down Expand Up @@ -164,7 +164,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
Expand Down
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@

# IDE Config files
.idea/
.vscode

# Test binary, built with `go test -c`
*.test
*gentxs
*node*


# Output of the go coverage tool, specifically when used with LiteIDE
*.out
Expand All @@ -20,8 +24,5 @@
# ignore auto-generated files for code quality assurance
.audit

# ignore visual studio code local config
.vscode

# ignore visual studio code dev container config
.devcontainer
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ endif
###############################################################################

check_version:
ifneq ($(GO_MINOR_VERSION),18)
@echo "ERROR: Go version 1.18 is required for this version of SGE. Go 1.19 has changes that are believed to break consensus."
ifneq ($(GO_MINOR_VERSION),19)
@echo "ERROR: Go version 1.19 is required for this version of SGE. Go 1.19 has changes that are believed to break consensus."
exit 1
endif

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ At launch, the SGE Network will be optimized to deploy an inaugural application:

## Installation Steps
>
>Prerequisite: go1.18+ required. [ref](https://golang.org/doc/install)
>Prerequisite: go1.19+ required. [ref](https://golang.org/doc/install)
Sge could be installed by two ways - downloading binary from releases page or build from source.

Expand Down
24 changes: 10 additions & 14 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/server/api"
Expand All @@ -21,7 +21,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
Expand All @@ -31,7 +30,7 @@ import (
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibcclientHandlers "github.com/cosmos/ibc-go/v4/modules/core/02-client/client"
ibcclientHandler "github.com/cosmos/ibc-go/v5/modules/core/02-client/client"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/sge-network/sge/app/keepers"
Expand All @@ -54,10 +53,10 @@ func getGovProposalHandlers() []govclient.ProposalHandler {
govProposalHandlers = append(govProposalHandlers,
paramsclient.ProposalHandler,
distrclient.ProposalHandler,
upgradeclient.ProposalHandler,
upgradeclient.CancelProposalHandler,
ibcclientHandlers.UpdateClientProposalHandler,
ibcclientHandlers.UpgradeProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
ibcclientHandler.UpdateClientProposalHandler,
ibcclientHandler.UpgradeProposalHandler,
)

return govProposalHandlers
Expand Down Expand Up @@ -317,16 +316,13 @@ func (app *SgeApp) GetSubspace(moduleName string) paramstypes.Subspace {
// API server.
func (app *SgeApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx
rpc.RegisterRoutes(clientCtx, apiSvr.Router)
// Register legacy tx routes.
authrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router)
// Register node gRPC service for grpc-gateway.
nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register grpc-gateway routes for all modules.
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// register swagger API from root so that other applications can override easily
Expand All @@ -347,7 +343,7 @@ func (app *SgeApp) RegisterTxService(clientCtx client.Context) {

// RegisterTendermintService implements the Application.RegisterTendermintService method.
func (app *SgeApp) RegisterTendermintService(clientCtx client.Context) {
tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry)
tmservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query)
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
Expand Down
18 changes: 13 additions & 5 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"encoding/json"
"fmt"
"log"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand Down Expand Up @@ -60,7 +61,8 @@ func (app *SgeApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
_, err := app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
if err != nil {
panic(err)
log := app.DistrKeeper.Logger(ctx)
log.Error(fmt.Sprintf("withdraw validator commission: %v", err))
}
return false
})
Expand All @@ -86,7 +88,9 @@ func (app *SgeApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
feePool.CommunityPool = feePool.CommunityPool.Add(scraps...)
app.DistrKeeper.SetFeePool(ctx, feePool)

app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()); err != nil {
panic(err)
}
return false
})

Expand Down Expand Up @@ -127,8 +131,12 @@ func (app *SgeApp) reInitializeAllDelegators(ctx sdk.Context, dels stakingtypes.
if err != nil {
panic(err)
}
app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr)
app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr)
if err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr); err != nil {
panic(err)
}
if err := app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr); err != nil {
panic(err)
}
}
}

Expand Down Expand Up @@ -215,7 +223,7 @@ func (app *SgeApp) resetValidatorsBondHeights(
counter := int16(0)

for ; iter.Valid(); iter.Next() {
addr := sdk.ValAddress(iter.Key()[1:])
addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key()))
validator, found := app.StakingKeeper.GetValidator(ctx, addr)
if !found {
panic("expected validator, not found")
Expand Down
42 changes: 25 additions & 17 deletions app/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,34 @@ import (

simappUtil "github.com/sge-network/sge/testutil/simapp"
"github.com/stretchr/testify/require"
tmtypes "github.com/tendermint/tendermint/types"
)

func TestExport(t *testing.T) {
tObjs, _, err := simappUtil.GetTestObjectsWithOptions(
simappUtil.Options{
CreateGenesisValidators: false,
testCases := []struct {
name string
forZeroHeight bool
}{
{
"for zero height",
true,
},
)
require.NoError(t, err)

exp, err := tObjs.ExportAppStateAndValidators(true, []string{})
require.NoError(t, err)

_, err = exp.AppState.MarshalJSON()
require.NoError(t, err)

require.Equal(t, []tmtypes.GenesisValidator(nil), exp.Validators)
require.Equal(t, int64(0), exp.Height)
{
"for non-zero height",
false,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
tApp, _, err := simappUtil.GetTestObjectsWithOptions(
simappUtil.Options{
CreateGenesisValidators: true,
},
)
require.NoError(t, err)

exp, err = tObjs.ExportAppStateAndValidators(false, []string{})
require.NoError(t, err)
tApp.Commit()
_, err = tApp.ExportAppStateAndValidators(tc.forZeroHeight, []string{})
require.NoError(t, err, "ExportAppStateAndValidators should not have an error")
})
}
}
Loading

0 comments on commit 2110d3f

Please sign in to comment.