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

feat: eigenda codebase and wvm code integration #7

Draft
wants to merge 2 commits into
base: main
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
1 change: 1 addition & 0 deletions flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
S3Category = "S3 Cache/Fallback"
VerifierCategory = "KZG and Cert Verifier"
VerifierDeprecatedCategory = "DEPRECATED VERIFIER FLAGS -- THESE WILL BE REMOVED IN V2.0.0"
WVMCategory = "WVM Storage option"
)

const (
Expand Down
2 changes: 2 additions & 0 deletions server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/Layr-Labs/eigenda-proxy/store/generated_key/memstore"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/redis"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/s3"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/wvm"
"github.com/Layr-Labs/eigenda-proxy/utils"
"github.com/Layr-Labs/eigenda-proxy/verify"
"github.com/Layr-Labs/eigenda/api/clients"
Expand All @@ -33,6 +34,7 @@ type Config struct {
// secondary storage
RedisConfig redis.Config
S3Config s3.Config
WVMConfig wvm.Config
}

// ReadConfig ... parses the Config from the provided flags or environment variables.
Expand Down
27 changes: 24 additions & 3 deletions server/load_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/Layr-Labs/eigenda-proxy/store/generated_key/memstore"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/redis"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/s3"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/wvm"
"github.com/Layr-Labs/eigenda-proxy/verify"
"github.com/Layr-Labs/eigenda/api/clients"
"github.com/ethereum/go-ethereum/log"
Expand All @@ -18,7 +19,9 @@ import (
// TODO - create structured abstraction for dependency injection vs. overloading stateless functions

// populateTargets ... creates a list of storage backends based on the provided target strings
func populateTargets(targets []string, s3 store.PrecomputedKeyStore, redis *redis.Store) []store.PrecomputedKeyStore {
func populateTargets(targets []string, s3 store.PrecomputedKeyStore,
redis *redis.Store, wvm store.PrecomputedKeyStore,
) []store.PrecomputedKeyStore {
stores := make([]store.PrecomputedKeyStore, len(targets))

for i, f := range targets {
Expand All @@ -37,6 +40,12 @@ func populateTargets(targets []string, s3 store.PrecomputedKeyStore, redis *redi
}
stores[i] = s3

case store.WVMBackendType:
if wvm == nil {
panic(fmt.Sprintf("S3 backend is not configured but specified in targets: %s", f))
}
stores[i] = wvm

case store.EigenDABackendType, store.MemoryBackendType:
panic(fmt.Sprintf("Invalid target for fallback: %s", f))

Expand All @@ -56,6 +65,8 @@ func LoadStoreManager(ctx context.Context, cfg CLIConfig, log log.Logger, m metr
// create S3 backend store (if enabled)
var err error
var s3Store store.PrecomputedKeyStore
// create WVM backend store (if enabled)
var wvmStore store.PrecomputedKeyStore
var redisStore *redis.Store

if cfg.EigenDAConfig.S3Config.Bucket != "" && cfg.EigenDAConfig.S3Config.Endpoint != "" {
Expand All @@ -66,6 +77,16 @@ func LoadStoreManager(ctx context.Context, cfg CLIConfig, log log.Logger, m metr
}
}

if cfg.EigenDAConfig.WVMConfig.Enabled {
if cfg.EigenDAConfig.WVMConfig.Endpoint != "" {
log.Info("Using WVM backend")
wvmStore, err = wvm.NewStore(&cfg.EigenDAConfig.WVMConfig, log)
if err != nil {
return nil, fmt.Errorf("failed to create WVM store: %w", err)
}
}
}

if cfg.EigenDAConfig.RedisConfig.Endpoint != "" {
log.Info("Using Redis backend")
// create Redis backend store
Expand Down Expand Up @@ -120,8 +141,8 @@ func LoadStoreManager(ctx context.Context, cfg CLIConfig, log log.Logger, m metr
}

// create secondary storage router
fallbacks := populateTargets(cfg.EigenDAConfig.FallbackTargets, s3Store, redisStore)
caches := populateTargets(cfg.EigenDAConfig.CacheTargets, s3Store, redisStore)
fallbacks := populateTargets(cfg.EigenDAConfig.FallbackTargets, s3Store, redisStore, wvmStore)
caches := populateTargets(cfg.EigenDAConfig.CacheTargets, s3Store, redisStore, wvmStore)
secondary := store.NewSecondaryManager(log, m, caches, fallbacks)

if secondary.Enabled() { // only spin-up go routines if secondary storage is enabled
Expand Down
61 changes: 61 additions & 0 deletions store/precomputed_key/wvm/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package wvm

import (
"github.com/urfave/cli/v2"
)

var (
EndpointFlagName = withFlagPrefix("endpoint")
ChainIDFlagName = withFlagPrefix("chain_id")
ArchiverAddressFlagName = withFlagPrefix("archiver_address")
TimeoutFlagName = withFlagPrefix("timeout")
)

func withFlagPrefix(s string) string {
return "wvm." + s
}

func withEnvPrefix(envPrefix, s string) []string {
return []string{envPrefix + "_WVM_" + s}
}

// CLIFlags ... used for WVM backend configuration
// category is used to group the flags in the help output (see https://cli.urfave.org/v2/examples/flags/#grouping)
func CLIFlags(envPrefix, category string) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: EndpointFlagName,
Usage: "endpoint for WVM chain rpc",
EnvVars: withEnvPrefix(envPrefix, "ENDPOINT"),
Category: category,
},
&cli.StringFlag{
Name: ChainIDFlagName,
Usage: "chain ID of WVM chain",
EnvVars: withEnvPrefix(envPrefix, "CHAIN_ID"),
Category: category,
},
&cli.StringFlag{
Name: ArchiverAddressFlagName,
Usage: "user's wvm chain address used for archiving data",
EnvVars: withEnvPrefix(envPrefix, "ARCHIVER_ADDRESS"),
Category: category,
},
// &cli.DurationFlag{
// Name: TimeoutFlagName,
// Usage: "timeout for S3 storage operations (e.g. get, put)",
// Value: 5 * time.Second,
// EnvVars: withEnvPrefix(envPrefix, "TIMEOUT"),
// Category: category,
// },
}
}

func ReadConfig(ctx *cli.Context) Config {
return Config{
Endpoint: ctx.String(EndpointFlagName),
ChainID: ctx.Int64(ChainIDFlagName),
ArchiverAddress: ctx.String(ArchiverAddressFlagName),
// Timeout: ctx.Duration(TimeoutFlagName),
}
}
Loading
Loading