Skip to content

Commit 9ccd5ca

Browse files
mojtaba-eskMojtaba
andauthored
chore: remove wasm dir on unsafe-reset (#2875)
## Describe your changes and provide context Fixes PLT-127 ## Testing performed to validate your change Co-authored-by: Mojtaba <mojtaba@celestia.org>
1 parent 14d3478 commit 9ccd5ca

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

  • sei-tendermint/cmd/tendermint/commands

sei-tendermint/cmd/tendermint/commands/reset.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
"github.com/sei-protocol/sei-chain/sei-tendermint/types"
1616
)
1717

18+
const wasmDirName = "wasm"
19+
1820
// MakeResetCommand constructs a command that removes the database of
1921
// the specified Tendermint core instance.
2022
func MakeResetCommand(conf *config.Config, logger log.Logger) *cobra.Command {
@@ -100,6 +102,13 @@ func ResetAll(dbDir, privValKeyFile, privValStateFile string, logger log.Logger,
100102
logger.Info("Removed dbDir")
101103
}
102104

105+
wasmDir := filepath.Join(homeDir, wasmDirName)
106+
if err := os.RemoveAll(wasmDir); err == nil {
107+
logger.Info("Removed wasm directory", "dir", wasmDir)
108+
} else {
109+
logger.Error("error removing wasm directory", "dir", wasmDir, "err", err)
110+
}
111+
103112
// recreate the dbDir since the privVal state needs to live there
104113
return ResetFilePV(filepath.Join(homeDir, privValKeyFile), filepath.Join(homeDir, privValStateFile), logger, keyType)
105114
}
@@ -198,8 +207,8 @@ func MakeUnsafeResetAllCommand(conf *config.Config, logger log.Logger) *cobra.Co
198207

199208
resetAllCmd := &cobra.Command{
200209
Use: "unsafe-reset-all",
201-
Short: "Removes all tendermint data including signing state",
202-
Long: `Removes all tendermint data including signing state.
210+
Short: "Removes all tendermint data, wasm directory, and signing state",
211+
Long: `Removes all tendermint data including signing state, and the wasm directory (contract blobs and compiled modules).
203212
Only use in testing. This can cause the node to double sign`,
204213
RunE: func(cmd *cobra.Command, args []string) error {
205214
// Get the --home flag value from the command

0 commit comments

Comments
 (0)