From b32d20324e48766f155c0de1d371c37e2cf405e0 Mon Sep 17 00:00:00 2001 From: zhiqiangxu <652732310@qq.com> Date: Mon, 26 Sep 2022 18:33:21 +0800 Subject: [PATCH] eth/downloader, les/downloader: fix subtle flaw in queue delivery (#25861) * fix queue.deliver * les/downloader: fix queue.deliver Co-authored-by: Martin Holst Swende --- eth/downloader/queue.go | 2 +- les/downloader/queue.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index 26c41711de..ab3ae3d77d 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -857,7 +857,7 @@ func (q *queue) deliver(id string, taskPool map[common.Hash]*types.Header, } for _, header := range request.Headers[:i] { - if res, stale, err := q.resultCache.GetDeliverySlot(header.Number.Uint64()); err == nil { + if res, stale, err := q.resultCache.GetDeliverySlot(header.Number.Uint64()); err == nil && !stale { reconstruct(accepted, res) } else { // else: between here and above, some other peer filled this result, diff --git a/les/downloader/queue.go b/les/downloader/queue.go index 98ebff526e..fe08c810a1 100644 --- a/les/downloader/queue.go +++ b/les/downloader/queue.go @@ -870,7 +870,7 @@ func (q *queue) deliver(id string, taskPool map[common.Hash]*types.Header, } for _, header := range request.Headers[:i] { - if res, stale, err := q.resultCache.GetDeliverySlot(header.Number.Uint64()); err == nil { + if res, stale, err := q.resultCache.GetDeliverySlot(header.Number.Uint64()); err == nil && !stale { reconstruct(accepted, res) } else { // else: between here and above, some other peer filled this result,