Skip to content

Commit

Permalink
flags: add verifier deprecated flags + fix some other small things
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Oct 5, 2024
1 parent 4a1bf67 commit d67e5fd
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 26 deletions.
14 changes: 8 additions & 6 deletions flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import (
)

const (
EigenDAClientCategory = "EigenDA Client"
EigenDADeprecatedCategory = "DEPRECATED EIGENDA CLIENT FLAGS -- THESE WILL BE REMOVED IN V2.0.0"
MemstoreFlagsCategory = "Memstore (for testing purposes - replaces EigenDA backend)"
RedisCategory = "Redis Cache/Fallback"
S3Category = "S3 Cache/Fallback"
VerifierCategory = "KZG and Cert Verifier"
EigenDAClientCategory = "EigenDA Client"
EigenDADeprecatedCategory = "DEPRECATED EIGENDA CLIENT FLAGS -- THESE WILL BE REMOVED IN V2.0.0"
MemstoreFlagsCategory = "Memstore (for testing purposes - replaces EigenDA backend)"
RedisCategory = "Redis Cache/Fallback"
S3Category = "S3 Cache/Fallback"
VerifierCategory = "KZG and Cert Verifier"
VerifierDeprecatedCategory = "DEPRECATED VERIFIER FLAGS -- THESE WILL BE REMOVED IN V2.0.0"
)

