diff --git a/Makefile b/Makefile index 5dff6d3..a60ccbe 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := v0.3.5 +VERSION := v0.3.6 ldflags := $(LDFLAGS) ldflags += -X main.version=$(VERSION) diff --git a/cmd/supervysor/commands/prune.go b/cmd/supervysor/commands/prune.go index 37236f6..d29cceb 100644 --- a/cmd/supervysor/commands/prune.go +++ b/cmd/supervysor/commands/prune.go @@ -22,6 +22,8 @@ func init() { pruneCmd.Flags().BoolVar(&statePruning, "state-pruning", true, "enable state pruning") + pruneCmd.Flags().BoolVar(&forceCompact, "force-compact", false, "prune with ForceCompact enabled") + pruneCmd.Flags().BoolVar(&optOut, "opt-out", false, "disable the collection of anonymous usage data") } @@ -31,7 +33,7 @@ var pruneCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { utils.TrackPruneEvent(optOut) - if err := store.Prune(home, untilHeight, statePruning, logger); err != nil { + if err := store.Prune(home, untilHeight, statePruning, forceCompact, logger); err != nil { logger.Error(err.Error()) } }, diff --git a/cmd/supervysor/commands/root.go b/cmd/supervysor/commands/root.go index 92d33f6..aec0c2d 100644 --- a/cmd/supervysor/commands/root.go +++ b/cmd/supervysor/commands/root.go @@ -22,6 +22,7 @@ var ( cfgFlag string chainId string config string + forceCompact bool home string metrics bool metricsPort int diff --git a/cmd/supervysor/commands/start.go b/cmd/supervysor/commands/start.go index 89d38a3..8112031 100644 --- a/cmd/supervysor/commands/start.go +++ b/cmd/supervysor/commands/start.go @@ -22,6 +22,8 @@ func init() { startCmd.Flags().BoolVar(&statePruning, "state-pruning", true, "enable state pruning") + startCmd.Flags().BoolVar(&forceCompact, "force-compact", false, "prune with ForceCompact enabled") + startCmd.Flags().StringVar(&binaryFlags, "flags", "", "flags for the underlying binary (e.g. '--address, ')") startCmd.Flags().BoolVar(&optOut, "opt-out", false, "disable the collection of anonymous usage data") @@ -51,6 +53,10 @@ var startCmd = &cobra.Command{ return err } + if !statePruning { + supervysorConfig.StatePruning = false + } + utils.TrackStartEvent(supervysorConfig.ChainId, optOut) metrics := supervysorConfig.Metrics @@ -132,7 +138,7 @@ var startCmd = &cobra.Command{ } logger.Info("pruning after node shutdown", "until-height", pruneHeight) - err = e.PruneData(supervysorConfig.HomePath, pruneHeight-1, supervysorConfig.StatePruning, binaryFlags) + err = e.PruneData(supervysorConfig.HomePath, pruneHeight-1, supervysorConfig.StatePruning, forceCompact, binaryFlags) if err != nil { logger.Error("could not prune", "err", err) return err @@ -141,7 +147,7 @@ var startCmd = &cobra.Command{ if nodeHeight < poolHeight { logger.Info("pruning after node shutdown", "until-height", nodeHeight) - err = e.PruneData(supervysorConfig.HomePath, nodeHeight-1, supervysorConfig.StatePruning, binaryFlags) + err = e.PruneData(supervysorConfig.HomePath, nodeHeight-1, supervysorConfig.StatePruning, forceCompact, binaryFlags) if err != nil { logger.Error("could not prune", "err", err) return err diff --git a/executor/executor.go b/executor/executor.go index baa60b0..a636bf0 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -94,18 +94,18 @@ func (e *Executor) EnableNormalMode(flags string) error { return nil } -func (e *Executor) PruneData(homePath string, pruneHeight int, statePruning bool, flags string) error { +func (e *Executor) PruneData(homePath string, pruneHeight int, statePruning, forceCompact bool, flags string) error { if err := e.Shutdown(); err != nil { e.Logger.Error("could not shutdown node process", "err", err) return err } - err := store.Prune(homePath, int64(pruneHeight)-1, statePruning, e.Logger) + err := store.Prune(homePath, int64(pruneHeight)-1, statePruning, forceCompact, e.Logger) if err != nil { e.Logger.Error("could not prune, exiting") return err } - time.Sleep(time.Second * time.Duration(10)) + time.Sleep(time.Second * time.Duration(30)) if e.Process.GhostMode { process, err := node.StartGhostNode(e.Cfg, e.Logger, &e.Process, true, flags) diff --git a/store/prune.go b/store/prune.go index 0be9dc2..0972638 100644 --- a/store/prune.go +++ b/store/prune.go @@ -9,12 +9,17 @@ import ( "cosmossdk.io/log" ) -func Prune(home string, untilHeight int64, statePruning bool, logger log.Logger) error { +func Prune(home string, untilHeight int64, statePruning, forceCompact bool, logger log.Logger) error { config, err := utils.LoadConfig(home) if err != nil { return fmt.Errorf("failed to load config: %w", err) } + if !forceCompact { + logger.Info("prune without ForceCompact") + return PruneAnyDB(home, untilHeight, statePruning, logger) + } + if strings.ToLower(config.DBBackend) == "goleveldb" { logger.Info("GoLevelDB detected, using ForceCompact") return PruneGoLevelDB(home, untilHeight, statePruning, logger)