From d8bed16fa7ead035bd2b0f0a624bb624deb98b29 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 4 Jun 2025 14:32:55 +0200 Subject: [PATCH] eth/downloader: different fix --- eth/downloader/downloader.go | 7 ------- eth/downloader/queue.go | 9 +++++++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 26d0c841aa..762fb9283e 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -1039,13 +1039,6 @@ func (d *Downloader) commitSnapSyncData(results []*fetchResult, stateSync *state for i, result := range results { blocks[i] = types.NewBlockWithHeader(result.Header).WithBody(result.body()) receipts[i] = result.Receipts - // Blockchain expects the receipts to be properly encoded - // as they are inserted into the db as they are. - // This workaround makes sure that blocks with no receipts - // have a valid encoding. - if len(result.Receipts) == 0 { - receipts[i] = rlp.EmptyList - } } if index, err := d.blockchain.InsertReceiptChain(blocks, receipts, d.ancientLimit); err != nil { log.Debug("Downloaded item processing failed", "number", results[index].Header.Number, "hash", results[index].Header.Hash(), "err", err) diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index bd7acadfc4..9fe169d5f7 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -83,8 +83,13 @@ func newFetchResult(header *types.Header, snapSync bool) *fetchResult { } else if header.WithdrawalsHash != nil { item.Withdrawals = make(types.Withdrawals, 0) } - if snapSync && !header.EmptyReceipts() { - item.pending.Store(item.pending.Load() | (1 << receiptType)) + if snapSync { + if header.EmptyReceipts() { + // Ensure the receipts list is valid even if it isn't actively fetched. + item.Receipts = rlp.EmptyList + } else { + item.pending.Store(item.pending.Load() | (1 << receiptType)) + } } return item }