From 765a37f426fddeeb3660e62419be20495f7d44e0 Mon Sep 17 00:00:00 2001 From: healthykim Date: Thu, 16 Apr 2026 22:26:13 +0200 Subject: [PATCH] eth/protocols: skip unavailable receipts --- eth/protocols/eth/handler_test.go | 5 +++++ eth/protocols/eth/handlers.go | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/eth/protocols/eth/handler_test.go b/eth/protocols/eth/handler_test.go index a45abc90eb..e07a591904 100644 --- a/eth/protocols/eth/handler_test.go +++ b/eth/protocols/eth/handler_test.go @@ -589,6 +589,11 @@ func testGetBlockReceipts(t *testing.T, protocol uint) { receipts rlp.RawList[*ReceiptList] ) for i := uint64(0); i <= backend.chain.CurrentBlock().Number.Uint64(); i++ { + if i == 1 { + // Insert a missing block hash to verify the server returns a nil placeholder + hashes = append(hashes, common.HexToHash("0xdeadbeef")) + receipts.Append(nil) + } block := backend.chain.GetBlockByNumber(i) hashes = append(hashes, block.Hash()) br := backend.chain.GetReceiptsByHash(block.Hash()) diff --git a/eth/protocols/eth/handlers.go b/eth/protocols/eth/handlers.go index 7556df9af2..bf388a022c 100644 --- a/eth/protocols/eth/handlers.go +++ b/eth/protocols/eth/handlers.go @@ -281,15 +281,18 @@ func ServiceGetReceiptsQuery69(chain *core.BlockChain, query GetReceiptsRequest) // Retrieve the requested block's receipts results := chain.GetReceiptsRLP(hash) if results == nil { - continue // Can't retrieve the receipts, so we just skip this block. + receipts.Append(nil) + continue } body := chain.GetBodyRLP(hash) if body == nil { - continue // The block body is missing, we also have to skip. + receipts.Append(nil) + continue } results, _, err := blockReceiptsToNetwork(results, body, receiptQueryParams{}) if err != nil { log.Error("Error in block receipts conversion", "hash", hash, "err", err) + receipts.Append(nil) continue } receipts.AppendRaw(results) @@ -313,11 +316,13 @@ func serviceGetReceiptsQuery70(chain *core.BlockChain, query GetReceiptsRequest, } results := chain.GetReceiptsRLP(hash) if results == nil { - continue // Can't retrieve the receipts, so we just skip this block. + receipts.Append(nil) + continue } body := chain.GetBodyRLP(hash) if body == nil { - continue // The block body is missing, we also have to skip. + receipts.Append(nil) + continue } q := receiptQueryParams{sizeLimit: uint64(maxPacketSize - bytes)} if i == 0 { @@ -326,6 +331,7 @@ func serviceGetReceiptsQuery70(chain *core.BlockChain, query GetReceiptsRequest, results, incomplete, err := blockReceiptsToNetwork(results, body, q) if err != nil { log.Error("Error in block receipts conversion", "hash", hash, "err", err) + receipts.Append(nil) continue } if results == nil {