From ed24b890a7c42a4215b5ac675b8090a628851b74 Mon Sep 17 00:00:00 2001 From: istae <14264581+istae@users.noreply.github.com> Date: Thu, 7 Dec 2023 06:30:14 -0300 Subject: [PATCH] fix: patch fix for batchstore reset and storage radius (#4494) --- pkg/statestore/storeadapter/migration.go | 1 + pkg/storer/internal/reserve/reserve.go | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/statestore/storeadapter/migration.go b/pkg/statestore/storeadapter/migration.go index 03e3ddb64e4..22ea712d052 100644 --- a/pkg/statestore/storeadapter/migration.go +++ b/pkg/statestore/storeadapter/migration.go @@ -17,6 +17,7 @@ func allSteps() migration.Steps { 2: deletePrefix("sync_interval"), 3: deletePrefix("sync_interval"), 4: deletePrefix("blocklist"), + 5: deletePrefix("batchstore"), } } diff --git a/pkg/storer/internal/reserve/reserve.go b/pkg/storer/internal/reserve/reserve.go index b48f5075e8c..8e7f9a121e8 100644 --- a/pkg/storer/internal/reserve/reserve.go +++ b/pkg/storer/internal/reserve/reserve.go @@ -25,9 +25,11 @@ import ( // loggerName is the tree path name of the logger for this package. const loggerName = "reserve" - const reserveNamespace = "reserve" +// hack: make sures the network's storage radius does not fall below a certain value +const minRadius = 9 + /* pull by bin - binID evict by bin - batchID @@ -69,7 +71,7 @@ func New( if err != nil && !errors.Is(err, storage.ErrNotFound) { return nil, err } - rs.radius.Store(uint32(rItem.Radius)) + rs.radius.Store(uint32(max(rItem.Radius, minRadius))) epochItem := &EpochItem{} err = store.Get(epochItem) @@ -463,6 +465,7 @@ func (r *Reserve) EvictionTarget() int { } func (r *Reserve) SetRadius(store storage.Store, rad uint8) error { + rad = max(rad, minRadius) r.radius.Store(uint32(rad)) r.radiusSetter.SetStorageRadius(rad) return store.Put(&radiusItem{Radius: rad})