diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index fdb807a00..17033540c 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -31,6 +31,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" ) @@ -765,6 +766,21 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, uncleLi if types.CalcUncleHash(uncleLists[index]) != header.UncleHash { return errInvalidBody } + // Blocks must have a number of blobs corresponding to the header gas usage, + // and zero before the Cancun hardfork + var blobs int + for _, tx := range txLists[index] { + blobs += len(tx.BlobHashes()) + } + if header.BlobGasUsed != nil { + if want := *header.BlobGasUsed / params.BlobTxBlobGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated + return errInvalidBody + } + } else { + if blobs != 0 { + return errInvalidBody + } + } return nil }