Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
Also added WaitForFinalization eigenda flag
  • Loading branch information
samlaf committed Sep 23, 2024
1 parent 34fd364 commit f424c1e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
11 changes: 10 additions & 1 deletion flags/eigenda_flags/cli.go → flags/eigendaflags/cli.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eigenda_flags
package eigendaflags

import (
"time"
Expand All @@ -20,6 +20,7 @@ var (
SignerPrivateKeyHexFlagName = withFlagPrefix("signer-private-key-hex")
PutBlobEncodingVersionFlagName = withFlagPrefix("put-blob-encoding-version")
DisablePointVerificationModeFlagName = withFlagPrefix("disable-point-verification-mode")
WaitForFinalizationFlagName = withFlagPrefix("wait-for-finalization")
)

func withFlagPrefix(s string) string {
Expand Down Expand Up @@ -94,6 +95,13 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
Value: false,
Category: category,
},
&cli.BoolFlag{
Name: WaitForFinalizationFlagName,
Usage: "Wait for blob finalization before returning from PutBlob.",
EnvVars: withEnvPrefix(envPrefix, "WAIT_FOR_FINALIZATION"),
Value: false,
Category: category,
},
}
}

Expand All @@ -108,5 +116,6 @@ func ReadConfig(ctx *cli.Context) clients.EigenDAClientConfig {
SignerPrivateKeyHex: ctx.String(SignerPrivateKeyHexFlagName),
PutBlobEncodingVersion: codecs.BlobEncodingVersion(ctx.Uint(PutBlobEncodingVersionFlagName)),
DisablePointVerificationMode: ctx.Bool(DisablePointVerificationModeFlagName),
WaitForFinalization: ctx.Bool(WaitForFinalizationFlagName),
}
}
4 changes: 2 additions & 2 deletions flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package flags
import (
"time"

"github.com/Layr-Labs/eigenda-proxy/flags/eigenda_flags"
"github.com/Layr-Labs/eigenda-proxy/flags/eigendaflags"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/redis"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/s3"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -107,7 +107,7 @@ func init() {
Flags = CLIFlags()
Flags = append(Flags, oplog.CLIFlags(EnvVarPrefix)...)
Flags = append(Flags, opmetrics.CLIFlags(EnvVarPrefix)...)
Flags = append(Flags, eigenda_flags.CLIFlags(EnvVarPrefix, EigenDAClientCategory)...)
Flags = append(Flags, eigendaflags.CLIFlags(EnvVarPrefix, EigenDAClientCategory)...)
Flags = append(Flags, redis.CLIFlags(EnvVarPrefix, RedisCategory)...)
Flags = append(Flags, s3.CLIFlags(EnvVarPrefix, S3Category)...)
}
18 changes: 3 additions & 15 deletions server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/urfave/cli/v2"

"github.com/Layr-Labs/eigenda-proxy/flags"
"github.com/Layr-Labs/eigenda-proxy/flags/eigenda_flags"
"github.com/Layr-Labs/eigenda-proxy/flags/eigendaflags"
"github.com/Layr-Labs/eigenda-proxy/store"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/redis"
"github.com/Layr-Labs/eigenda-proxy/store/precomputed_key/s3"
Expand Down Expand Up @@ -44,10 +44,10 @@ type Config struct {

// ReadConfig ... parses the Config from the provided flags or environment variables.
func ReadConfig(ctx *cli.Context) Config {
cfg := Config{
return Config{
RedisConfig: redis.ReadConfig(ctx),
S3Config: s3.ReadConfig(ctx),
EdaClientConfig: eigenda_flags.ReadConfig(ctx),
EdaClientConfig: eigendaflags.ReadConfig(ctx),
VerifierConfig: verify.ReadConfig(ctx),
MemstoreEnabled: ctx.Bool(flags.MemstoreFlagName),
MemstoreBlobExpiration: ctx.Duration(flags.MemstoreExpirationFlagName),
Expand All @@ -56,17 +56,6 @@ func ReadConfig(ctx *cli.Context) Config {
FallbackTargets: ctx.StringSlice(flags.FallbackTargetsFlagName),
CacheTargets: ctx.StringSlice(flags.CacheTargetsFlagName),
}
// the eigenda client can only wait for 0 confirmations or finality
// the da-proxy has a more fine-grained notion of confirmation depth
// we use -1 to let the da client wait for finality, and then need to set the confirmation depth
// for the da-proxy to 0 (because negative confirmation depth doesn't mean anything and leads to errors)
// TODO: should the eigenda-client implement this feature for us instead?
if cfg.VerifierConfig.EthConfirmationDepth < 0 {
cfg.EdaClientConfig.WaitForFinalization = true
cfg.VerifierConfig.EthConfirmationDepth = 0
}

return cfg
}

// checkTargets ... verifies that a backend target slice is constructed correctly
Expand All @@ -90,7 +79,6 @@ func (cfg *Config) checkTargets(targets []string) error {

// Check ... verifies that configuration values are adequately set
func (cfg *Config) Check() error {

if !cfg.MemstoreEnabled {
if cfg.EdaClientConfig.RPC == "" {
return fmt.Errorf("using eigenda backend (memstore.enabled=false) but eigenda disperser rpc url is not set")
Expand Down
2 changes: 1 addition & 1 deletion server/load_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func LoadStoreRouter(ctx context.Context, cfg CLIConfig, log log.Logger) (store.
log,
&eigenda.StoreConfig{
MaxBlobSizeBytes: verify.MaxBlobLengthBytes,
EthConfirmationDepth: uint64(cfg.EigenDAConfig.VerifierConfig.EthConfirmationDepth), // #nosec G115
EthConfirmationDepth: cfg.EigenDAConfig.VerifierConfig.EthConfirmationDepth,
StatusQueryTimeout: cfg.EigenDAConfig.EdaClientConfig.StatusQueryTimeout,
},
)
Expand Down
8 changes: 4 additions & 4 deletions verify/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
EnvVars: withEnvPrefix(envPrefix, "SERVICE_MANAGER_ADDR"),
Category: category,
},
&cli.Int64Flag{
&cli.Uint64Flag{
Name: EthConfirmationDepthFlagName,
Usage: "The number of Ethereum blocks to wait before considering a submitted blob's DA batch submission confirmed. `0` means wait for inclusion only. `-1` means wait for finality.",
Usage: "The number of Ethereum blocks to wait before considering a submitted blob's DA batch submission confirmed. `0` means wait for inclusion only.",
EnvVars: withEnvPrefix(envPrefix, "ETH_CONFIRMATION_DEPTH"),
Value: -1,
Value: 0,
Category: category,
},
// kzg flags
Expand Down Expand Up @@ -105,7 +105,7 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
Usage: "Maximum blob length to be written or read from EigenDA. Determines the number of SRS points loaded into memory for KZG commitments. Example units: '30MiB', '4Kb', '30MB'. Maximum size slightly exceeds 1GB.",
EnvVars: withEnvPrefix(envPrefix, "MAX_BLOB_LENGTH"),
Value: "16MiB",
Action: func(c *cli.Context, maxBlobLengthStr string) error {
Action: func(_ *cli.Context, maxBlobLengthStr string) error {
// parse the string to a uint64 and set the maxBlobLengthBytes var to be used by ReadConfig()
numBytes, err := utils.ParseBytesAmount(maxBlobLengthStr)
if err != nil {
Expand Down

0 comments on commit f424c1e

Please sign in to comment.