crypto/kzg4844: add helpers for versioned blob hashes (#28827)

The code to compute a versioned hash was duplicated a couple times, and also had a small
issue: if we ever change params.BlobTxHashVersion, it will most likely also cause changes
to the actual hash computation. So it's a bit useless to have this constant in params.
This commit is contained in:
Felix Lange
2024-01-19 11:41:17 +01:00
committed by GitHub
parent 830f3c764c
commit 0e93da3197
7 changed files with 31 additions and 39 deletions
+2 -1
View File
@@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/prque"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/params"
@@ -810,7 +811,7 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
return errInvalidBody
}
for _, hash := range tx.BlobHashes() {
if hash[0] != params.BlobTxHashVersion {
if !kzg4844.IsValidVersionedHash(hash[:]) {
return errInvalidBody
}
}