Small extra check of ReceiptHash (#8469)

Small addition to PR #8467
This commit is contained in:
Andrew Ashikhmin 2023-10-14 03:40:45 +02:00 committed by GitHub
parent 757a91c44d
commit f1477e5b2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1579,6 +1579,10 @@ func (b *Block) HashCheck() error {
return fmt.Errorf("block has empty receipt hash: %x but it includes %x transactions", b.ReceiptHash(), len(b.transactions))
}
if len(b.transactions) == 0 && b.ReceiptHash() != EmptyRootHash {
return fmt.Errorf("block has non-empty receipt hash: %x but no transactions", b.ReceiptHash())
}
if hash := CalcUncleHash(b.Uncles()); hash != b.UncleHash() {
return fmt.Errorf("block has invalid uncle hash: have %x, exp: %x", hash, b.UncleHash())
}