Skip to content

Commit ee05d3c

Browse files
committed
remove split blobs
1 parent 2c98c5d commit ee05d3c

2 files changed

Lines changed: 6 additions & 98 deletions

File tree

block/internal/da/fiber_client.go

Lines changed: 6 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package da
22

33
import (
44
"context"
5-
"encoding/binary"
65
"errors"
76
"fmt"
87
"sync"
@@ -253,21 +252,9 @@ loop:
253252
},
254253
}
255254
}
256-
split, splitErr := splitBlobs(blobData)
257-
if splitErr != nil {
258-
return datypes.ResultRetrieve{
259-
BaseResult: datypes.BaseResult{
260-
Code: datypes.StatusError,
261-
Message: fmt.Sprintf("fiber decode failed for blob %x: %v", blobID, splitErr),
262-
Height: height,
263-
Timestamp: time.Now(),
264-
},
265-
}
266-
}
267-
for _, b := range split {
268-
ids = append(ids, blobID)
269-
data = append(data, b)
270-
}
255+
256+
ids = append(ids, blobID)
257+
data = append(data, blobData)
271258
}
272259

273260
return datypes.ResultRetrieve{
@@ -294,11 +281,8 @@ func (c *fiberDAClient) Get(ctx context.Context, ids []datypes.ID, _ []byte) ([]
294281
if err != nil {
295282
return nil, fmt.Errorf("fiber download failed for blob %x: %w", id, err)
296283
}
297-
split, splitErr := splitBlobs(data)
298-
if splitErr != nil {
299-
return nil, fmt.Errorf("fiber decode failed for blob %x: %w", id, splitErr)
300-
}
301-
res = append(res, split...)
284+
285+
res = append(res, data)
302286
}
303287

304288
return res, nil
@@ -312,10 +296,6 @@ func (c *fiberDAClient) Subscribe(ctx context.Context, namespace []byte, _ bool)
312296
go func() {
313297
defer close(out)
314298

315-
// The outer DA Subscribe entry point does not expose a starting
316-
// height, so start from the live tip (fromHeight=0). A future
317-
// refactor that plumbs resume-from-height through datypes.DA can
318-
// thread the value here.
319299
blobCh, err := c.fiber.Listen(ctx, namespace[len(namespace)-10:], c.lastKnownDAHeight)
320300
if err != nil {
321301
c.logger.Error().Err(err).Msg("fiber listen failed")
@@ -337,17 +317,11 @@ func (c *fiberDAClient) Subscribe(ctx context.Context, namespace []byte, _ bool)
337317
continue
338318
}
339319

340-
split, splitErr := splitBlobs(blobData)
341-
if splitErr != nil {
342-
c.logger.Error().Err(splitErr).Bytes("blob_id", event.BlobID).Msg("failed to decode blob")
343-
continue
344-
}
345-
346320
select {
347321
case out <- datypes.SubscriptionEvent{
348322
Height: event.Height,
349323
Timestamp: time.Now(),
350-
Blobs: split,
324+
Blobs: [][]byte{blobData},
351325
}:
352326
case <-ctx.Done():
353327
return
@@ -398,48 +372,6 @@ func (c *fiberDAClient) Validate(_ context.Context, ids []datypes.ID, proofs []d
398372
func (c *fiberDAClient) GetHeaderNamespace() []byte { return c.namespaceBz }
399373
func (c *fiberDAClient) GetDataNamespace() []byte { return c.dataNamespaceBz }
400374

401-
// splitBlobs decodes the legacy "count + per-item length" framing that
402-
// the previous Submit path used to pack multiple blobs into a single
403-
// Upload. The per-item-concurrent Submit path no longer writes that
404-
// framing — each item is uploaded raw — so any blob written by this
405-
// branch's Submit will fail to decode here.
406-
//
407-
// Callers (Retrieve / RetrieveBlobs / Get / Subscribe) therefore only
408-
// work for blobs written by the OLD code path, OR for the multi-item
409-
// header batches that still use it. Pair the format change with a
410-
// matching update to the read path before any node on this branch
411-
// tries to sync from another node on this branch.
412-
//
413-
// Tracked alongside the wire-format TODO on Submit (above).
414-
func splitBlobs(data []byte) ([][]byte, error) {
415-
if len(data) == 0 {
416-
return nil, nil
417-
}
418-
if len(data) < 4 {
419-
return nil, fmt.Errorf("invalid blob encoding: header too short")
420-
}
421-
422-
count := int(binary.BigEndian.Uint32(data))
423-
off := 4
424-
blobs := make([][]byte, 0, count)
425-
for i := range count {
426-
if off+4 > len(data) {
427-
return nil, fmt.Errorf("invalid blob encoding: truncated length at index %d", i)
428-
}
429-
size := int(binary.BigEndian.Uint32(data[off:]))
430-
off += 4
431-
end := off + size
432-
if end < off || end > len(data) {
433-
return nil, fmt.Errorf("invalid blob encoding: truncated data at index %d", i)
434-
}
435-
blob := make([]byte, size)
436-
copy(blob, data[off:end])
437-
off = end
438-
blobs = append(blobs, blob)
439-
}
440-
return blobs, nil
441-
}
442-
443375
// Force Inclusion is disabled for Fiber PoC.
444376
func (c *fiberDAClient) HasForcedInclusionNamespace() bool { return false }
445377
func (c *fiberDAClient) GetForcedInclusionNamespace() []byte { return nil }

block/internal/da/fiber_client_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -479,27 +479,3 @@ func (f *failOnNthUpload) Upload(ctx context.Context, namespace, data []byte) (f
479479
}
480480
return f.FiberClient.Upload(ctx, namespace, data)
481481
}
482-
483-
func TestSplitBlobs_Empty(t *testing.T) {
484-
got, err := splitBlobs(nil)
485-
require.NoError(t, err)
486-
require.Nil(t, got)
487-
488-
got, err = splitBlobs([]byte{})
489-
require.NoError(t, err)
490-
require.Nil(t, got)
491-
}
492-
493-
func TestSplitBlobs_Truncated(t *testing.T) {
494-
_, err := splitBlobs([]byte{0x01})
495-
require.Error(t, err)
496-
497-
_, err = splitBlobs([]byte{0x00, 0x00, 0x00, 0x01, 0x00, 0x00})
498-
require.Error(t, err)
499-
}
500-
501-
func TestSplitBlobs_CountMismatch(t *testing.T) {
502-
data := []byte{0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x41}
503-
_, err := splitBlobs(data)
504-
require.Error(t, err)
505-
}

0 commit comments

Comments
 (0)