Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single DataAPI serving both v1 + v2 APIs #1046

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions disperser/cmd/dataapi/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type Config struct {
DisperserHostname string
ChurnerHostname string
BatcherHealthEndpt string

BlobMetadataV2TableName string
}

func NewConfig(ctx *cli.Context) (Config, error) {
Expand Down Expand Up @@ -77,10 +79,11 @@ func NewConfig(ctx *cli.Context) (Config, error) {
HTTPPort: ctx.GlobalString(flags.MetricsHTTPPort.Name),
EnableMetrics: ctx.GlobalBool(flags.EnableMetricsFlag.Name),
},
DisperserHostname: ctx.GlobalString(flags.DisperserHostnameFlag.Name),
ChurnerHostname: ctx.GlobalString(flags.ChurnerHostnameFlag.Name),
BatcherHealthEndpt: ctx.GlobalString(flags.BatcherHealthEndptFlag.Name),
ChainStateConfig: thegraph.ReadCLIConfig(ctx),
DisperserHostname: ctx.GlobalString(flags.DisperserHostnameFlag.Name),
ChurnerHostname: ctx.GlobalString(flags.ChurnerHostnameFlag.Name),
BatcherHealthEndpt: ctx.GlobalString(flags.BatcherHealthEndptFlag.Name),
ChainStateConfig: thegraph.ReadCLIConfig(ctx),
BlobMetadataV2TableName: ctx.GlobalString(flags.DynamoV2TableNameFlag.Name),
}
return config, nil
}
7 changes: 7 additions & 0 deletions disperser/cmd/dataapi/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ var (
Required: true,
EnvVar: common.PrefixEnvVar(envVarPrefix, "DYNAMO_TABLE_NAME"),
}
DynamoV2TableNameFlag = cli.StringFlag{
Name: common.PrefixFlag(FlagPrefix, "dynamo-v2-table-name"),
Usage: "Name of the dynamo table to store v2 blob metadata",
Required: true,
EnvVar: common.PrefixEnvVar(envVarPrefix, "DYNAMO_V2_TABLE_NAME"),
}
S3BucketNameFlag = cli.StringFlag{
Name: common.PrefixFlag(FlagPrefix, "s3-bucket-name"),
Usage: "Name of the bucket to store blobs",
Expand Down Expand Up @@ -143,6 +149,7 @@ var (

var requiredFlags = []cli.Flag{
DynamoTableNameFlag,
DynamoV2TableNameFlag,
SocketAddrFlag,
S3BucketNameFlag,
SubgraphApiBatchMetadataAddrFlag,
Expand Down
43 changes: 11 additions & 32 deletions disperser/cmd/dataapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,16 @@ func RunDataApi(ctx *cli.Context) error {
}

var (
promClient = dataapi.NewPrometheusClient(promApi, config.PrometheusConfig.Cluster)
blobMetadataStore = blobstore.NewBlobMetadataStore(dynamoClient, logger, config.BlobstoreConfig.TableName, 0)
sharedStorage = blobstore.NewSharedStorage(config.BlobstoreConfig.BucketName, s3Client, blobMetadataStore, logger)
subgraphApi = subgraph.NewApi(config.SubgraphApiBatchMetadataAddr, config.SubgraphApiOperatorStateAddr)
subgraphClient = dataapi.NewSubgraphClient(subgraphApi, logger)
chainState = coreeth.NewChainState(tx, client)
indexedChainState = thegraph.MakeIndexedChainState(config.ChainStateConfig, chainState, logger)
metrics = dataapi.NewMetrics(blobMetadataStore, config.MetricsConfig.HTTPPort, logger)
server = dataapi.NewServer(
promClient = dataapi.NewPrometheusClient(promApi, config.PrometheusConfig.Cluster)
blobMetadataStore = blobstore.NewBlobMetadataStore(dynamoClient, logger, config.BlobstoreConfig.TableName, 0)
blobMetadataStoreV2 = blobstorev2.NewBlobMetadataStore(dynamoClient, logger, config.BlobMetadataV2TableName)
sharedStorage = blobstore.NewSharedStorage(config.BlobstoreConfig.BucketName, s3Client, blobMetadataStore, logger)
subgraphApi = subgraph.NewApi(config.SubgraphApiBatchMetadataAddr, config.SubgraphApiOperatorStateAddr)
subgraphClient = dataapi.NewSubgraphClient(subgraphApi, logger)
chainState = coreeth.NewChainState(tx, client)
indexedChainState = thegraph.MakeIndexedChainState(config.ChainStateConfig, chainState, logger)
metrics = dataapi.NewMetrics(blobMetadataStore, config.MetricsConfig.HTTPPort, logger)
server = dataapi.NewServer(
dataapi.Config{
ServerMode: config.ServerMode,
SocketAddr: config.SocketAddr,
Expand All @@ -119,6 +120,7 @@ func RunDataApi(ctx *cli.Context) error {
nil,
nil,
nil,
blobMetadataStoreV2,
)
)

Expand All @@ -129,29 +131,6 @@ func RunDataApi(ctx *cli.Context) error {
logger.Info("Enabled metrics for Data Access API", "socket", httpSocket)
}

if config.ServerVersion == 2 {
blobMetadataStorev2 := blobstorev2.NewBlobMetadataStore(dynamoClient, logger, config.BlobstoreConfig.TableName)
serverv2 := dataapi.NewServerV2(
dataapi.Config{
ServerMode: config.ServerMode,
SocketAddr: config.SocketAddr,
AllowOrigins: config.AllowOrigins,
DisperserHostname: config.DisperserHostname,
ChurnerHostname: config.ChurnerHostname,
BatcherHealthEndpt: config.BatcherHealthEndpt,
},
blobMetadataStorev2,
promClient,
subgraphClient,
tx,
chainState,
indexedChainState,
logger,
metrics,
)
return runServer(serverv2, logger)
}

return runServer(server, logger)
}

Expand Down
Loading