Skip to content

Commit

Permalink
fix: offchain store in setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 16, 2024
1 parent 407ea88 commit cfc72f4
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 229 deletions.
22 changes: 4 additions & 18 deletions core/meterer/offchain_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,16 @@ func NewOffchainStore(
return OffchainStore{}, err
}

// fmt.Println("check if reservation exists", reservationTableName)
// err = dynamoClient.TableExists(context.Background(), reservationTableName)
// if err != nil {
// return OffchainStore{}, err
// }
// fmt.Println("check if ondemand exists", onDemandTableName)
// err = dynamoClient.TableExists(context.Background(), onDemandTableName)
// if err != nil {
// return OffchainStore{}, err
// }
// fmt.Println("check if global exists", globalBinTableName)
// err = dynamoClient.TableExists(context.Background(), globalBinTableName)
// if err != nil {
// return OffchainStore{}, err
// }
err = CreateReservationTable(cfg, reservationTableName)
fmt.Println("check if payment tables exist", reservationTableName)
err = dynamoClient.TableExists(context.Background(), reservationTableName)
if err != nil {
return OffchainStore{}, err
}
err = CreateOnDemandTable(cfg, onDemandTableName)
err = dynamoClient.TableExists(context.Background(), onDemandTableName)
if err != nil {
return OffchainStore{}, err
}
err = CreateGlobalReservationTable(cfg, globalBinTableName)
err = dynamoClient.TableExists(context.Background(), globalBinTableName)
if err != nil {
return OffchainStore{}, err
}
Expand Down
26 changes: 13 additions & 13 deletions inabox/deploy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ func (env *Config) generateDisperserV2Vars(ind int, logPath, dbPath, grpcPort st
DISPERSER_SERVER_DISPERSER_VERSION: "2",

DISPERSER_SERVER_ENABLE_PAYMENT_METERER: "true",
DISPERSER_SERVER_RESERVATIONS_TABLE_NAME: "e2e-v2-reservation",
DISPERSER_SERVER_ON_DEMAND_TABLE_NAME: "e2e-v2-ondemand",
DISPERSER_SERVER_GLOBAL_RATE_TABLE_NAME: "e2e-v2-global-reservation",
DISPERSER_SERVER_RESERVATIONS_TABLE_NAME: "e2e_v2_reservation",
DISPERSER_SERVER_ON_DEMAND_TABLE_NAME: "e2e_v2_ondemand",
DISPERSER_SERVER_GLOBAL_RATE_TABLE_NAME: "e2e_v2_global_reservation",
}

env.applyDefaults(&v, "DISPERSER_SERVER", "dis", ind)
Expand Down Expand Up @@ -714,17 +714,17 @@ func (env *Config) GenerateAllVariables() {
filename, []string{grpcPort})
}

// Disperser clients
for i := 0; i < 4; i++ {
name := fmt.Sprintf("client%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)

participant := DisperserClient{
Address: address,
PrivateKeyHex: key[2:],
}
env.DisperserClients = append(env.DisperserClients, participant)
}
// participant := DisperserClient{
// Address: address,
// PrivateKeyHex: key[2:],
// }
// env.DisperserClients = append(env.DisperserClients, participant)
// }

name = "retriever0"
key, _ = env.getKey(name)
Expand Down
16 changes: 8 additions & 8 deletions inabox/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -72,12 +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))
}
fmt.Println("------- clients -------", clients)
// // 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,
Expand All @@ -86,7 +86,7 @@ func (env *Config) generateEigenDADeployConfig() EigenDADeployConfig {
StakerPrivateKeys: stakers,
StakerTokenAmounts: stakes,
OperatorPrivateKeys: operators,
ClientPrivateKeys: clients,
// ClientPrivateKeys: clients,
ConfirmerPrivateKey: env.getKeyString("batcher0"),
}

Expand Down
89 changes: 15 additions & 74 deletions inabox/deploy/localstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,83 +143,24 @@ func DeployResources(
return err
}

// fmt.Println("Creating payment related tables ---- in localstack")
// // create payment related tables
// err = meterer.CreateReservationTable(cfg, v2MetadataTableName+"_reservation")
// if err != nil {
// fmt.Println("err", err)
// return err
// }
// err = meterer.CreateOnDemandTable(cfg, v2MetadataTableName+"_ondemand")
// if err != nil {
// fmt.Println("err", err)
// return err
// }
// err = meterer.CreateGlobalReservationTable(cfg, v2MetadataTableName+"_global_reservation")
// if err != nil {
// fmt.Println("err", err)
// return err
// }
}

return err

}

func DeployPaymentRelatedTables(
pool *dockertest.Pool,
localStackPort string,
) error {

if pool == nil {
var err error
pool, err = dockertest.NewPool("")
v2PaymentName := "e2e_v2"
fmt.Println("Creating payment related tables ---- in localstack")
// create payment related tables
err = meterer.CreateReservationTable(cfg, v2PaymentName+"_reservation")
if err != nil {
fmt.Println("Could not construct pool: %w", err)
fmt.Println("err", err)
return err
}
err = meterer.CreateOnDemandTable(cfg, v2PaymentName+"_ondemand")
if err != nil {
fmt.Println("err", err)
return err
}
err = meterer.CreateGlobalReservationTable(cfg, v2PaymentName+"_global_reservation")
if err != nil {
fmt.Println("err", err)
return err
}
}

// exponential backoff-retry, because the application in
// the container might not be ready to accept connections yet
pool.MaxWait = 10 * time.Second
_, b, _, _ := runtime.Caller(0)
rootPath := filepath.Join(filepath.Dir(b), "../..")
changeDirectory(filepath.Join(rootPath, "inabox"))
if err := pool.Retry(func() error {
fmt.Println("Creating S3 bucket")
return execCmd("./create-s3-bucket.sh", []string{}, []string{fmt.Sprintf("AWS_URL=http://0.0.0.0:%s", localStackPort)})
}); err != nil {
fmt.Println("Might be connected already:", err)
// return err
}

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 deploy hleper")

v2TableName := "test_v2"
fmt.Println("Creating payment related tables")
// create payment related tables
err := meterer.CreateReservationTable(cfg, v2TableName+"_reservation")
if err != nil {
fmt.Println("err", err)
return err
}
err = meterer.CreateOnDemandTable(cfg, v2TableName+"_ondemand")
if err != nil {
fmt.Println("err", err)
return err
}
err = meterer.CreateGlobalReservationTable(cfg, v2TableName+"_global_reservation")
if err != nil {
fmt.Println("err", err)
return err
}

return err
Expand Down
111 changes: 0 additions & 111 deletions inabox/tests/integration_payment_test.go

This file was deleted.

4 changes: 0 additions & 4 deletions inabox/tests/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ var _ = BeforeSuite(func() {
fmt.Println("Using in-memory Blob Store")
}

// fmt.Println("Making payment related tables....")
// err = deploy.DeployPaymentRelatedTables(pool, localStackPort)
// Expect(err).To(BeNil())

fmt.Println("Starting anvil")
testConfig.StartAnvil()

Expand Down
2 changes: 1 addition & 1 deletion inabox/tests/integration_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

var _ = Describe("Inabox v2 Integration", func() {
It("test end to end scenario", func() {
ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()

privateKeyHex := "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcded"
Expand Down

0 comments on commit cfc72f4

Please sign in to comment.