Skip to content

Commit

Permalink
flags: change withEnvPrefix to return single string for better deprec…
Browse files Browse the repository at this point in the history
…ated error msgs
  • Loading branch information
samlaf committed Oct 7, 2024
1 parent 24e3aa0 commit e6f4439
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
24 changes: 12 additions & 12 deletions flags/eigendaflags/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func withFlagPrefix(s string) string {
return "eigenda." + s
}

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

// CLIFlags ... used for EigenDA client configuration
Expand All @@ -37,68 +37,68 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
&cli.StringFlag{
Name: DisperserRPCFlagName,
Usage: "RPC endpoint of the EigenDA disperser.",
EnvVars: withEnvPrefix(envPrefix, "DISPERSER_RPC"),
EnvVars: []string{withEnvPrefix(envPrefix, "DISPERSER_RPC")},
Category: category,
},
&cli.DurationFlag{
Name: StatusQueryTimeoutFlagName,
Usage: "Duration to wait for a blob to finalize after being sent for dispersal. Default is 30 minutes.",
Value: 30 * time.Minute,
EnvVars: withEnvPrefix(envPrefix, "STATUS_QUERY_TIMEOUT"),
EnvVars: []string{withEnvPrefix(envPrefix, "STATUS_QUERY_TIMEOUT")},
Category: category,
},
&cli.DurationFlag{
Name: StatusQueryRetryIntervalFlagName,
Usage: "Interval between retries when awaiting network blob finalization. Default is 5 seconds.",
Value: 5 * time.Second,
EnvVars: withEnvPrefix(envPrefix, "STATUS_QUERY_INTERVAL"),
EnvVars: []string{withEnvPrefix(envPrefix, "STATUS_QUERY_INTERVAL")},
Category: category,
},
&cli.BoolFlag{
Name: DisableTLSFlagName,
Usage: "Disable TLS for gRPC communication with the EigenDA disperser. Default is false.",
Value: false,
EnvVars: withEnvPrefix(envPrefix, "GRPC_DISABLE_TLS"),
EnvVars: []string{withEnvPrefix(envPrefix, "GRPC_DISABLE_TLS")},
Category: category,
},
&cli.DurationFlag{
Name: ResponseTimeoutFlagName,
Usage: "Total time to wait for a response from the EigenDA disperser. Default is 60 seconds.",
Value: 60 * time.Second,
EnvVars: withEnvPrefix(envPrefix, "RESPONSE_TIMEOUT"),
EnvVars: []string{withEnvPrefix(envPrefix, "RESPONSE_TIMEOUT")},
Category: category,
},
&cli.UintSliceFlag{
Name: CustomQuorumIDsFlagName,
Usage: "Custom quorum IDs for writing blobs. Should not include default quorums 0 or 1.",
Value: cli.NewUintSlice(),
EnvVars: withEnvPrefix(envPrefix, "CUSTOM_QUORUM_IDS"),
EnvVars: []string{withEnvPrefix(envPrefix, "CUSTOM_QUORUM_IDS")},
Category: category,
},
&cli.StringFlag{
Name: SignerPrivateKeyHexFlagName,
Usage: "Hex-encoded signer private key. This key should not be associated with an Ethereum address holding any funds.",
EnvVars: withEnvPrefix(envPrefix, "SIGNER_PRIVATE_KEY_HEX"),
EnvVars: []string{withEnvPrefix(envPrefix, "SIGNER_PRIVATE_KEY_HEX")},
Category: category,
},
&cli.UintFlag{
Name: PutBlobEncodingVersionFlagName,
Usage: "Blob encoding version to use when writing blobs from the high-level interface.",
EnvVars: withEnvPrefix(envPrefix, "PUT_BLOB_ENCODING_VERSION"),
EnvVars: []string{withEnvPrefix(envPrefix, "PUT_BLOB_ENCODING_VERSION")},
Value: 0,
Category: category,
},
&cli.BoolFlag{
Name: DisablePointVerificationModeFlagName,
Usage: "Disable point verification mode. This mode performs IFFT on data before writing and FFT on data after reading. Disabling requires supplying the entire blob for verification against the KZG commitment.",
EnvVars: withEnvPrefix(envPrefix, "DISABLE_POINT_VERIFICATION_MODE"),
EnvVars: []string{withEnvPrefix(envPrefix, "DISABLE_POINT_VERIFICATION_MODE")},
Value: false,
Category: category,
},
&cli.BoolFlag{
Name: WaitForFinalizationFlagName,
Usage: "Wait for blob finalization before returning from PutBlob.",
EnvVars: withEnvPrefix(envPrefix, "WAIT_FOR_FINALIZATION"),
EnvVars: []string{withEnvPrefix(envPrefix, "WAIT_FOR_FINALIZATION")},
Value: false,
Category: category,
},
Expand Down
14 changes: 6 additions & 8 deletions store/generated_key/memstore/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ func withFlagPrefix(s string) string {
return "memstore." + s
}

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

