Skip to content

Commit 9fd474e

Browse files
Merge pull request #6445 from oasisprotocol/martin/fix/storage-committee-prune-handler
go/worker/storage/committee: Fix prune handler
2 parents ca29d1f + be877f2 commit 9fd474e

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)