|
|
@ -362,20 +362,20 @@ func (q *queue) Schedule(headers []*types.Header, from uint64) []*types.Header { |
|
|
|
// Make sure chain order is honoured and preserved throughout
|
|
|
|
// Make sure chain order is honoured and preserved throughout
|
|
|
|
hash := header.Hash() |
|
|
|
hash := header.Hash() |
|
|
|
if header.Number == nil || header.Number.Uint64() != from { |
|
|
|
if header.Number == nil || header.Number.Uint64() != from { |
|
|
|
glog.V(logger.Warn).Infof("Header #%v [%x] broke chain ordering, expected %d", header.Number, hash[:4], from) |
|
|
|
glog.V(logger.Warn).Infof("Header #%v [%x…] broke chain ordering, expected %d", header.Number, hash[:4], from) |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if q.headerHead != (common.Hash{}) && q.headerHead != header.ParentHash { |
|
|
|
if q.headerHead != (common.Hash{}) && q.headerHead != header.ParentHash { |
|
|
|
glog.V(logger.Warn).Infof("Header #%v [%x] broke chain ancestry", header.Number, hash[:4]) |
|
|
|
glog.V(logger.Warn).Infof("Header #%v [%x…] broke chain ancestry", header.Number, hash[:4]) |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
// Make sure no duplicate requests are executed
|
|
|
|
// Make sure no duplicate requests are executed
|
|
|
|
if _, ok := q.blockTaskPool[hash]; ok { |
|
|
|
if _, ok := q.blockTaskPool[hash]; ok { |
|
|
|
glog.V(logger.Warn).Infof("Header #%d [%x] already scheduled for block fetch", header.Number.Uint64(), hash[:4]) |
|
|
|
glog.V(logger.Warn).Infof("Header #%d [%x…] already scheduled for block fetch", header.Number.Uint64(), hash[:4]) |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
if _, ok := q.receiptTaskPool[hash]; ok { |
|
|
|
if _, ok := q.receiptTaskPool[hash]; ok { |
|
|
|
glog.V(logger.Warn).Infof("Header #%d [%x] already scheduled for receipt fetch", header.Number.Uint64(), hash[:4]) |
|
|
|
glog.V(logger.Warn).Infof("Header #%d [%x…] already scheduled for receipt fetch", header.Number.Uint64(), hash[:4]) |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
// Queue the header for content retrieval
|
|
|
|
// Queue the header for content retrieval
|
|
|
@ -388,7 +388,16 @@ func (q *queue) Schedule(headers []*types.Header, from uint64) []*types.Header { |
|
|
|
q.receiptTaskQueue.Push(header, -float32(header.Number.Uint64())) |
|
|
|
q.receiptTaskQueue.Push(header, -float32(header.Number.Uint64())) |
|
|
|
} |
|
|
|
} |
|
|
|
if q.mode == FastSync && header.Number.Uint64() == q.fastSyncPivot { |
|
|
|
if q.mode == FastSync && header.Number.Uint64() == q.fastSyncPivot { |
|
|
|
// Pivoting point of the fast sync, retrieve the state tries
|
|
|
|
// Pivoting point of the fast sync, switch the state retrieval to this
|
|
|
|
|
|
|
|
glog.V(logger.Debug).Infof("Switching state downloads to %d [%x…]", header.Number.Uint64(), header.Hash().Bytes()[:4]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
q.stateTaskIndex = 0 |
|
|
|
|
|
|
|
q.stateTaskPool = make(map[common.Hash]int) |
|
|
|
|
|
|
|
q.stateTaskQueue.Reset() |
|
|
|
|
|
|
|
for _, req := range q.statePendPool { |
|
|
|
|
|
|
|
req.Hashes = make(map[common.Hash]int) // Make sure executing requests fail, but don't disappear
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
q.stateSchedLock.Lock() |
|
|
|
q.stateSchedLock.Lock() |
|
|
|
q.stateScheduler = state.NewStateSync(header.Root, q.stateDatabase) |
|
|
|
q.stateScheduler = state.NewStateSync(header.Root, q.stateDatabase) |
|
|
|
q.stateSchedLock.Unlock() |
|
|
|
q.stateSchedLock.Unlock() |
|
|
@ -866,10 +875,10 @@ func (q *queue) DeliverHeaders(id string, headers []*types.Header, headerProcCh |
|
|
|
accepted := len(headers) == MaxHeaderFetch |
|
|
|
accepted := len(headers) == MaxHeaderFetch |
|
|
|
if accepted { |
|
|
|
if accepted { |
|
|
|
if headers[0].Number.Uint64() != request.From { |
|
|
|
if headers[0].Number.Uint64() != request.From { |
|
|
|
glog.V(logger.Detail).Infof("Peer %s: first header #%v [%x] broke chain ordering, expected %d", id, headers[0].Number, headers[0].Hash().Bytes()[:4], request.From) |
|
|
|
glog.V(logger.Detail).Infof("Peer %s: first header #%v [%x…] broke chain ordering, expected %d", id, headers[0].Number, headers[0].Hash().Bytes()[:4], request.From) |
|
|
|
accepted = false |
|
|
|
accepted = false |
|
|
|
} else if headers[len(headers)-1].Hash() != target { |
|
|
|
} else if headers[len(headers)-1].Hash() != target { |
|
|
|
glog.V(logger.Detail).Infof("Peer %s: last header #%v [%x] broke skeleton structure, expected %x", id, headers[len(headers)-1].Number, headers[len(headers)-1].Hash().Bytes()[:4], target[:4]) |
|
|
|
glog.V(logger.Detail).Infof("Peer %s: last header #%v [%x…] broke skeleton structure, expected %x", id, headers[len(headers)-1].Number, headers[len(headers)-1].Hash().Bytes()[:4], target[:4]) |
|
|
|
accepted = false |
|
|
|
accepted = false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -877,12 +886,12 @@ func (q *queue) DeliverHeaders(id string, headers []*types.Header, headerProcCh |
|
|
|
for i, header := range headers[1:] { |
|
|
|
for i, header := range headers[1:] { |
|
|
|
hash := header.Hash() |
|
|
|
hash := header.Hash() |
|
|
|
if want := request.From + 1 + uint64(i); header.Number.Uint64() != want { |
|
|
|
if want := request.From + 1 + uint64(i); header.Number.Uint64() != want { |
|
|
|
glog.V(logger.Warn).Infof("Peer %s: header #%v [%x] broke chain ordering, expected %d", id, header.Number, hash[:4], want) |
|
|
|
glog.V(logger.Warn).Infof("Peer %s: header #%v [%x…] broke chain ordering, expected %d", id, header.Number, hash[:4], want) |
|
|
|
accepted = false |
|
|
|
accepted = false |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if headers[i].Hash() != header.ParentHash { |
|
|
|
if headers[i].Hash() != header.ParentHash { |
|
|
|
glog.V(logger.Warn).Infof("Peer %s: header #%v [%x] broke chain ancestry", id, header.Number, hash[:4]) |
|
|
|
glog.V(logger.Warn).Infof("Peer %s: header #%v [%x…] broke chain ancestry", id, header.Number, hash[:4]) |
|
|
|
accepted = false |
|
|
|
accepted = false |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|