From 70a404fe2e5e087f9a59f2f31d99abda8a6795cf Mon Sep 17 00:00:00 2001
From: Alex Sharov <AskAlexSharov@gmail.com>
Date: Fri, 4 Jun 2021 21:12:29 +0700
Subject: [PATCH] fix master (#2098)

---
 core/rawdb/accessors_chain.go     | 17 ++++++++++-------
 eth/protocols/eth/getters_test.go |  6 +++++-
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go
index 9c74f1fe7a..6cd70a755e 100644
--- a/core/rawdb/accessors_chain.go
+++ b/core/rawdb/accessors_chain.go
@@ -742,16 +742,19 @@ func ReadReceiptsByHashDeprecated(db ethdb.Getter, hash common.Hash) types.Recei
 	return receipts
 }
 
-func ReadReceiptsByHash(db ethdb.Tx, hash common.Hash) types.Receipts {
-	number := ReadHeaderNumber(db, hash)
-	if number == nil {
-		return nil
+func ReadReceiptsByHash(db ethdb.Tx, hash common.Hash) (types.Receipts, error) {
+	b, s, err := ReadBlockByHashWithSenders(db, hash)
+	if err != nil {
+		return nil, err
 	}
-	receipts := ReadReceipts(db, hash, *number)
+	if b == nil {
+		return nil, nil
+	}
+	receipts := ReadReceipts(db, b, s)
 	if receipts == nil {
-		return nil
+		return nil, nil
 	}
-	return receipts
+	return receipts, nil
 }
 func ReadReceiptsByNumber(db ethdb.Getter, number uint64) types.Receipts {
 	h, _ := ReadCanonicalHash(db, number)
diff --git a/eth/protocols/eth/getters_test.go b/eth/protocols/eth/getters_test.go
index c111c323b2..129583d1cd 100644
--- a/eth/protocols/eth/getters_test.go
+++ b/eth/protocols/eth/getters_test.go
@@ -83,7 +83,11 @@ func testGetBlockReceipts(t *testing.T, protocol uint) {
 
 			hashes = append(hashes, block.Hash())
 			// If known, encode and queue for response packet
-			encoded, err := rlp.EncodeToBytes(rawdb.ReadReceiptsByHash(tx, block.Hash()))
+			r, err := rawdb.ReadReceiptsByHash(tx, block.Hash())
+			if err != nil {
+				return err
+			}
+			encoded, err := rlp.EncodeToBytes(r)
 			require.NoError(t, err)
 			receipts = append(receipts, encoded)
 		}
-- 
GitLab