diff --git a/eth/downloader/beaconsync.go b/eth/downloader/beaconsync.go index 1f6fad26ee0f..6c0b76016053 100644 --- a/eth/downloader/beaconsync.go +++ b/eth/downloader/beaconsync.go @@ -54,6 +54,12 @@ func (b *beaconBackfiller) suspend() { // resume starts the downloader threads for backfilling state and chain data. func (b *beaconBackfiller) resume() { b.lock.Lock() + if b.filling { + // If a previous filling cycle is still running, just ignore this start + // request. // TODO(karalabe): We should make this channel driven + b.lock.Unlock() + return + } b.filling = true mode := b.syncMode b.lock.Unlock() diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 0463025eaaa2..c0c483678a54 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -1296,8 +1296,6 @@ func (d *Downloader) processHeaders(origin uint64, td *big.Int, beaconMode bool) } d.pivotLock.RUnlock() - fmt.Println(pivot) - frequency := fsHeaderCheckFrequency if chunk[len(chunk)-1].Number.Uint64()+uint64(fsHeaderForceVerify) > pivot { frequency = 1 diff --git a/eth/downloader/skeleton.go b/eth/downloader/skeleton.go index 698acfc9c1dd..7c604cbffac7 100644 --- a/eth/downloader/skeleton.go +++ b/eth/downloader/skeleton.go @@ -294,6 +294,7 @@ func (s *skeleton) Terminate() error { // This method does not block, rather it just waits until the syncer receives the // fed header. What the syncer does with it is the syncer's problem. func (s *skeleton) Sync(head *types.Header) error { + log.Trace("New skeleton head announced", "number", head.Number, "hash", head.Hash()) select { case s.headEvents <- head: return nil @@ -393,6 +394,12 @@ func (s *skeleton) sync(head *types.Header) (*types.Header, error) { if reorged := s.processNewHead(head); reorged { return head, errSyncReorged } + // New head was integrated into the skeleton chain. If the backfiller + // is still running, it will pick it up. If it already terminated, + // a new cycle needs to be spun up. + if s.scratchHead == 0 { + s.filler.resume() + } case req := <-requestFails: s.revertRequest(req)