Skip to content

Commit 062f02e

Browse files
committed
fix(pruner): skip pruning when L1 head or chain height is missing
1 parent dd42f66 commit 062f02e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

pruner/pruner.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package pruner
1616

1717
import (
1818
"context"
19+
"errors"
1920
"time"
2021

2122
"github.com/NethermindEth/juno/core"
@@ -162,6 +163,10 @@ func (p *Pruner) Run(ctx context.Context) error {
162163
func (p *Pruner) onNewBlock(ctx context.Context, block *core.Block) error {
163164
l1Head, err := core.GetL1Head(p.database)
164165
if err != nil {
166+
if errors.Is(err, db.ErrKeyNotFound) {
167+
// No L1 head yet — can't anchor the retention floor.
168+
return nil
169+
}
165170
return err
166171
}
167172

@@ -183,6 +188,10 @@ func (p *Pruner) onNewBlock(ctx context.Context, block *core.Block) error {
183188
func (p *Pruner) onNewL1Head(ctx context.Context, l1Head *core.L1Head) error {
184189
chainHeight, err := core.GetChainHeight(p.database)
185190
if err != nil {
191+
if errors.Is(err, db.ErrKeyNotFound) {
192+
// No chain height yet — nothing to prune against.
193+
return nil
194+
}
186195
return err
187196
}
188197

0 commit comments

Comments
 (0)