Skip to content

Commit f203dfc

Browse files
dguentherMariusVanDerWijden
authored andcommitted
eth/catalyst: allow duplicate blob hashes (#31788)
While running kurtosis and spamoor, I noticed occasional `null` entries coming back from `getBlobsV2`. After investigating, I found that spamoor can use the same blob data across multiple transactions, so with larger blob counts, there's an increased chance that a blob is included in a block more than once. As a result, previous indexes in the hash-to-index map in `getBlobsV2` would get overwritten. I changed the map from `map[common.Hash]int` to `map[common.Hash][]int` to handle this case. I decided to go this route because it's the smallest-possible fix, but it could also make sense to update `blobpool.GetBlobs` to de-duplicate the hashes.
1 parent 10e76e8 commit f203dfc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

eth/catalyst/api.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -590,12 +590,12 @@ func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProo
590590
// pull up the blob hashes
591591
var (
592592
res = make([]*engine.BlobAndProofV2, len(hashes))
593-
index = make(map[common.Hash]int)
593+
index = make(map[common.Hash][]int)
594594
sidecars = api.eth.TxPool().GetBlobs(hashes)
595595
)
596596

597597
for i, hash := range hashes {
598-
index[hash] = i
598+
index[hash] = append(index[hash], i)
599599
}
600600
for i, sidecar := range sidecars {
601601
if res[i] != nil {
@@ -611,15 +611,17 @@ func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProo
611611
}
612612
blobHashes := sidecar.BlobHashes()
613613
for bIdx, hash := range blobHashes {
614-
if idx, ok := index[hash]; ok {
614+
if idxes, ok := index[hash]; ok {
615615
proofs := sidecar.CellProofsAt(bIdx)
616616
var cellProofs []hexutil.Bytes
617617
for _, proof := range proofs {
618618
cellProofs = append(cellProofs, proof[:])
619619
}
620-
res[idx] = &engine.BlobAndProofV2{
621-
Blob: sidecar.Blobs[bIdx][:],
622-
CellProofs: cellProofs,
620+
for _, idx := range idxes {
621+
res[idx] = &engine.BlobAndProofV2{
622+
Blob: sidecar.Blobs[bIdx][:],
623+
CellProofs: cellProofs,
624+
}
623625
}
624626
}
625627
}

0 commit comments

Comments
 (0)