From 66a908c5e87a4f38c0507ae2c7e53b242deb7128 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Tue, 4 Jan 2022 19:02:37 +0100 Subject: [PATCH] core/rawdb: fix double-lock causing hang (#24189) Fixes #24159 Co-authored-by: Felix Lange --- core/rawdb/accessors_chain.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 891349d5f..8e9706ea6 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -447,8 +447,11 @@ func ReadCanonicalBodyRLP(db ethdb.Reader, number uint64) rlp.RawValue { if len(data) > 0 { return nil } - // Get it by hash from leveldb - data, _ = db.Get(blockBodyKey(number, ReadCanonicalHash(db, number))) + // Block is not in ancients, read from leveldb by hash and number. + // Note: ReadCanonicalHash cannot be used here because it also + // calls ReadAncients internally. + hash, _ := db.Get(headerHashKey(number)) + data, _ = db.Get(blockBodyKey(number, common.BytesToHash(hash))) return nil }) return data