Body downloader: fix empty withdrawals in empty bodies (#6893)

Potentially fixes Issue #6817.
This commit is contained in:
Andrew Ashikhmin 2023-02-17 15:05:49 +01:00 committed by GitHub
parent 433f031db3
commit e31678f355
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,17 +136,23 @@ func (bd *BodyDownload) RequestMoreBodies(tx kv.RwTx, blockReader services.FullB
}
}
if request {
if header.UncleHash != types.EmptyUncleHash || header.TxHash != types.EmptyRootHash ||
(header.WithdrawalsHash != nil && *header.WithdrawalsHash != types.EmptyRootHash) {
if header.UncleHash == types.EmptyUncleHash && header.TxHash == types.EmptyRootHash &&
(header.WithdrawalsHash == nil || *header.WithdrawalsHash == types.EmptyRootHash) {
// Empty block body
body := &types.RawBody{}
if header.WithdrawalsHash != nil {
// implies *header.WithdrawalsHash == types.EmptyRootHash
body.Withdrawals = make([]*types.Withdrawal, 0)
}
bd.addBodyToCache(blockNum, body)
request = false
} else {
// Perhaps we already have this block
block := rawdb.ReadBlock(tx, hash, blockNum)
if block != nil {
bd.addBodyToCache(blockNum, block.RawBody())
request = false
}
} else {
bd.addBodyToCache(blockNum, &types.RawBody{})
request = false
}
}
if request {