Skip to content

Commit

Permalink
Fix current slot value and finishing progress for backfilling. (#3304)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheatfate authored Jan 21, 2022
1 parent 9699858 commit 0ea6dfa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions beacon_chain/sync/sync_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{.push raises: [Defect].}

import std/[options, heapqueue, tables, strutils, sequtils, algorithm]
import stew/results, chronos, chronicles
import stew/[results, base10], chronos, chronicles
import
../spec/datatypes/[phase0, altair],
../spec/eth2_apis/rpc_types,
Expand Down Expand Up @@ -614,12 +614,18 @@ proc syncLoop[A, B](man: SyncManager[A, B]) {.async.} =
if man.avgSyncSpeed >= 0.001:
Duration.fromFloatSeconds(remaining / man.avgSyncSpeed)
else: InfiniteDuration
currentSlot = Base10.toString(
if man.queue.kind == SyncQueueKind.Forward:
min(uint64(man.queue.outSlot) - 1'u64, 0'u64)
else:
uint64(man.queue.outSlot) + 1'u64
)

# Update status string
man.syncStatus = timeLeft.toTimeLeftString() & " (" &
(done * 100).formatBiggestFloat(ffDecimal, 2) & "%) " &
man.avgSyncSpeed.formatBiggestFloat(ffDecimal, 4) &
"slots/s (" & map & ":" & $man.queue.outSlot & ")"
"slots/s (" & map & ":" & currentSlot & ")"

if man.remainingSlots() <= man.maxHeadAge:
man.notInSyncEvent.clear()
Expand Down Expand Up @@ -671,6 +677,7 @@ proc syncLoop[A, B](man: SyncManager[A, B]) {.async.} =
res.add(worker.future)
res
await allFutures(pendingTasks)
man.inProgress = false
debug "Backward synchronization process finished, exiting",
wall_head_slot = wallSlot, local_head_slot = headSlot,
backfill_slot = man.getLastSlot(),
Expand Down

0 comments on commit 0ea6dfa

Please sign in to comment.