Skip to content

Commit

Permalink
Update to SDK 0.46.14, ibc-go 6.2.0, latest gravity (#237)
Browse files Browse the repository at this point in the history
* WIP - gravity mod update

* Remove rest clients

* mod tidy and extraneous rest reference in auction

* WIP - axelar fixes, upgrade stuff, SDK bump

* Fix cork mocks for updated staking API

* Fix no-longer compiling v6 upgrade

* Fix cork keeper mocks package

* update cmd

* x/auction compiles

* x/axelarcork mostly compiles

need to fix IBC middleware mocks

* remove RegisterRESTRoutes

* x/cellarfees compiles

* x/incentives compiles

* x/pubsub compiles, fix proposal init()

* x/cork mostly compiles

needs regenerated mocks for staking

* Fix staking mocks in x/cork

* Fix axelarcork mocks

* Fix return type for SendPacket in test mock

* integration tests compile

* remove strconv and extraneous tests from cork cli

* fix erroneous use of sdkerrors.New

* add missing expected mock in axelarcork

* Update gravity deps to latest

* Update orchestrator image, TODO in v7 upgrade

* Try latest version of golangci-lint

* fix scheduled cork integration test

Invalid legacy proposals do not seem to return a specific error code,
but rather fail silently. For the initial invalid proposal test, we
submit it and then query the gov module to see that no props have been
created.

* update sdkerrors wrap/register calls to errorsmod

* more lint errors fixes in integration tests

* remove deprecated functionality from cork test env

* fix old references to sdk.Int

* ioutil -> os
  • Loading branch information
EricBolten authored Dec 13, 2023
1 parent 10451f0 commit b327ad5
Show file tree
Hide file tree
Showing 136 changed files with 1,573 additions and 2,190 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
packages: write
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
Expand Down Expand Up @@ -127,10 +127,10 @@ jobs:
"Incentives",
]
steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19
- name: checkout
uses: actions/checkout@v2
- name: go-cache
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.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
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
with:
Expand All @@ -26,7 +26,7 @@ jobs:
- uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.47
version: v1.55
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: env.GIT_DIFF
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-go@v2
with:
go-version: '1.18'
go-version: '1.19'

- run: echo ":rocket::rocket::rocket:" > ../release_notes.md
if: startsWith(github.ref, 'refs/tags/')
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.18]
go-version: [1.19]
os: [ubuntu-latest]
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ tools-clean:
# Integration tests #
#####################

ORCHESTRATOR_IMAGE := "ghcr.io/peggyjv/gravity-bridge-orchestrator:v2.0.4"
ORCHESTRATOR_IMAGE := "ghcr.io/peggyjv/gravity-bridge-orchestrator:main"

e2e_build_images: e2e_clean_slate
@docker pull $(ORCHESTRATOR_IMAGE)
Expand Down
150 changes: 78 additions & 72 deletions app/app.go

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions app/params/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package params

import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
Expand Down Expand Up @@ -47,16 +48,16 @@ func SetAddressPrefixes() {
// source: https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-beta1/types/address.go#L141
config.SetAddressVerifier(func(bytes []byte) error {
if len(bytes) == 0 {
return sdkerrors.Wrap(sdkerrors.ErrUnknownAddress, "addresses cannot be empty")
return errorsmod.Wrap(sdkerrors.ErrUnknownAddress, "addresses cannot be empty")
}

if len(bytes) > 255 {
return sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "address max length is %d, got %d", 255, len(bytes))
return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "address max length is %d, got %d", 255, len(bytes))
}

// TODO: Do we want to allow addresses of lengths other than 20 and 32 bytes?
if len(bytes) != 20 && len(bytes) != 32 {
return sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "address length must be 20 or 32 bytes, got %d", len(bytes))
return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "address length must be 20 or 32 bytes, got %d", len(bytes))
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v4/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v3/x/gravity/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
cellarfeestypes "github.com/peggyjv/sommelier/v7/x/cellarfees/types"
corktypes "github.com/peggyjv/sommelier/v7/x/cork/types"
)
Expand Down
16 changes: 8 additions & 8 deletions app/upgrades/v6/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts"
icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"
transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
ica "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts"
icacontrollertypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
)

