diff --git a/inabox/deploy/config.go b/inabox/deploy/config.go index 49cc448a4..53a3ed121 100644 --- a/inabox/deploy/config.go +++ b/inabox/deploy/config.go @@ -692,7 +692,7 @@ func (env *Config) GenerateAllVariables() { name := fmt.Sprintf("staker%v", i) key, address := env.getKey(name) - // Create staker paritipants + // Create client paritipants participant := Staker{ Address: address, PrivateKey: key[2:], @@ -714,19 +714,17 @@ func (env *Config) GenerateAllVariables() { filename, []string{grpcPort}) } - // // Payment clients - // for i := 0; i < env.Services.Counts.NumOpr; i++ { - - // name := fmt.Sprintf("staker%v", i) - // key, address := env.getKey(name) + // Disperser clients + for i := 0; i < 4; i++ { + name := fmt.Sprintf("client%v", i) + key, address := env.getKey(name) - // // Create staker paritipants - // participant := Staker{ - // Address: address, - // PrivateKey: key[2:], - // } - // env.Stakers = append(env.Stakers, participant) - // } + participant := DisperserClient{ + Address: address, + PrivateKeyHex: key[2:], + } + env.DisperserClients = append(env.DisperserClients, participant) + } name = "retriever0" key, _ = env.getKey(name) diff --git a/inabox/deploy/config_types.go b/inabox/deploy/config_types.go index 314976cb3..0f98b863b 100644 --- a/inabox/deploy/config_types.go +++ b/inabox/deploy/config_types.go @@ -16,6 +16,11 @@ type Staker struct { Stake string `json:"stake"` } +type DisperserClient struct { + Address string `json:"address"` + PrivateKeyHex string `json:"privateKeyHex"` +} + // Docker compose type testbed struct { Services map[string]map[string]interface{} `yaml:"services"` @@ -174,15 +179,16 @@ type Config struct { Telemetry TelemetryConfig `yaml:"telemetry"` - Churner ChurnerVars - Dispersers []DisperserVars - Batcher []BatcherVars - Encoder []EncoderVars - Operators []OperatorVars - Stakers []Staker - Retriever RetrieverVars - Controller ControllerVars - Relays []RelayVars + Churner ChurnerVars + Dispersers []DisperserVars + Batcher []BatcherVars + Encoder []EncoderVars + Operators []OperatorVars + Stakers []Staker + Retriever RetrieverVars + Controller ControllerVars + Relays []RelayVars + DisperserClients []DisperserClient } func (c Config) IsEigenDADeployed() bool { diff --git a/inabox/deploy/deploy.go b/inabox/deploy/deploy.go index cd252ce50..902474de2 100644 --- a/inabox/deploy/deploy.go +++ b/inabox/deploy/deploy.go @@ -44,7 +44,7 @@ func (env *Config) generateEigenDADeployConfig() EigenDADeployConfig { operators := make([]string, 0) stakers := make([]string, 0) - // clients := make([]string, 0) + clients := make([]string, 0) maxOperatorCount := env.Services.Counts.NumMaxOperatorCount numStrategies := len(env.Services.Stakes) @@ -72,11 +72,12 @@ func (env *Config) generateEigenDADeployConfig() EigenDADeployConfig { operators = append(operators, env.getKeyString(operatorName)) } - // // 4 clients: with both, with reservations, with on-demand payments, without payments - // for i := 0; i < 4; i++ { - // clientName := fmt.Sprintf("client%d", i) - // clients = append(clients, env.getKeyString(clientName)) - // } + // 4 clients: with both, with reservations, with on-demand payments, without payments + for i := 0; i < 4; i++ { + clientName := fmt.Sprintf("client%d", i) + clients = append(clients, env.getKeyString(clientName)) + } + fmt.Println("------- clients -------", clients) config := EigenDADeployConfig{ UseDefaults: true, @@ -85,7 +86,7 @@ func (env *Config) generateEigenDADeployConfig() EigenDADeployConfig { StakerPrivateKeys: stakers, StakerTokenAmounts: stakes, OperatorPrivateKeys: operators, - // ClientPrivateKeys: clients, + ClientPrivateKeys: clients, ConfirmerPrivateKey: env.getKeyString("batcher0"), } diff --git a/inabox/tests/integration_payment_test.go b/inabox/tests/integration_payment_test.go new file mode 100644 index 000000000..53a884e1c --- /dev/null +++ b/inabox/tests/integration_payment_test.go @@ -0,0 +1,111 @@ +package integration_test + +import ( + "context" + "crypto/rand" + "fmt" + "time" + + "github.com/Layr-Labs/eigenda/api/clients/v2" + auth "github.com/Layr-Labs/eigenda/core/auth/v2" + "github.com/Layr-Labs/eigenda/encoding/utils/codec" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("Inabox v2 Integration - Payment", func() { + It("test reserved payment only scenario", func() { + ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second) + defer cancel() + + privateKeyHex := "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdee" + signer := auth.NewLocalBlobRequestSigner(privateKeyHex) + + accountID, err := signer.GetAccountID() + fmt.Println("accountID", accountID) + Expect(err).To(BeNil()) + + disp, err := clients.NewDisperserClient(&clients.DisperserClientConfig{ + Hostname: "localhost", + Port: "32005", + }, signer, nil, nil) + Expect(err).To(BeNil()) + Expect(disp).To(Not(BeNil())) + err = disp.PopulateAccountant(ctx) + Expect(err).To(BeNil()) + + data1 := make([]byte, 992) + _, err = rand.Read(data1) + Expect(err).To(BeNil()) + data2 := make([]byte, 123) + _, err = rand.Read(data2) + Expect(err).To(BeNil()) + + paddedData1 := codec.ConvertByPaddingEmptyByte(data1) + + blobStatus1, key1, err := disp.DisperseBlob(ctx, paddedData1, 0, []uint8{0, 1}, 0) + Expect(err).To(Not(BeNil())) + Expect(key1).To(BeNil()) + Expect(blobStatus1).To(BeNil()) + }) + It("test ondemand payment only scenario", func() { + ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second) + defer cancel() + + privateKeyHex := "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdee" + signer := auth.NewLocalBlobRequestSigner(privateKeyHex) + + disp, err := clients.NewDisperserClient(&clients.DisperserClientConfig{ + Hostname: "localhost", + Port: "32005", + }, signer, nil, nil) + Expect(err).To(BeNil()) + Expect(disp).To(Not(BeNil())) + err = disp.PopulateAccountant(ctx) + Expect(err).To(BeNil()) + + data1 := make([]byte, 992) + _, err = rand.Read(data1) + Expect(err).To(BeNil()) + data2 := make([]byte, 123) + _, err = rand.Read(data2) + Expect(err).To(BeNil()) + + paddedData1 := codec.ConvertByPaddingEmptyByte(data1) + + blobStatus1, key1, err := disp.DisperseBlob(ctx, paddedData1, 0, []uint8{0, 1}, 0) + Expect(err).To(Not(BeNil())) + Expect(key1).To(BeNil()) + Expect(blobStatus1).To(BeNil()) + }) + It("test failing payment scenario", func() { + ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second) + defer cancel() + + privateKeyHex := "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdee" + signer := auth.NewLocalBlobRequestSigner(privateKeyHex) + + disp, err := clients.NewDisperserClient(&clients.DisperserClientConfig{ + Hostname: "localhost", + Port: "32005", + }, signer, nil, nil) + Expect(err).To(BeNil()) + Expect(disp).To(Not(BeNil())) + err = disp.PopulateAccountant(ctx) + Expect(err).To(BeNil()) + + data1 := make([]byte, 992) + _, err = rand.Read(data1) + Expect(err).To(BeNil()) + data2 := make([]byte, 123) + _, err = rand.Read(data2) + Expect(err).To(BeNil()) + + paddedData1 := codec.ConvertByPaddingEmptyByte(data1) + + blobStatus1, key1, err := disp.DisperseBlob(ctx, paddedData1, 0, []uint8{0, 1}, 0) + Expect(err).To(Not(BeNil())) + Expect(key1).To(BeNil()) + Expect(blobStatus1).To(BeNil()) + }) +}) diff --git a/inabox/tests/integration_v2_test.go b/inabox/tests/integration_v2_test.go index a199d7312..dcae3b61f 100644 --- a/inabox/tests/integration_v2_test.go +++ b/inabox/tests/integration_v2_test.go @@ -25,61 +25,12 @@ var _ = Describe("Inabox v2 Integration", func() { ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second) defer cancel() - // cfg := aws.ClientConfig{ - // Region: "us-east-1", - // AccessKey: "localstack", - // SecretAccessKey: "localstack", - // EndpointURL: fmt.Sprintf("http://0.0.0.0:%s", localStackPort), - // } - - // fmt.Println("Creating v2 tables IN integration_v2_test.go") - // fmt.Println("Creating payment related tables v2") - // // create payment related tables - // err := meterer.CreateReservationTable(cfg, "e2e-v2-reservation") - // fmt.Println("err", err) - // Expect(err).To(BeNil()) - - // err = meterer.CreateOnDemandTable(cfg, "e2e-v2-ondemand") - // fmt.Println("err", err) - // Expect(err).To(BeNil()) - // err = meterer.CreateGlobalReservationTable(cfg, "e2e-v2-global-reservation") - // fmt.Println("err", err) - // Expect(err).To(BeNil()) - // fmt.Println("offchain store dynamodb created") - privateKeyHex := "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcded" signer := auth.NewLocalBlobRequestSigner(privateKeyHex) - // reserved := core.ReservedPayment{ - // SymbolsPerSecond: 452198, - // StartTimestamp: 1734305428, - // EndTimestamp: 2734305428, - // QuorumNumbers: []uint8{0, 1}, - // QuorumSplits: []uint8{50, 50}, - // } - - // accountId, err := signer.GetAccountID() - // Expect(err).To(BeNil()) - - // // // Get public key - // // publicKey := privateKey.Public() - // // publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) - // // Expect(ok) - // // address := crypto.PubkeyToAddress(*publicKeyECDSA) - // fmt.Println("address", accountId) - - // onDemand := core.OnDemandPayment{CumulativePayment: big.NewInt(100000)} - // reservationWindow := 60 - // pricePerSymbol := 47000000 - // minNumSymbols := 8192 - // numBins := 3 - - // accountant := clients.NewAccountant(accountId, &reserved, &onDemand, uint32(reservationWindow), uint32(pricePerSymbol), uint32(minNumSymbols), uint32(numBins)) - disp, err := clients.NewDisperserClient(&clients.DisperserClientConfig{ Hostname: "localhost", Port: "32005", - // }, signer, nil, accountant) }, signer, nil, nil) Expect(err).To(BeNil()) Expect(disp).To(Not(BeNil()))