Skip to content

Commit be877f2

Browse files
committed
go/worker/storage/committee: Fix prune handler
In case of empty state DB, last synced round is set to max uint64 value, thus the worker prunes light history even if it should not do it.
1 parent ca29d1f commit be877f2

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

.changelog/6445.bugfix.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
go/worker/storage/committee: Fix prune handler
2+
3+
Prune handler had an edge case when State DB was empty,
4+
which could cause runtime light history to be pruned prematurely.

go/worker/storage/committee/prune.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ type pruneHandler struct {
2020
// Implements runtime.history.PruneHandler.
2121
func (p *pruneHandler) CanPruneRuntime(rounds []uint64) error {
2222
lastSycnedRound, _, _ := p.worker.GetLastSynced()
23+
if lastSycnedRound == defaultUndefinedRound {
24+
return fmt.Errorf("worker/storage: tried to prune past last synced round (empty state db)")
25+
}
2326

2427
for _, round := range rounds {
2528
if round >= lastSycnedRound {

0 commit comments

Comments
 (0)