Skip to content

Commit

Permalink
Check 10 extra slots during backfill after first alreadyExists
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseguy committed Jun 18, 2024
1 parent 495fd46 commit 1b7431a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
20 changes: 12 additions & 8 deletions archiver/service/archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (a *Archiver) backfillBlobs(ctx context.Context, latest *v1.BeaconBlockHead

backfillLoop := func(start *v1.BeaconBlockHeader, current *v1.BeaconBlockHeader) {
curr, alreadyExists, err := current, false, error(nil)
count := 0
storedCount, numExists := 0, 0
a.log.Info("backfill process initiated",
"currHash", curr.Root.String(),
"currSlot", curr.Header.Message.Slot,
Expand All @@ -164,7 +164,7 @@ func (a *Archiver) backfillBlobs(ctx context.Context, latest *v1.BeaconBlockHead
a.dataStoreClient.WriteBackfillProcesses(ctx, backfillProcesses)
}()

for !alreadyExists {
for !alreadyExists || numExists < 10 {
previous := curr

if common.Hash(curr.Root) == a.cfg.OriginBlock {
Expand All @@ -183,12 +183,16 @@ func (a *Archiver) backfillBlobs(ctx context.Context, latest *v1.BeaconBlockHead

if !alreadyExists {
a.metrics.RecordProcessedBlock(metrics.BlockSourceBackfill)
}

count++
if count%10 == 0 {
backfillProcesses[common.Hash(start.Root)] = storage.BackfillProcess{Start: *start, Current: *curr}
a.dataStoreClient.WriteBackfillProcesses(ctx, backfillProcesses)
numExists = 0
storedCount++
if storedCount%10 == 0 {
// Update storage every 10 slots
backfillProcesses[common.Hash(start.Root)] = storage.BackfillProcess{Start: *start, Current: *curr}
a.dataStoreClient.WriteBackfillProcesses(ctx, backfillProcesses)
}
} else {
numExists++
a.log.Info("backfill found pre-existing slot", "numExists", numExists)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion archiver/service/archiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ func TestArchiver_BackfillFinishOldProcess(t *testing.T) {

actualProcesses, err = svc.dataStoreClient.ReadBackfillProcesses(context.Background())
require.NoError(t, err)
svc.log.Info("backfill processes", "processes", actualProcesses)
require.Equal(t, storage.BackfillProcesses{}, actualProcesses)

}
Expand Down

0 comments on commit 1b7431a

Please sign in to comment.