good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 84da57f6 authored by Alex Sharov's avatar Alex Sharov Committed by GitHub
Browse files

revert run only stage.Headers at first cycle (#2879)

parent 810c004d
No related branches found
No related tags found
No related merge requests found
......@@ -389,6 +389,7 @@ func (s *Sync) pruneStage(firstCycle bool, stage *Stage, db kv.RwDB, tx kv.RwTx)
return nil
}
// DisableAllStages - including their unwinds
func (s *Sync) DisableAllStages() []stages.SyncStage {
var backupEnabledIds []stages.SyncStage
for i := range s.stages {
......
......@@ -52,18 +52,7 @@ func StageLoop(
start := time.Now()
// Estimate the current top height seen from the peer
height, err := TopSeenHeight(db, sync, initialCycle, hd)
if err != nil {
if errors.Is(err, libcommon.ErrStopped) || errors.Is(err, context.Canceled) {
return
}
log.Error("Staged Sync", "error", err)
if recoveryErr := hd.RecoverFromDb(db); recoveryErr != nil {
log.Error("Failed to recover header downloader", "error", recoveryErr)
}
continue
}
height := hd.TopSeenHeight()
if err := StageLoopStep(ctx, db, sync, height, notifications, initialCycle, updateHead, nil); err != nil {
if errors.Is(err, libcommon.ErrStopped) || errors.Is(err, context.Canceled) {
return
......@@ -92,27 +81,6 @@ func StageLoop(
}
}
// TopSeenHeight - returns hd.TopSeenHeight() or run stages.Header once to set correct hd.TopSeenHeight()
// because headers downloading process happening in the background - means if hd.TopSeenHeight() > 0 is a
// good estimation for sync step size
func TopSeenHeight(db kv.RwDB, sync *stagedsync.Sync, initialCycle bool, hd *headerdownload.HeaderDownload) (uint64, error) {
height := hd.TopSeenHeight()
if height > 0 {
return height, nil
}
if !initialCycle {
return height, nil
}
stagesBackup := sync.DisableAllStages()
defer sync.EnableStages(stagesBackup...)
sync.EnableStages(stages.Headers)
if err := sync.Run(db, nil, true); err != nil {
return 0, err
}
return hd.TopSeenHeight(), nil
}
func StageLoopStep(
ctx context.Context,
db kv.RwDB,
......@@ -144,7 +112,7 @@ func StageLoopStep(
return err
}
canRunCycleInOneTransaction := highestSeenHeader-origin < 8096 && highestSeenHeader-finishProgressBefore < 8096
canRunCycleInOneTransaction := !initialCycle && highestSeenHeader-origin < 8096 && highestSeenHeader-finishProgressBefore < 8096
var tx kv.RwTx // on this variable will run sync cycle.
if canRunCycleInOneTransaction {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment