core, eth/downloader, params: validate blob tx bodies (#27392)
This commit is contained in:
@@ -801,7 +801,23 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
|
||||
// and zero before the Cancun hardfork
|
||||
var blobs int
|
||||
for _, tx := range txLists[index] {
|
||||
// Count the number of blobs to validate against the header's dataGasUsed
|
||||
blobs += len(tx.BlobHashes())
|
||||
|
||||
// Validate the data blobs individually too
|
||||
if tx.Type() == types.BlobTxType {
|
||||
if tx.To() == nil {
|
||||
return errInvalidBody // TODO(karalabe): Why not make the field non-nil-able
|
||||
}
|
||||
if len(tx.BlobHashes()) == 0 {
|
||||
return errInvalidBody
|
||||
}
|
||||
for _, hash := range tx.BlobHashes() {
|
||||
if hash[0] != params.BlobTxHashVersion {
|
||||
return errInvalidBody
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if header.DataGasUsed != nil {
|
||||
if want := *header.DataGasUsed / params.BlobTxDataGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated
|
||||
|
||||
Reference in New Issue
Block a user