Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wait after pruning. #15

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := v0.3.3
VERSION := v0.3.5

ldflags := $(LDFLAGS)
ldflags += -X main.version=$(VERSION)
Expand Down
2 changes: 1 addition & 1 deletion cmd/supervysor/commands/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func init() {
panic(fmt.Errorf("flag 'home' should be required: %w", err))
}

pruneCmd.Flags().Int64Var(&untilHeight, "until-height", 0, "prune blocks until specified height (excluding)")
pruneCmd.Flags().Int64Var(&untilHeight, "until-height", 0, "prune until specified height (excluding)")
if err := pruneCmd.MarkFlagRequired("until-height"); err != nil {
panic(fmt.Errorf("flag 'until-height' should be required: %w", err))
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/supervysor/commands/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,20 @@ var startCmd = &cobra.Command{
if nodeHeight < poolHeight {
pruneHeight = nodeHeight
}
logger.Info("pruning blocks after node shutdown", "until-height", pruneHeight)
logger.Info("pruning after node shutdown", "until-height", pruneHeight)

err = e.PruneData(supervysorConfig.HomePath, pruneHeight-1, supervysorConfig.StatePruning, binaryFlags)
if err != nil {
logger.Error("could not prune blocks", "err", err)
logger.Error("could not prune", "err", err)
return err
}
} else {
if nodeHeight < poolHeight {
logger.Info("pruning blocks after node shutdown", "until-height", nodeHeight)
logger.Info("pruning after node shutdown", "until-height", nodeHeight)

err = e.PruneData(supervysorConfig.HomePath, nodeHeight-1, supervysorConfig.StatePruning, binaryFlags)
if err != nil {
logger.Error("could not prune blocks", "err", err)
logger.Error("could not prune", "err", err)
return err
}
}
Expand Down
8 changes: 5 additions & 3 deletions executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ func (e *Executor) PruneData(homePath string, pruneHeight int, statePruning bool
}
err := store.Prune(homePath, int64(pruneHeight)-1, statePruning, e.Logger)
if err != nil {
e.Logger.Error("could not prune blocks, exiting")
e.Logger.Error("could not prune, exiting")
return err
}

time.Sleep(time.Second * time.Duration(10))

if e.Process.GhostMode {
process, err := node.StartGhostNode(e.Cfg, e.Logger, &e.Process, true, flags)
if err != nil {
Expand All @@ -113,7 +115,7 @@ func (e *Executor) PruneData(homePath string, pruneHeight int, statePruning bool
if process != nil && process.Pid > 0 {
e.Process.Id = process.Pid
e.Process.GhostMode = true
e.Logger.Info("node started in GhostMode after pruning blocks")
e.Logger.Info("node started in GhostMode after pruning")
} else {
return fmt.Errorf("enabling Ghost Mode failed: process is not defined")
}
Expand All @@ -126,7 +128,7 @@ func (e *Executor) PruneData(homePath string, pruneHeight int, statePruning bool
if process != nil && process.Pid > 0 {
e.Process.Id = process.Pid
e.Process.GhostMode = false
e.Logger.Info("Node started in Normal Mode after pruning blocks", "pId", process.Pid)
e.Logger.Info("Node started in Normal Mode after pruning", "pId", process.Pid)
} else {
return fmt.Errorf("GhostMode disabling failed: process is not defined")
}
Expand Down