Skip to content

Commit fe644d8

Browse files
ADR-101: Pruning mechanism minor fixes (#1246)
* Applied @serigo-mena's comments * Update state/pruner.go Co-authored-by: Thane Thomson <connect@thanethomson.com> * Applied further comments from PR * Fixed batching interval --------- Co-authored-by: Thane Thomson <connect@thanethomson.com>
1 parent c710bb8 commit fe644d8

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ func getDefaultMoniker() string {
13761376

13771377
type PruningConfig struct {
13781378
// The time period between automated background pruning operations.
1379-
Interval time.Duration `mapstructure:"period"`
1379+
Interval time.Duration `mapstructure:"interval"`
13801380
// Data companion-related pruning configuration.
13811381
DataCompanion *DataCompanionPruningConfig `mapstructure:"data_companion"`
13821382
}

state/pruner.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func (p *Pruner) pruneBlocksToRetainHeight(lastRetainHeight int64) int64 {
287287
p.logger.Error("Failed to prune blocks", "err", err, "targetRetainHeight", targetRetainHeight, "newRetainHeight", newRetainHeight)
288288
} else if pruned > 0 {
289289
p.metrics.BlockStoreBaseHeight.Set(float64(newRetainHeight))
290-
p.logger.Info("Pruned blocks", "count", pruned, "evidenceRetainHeight", evRetainHeight, "newRetainHeight", newRetainHeight)
290+
p.logger.Debug("Pruned blocks", "count", pruned, "evidenceRetainHeight", evRetainHeight, "newRetainHeight", newRetainHeight)
291291
}
292292
return newRetainHeight
293293
}
@@ -332,13 +332,15 @@ func (p *Pruner) findMinRetainHeight() int64 {
332332
appRetainHeight, err := p.stateStore.GetApplicationRetainHeight()
333333
if err != nil {
334334
if !errors.Is(err, ErrKeyNotFound) {
335+
p.logger.Error("Unexpected error fetching application retain height", "err", err)
335336
return 0
336337
}
337338
noAppRetainHeightSet = true
338339
}
339340
dcRetainHeight, err := p.stateStore.GetCompanionBlockRetainHeight()
340341
if err != nil {
341342
if !errors.Is(err, ErrKeyNotFound) {
343+
p.logger.Error("Unexpected error fetching data companion retain height", "err", err)
342344
return 0
343345
}
344346
// The Application height was set so we can return that immediately

state/store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func (store dbStore) PruneStates(from int64, to int64, evidenceThresholdHeight i
394394
// pruned and the new retain height.
395395
func (store dbStore) PruneABCIResponses(targetRetainHeight int64) (int64, int64, error) {
396396
if store.DiscardABCIResponses {
397-
return 0, 0, errors.New("ABCI responses are discarded, nothing to prune")
397+
return 0, 0, nil
398398
}
399399
lastRetainHeight, err := store.getLastABCIResponsesRetainHeight()
400400
if err != nil {
@@ -415,7 +415,7 @@ func (store dbStore) PruneABCIResponses(targetRetainHeight int64) (int64, int64,
415415
return pruned, lastRetainHeight + pruned, fmt.Errorf("failed to delete ABCI responses at height %d: %w", h, err)
416416
}
417417
batchPruned++
418-
if batchPruned%1000 == 0 && batchPruned > 0 {
418+
if batchPruned >= 1000 {
419419
if err := batch.Write(); err != nil {
420420
return pruned, lastRetainHeight + pruned, fmt.Errorf("failed to write ABCI responses deletion batch at height %d: %w", h, err)
421421
}

0 commit comments

Comments
 (0)