Skip to content

Commit

Permalink
feat(logic): update for sdk047
Browse files Browse the repository at this point in the history
  • Loading branch information
bdeneux committed Apr 7, 2023
1 parent d823c27 commit 58c7efd
Show file tree
Hide file tree
Showing 24 changed files with 76 additions and 392 deletions.
58 changes: 26 additions & 32 deletions cmd/okp4d/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import (
"path/filepath"
"strings"

dbm "github.com/cometbft/cometbft-db"
tmcfg "github.com/cometbft/cometbft/config"
tmcli "github.com/cometbft/cometbft/libs/cli"
"github.com/cometbft/cometbft/libs/log"
tmtypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
Expand All @@ -25,15 +30,12 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/crisis"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/ignite/cli/ignite/services/network"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"github.com/spf13/cast"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
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"

// this line is used by starport scaffolding # root/moduleImport.

Expand Down Expand Up @@ -111,9 +113,11 @@ func initRootCmd(
// Set config
initSDKConfig()

gentxModule := app.ModuleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic)

rootCmd.AddCommand(
genutilcli.InitCmd(app.ModuleBasics, app.DefaultNodeHome),
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome),
genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome, gentxModule.GenTxValidator),
genutilcli.MigrateGenesisCmd(),
genutilcli.GenTxCmd(
app.ModuleBasics,
Expand Down Expand Up @@ -148,7 +152,6 @@ func initRootCmd(
queryCommand(),
txCommand(),
keys.Commands(app.DefaultNodeHome),
startWithTunnelingCommand(a, app.DefaultNodeHome),
)
}

Expand Down Expand Up @@ -204,29 +207,6 @@ func txCommand() *cobra.Command {
return cmd
}

// startWithTunnelingCommand returns a new start command with http tunneling
// enabled.
func startWithTunnelingCommand(appCreator appCreator, defaultNodeHome string) *cobra.Command {
startCmd := server.StartCmd(appCreator.newApp, defaultNodeHome)
startCmd.Use = "start-with-http-tunneling"
startCmd.Short = "Run the full node with http tunneling"
// Backup existing PreRunE, since we'll override it.
startPreRunE := startCmd.PreRunE
startCmd.PreRunE = func(cmd *cobra.Command, args []string) error {
var (
ctx = cmd.Context()
clientCtx = client.GetClientContextFromCmd(cmd)
serverCtx = server.GetServerContextFromCmd(cmd)
)
network.StartProxyForTunneledPeers(ctx, clientCtx, serverCtx)
if startPreRunE == nil {
return nil
}
return startPreRunE(cmd, args)
}
return startCmd
}

func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
// this line is used by starport scaffolding # root/arguments
Expand Down Expand Up @@ -276,6 +256,18 @@ func (a appCreator) newApp(
panic(err)
}

homeDir := cast.ToString(appOpts.Get(flags.FlagHome))
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
if chainID == "" {
// fallback to genesis chain-id
appGenesis, err := tmtypes.GenesisDocFromFile(filepath.Join(homeDir, "config", "genesis.json"))
if err != nil {
panic(err)
}

chainID = appGenesis.ChainID
}

snapshotDir := filepath.Join(cast.ToString(appOpts.Get(flags.FlagHome)), "data", "snapshots")
snapshotDB, err := dbm.NewDB("metadata", dbm.GoLevelDBBackend, snapshotDir)
if err != nil {
Expand Down Expand Up @@ -303,15 +295,16 @@ func (a appCreator) newApp(
appOpts,
baseapp.SetPruning(pruningOpts),
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))),
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.SetSnapshot(snapshotStore, snapshotOptions),
baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))),
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagDisableIAVLFastNode))),
baseapp.SetChainID(chainID),
)
}

Expand All @@ -324,6 +317,7 @@ func (a appCreator) appExport(
forZeroHeight bool,
jailAllowedAddrs []string,
appOpts servertypes.AppOptions,
modulesToExport []string,
) (servertypes.ExportedApp, error) {
homePath, ok := appOpts.Get(flags.FlagHome).(string)
if !ok || homePath == "" {
Expand All @@ -348,7 +342,7 @@ func (a appCreator) appExport(
}
}

return app.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
return app.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport)
}

// initAppConfig helps to override default appConfig template and configs.
Expand Down
6 changes: 3 additions & 3 deletions x/logic/fs/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
"net/url"
"testing"

tmdb "github.com/cometbft/cometbft-db"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/golang/mock/gomock"
"github.com/okp4/okp4d/x/logic/testutil"
. "github.com/smartystreets/goconvey/convey"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmdb "github.com/tendermint/tm-db"
)

func TestWasmHandler(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/logic/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
goctx "context"
"fmt"

"github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/okp4/okp4d/x/logic/fs"
"github.com/okp4/okp4d/x/logic/types"
"github.com/tendermint/tendermint/libs/log"
)

type FSProvider = func(ctx goctx.Context) fs.FS
Expand Down
5 changes: 2 additions & 3 deletions x/logic/migrations/v2/types/genesis.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions x/logic/migrations/v2/types/params.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions x/logic/migrations/v2/types/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 58c7efd

Please sign in to comment.