core, eth/downloader: make body validation more strict (#26704)
This commit is contained in:
+11
-8
@@ -781,14 +781,17 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
|
||||
return errInvalidBody
|
||||
}
|
||||
if header.WithdrawalsHash == nil {
|
||||
// discard any withdrawals if we don't have a withdrawal hash set
|
||||
withdrawalLists[index] = nil
|
||||
} else if *header.WithdrawalsHash == types.EmptyRootHash && withdrawalLists[index] == nil {
|
||||
// if the withdrawal hash is the emptyRootHash,
|
||||
// we expect withdrawals to be [] instead of nil
|
||||
withdrawalLists[index] = make([]*types.Withdrawal, 0)
|
||||
} else if withdrawalListHashes[index] != *header.WithdrawalsHash {
|
||||
return errInvalidBody
|
||||
// nil hash means there withdrawals should not be present in body
|
||||
if withdrawalLists[index] != nil {
|
||||
return errInvalidBody
|
||||
}
|
||||
} else { // non-nil hash: body must have withdrawals
|
||||
if withdrawalLists[index] == nil {
|
||||
return errInvalidBody
|
||||
}
|
||||
if withdrawalListHashes[index] != *header.WithdrawalsHash {
|
||||
return errInvalidBody
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user