eth/downloader: different fix

This commit is contained in:
Felix Lange 2025-06-04 14:32:55 +02:00
parent 2bad9dbca9
commit d8bed16fa7
2 changed files with 7 additions and 9 deletions

View file

@ -1039,13 +1039,6 @@ func (d *Downloader) commitSnapSyncData(results []*fetchResult, stateSync *state
for i, result := range results { for i, result := range results {
blocks[i] = types.NewBlockWithHeader(result.Header).WithBody(result.body()) blocks[i] = types.NewBlockWithHeader(result.Header).WithBody(result.body())
receipts[i] = result.Receipts 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 { 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) log.Debug("Downloaded item processing failed", "number", results[index].Header.Number, "hash", results[index].Header.Hash(), "err", err)

View file

@ -83,8 +83,13 @@ func newFetchResult(header *types.Header, snapSync bool) *fetchResult {
} else if header.WithdrawalsHash != nil { } else if header.WithdrawalsHash != nil {
item.Withdrawals = make(types.Withdrawals, 0) item.Withdrawals = make(types.Withdrawals, 0)
} }
if snapSync && !header.EmptyReceipts() { if snapSync {
item.pending.Store(item.pending.Load() | (1 << receiptType)) 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 return item
} }