mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
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.
This commit is contained in:
parent
4df10987d2
commit
8c220595bb
1 changed files with 8 additions and 6 deletions
|
|
@ -590,12 +590,12 @@ func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProo
|
|||
// pull up the blob hashes
|
||||
var (
|
||||
res = make([]*engine.BlobAndProofV2, len(hashes))
|
||||
index = make(map[common.Hash]int)
|
||||
index = make(map[common.Hash][]int)
|
||||
sidecars = api.eth.TxPool().GetBlobs(hashes)
|
||||
)
|
||||
|
||||
for i, hash := range hashes {
|
||||
index[hash] = i
|
||||
index[hash] = append(index[hash], i)
|
||||
}
|
||||
for i, sidecar := range sidecars {
|
||||
if res[i] != nil {
|
||||
|
|
@ -611,15 +611,17 @@ func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProo
|
|||
}
|
||||
blobHashes := sidecar.BlobHashes()
|
||||
for bIdx, hash := range blobHashes {
|
||||
if idx, ok := index[hash]; ok {
|
||||
if idxes, ok := index[hash]; ok {
|
||||
proofs := sidecar.CellProofsAt(bIdx)
|
||||
var cellProofs []hexutil.Bytes
|
||||
for _, proof := range proofs {
|
||||
cellProofs = append(cellProofs, proof[:])
|
||||
}
|
||||
res[idx] = &engine.BlobAndProofV2{
|
||||
Blob: sidecar.Blobs[bIdx][:],
|
||||
CellProofs: cellProofs,
|
||||
for _, idx := range idxes {
|
||||
res[idx] = &engine.BlobAndProofV2{
|
||||
Blob: sidecar.Blobs[bIdx][:],
|
||||
CellProofs: cellProofs,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue