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)
|
taskpool)
|
||||||
syncManager = newSyncManager[Peer, PeerID](
|
syncManager = newSyncManager[Peer, PeerID](
|
||||||
network.peerPool, SyncQueueKind.Forward, getLocalHeadSlot, getLocalWallSlot,
|
network.peerPool, SyncQueueKind.Forward, getLocalHeadSlot, getLocalWallSlot,
|
||||||
getFirstSlotAtFinalizedEpoch, getBackfillSlot, blockVerifier)
|
getFirstSlotAtFinalizedEpoch, getBackfillSlot, dag.tail.slot,
|
||||||
|
blockVerifier)
|
||||||
|
|
||||||
let stateTtlCache = if config.restCacheSize > 0:
|
let stateTtlCache = if config.restCacheSize > 0:
|
||||||
StateTtlCache.init(
|
StateTtlCache.init(
|
||||||
|
|
|
@ -54,6 +54,7 @@ type
|
||||||
getSafeSlot: GetSlotCallback
|
getSafeSlot: GetSlotCallback
|
||||||
getFirstSlot: GetSlotCallback
|
getFirstSlot: GetSlotCallback
|
||||||
getLastSlot: GetSlotCallback
|
getLastSlot: GetSlotCallback
|
||||||
|
progressPivot: Slot
|
||||||
workers: array[SyncWorkersCount, SyncWorker[A, B]]
|
workers: array[SyncWorkersCount, SyncWorker[A, B]]
|
||||||
notInSyncEvent: AsyncEvent
|
notInSyncEvent: AsyncEvent
|
||||||
rangeAge: uint64
|
rangeAge: uint64
|
||||||
|
@ -98,6 +99,7 @@ proc newSyncManager*[A, B](pool: PeerPool[A, B],
|
||||||
getLocalWallSlotCb: GetSlotCallback,
|
getLocalWallSlotCb: GetSlotCallback,
|
||||||
getFinalizedSlotCb: GetSlotCallback,
|
getFinalizedSlotCb: GetSlotCallback,
|
||||||
getBackfillSlotCb: GetSlotCallback,
|
getBackfillSlotCb: GetSlotCallback,
|
||||||
|
progressPivot: Slot,
|
||||||
blockVerifier: BlockVerifier,
|
blockVerifier: BlockVerifier,
|
||||||
maxStatusAge = uint64(SLOTS_PER_EPOCH * 4),
|
maxStatusAge = uint64(SLOTS_PER_EPOCH * 4),
|
||||||
maxHeadAge = uint64(SLOTS_PER_EPOCH * 1),
|
maxHeadAge = uint64(SLOTS_PER_EPOCH * 1),
|
||||||
|
@ -120,6 +122,7 @@ proc newSyncManager*[A, B](pool: PeerPool[A, B],
|
||||||
getSafeSlot: getSafeSlot,
|
getSafeSlot: getSafeSlot,
|
||||||
getFirstSlot: getFirstSlot,
|
getFirstSlot: getFirstSlot,
|
||||||
getLastSlot: getLastSlot,
|
getLastSlot: getLastSlot,
|
||||||
|
progressPivot: progressPivot,
|
||||||
maxHeadAge: maxHeadAge,
|
maxHeadAge: maxHeadAge,
|
||||||
sleepTime: sleepTime,
|
sleepTime: sleepTime,
|
||||||
chunkSize: chunkSize,
|
chunkSize: chunkSize,
|
||||||
|
@ -550,8 +553,13 @@ proc syncLoop[A, B](man: SyncManager[A, B]) {.async.} =
|
||||||
direction = man.direction, topics = "syncman"
|
direction = man.direction, topics = "syncman"
|
||||||
|
|
||||||
let
|
let
|
||||||
progress = float(man.queue.progress())
|
pivot = man.progressPivot
|
||||||
total = float(man.queue.total())
|
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
|
remaining = total - progress
|
||||||
done = if total > 0.0: progress / total else: 1.0
|
done = if total > 0.0: progress / total else: 1.0
|
||||||
timeleft =
|
timeleft =
|
||||||
|
|
Loading…
Reference in New Issue