Skip to content

Commit

Permalink
update iavl cmd for v0.26 dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pirtleshell committed May 10, 2024
1 parent 539a456 commit 812bd7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 47 deletions.
45 changes: 1 addition & 44 deletions cmd/kava/cmd/iavl.go
Expand Up @@ -6,21 +6,16 @@ import (
"encoding/hex"
"fmt"
"os"
"path/filepath"
"strconv"
"strings"

"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/store/wrapper"
sdk "github.com/cosmos/cosmos-sdk/types"
ethermintserver "github.com/evmos/ethermint/server"
"github.com/spf13/cast"
"github.com/spf13/cobra"
tdbm "github.com/tendermint/tm-db"

"github.com/cosmos/iavl"
)
Expand Down Expand Up @@ -49,7 +44,7 @@ func newIavlViewerCmd(opts ethermintserver.StartOptions) *cobra.Command {
ctx := server.GetServerContextFromCmd(cmd)
ctx.Config.SetRoot(clientCtx.HomeDir)

db, err := opts.DBOpener(ctx.Viper, clientCtx.HomeDir, getAppDBBackend(ctx.Viper))
db, err := opts.DBOpener(ctx.Viper, clientCtx.HomeDir, server.GetAppDBBackend(ctx.Viper))
if err != nil {
return err
}
Expand Down Expand Up @@ -85,30 +80,6 @@ func newIavlViewerCmd(opts ethermintserver.StartOptions) *cobra.Command {
return cmd
}

func parseDBArgs(dir string) (string, string, error) {
switch {
case strings.HasSuffix(dir, ".db"):
dir = dir[:len(dir)-3]
case strings.HasSuffix(dir, ".db/"):
dir = dir[:len(dir)-4]
default:
return "", "", fmt.Errorf("database directory must end with .db")
}

dir, err := filepath.Abs(dir)
if err != nil {
return "", "", err
}

// TODO: doesn't work on windows!
cut := strings.LastIndex(dir, "/")
if cut == -1 {
return "", "", fmt.Errorf("cannot cut paths on %s", dir)
}

return dir[cut+1:], dir[:cut], nil
}

func PrintDBStats(db dbm.DB) {
count := 0
prefix := map[string]int{}
Expand Down Expand Up @@ -207,17 +178,3 @@ func printVersions(tree *iavl.MutableTree) {
fmt.Printf(" %d\n", v)
}
}

func getAppDBBackend(opts types.AppOptions) tdbm.BackendType {
rv := cast.ToString(opts.Get("app-db-backend"))
if len(rv) == 0 {
rv = sdk.DBBackend
}
if len(rv) == 0 {
rv = cast.ToString(opts.Get("db-backend"))
}
if len(rv) != 0 {
return tdbm.BackendType(rv)
}
return tdbm.GoLevelDBBackend
}
6 changes: 3 additions & 3 deletions go.mod
Expand Up @@ -4,15 +4,18 @@ go 1.21

require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.3.1
cosmossdk.io/math v1.3.0
cosmossdk.io/simapp v0.0.0-20231127212628-044ff4d8c015
github.com/cenkalti/backoff/v4 v4.1.3
github.com/cometbft/cometbft v0.37.4
github.com/cometbft/cometbft-db v0.9.1
github.com/cosmos/cosmos-db v1.0.0
github.com/cosmos/cosmos-proto v1.0.0-beta.4
github.com/cosmos/cosmos-sdk v0.47.10
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/iavl v1.0.0
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.1.3
github.com/cosmos/ibc-go/v7 v7.4.0
github.com/ethereum/go-ethereum v1.10.26
Expand Down Expand Up @@ -47,7 +50,6 @@ require (
cosmossdk.io/api v0.3.1 // indirect
cosmossdk.io/core v0.6.1 // indirect
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
cosmossdk.io/log v1.3.1 // indirect
cosmossdk.io/tools/rosetta v0.2.1 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
Expand Down Expand Up @@ -77,9 +79,7 @@ require (
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
github.com/confio/ics23/go v0.9.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.0.0 // indirect
github.com/cosmos/ics23/go v0.10.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.1 // indirect
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
Expand Down

0 comments on commit 812bd7c

Please sign in to comment.