core/rawdb: fix double-lock causing hang (#24189)

Fixes #24159

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
Martin Holst Swende 2022-01-04 19:02:37 +01:00 committed by GitHub
parent d0bd5017ed
commit 66a908c5e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -447,8 +447,11 @@ func ReadCanonicalBodyRLP(db ethdb.Reader, number uint64) rlp.RawValue {
if len(data) > 0 { if len(data) > 0 {
return nil return nil
} }
// Get it by hash from leveldb // Block is not in ancients, read from leveldb by hash and number.
data, _ = db.Get(blockBodyKey(number, ReadCanonicalHash(db, 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 nil
}) })
return data return data