// if these deprecated env vars are used, we force the user to update their config
Expand All @@ -39,7 +37,7 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
&cli.BoolFlag{
Name: EnabledFlagName,
Usage: "Whether to use memstore for DA logic.",
EnvVars: append(withEnvPrefix(envPrefix, "ENABLED"), withDeprecatedEnvPrefix(envPrefix, "ENABLED")),
EnvVars: []string{withEnvPrefix(envPrefix, "ENABLED"), withDeprecatedEnvPrefix(envPrefix, "ENABLED")},
Category: category,
Action: func(_ *cli.Context, _ bool) error {
if _, ok := os.LookupEnv(withDeprecatedEnvPrefix(envPrefix, "ENABLED")); ok {
Expand All @@ -55,7 +53,7 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
Name: ExpirationFlagName,
Usage: "Duration that a memstore blob/commitment pair is allowed to live.",
Value: 25 * time.Minute,
EnvVars: append(withEnvPrefix(envPrefix, "EXPIRATION"), withDeprecatedEnvPrefix(envPrefix, "EXPIRATION")),
EnvVars: []string{withEnvPrefix(envPrefix, "EXPIRATION"), withDeprecatedEnvPrefix(envPrefix, "EXPIRATION")},
Category: category,
Action: func(_ *cli.Context, _ time.Duration) error {
if _, ok := os.LookupEnv(withDeprecatedEnvPrefix(envPrefix, "EXPIRATION")); ok {
Expand All @@ -71,14 +69,14 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
Name: PutLatencyFlagName,
Usage: "Artificial latency added for memstore backend to mimic EigenDA's dispersal latency.",
Value: 0,
EnvVars: withEnvPrefix(envPrefix, "PUT_LATENCY"),
EnvVars: []string{withEnvPrefix(envPrefix, "PUT_LATENCY")},
Category: category,
},
&cli.DurationFlag{
Name: GetLatencyFlagName,
Usage: "Artificial latency added for memstore backend to mimic EigenDA's retrieval latency.",
Value: 0,
EnvVars: withEnvPrefix(envPrefix, "GET_LATENCY"),
EnvVars: []string{withEnvPrefix(envPrefix, "GET_LATENCY")},
Category: category,
},
}
Expand Down
20 changes: 10 additions & 10 deletions verify/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func withFlagPrefix(s string) string {
return "eigenda." + s
}

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

// CLIFlags ... used for Verifier configuration
Expand All @@ -51,34 +51,34 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
&cli.BoolFlag{
Name: CertVerificationDisabledFlagName,
Usage: "Whether to verify certificates received from EigenDA disperser.",
EnvVars: withEnvPrefix(envPrefix, "CERT_VERIFICATION_DISABLED"),
EnvVars: []string{withEnvPrefix(envPrefix, "CERT_VERIFICATION_DISABLED")},
Value: false,
Category: category,
},
&cli.StringFlag{
Name: EthRPCFlagName,
Usage: "JSON RPC node endpoint for the Ethereum network used for finalizing DA blobs. See available list here: https://docs.eigenlayer.xyz/eigenda/networks/",
EnvVars: withEnvPrefix(envPrefix, "ETH_RPC"),
EnvVars: []string{withEnvPrefix(envPrefix, "ETH_RPC")},
Category: category,
},
&cli.StringFlag{
Name: SvcManagerAddrFlagName,
Usage: "The deployed EigenDA service manager address. The list can be found here: https://github.com/Layr-Labs/eigenlayer-middleware/?tab=readme-ov-file#current-mainnet-deployment",
EnvVars: withEnvPrefix(envPrefix, "SERVICE_MANAGER_ADDR"),
EnvVars: []string{withEnvPrefix(envPrefix, "SERVICE_MANAGER_ADDR")},
Category: category,
},
&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.",
EnvVars: withEnvPrefix(envPrefix, "ETH_CONFIRMATION_DEPTH"),
EnvVars: []string{withEnvPrefix(envPrefix, "ETH_CONFIRMATION_DEPTH")},
Value: 0,
Category: category,
},
// kzg flags
&cli.StringFlag{
Name: G1PathFlagName,
Usage: "Directory path to g1.point file.",
EnvVars: withEnvPrefix(envPrefix, "TARGET_KZG_G1_PATH"),
EnvVars: []string{withEnvPrefix(envPrefix, "TARGET_KZG_G1_PATH")},
// we use a relative path so that the path works for both the binary and the docker container
// aka we assume the binary is run from root dir, and that the resources/ dir is copied into the working dir of the container
Value: "resources/g1.point",
Expand All @@ -87,7 +87,7 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
&cli.StringFlag{
Name: G2PowerOf2PathFlagName,
Usage: "Directory path to g2.point.powerOf2 file. This resource is not currently used, but needed because of the shared eigenda KZG library that we use. We will eventually fix this.",
EnvVars: withEnvPrefix(envPrefix, "TARGET_KZG_G2_POWER_OF_2_PATH"),
EnvVars: []string{withEnvPrefix(envPrefix, "TARGET_KZG_G2_POWER_OF_2_PATH")},
// we use a relative path so that the path works for both the binary and the docker container
// aka we assume the binary is run from root dir, and that the resources/ dir is copied into the working dir of the container
Value: "resources/g2.point.powerOf2",
Expand All @@ -96,7 +96,7 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
&cli.StringFlag{
Name: CachePathFlagName,
Usage: "Directory path to SRS tables for caching. This resource is not currently used, but needed because of the shared eigenda KZG library that we use. We will eventually fix this.",
EnvVars: withEnvPrefix(envPrefix, "TARGET_CACHE_PATH"),
EnvVars: []string{withEnvPrefix(envPrefix, "TARGET_CACHE_PATH")},
// we use a relative path so that the path works for both the binary and the docker container
// aka we assume the binary is run from root dir, and that the resources/ dir is copied into the working dir of the container
Value: "resources/SRSTables/",
Expand All @@ -106,7 +106,7 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
&cli.StringFlag{
Name: MaxBlobLengthFlagName,
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"),
EnvVars: []string{withEnvPrefix(envPrefix, "MAX_BLOB_LENGTH")},
Value: "16MiB",
// set to true to force action to run on the default Value
// see https://github.com/urfave/cli/issues/1973
Expand Down

0 comments on commit e6f4439

Please sign in to comment.