core/txpool/blobpool: do not expect conversion in GetBlobs test

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2025-09-18 15:20:45 +02:00
parent f983cdb37e
commit 940a68359e
No known key found for this signature in database
GPG key ID: 0FE274EE8C95166E
3 changed files with 40 additions and 40 deletions

View file

@ -1379,14 +1379,15 @@ func (p *BlobPool) GetBlobs(vhashes []common.Hash, version byte, convert bool) (
} }
// Traverse the blobs in the transaction // Traverse the blobs in the transaction
for i, hash := range tx.BlobHashes() { for i, hash := range tx.BlobHashes() {
skip := false // if true, skip using null, but proceed
list, ok := indices[hash] list, ok := indices[hash]
if !ok { if !ok {
continue // non-interesting blob continue // non-interesting blob
} }
var pf []kzg4844.Proof var pf []kzg4844.Proof
if !convert && sidecar.Version != version { if !convert && sidecar.Version != version {
return nil, nil, nil, fmt.Errorf("blob sidecar version mismatch: want %d, have %d", version, sidecar.Version) skip = true // blob sidecar version mismatch, skip but proceed
} } else {
switch version { switch version {
case types.BlobSidecarVersion0: case types.BlobSidecarVersion0:
if sidecar.Version == types.BlobSidecarVersion0 { if sidecar.Version == types.BlobSidecarVersion0 {
@ -1413,11 +1414,14 @@ func (p *BlobPool) GetBlobs(vhashes []common.Hash, version byte, convert bool) (
pf = cellProofs pf = cellProofs
} }
} }
if !skip {
for _, index := range list { for _, index := range list {
blobs[index] = &sidecar.Blobs[i] blobs[index] = &sidecar.Blobs[i]
commitments[index] = sidecar.Commitments[i] commitments[index] = sidecar.Commitments[i]
proofs[index] = pf proofs[index] = pf
} }
}
}
filled[hash] = struct{}{} filled[hash] = struct{}{}
} }
} }

View file

@ -423,11 +423,11 @@ func verifyBlobRetrievals(t *testing.T, pool *BlobPool) {
hashes = append(hashes, tx.vhashes...) hashes = append(hashes, tx.vhashes...)
} }
} }
blobs1, _, proofs1, err := pool.GetBlobs(hashes, types.BlobSidecarVersion0, true) blobs1, _, proofs1, err := pool.GetBlobs(hashes, types.BlobSidecarVersion0, false)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
blobs2, _, proofs2, err := pool.GetBlobs(hashes, types.BlobSidecarVersion1, true) blobs2, _, proofs2, err := pool.GetBlobs(hashes, types.BlobSidecarVersion1, false)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -441,22 +441,18 @@ func verifyBlobRetrievals(t *testing.T, pool *BlobPool) {
return return
} }
for i, hash := range hashes { for i, hash := range hashes {
// If an item is missing, but shouldn't, error // If an item is missing from both, but shouldn't, error
if blobs1[i] == nil || proofs1[i] == nil { if (blobs1[i] == nil || proofs1[i] == nil) && (blobs2[i] == nil || proofs2[i] == nil) {
t.Errorf("tracked blob retrieval failed: item %d, hash %x", i, hash)
continue
}
if blobs2[i] == nil || proofs2[i] == nil {
t.Errorf("tracked blob retrieval failed: item %d, hash %x", i, hash) t.Errorf("tracked blob retrieval failed: item %d, hash %x", i, hash)
continue continue
} }
// Item retrieved, make sure it matches the expectation // Item retrieved, make sure it matches the expectation
index := testBlobIndices[hash] index := testBlobIndices[hash]
if *blobs1[i] != *testBlobs[index] || proofs1[i][0] != testBlobProofs[index] { if blobs1[i] != nil && (*blobs1[i] != *testBlobs[index] || proofs1[i][0] != testBlobProofs[index]) {
t.Errorf("retrieved blob or proof mismatch: item %d, hash %x", i, hash) t.Errorf("retrieved blob or proof mismatch: item %d, hash %x", i, hash)
continue continue
} }
if *blobs2[i] != *testBlobs[index] || !slices.Equal(proofs2[i], testBlobCellProofs[index]) { if blobs2[i] != nil && (*blobs2[i] != *testBlobs[index] || !slices.Equal(proofs2[i], testBlobCellProofs[index])) {
t.Errorf("retrieved blob or proof mismatch: item %d, hash %x", i, hash) t.Errorf("retrieved blob or proof mismatch: item %d, hash %x", i, hash)
continue continue
} }

View file

@ -482,7 +482,7 @@ func (api *ConsensusAPI) GetBlobsV1(hashes []common.Hash) ([]*engine.BlobAndProo
if len(hashes) > 128 { if len(hashes) > 128 {
return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes))) return nil, engine.TooLargeRequest.With(fmt.Errorf("requested blob count too large: %v", len(hashes)))
} }
blobs, _, proofs, err := api.eth.BlobTxPool().GetBlobs(hashes, types.BlobSidecarVersion0, true) blobs, _, proofs, err := api.eth.BlobTxPool().GetBlobs(hashes, types.BlobSidecarVersion0, false)
if err != nil { if err != nil {
return nil, engine.InvalidParams.With(err) return nil, engine.InvalidParams.With(err)
} }
@ -542,7 +542,7 @@ func (api *ConsensusAPI) GetBlobsV2(hashes []common.Hash) ([]*engine.BlobAndProo
return nil, nil return nil, nil
} }
blobs, _, proofs, err := api.eth.BlobTxPool().GetBlobs(hashes, types.BlobSidecarVersion1, true) blobs, _, proofs, err := api.eth.BlobTxPool().GetBlobs(hashes, types.BlobSidecarVersion1, false)
if err != nil { if err != nil {
return nil, engine.InvalidParams.With(err) return nil, engine.InvalidParams.With(err)
} }