Skip to content

Commit

Permalink
Fix the bytes accounting at DA Node (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix authored Nov 29, 2023
1 parent 55fe65a commit 9c2c5be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions node/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/node/leveldb"
"github.com/Layr-Labs/eigenda/pkg/kzg/bn254"
"github.com/ethereum/go-ethereum/common/hexutil"
"google.golang.org/protobuf/proto"
)
Expand Down Expand Up @@ -132,21 +131,14 @@ func (s *Store) deleteNBatches(currentTimeUnixSec int64, numBatches int) (int, e
blobHeaderIter := s.db.NewIterator(EncodeBlobHeaderKeyPrefix(batchHeaderHash))
for blobHeaderIter.Next() {
expiredKeys = append(expiredKeys, copyBytes(blobHeaderIter.Key()))

// Collect the size in bytes for all the quorums of the blob.
var protoBlobHeader node.BlobHeader
if proto.Unmarshal(blobHeaderIter.Value(), &protoBlobHeader) == nil {
for _, qh := range protoBlobHeader.GetQuorumHeaders() {
size += int(qh.GetEncodedBlobLength() * bn254.BYTES_PER_COEFFICIENT)
}
}
}
blobHeaderIter.Release()

// Blob chunks.
blobIter := s.db.NewIterator(bytes.NewBuffer(hash).Bytes())
for blobIter.Next() {
expiredKeys = append(expiredKeys, copyBytes(blobIter.Key()))
size += len(blobIter.Value())
}
blobIter.Release()
}
Expand Down Expand Up @@ -256,12 +248,12 @@ func (s *Store) StoreBatch(ctx context.Context, header *core.BatchHeader, blobs
log.Error("Cannot serialize chunk:", "err", err)
return nil, err
}
size += chunk.Size()
}
chunkBytes, err := encodeChunks(bundleRaw)
if err != nil {
return nil, err
}
size += len(chunkBytes)

keys = append(keys, key)
values = append(values, chunkBytes)
Expand Down
2 changes: 1 addition & 1 deletion node/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func CreateBatch(t *testing.T) (*core.BatchHeader, []*core.BlobMessage, []*pb.Bl
}
chunk1 := &core.Chunk{
Proof: commitment,
Coeffs: []core.Symbol{},
Coeffs: []core.Symbol{bn254.ONE},
}

blobMessage := []*core.BlobMessage{
Expand Down

0 comments on commit 9c2c5be

Please sign in to comment.