Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-hub-genesis-module
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 committed Mar 19, 2024
2 parents 7402cce + 0a9c24b commit 320e5b5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
41 changes: 40 additions & 1 deletion server/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package server

import (
"fmt"
"os"
"path/filepath"

"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/types"
Expand All @@ -12,6 +14,7 @@ import (
"github.com/libp2p/go-libp2p"
"github.com/spf13/cobra"
tmcmd "github.com/tendermint/tendermint/cmd/cometbft/commands"
cmtos "github.com/tendermint/tendermint/libs/os"
"github.com/tendermint/tendermint/p2p"
)

Expand All @@ -28,7 +31,7 @@ func AddRollappCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreat
commands.InspectStateCmd(),
ResetAll(),
server.VersionCmd(),
tmcmd.ResetStateCmd,
ResetState(),
)

rootCmd.AddCommand(
Expand Down Expand Up @@ -83,3 +86,39 @@ func ResetAll() *cobra.Command {

return resetAll
}

// ResetState removes all the block state stored in dymint
func ResetState() *cobra.Command {
return &cobra.Command{
Use: "reset-state",
Aliases: []string{"reset_state"},
Short: "Remove all the data and WAL",
RunE: func(cmd *cobra.Command, args []string) (err error) {

config := server.GetServerContextFromCmd(cmd).Config
var paths []string
appdb := filepath.Join(config.DBDir(), "application.db")
dymintdb := filepath.Join(config.DBDir(), "dymint")
settlementdb := filepath.Join(config.DBDir(), "settlement")
paths = append(paths, appdb, dymintdb, settlementdb)
for _, path := range paths {
err := removePath(path)
if err != nil {
fmt.Printf("error removing %s with error %s\n", path, err)
}
}
return nil
},
}
}

func removePath(path string) error {
if cmtos.FileExists(path) {
if err := os.RemoveAll(path); err == nil {
fmt.Println("Path removed", "path", path)
} else {
return err
}
}
return nil
}
6 changes: 2 additions & 4 deletions testutil/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ package app

import (
"encoding/json"
"io"
"net/http"

hubgenesis "github.com/dymensionxyz/dymension-rdk/x/hub-genesis"
hubgenkeeper "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/keeper"
hubgentypes "github.com/dymensionxyz/dymension-rdk/x/hub-genesis/types"

"github.com/cosmos/cosmos-sdk/std"

"io"
"net/http"

"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
abci "github.com/tendermint/tendermint/abci/types"
Expand Down

0 comments on commit 320e5b5

Please sign in to comment.