mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-10 22:36:01 +00:00
use tail block as sync pivot (#3276)
When syncing, we show how much of the sync has completed - with checkpoint sync, the syncing does not always go from slot 0 to head, but rather can start in the middle. To show a consistent `%` between restarts, we introduce the concept of a pivot point, such that if I sync 10% of the chain, then restart the client, it picks up at 10% (instead of counting from 0). What it looks like: ``` INF ... sync="01d12h41m (15.96%) 13.5158slots/s (QDDQDDQQDP:339018)" ... ```
This commit is contained in:
parent
184f71cb59
commit
d57c2dc4e5
@ -468,7 +468,8 @@ proc init*(T: type BeaconNode,
|
||||
taskpool)
|
||||
syncManager = newSyncManager[Peer, PeerID](
|
||||
network.peerPool, SyncQueueKind.Forward, getLocalHeadSlot, getLocalWallSlot,
|
||||
getFirstSlotAtFinalizedEpoch, getBackfillSlot, blockVerifier)
|
||||
getFirstSlotAtFinalizedEpoch, getBackfillSlot, dag.tail.slot,
|
||||
blockVerifier)
|
||||
|
||||
let stateTtlCache = if config.restCacheSize > 0:
|
||||
StateTtlCache.init(
|
||||
|
@ -54,6 +54,7 @@ type
|
||||
getSafeSlot: GetSlotCallback
|
||||
getFirstSlot: GetSlotCallback
|
||||
getLastSlot: GetSlotCallback
|
||||
progressPivot: Slot
|
||||
workers: array[SyncWorkersCount, SyncWorker[A, B]]
|
||||
notInSyncEvent: AsyncEvent
|
||||
rangeAge: uint64
|
||||
@ -98,6 +99,7 @@ proc newSyncManager*[A, B](pool: PeerPool[A, B],
|
||||
getLocalWallSlotCb: GetSlotCallback,
|
||||
getFinalizedSlotCb: GetSlotCallback,
|
||||
getBackfillSlotCb: GetSlotCallback,
|
||||
progressPivot: Slot,
|
||||
blockVerifier: BlockVerifier,
|
||||
maxStatusAge = uint64(SLOTS_PER_EPOCH * 4),
|
||||
maxHeadAge = uint64(SLOTS_PER_EPOCH * 1),
|
||||
@ -120,6 +122,7 @@ proc newSyncManager*[A, B](pool: PeerPool[A, B],
|
||||
getSafeSlot: getSafeSlot,
|
||||
getFirstSlot: getFirstSlot,
|
||||
getLastSlot: getLastSlot,
|
||||
progressPivot: progressPivot,
|
||||
maxHeadAge: maxHeadAge,
|
||||
sleepTime: sleepTime,
|
||||
chunkSize: chunkSize,
|
||||
@ -550,8 +553,13 @@ proc syncLoop[A, B](man: SyncManager[A, B]) {.async.} =
|
||||
direction = man.direction, topics = "syncman"
|
||||
|
||||
let
|
||||
progress = float(man.queue.progress())
|
||||
total = float(man.queue.total())
|
||||
pivot = man.progressPivot
|
||||
progress = float(
|
||||
if man.queue.kind == SyncQueueKind.Forward: man.queue.outSlot - pivot
|
||||
else: pivot - man.queue.outSlot)
|
||||
total = float(
|
||||
if man.queue.kind == SyncQueueKind.Forward: man.queue.finalSlot - pivot
|
||||
else: pivot - man.queue.finalSlot)
|
||||
remaining = total - progress
|
||||
done = if total > 0.0: progress / total else: 1.0
|
||||
timeleft =
|
||||
|
Loading…
x
Reference in New Issue
Block a user