fix: set withdrawals properly when fetching empty block (#2386)

This commit is contained in:
buddho 2024-04-10 19:46:34 +08:00 committed by GitHub
parent f4bad20447
commit d7836bfe98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

@ -639,6 +639,9 @@ func (f *BlockFetcher) loop() {
log.Trace("Block empty, skipping body retrieval", "peer", announce.origin, "number", header.Number, "hash", header.Hash())
block := types.NewBlockWithHeader(header)
if block.Header().EmptyWithdrawalsHash() {
block = block.WithWithdrawals(make([]*types.Withdrawal, 0))
}
block.ReceivedAt = task.time
complete = append(complete, block)

@ -366,7 +366,6 @@ func handleBlockBodies(backend Backend, msg Decoder, peer *Peer) error {
for i, body := range res.BlockBodiesResponse {
txsHashes[i] = types.DeriveSha(types.Transactions(body.Transactions), hasher)
uncleHashes[i] = types.CalcUncleHash(body.Uncles)
// Withdrawals may be not nil, but a empty value when Sidecars not empty
if body.Withdrawals != nil {
withdrawalHashes[i] = types.DeriveSha(types.Withdrawals(body.Withdrawals), hasher)
}