func CreateUpgradeHandler(
Expand All @@ -38,8 +38,8 @@ func CreateUpgradeHandler(
sdk.MsgTypeURL(&distrtypes.MsgWithdrawDelegatorReward{}),
sdk.MsgTypeURL(&distrtypes.MsgWithdrawValidatorCommission{}),
sdk.MsgTypeURL(&distrtypes.MsgFundCommunityPool{}),
sdk.MsgTypeURL(&govtypes.MsgVote{}),
sdk.MsgTypeURL(&govtypes.MsgVoteWeighted{}),
sdk.MsgTypeURL(&govtypesv1beta1.MsgVote{}),
sdk.MsgTypeURL(&govtypesv1beta1.MsgVoteWeighted{}),
sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}),
sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}),
sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}),
Expand Down
12 changes: 12 additions & 0 deletions app/upgrades/v7/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icahostkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/keeper"
icahosttypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/types"
auctionkeeper "github.com/peggyjv/sommelier/v7/x/auction/keeper"
auctiontypes "github.com/peggyjv/sommelier/v7/x/auction/types"
cellarfeeskeeper "github.com/peggyjv/sommelier/v7/x/cellarfees/keeper"
Expand All @@ -17,11 +19,18 @@ func CreateUpgradeHandler(
configurator module.Configurator,
auctionKeeper auctionkeeper.Keeper,
cellarfeesKeeper cellarfeeskeeper.Keeper,
icaHostKeeper icahostkeeper.Keeper,
pubsubKeeper pubsubkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("v7 upgrade: entering handler")

// TODO(bolten): get a sanity check on this
// Now that we're on IBC V6, we can update the ICA host module to allow all message types rather than
// the list we specified in the v6 upgrade -- a default of HostEnabled: true and the string "*" for messages
icaParams := icahosttypes.DefaultParams()
icaHostKeeper.SetParams(ctx, icaParams)

// We must manually run InitGenesis for pubsub and auctions so we can adjust their values
// during the upgrade process. RunMigrations will migrate to the new cork version. Setting the consensus
// version to 1 prevents RunMigrations from running InitGenesis itself.
Expand All @@ -33,12 +42,15 @@ func CreateUpgradeHandler(
ctx.Logger().Info("v7 upgrading: setting cellarfees default params")
cellarfeesKeeper.SetParams(ctx, cellarfeestypes.DefaultParams())

//TODO(bolten): verify that the default params are fine or if we need to customize them for auction and pubsub
ctx.Logger().Info("v7 upgrade: initializing auction genesis state")
auctionInitGenesis(ctx, auctionKeeper)

ctx.Logger().Info("v7 upgrade: initializing pubsub genesis state")
pubsubInitGenesis(ctx, pubsubKeeper)

//TODO(bolten): axelarcork module initialization

ctx.Logger().Info("v7 upgrade: running migrations and exiting handler")
return mm.RunMigrations(ctx, configurator, fromVM)
}
Expand Down
49 changes: 12 additions & 37 deletions cmd/sommelier/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package cmd
import (
"io"
"os"
"path/filepath"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/client/debug"
Expand All @@ -15,8 +13,6 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/snapshots"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/auth/types"
Expand All @@ -26,11 +22,12 @@ import (
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/spf13/cast"
"github.com/spf13/cobra"
tmcfg "github.com/tendermint/tendermint/config"
tmcli "github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

bridgecmd "github.com/peggyjv/gravity-bridge/module/v3/cmd/gravity/cmd"
bridgecmd "github.com/peggyjv/gravity-bridge/module/v4/cmd/gravity/cmd"
"github.com/peggyjv/sommelier/v7/app"
"github.com/peggyjv/sommelier/v7/app/params"
)
Expand Down Expand Up @@ -72,7 +69,7 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
return err
}

return server.InterceptConfigsPreRunHandler(cmd, "", nil)
return server.InterceptConfigsPreRunHandler(cmd, "", nil, tmcfg.DefaultConfig())
},
}

Expand Down Expand Up @@ -178,49 +175,27 @@ func txCommand() *cobra.Command {
}

func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application {
var cache sdk.MultiStorePersistentCache

if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
cache = store.NewCommitKVStoreCacheManager()
}

skipUpgradeHeights := make(map[int64]bool)
for _, h := range cast.ToIntSlice(appOpts.Get(server.FlagUnsafeSkipUpgrades)) {
skipUpgradeHeights[int64(h)] = true
}

pruningOpts, err := server.GetPruningOptionsFromFlags(appOpts)
if err != nil {
panic(err)
}

snapshotDir := filepath.Join(cast.ToString(appOpts.Get(flags.FlagHome)), "data", "snapshots")
snapshotDB, err := sdk.NewLevelDB("metadata", snapshotDir)
if err != nil {
panic(err)
}
snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir)
if err != nil {
panic(err)
}
// TODO(bolten): sanity check this update
// appears to do exactly the same things we were manually doing before, and also
// includes new baseapp options:
//
// baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(FlagIAVLCacheSize))),
// baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(FlagDisableIAVLFastNode))),
// baseapp.SetIAVLLazyLoading(cast.ToBool(appOpts.Get(FlagIAVLLazyLoading))),
baseappOptions := server.DefaultBaseappOptions(appOpts)

return app.NewSommelierApp(
logger, db, traceStore, true, skipUpgradeHeights,
cast.ToString(appOpts.Get(flags.FlagHome)),
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
app.MakeEncodingConfig(), // Ideally, we would reuse the one created by NewRootCmd.
appOpts,
baseapp.SetPruning(pruningOpts),
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))),
baseapp.SetHaltTime(cast.ToUint64(appOpts.Get(server.FlagHaltTime))),
baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))),
baseapp.SetInterBlockCache(cache),
baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
baseapp.SetSnapshotStore(snapshotStore),
baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval))),
baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent))),
baseappOptions...,
)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/sommelier/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func InitTestnet(
memo := fmt.Sprintf("%s@%s:26656", nodeIDs[i], ip)
genFiles = append(genFiles, nodeConfig.GenesisFile())

kb, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, nodeDir, inBuf)
kb, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, nodeDir, inBuf, clientCtx.Codec)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/sommelier/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func main() {
rootCmd, _ := cmd.NewRootCmd()
if err := scmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
if err := scmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
switch e := err.(type) {
case server.ErrorCode:
os.Exit(e.Code)
Expand Down
Loading

0 comments on commit b327ad5

Please sign in to comment.