|
|
@ -84,7 +84,23 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error { |
|
|
|
// Blob transactions may be present after the Cancun fork.
|
|
|
|
// Blob transactions may be present after the Cancun fork.
|
|
|
|
var blobs int |
|
|
|
var blobs int |
|
|
|
for _, tx := range block.Transactions() { |
|
|
|
for _, tx := range block.Transactions() { |
|
|
|
|
|
|
|
// Count the number of blobs to validate against the header's dataGasUsed
|
|
|
|
blobs += len(tx.BlobHashes()) |
|
|
|
blobs += len(tx.BlobHashes()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Validate the data blobs individually too
|
|
|
|
|
|
|
|
if tx.Type() == types.BlobTxType { |
|
|
|
|
|
|
|
if tx.To() == nil { |
|
|
|
|
|
|
|
return errors.New("contract creation attempt by blob transaction") // TODO(karalabe): Why not make the field non-nil-able
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if len(tx.BlobHashes()) == 0 { |
|
|
|
|
|
|
|
return errors.New("no-blob blob transaction present in block body") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for _, hash := range tx.BlobHashes() { |
|
|
|
|
|
|
|
if hash[0] != params.BlobTxHashVersion { |
|
|
|
|
|
|
|
return fmt.Errorf("blob hash version mismatch (have %d, supported %d)", hash[0], params.BlobTxHashVersion) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if header.DataGasUsed != nil { |
|
|
|
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
|
|
|
|
if want := *header.DataGasUsed / params.BlobTxDataGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated
|
|
|
|