core, eth/downloader, params: validate blob tx bodies (#27392)

This commit is contained in:
Péter Szilágyi
2023-05-31 11:12:26 +03:00
committed by GitHub
parent 1f9b69b36d
commit 495692c9db
3 changed files with 33 additions and 0 deletions
+16
View File
@@ -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