consensus, core, eth/downloader, params: 4844 chain validation (#27382)

This commit is contained in:
Péter Szilágyi
2023-05-31 10:21:13 +03:00
committed by GitHub
parent cc2ab421e4
commit 1f9b69b36d
13 changed files with 208 additions and 65 deletions
+16
View File
@@ -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"
)
const (
@@ -796,6 +797,21 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
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.DataGasUsed != nil {
if want := *header.DataGasUsed / params.BlobTxDataGasPerBlob; 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
}