const (
Expand Down Expand Up @@ -82,4 +83,5 @@ func init() {
Flags = append(Flags, s3.CLIFlags(EnvVarPrefix, S3Category)...)
Flags = append(Flags, memstore.CLIFlags(EnvVarPrefix, MemstoreFlagsCategory)...)
Flags = append(Flags, verify.CLIFlags(EnvVarPrefix, VerifierCategory)...)
Flags = append(Flags, verify.DeprecatedCLIFlags(EnvVarPrefix, VerifierDeprecatedCategory)...)
}
39 changes: 19 additions & 20 deletions verify/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ const srsOrder = 268435456 // 2 ^ 32

var (
// cert verification flags
// TODO: we keep the eigenda prefix like eigenda client flags, because we
// plan to upstream this verification logic into the eigenda client
CertVerificationEnabledFlagName = withFlagPrefix("cert-verification-enabled")
EthRPCFlagName = withFlagPrefix("eth-rpc")
SvcManagerAddrFlagName = withFlagPrefix("svc-manager-addr")
EthConfirmationDepthFlagName = withFlagPrefix("eth-confirmation-depth")
CertVerificationDisabledFlagName = withFlagPrefix("cert-verification-disabled")
EthRPCFlagName = withFlagPrefix("eth-rpc")
SvcManagerAddrFlagName = withFlagPrefix("svc-manager-addr")
EthConfirmationDepthFlagName = withFlagPrefix("eth-confirmation-depth")

// kzg flags
G1PathFlagName = withFlagPrefix("g1-path")
G2TauFlagName = withFlagPrefix("g2-tau-path")
CachePathFlagName = withFlagPrefix("cache-path")
MaxBlobLengthFlagName = withFlagPrefix("max-blob-length")
G1PathFlagName = withFlagPrefix("g1-path")
G2PowerOf2PathFlagName = withFlagPrefix("g2-power-of-2-path")
CachePathFlagName = withFlagPrefix("cache-path")
MaxBlobLengthFlagName = withFlagPrefix("max-blob-length")
)

// we keep the eigenda prefix like eigenda client flags, because we
// plan to upstream this verification logic into the eigenda client
func withFlagPrefix(s string) string {
return "eigenda." + s
}
Expand All @@ -49,10 +49,9 @@ func withEnvPrefix(envPrefix, s string) []string {
func CLIFlags(envPrefix, category string) []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: CertVerificationEnabledFlagName,
Usage: "Whether to verify certificates received from EigenDA disperser.",
EnvVars: withEnvPrefix(envPrefix, "CERT_VERIFICATION_ENABLED"),
// TODO: ideally we'd want this to be turned on by default when eigenda backend is used (memstore.enabled=false)
Name: CertVerificationDisabledFlagName,
Usage: "Whether to verify certificates received from EigenDA disperser.",
EnvVars: withEnvPrefix(envPrefix, "CERT_VERIFICATION_DISABLED"),
Value: false,
Category: category,
},
Expand Down Expand Up @@ -86,17 +85,17 @@ func CLIFlags(envPrefix, category string) []cli.Flag {
Category: category,
},
&cli.StringFlag{
Name: G2TauFlagName,
Usage: "Directory path to g2.point.powerOf2 file.",
EnvVars: withEnvPrefix(envPrefix, "TARGET_G2_TAU_PATH"),
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"),
// 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",
Category: category,
},
&cli.StringFlag{
Name: CachePathFlagName,
Usage: "Directory path to SRS tables for caching.",
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"),
// 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
Expand Down Expand Up @@ -141,7 +140,7 @@ var MaxBlobLengthBytes uint64
func ReadConfig(ctx *cli.Context) Config {
kzgCfg := &kzg.KzgConfig{
G1Path: ctx.String(G1PathFlagName),
G2PowerOf2Path: ctx.String(G2TauFlagName),
G2PowerOf2Path: ctx.String(G2PowerOf2PathFlagName),
CacheDir: ctx.String(CachePathFlagName),
SRSOrder: srsOrder,
SRSNumberToLoad: MaxBlobLengthBytes / 32, // # of fr.Elements
Expand All @@ -150,7 +149,7 @@ func ReadConfig(ctx *cli.Context) Config {

return Config{
KzgConfig: kzgCfg,
VerifyCerts: ctx.Bool(CertVerificationEnabledFlagName),
VerifyCerts: !ctx.Bool(CertVerificationDisabledFlagName),
RPCURL: ctx.String(EthRPCFlagName),
SvcManagerAddr: ctx.String(SvcManagerAddrFlagName),
EthConfirmationDepth: uint64(ctx.Int64(EthConfirmationDepthFlagName)), // #nosec G115
Expand Down
130 changes: 130 additions & 0 deletions verify/deprecated_flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package verify

import (
"fmt"

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

// TODO: we should also upstream these deprecated flags into the eigenda client
// if we upstream the changes before removing the deprecated flags
var (
// cert verification flags
DeprecatedCertVerificationEnabledFlagName = withDeprecatedFlagPrefix("cert-verification-enabled")
DeprecatedEthRPCFlagName = withDeprecatedFlagPrefix("eth-rpc")
DeprecatedSvcManagerAddrFlagName = withDeprecatedFlagPrefix("svc-manager-addr")
DeprecatedEthConfirmationDepthFlagName = withDeprecatedFlagPrefix("eth-confirmation-depth")

// kzg flags
DeprecatedG1PathFlagName = withDeprecatedFlagPrefix("g1-path")
DeprecatedG2TauFlagName = withDeprecatedFlagPrefix("g2-tau-path")
DeprecatedCachePathFlagName = withDeprecatedFlagPrefix("cache-path")
DeprecatedMaxBlobLengthFlagName = withDeprecatedFlagPrefix("max-blob-length")
)

func withDeprecatedFlagPrefix(s string) string {
return "eigenda-" + s
}

func withDeprecatedEnvPrefix(envPrefix, s string) []string {
return []string{envPrefix + "_" + s}
}

// CLIFlags ... used for Verifier configuration
// category is used to group the flags in the help output (see https://cli.urfave.org/v2/examples/flags/#grouping)
func DeprecatedCLIFlags(envPrefix, category string) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: DeprecatedEthRPCFlagName,
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: withDeprecatedEnvPrefix(envPrefix, "ETH_RPC"),
Action: func(_ *cli.Context, _ string) error {
return fmt.Errorf("flag --%s (env var %s) is deprecated, use --%s (env var %s) instead",
DeprecatedEthRPCFlagName, withDeprecatedEnvPrefix(envPrefix, "ETH_RPC"),
EthRPCFlagName, withEnvPrefix(envPrefix, "ETH_RPC"))
},
Category: category,
},
&cli.StringFlag{
Name: DeprecatedSvcManagerAddrFlagName,
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: withDeprecatedEnvPrefix(envPrefix, "SERVICE_MANAGER_ADDR"),
Action: func(_ *cli.Context, _ string) error {
return fmt.Errorf("flag --%s (env var %s) is deprecated, use --%s (env var %s) instead",
DeprecatedSvcManagerAddrFlagName, withDeprecatedEnvPrefix(envPrefix, "SERVICE_MANAGER_ADDR"),
SvcManagerAddrFlagName, withEnvPrefix(envPrefix, "SERVICE_MANAGER_ADDR"))
},
Category: category,
},
&cli.Uint64Flag{
Name: DeprecatedEthConfirmationDepthFlagName,
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: withDeprecatedEnvPrefix(envPrefix, "ETH_CONFIRMATION_DEPTH"),
Value: 0,
Action: func(_ *cli.Context, _ uint64) error {
return fmt.Errorf("flag --%s (env var %s) is deprecated, use --%s (env var %s) instead",
DeprecatedEthConfirmationDepthFlagName, withDeprecatedEnvPrefix(envPrefix, "ETH_CONFIRMATION_DEPTH"),
EthConfirmationDepthFlagName, withEnvPrefix(envPrefix, "ETH_CONFIRMATION_DEPTH"))
},
Category: category,
},
// kzg flags
&cli.StringFlag{
Name: DeprecatedG1PathFlagName,
Usage: "Directory path to g1.point file.",
EnvVars: withDeprecatedEnvPrefix(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",
Action: func(_ *cli.Context, _ string) error {
return fmt.Errorf("flag --%s (env var %s) is deprecated, use --%s (env var %s) instead",
DeprecatedG1PathFlagName, withDeprecatedEnvPrefix(envPrefix, "TARGET_KZG_G1_PATH"),
G1PathFlagName, withEnvPrefix(envPrefix, "TARGET_KZG_G1_PATH"))
},
Category: category,
},
&cli.StringFlag{
Name: DeprecatedG2TauFlagName,
Usage: "Directory path to g2.point.powerOf2 file.",
EnvVars: withDeprecatedEnvPrefix(envPrefix, "TARGET_G2_TAU_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",
Action: func(_ *cli.Context, _ string) error {
return fmt.Errorf("flag --%s (env var %s) is deprecated, use --%s (env var %s) instead",
DeprecatedG2TauFlagName, withDeprecatedEnvPrefix(envPrefix, "TARGET_G2_TAU_PATH"),
G2PowerOf2PathFlagName, withEnvPrefix(envPrefix, "TARGET_KZG_G2_POWER_OF_2_PATH"))
},
Category: category,
},
&cli.StringFlag{
Name: DeprecatedCachePathFlagName,
Usage: "Directory path to SRS tables for caching.",
EnvVars: withDeprecatedEnvPrefix(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/",
Action: func(_ *cli.Context, _ string) error {
return fmt.Errorf("flag --%s (env var %s) is deprecated, use --%s (env var %s) instead",
DeprecatedCachePathFlagName, withDeprecatedEnvPrefix(envPrefix, "TARGET_CACHE_PATH"),
CachePathFlagName, withEnvPrefix(envPrefix, "TARGET_CACHE_PATH"))
},
Category: category,
},
// TODO: can we use a genericFlag for this, and automatically parse the string into a uint64?
&cli.StringFlag{
Name: DeprecatedMaxBlobLengthFlagName,
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: withDeprecatedEnvPrefix(envPrefix, "MAX_BLOB_LENGTH"),
Value: "16MiB",
Action: func(_ *cli.Context, _ string) error {
return fmt.Errorf("flag --%s (env var %s) is deprecated, use --%s (env var %s) instead",
DeprecatedMaxBlobLengthFlagName, withDeprecatedEnvPrefix(envPrefix, "MAX_BLOB_LENGTH"),
MaxBlobLengthFlagName, withEnvPrefix(envPrefix, "MAX_BLOB_LENGTH"))
},
// we also use this flag for memstore.
// should we duplicate the flag? Or is there a better way to handle this?
Category: category,
},
}
}

0 comments on commit d67e5fd

Please sign in to comment.