Skip to content

Commit

Permalink
Add scaling factor to encoded chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
pschork committed May 30, 2024
1 parent 6c0314d commit a2b84d3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion tools/batchgen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ proto:
protoc --go_out=. store_chunks.proto

run: build
./bin/batchgen localhost:32005
./bin/batchgen 10000 localhost:32005
49 changes: 29 additions & 20 deletions tools/batchgen/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -139,19 +148,19 @@ 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},
},
},
},
{
Header: blobHeaderProto1,
Bundles: []*pb.Bundle{
{
Chunks: [][]byte{encodedChunk},
Chunks: [][]byte{newEncodedChunk},
},
},
},
Expand Down

0 comments on commit a2b84d3

Please sign in to comment.