From a2b84d32b0a72051ec813f0130140031d177b6d1 Mon Sep 17 00:00:00 2001 From: Patrick Schork <354473+pschork@users.noreply.github.com> Date: Wed, 29 May 2024 17:39:57 -0700 Subject: [PATCH] Add scaling factor to encoded chunk --- tools/batchgen/Makefile | 2 +- tools/batchgen/cmd/main.go | 49 ++++++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/tools/batchgen/Makefile b/tools/batchgen/Makefile index ccb9b06290..382e3fc5e4 100644 --- a/tools/batchgen/Makefile +++ b/tools/batchgen/Makefile @@ -9,4 +9,4 @@ proto: protoc --go_out=. store_chunks.proto run: build - ./bin/batchgen localhost:32005 + ./bin/batchgen 10000 localhost:32005 diff --git a/tools/batchgen/cmd/main.go b/tools/batchgen/cmd/main.go index 33c3658dbe..ae580d3311 100644 --- a/tools/batchgen/cmd/main.go +++ b/tools/batchgen/cmd/main.go @@ -4,9 +4,7 @@ import ( "context" "log" "os" - - //"errors" - //"time" + "strconv" commonpb "github.com/Layr-Labs/eigenda/api/grpc/common" pb "github.com/Layr-Labs/eigenda/api/grpc/node" @@ -25,32 +23,43 @@ var ( ) func main() { - req, _, _, _, _ := makeStoreChunksRequest(100, 10) + factor, err := strconv.Atoi(os.Args[1]) + if err != nil { + log.Println("failed to convert factor to int:", err) + return + } + req, _, _, _, _ := makeStoreChunksRequest(100, 10, factor) - host := os.Args[1] - log.Println("Connecting to operator", "operator", host) + host := os.Args[2] conn, err := grpc.Dial(host, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { - log.Println("Batchgen cannot connect to operator dispersal socket", "dispersal_socket", host, "err", err) + log.Println("failed to dial", host, "err", err) return } defer conn.Close() client := pb.NewDispersalClient(conn) - //opt := grpc.MaxCallSendMsgSize(60 * 1024 * 1024 * 1024) - - log.Println("sending chunks to operator", "operator", host, "request message size", proto.Size(req)) - reply, err := client.StoreChunks(context.Background(), req) + opt := grpc.MaxCallSendMsgSize(60 * 1024 * 1024 * 1024) + log.Println("sending chunks to operator", host, "request message size", proto.Size(req)) + reply, err := client.StoreChunks(context.Background(), req, opt) if err != nil { - log.Println("Reply err", err) - return + log.Println("reply", err) } - log.Println("Reply", reply) - log.Println("Signature", reply.GetSignature()) + log.Println("reply", reply) + log.Println("signature", reply.GetSignature()) } -func makeStoreChunksRequest(quorumThreshold, adversaryThreshold uint8) (*pb.StoreChunksRequest, [32]byte, [32]byte, []*core.BlobHeader, []*pb.BlobHeader) { +func makeStoreChunksRequest(quorumThreshold, adversaryThreshold uint8, factor int) (*pb.StoreChunksRequest, [32]byte, [32]byte, []*core.BlobHeader, []*pb.BlobHeader) { + // Create a new slice with the required length + newSize := len(encodedChunk) * factor + newEncodedChunk := make([]byte, newSize) + + // Fill the new slice with repeated data from the original slice + for i := 0; i < factor; i++ { + copy(newEncodedChunk[i*len(encodedChunk):], encodedChunk) + } + var commitX, commitY fp.Element _, err := commitX.SetString("21661178944771197726808973281966770251114553549453983978976194544185382599016") if err != nil { @@ -139,11 +148,11 @@ func makeStoreChunksRequest(quorumThreshold, adversaryThreshold uint8) (*pb.Stor Header: blobHeaderProto0, Bundles: []*pb.Bundle{ { - Chunks: [][]byte{encodedChunk}, + Chunks: [][]byte{newEncodedChunk}, }, { - // Empty bundle for the second quorum - Chunks: [][]byte{}, + // second quorum + Chunks: [][]byte{newEncodedChunk}, }, }, }, @@ -151,7 +160,7 @@ func makeStoreChunksRequest(quorumThreshold, adversaryThreshold uint8) (*pb.Stor Header: blobHeaderProto1, Bundles: []*pb.Bundle{ { - Chunks: [][]byte{encodedChunk}, + Chunks: [][]byte{newEncodedChunk}, }, }, },