Skip to content
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
6 changes: 3 additions & 3 deletions cmd/juno/juno.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ const (
"it on. The value is the size of the retention window in blocks, counted " +
"back from the retention pivot (the lower of the L1-verified head and " +
"the local L2 head):\n" +
" --prune-mode same as --prune-mode=0; prune up to the pivot\n" +
" --prune-mode same as --prune-mode=128; keep 128 blocks below the pivot\n" +
" --prune-mode=N keep blocks in [pivot - N, l2_head], prune below\n" +
"Blocks at or above the L2 head are always kept. The pivot is at or " +
"below the L1-verified head, so pruned blocks are reorg-safe. RPC " +
Expand Down Expand Up @@ -495,8 +495,8 @@ func NewCmd(config *node.Config, run func(*cobra.Command, []string) error) *cobr

// --- Pruning ---
junoCmd.Flags().Uint64(pruneModeF, defaultPruneMode, pruneModeUsage)
// NoOptDefVal lets users pass --prune-mode without a value (treated as 0).
junoCmd.Flags().Lookup(pruneModeF).NoOptDefVal = "0"
// NoOptDefVal lets users pass --prune-mode without a value (treated as 128).
Comment thread
rodrodros marked this conversation as resolved.
junoCmd.Flags().Lookup(pruneModeF).NoOptDefVal = "128"
junoCmd.Flags().Duration(pruneMinAgeF, defaultPruneMinAge, pruneMinAgeUsage)
setCategory(junoCmd, catPruning, pruneModeF, pruneMinAgeF)

Expand Down
22 changes: 13 additions & 9 deletions pruner/pruner.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
var sampleTickerC <-chan time.Time
if p.minAge > 0 {
if err := p.seedFloor(); err != nil {
return fmt.Errorf("pruner: seed minimum-age floor: %w", err)
return fmt.Errorf("seed minimum-age floor: %w", err)

Check warning on line 206 in pruner/pruner.go

View check run for this annotation

Codecov / codecov/patch

pruner/pruner.go#L206

Added line #L206 was not covered by tests
}
sampleTicker := time.NewTicker(p.floorTickInterval)
defer sampleTicker.Stop()
Expand Down Expand Up @@ -245,7 +245,8 @@
case <-staleTicker.C:
p.listener.OnL1Stale()
p.logger.Warn("no L1 head received in more than 24 hours. " +
"Pruning is paused and disk usage will slowly grow until L1 head delivery resumes",
"Pruning is paused and disk usage will slowly grow until L1 head delivery resumes" +
". Verify that the L1 client connected is live and synced.",
)
staleTicker.Reset(periodicStalenessTick)
}
Expand Down Expand Up @@ -274,7 +275,7 @@
mid := low + (high-low)/2
header, err := core.GetBlockHeaderByNumber(database, mid)
if err != nil {
return 0, err
return 0, fmt.Errorf("getting block header for block %d: %w", mid, err)
}
if header.Timestamp < cutoffUnix {
low = mid + 1
Expand All @@ -295,7 +296,7 @@
if errors.Is(err, db.ErrKeyNotFound) {
return nil
}
return err
return fmt.Errorf("getting chain height: %w", err)

Check warning on line 299 in pruner/pruner.go

View check run for this annotation

Codecov / codecov/patch

pruner/pruner.go#L299

Added line #L299 was not covered by tests
}
cutoff := time.Now().Add(-p.minAge)
// Reuse the previous floor as the lower bound: the cutoff only
Expand All @@ -307,7 +308,10 @@
p.latestSampledHeight = height
return nil
}
return err
return fmt.Errorf(
"finding oldest block between %d and %d: %w",
p.latestSampledHeight, height, err,
)

Check warning on line 314 in pruner/pruner.go

View check run for this annotation

Codecov / codecov/patch

pruner/pruner.go#L311-L314

Added lines #L311 - L314 were not covered by tests
}
p.latestSampledHeight = floor
return nil
Expand Down Expand Up @@ -403,10 +407,10 @@

elapsed := time.Since(start)
p.listener.OnPrune(oldestKept, blocksPruned, elapsed)
p.logger.Info("Pruner",
zap.Uint64("oldest_kept", oldestKept),
zap.Uint64("block_pruned", blocksPruned),
zap.Duration("elapsed", elapsed),
p.logger.Info("Pruned Blocks",
zap.Uint64("prunedBelow", oldestKept),
zap.Uint64("blocksPruned", blocksPruned),
zap.Duration("duration", elapsed),
)
return nil
}
Expand Down
Loading