From 0cfd4f824c768ce117e7e0652bedfc96a74c0c66 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 fac784e0c49c..89ad0a2f45bc 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -415,8 +415,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