From 8b859f71dfe46142a7fa9b139ee8756f246373e4 Mon Sep 17 00:00:00 2001 From: Jian Xiao Date: Wed, 29 Nov 2023 18:13:27 +0000 Subject: [PATCH] Fix the bytes accounting at DA Node --- node/store.go | 12 ++---------- node/store_test.go | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/node/store.go b/node/store.go index ceb5d16aa..4eb52ed01 100644 --- a/node/store.go +++ b/node/store.go @@ -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" ) @@ -132,14 +131,6 @@ 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() @@ -147,6 +138,7 @@ func (s *Store) deleteNBatches(currentTimeUnixSec int64, numBatches int) (int, e blobIter := s.db.NewIterator(bytes.NewBuffer(hash).Bytes()) for blobIter.Next() { expiredKeys = append(expiredKeys, copyBytes(blobIter.Key())) + size += len(blobIter.Value()) } blobIter.Release() } @@ -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) diff --git a/node/store_test.go b/node/store_test.go index c55436341..b6e867fee 100644 --- a/node/store_test.go +++ b/node/store_test.go @@ -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{