Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Layr-Labs/eigenda into no…
Browse files Browse the repository at this point in the history
…debreakdown
  • Loading branch information
jianoaix committed May 8, 2024
2 parents 5ca7a18 + ea558f7 commit 9b94fb7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
23 changes: 16 additions & 7 deletions node/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,20 @@ func (s *Store) StoreBatch(ctx context.Context, header *core.BatchHeader, blobs
keys = append(keys, blobHeaderKey)
values = append(values, blobHeaderBytes)

// Get raw chunks
rawBlob := blobsProto[idx]
if len(rawBlob.GetBundles()) != len(blob.Bundles) {
return nil, errors.New("internal error: the number of bundles in parsed blob must be the same as in raw blob")
}
rawChunks := make(map[core.QuorumID][][]byte)
for i, chunks := range rawBlob.GetBundles() {
quorumID := uint8(rawBlob.GetHeader().GetQuorumHeaders()[i].GetQuorumId())
rawChunks[quorumID] = make([][]byte, len(chunks.GetChunks()))
for j, chunk := range chunks.GetChunks() {
rawChunks[quorumID][j] = chunk
}
}

// blob chunks
for quorumID, bundle := range blob.Bundles {
key, err := EncodeBlobKey(batchHeaderHash, idx, quorumID)
Expand All @@ -245,12 +259,8 @@ func (s *Store) StoreBatch(ctx context.Context, header *core.BatchHeader, blobs

start := time.Now()
bundleRaw := make([][]byte, len(bundle))
for i, chunk := range bundle {
bundleRaw[i], err = chunk.Serialize()
if err != nil {
log.Error("Cannot serialize chunk:", "err", err)
return nil, err
}
for i := 0; i < len(bundle); i++ {
bundleRaw[i] = rawChunks[quorumID][i]
}
serializationDuration += time.Since(start)
start = time.Now()
Expand All @@ -263,7 +273,6 @@ func (s *Store) StoreBatch(ctx context.Context, header *core.BatchHeader, blobs

keys = append(keys, key)
values = append(values, chunkBytes)

}
}

Expand Down
15 changes: 13 additions & 2 deletions node/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func CreateBatch(t *testing.T) (*core.BatchHeader, []*core.BlobMessage, []*pb.Bl
Proof: commitment,
Coeffs: []encoding.Symbol{encoding.ONE},
}
chunk1bytes, err := chunk1.Serialize()
assert.Nil(t, err)

blobMessage := []*core.BlobMessage{
{
Expand Down Expand Up @@ -163,12 +165,21 @@ func CreateBatch(t *testing.T) (*core.BatchHeader, []*core.BlobMessage, []*pb.Bl
Length: uint32(50),
QuorumHeaders: []*pb.BlobQuorumInfo{quorumHeaderProto},
}
bundles := []*pb.Bundle{
{
Chunks: [][]byte{
chunk1bytes,
},
},
}
blobs := []*pb.Blob{
{
Header: blobHeaderProto0,
Header: blobHeaderProto0,
Bundles: bundles,
},
{
Header: blobHeaderProto1,
Header: blobHeaderProto1,
Bundles: bundles,
},
}
return &batchHeader, blobMessage, blobs
Expand Down

0 comments on commit 9b94fb7

Please sign in to comment.