Skip to content

Commit

Permalink
respond to comments, make on of g2path be manditory
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Feb 6, 2024
1 parent 5c0198c commit e26b937
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
8 changes: 0 additions & 8 deletions core/encoding/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const (
PreloadEncoderFlagName = "kzg.preload-encoder"
CacheEncodedBlobsFlagName = "cache-encoded-blobs"
SRSLoadingNumberFlagName = "kzg.srs-load"
G1PowerOf2PathFlagName = "kzg.g1-power-of-2-path"
G2PowerOf2PathFlagName = "kzg.g2-power-of-2-path"
)

Expand Down Expand Up @@ -79,12 +78,6 @@ func CLIFlags(envPrefix string) []cli.Flag {
Required: false,
EnvVar: common.PrefixEnvVar(envPrefix, "PRELOAD_ENCODER"),
},
cli.StringFlag{
Name: G1PowerOf2PathFlagName,
Usage: "Path to G1 SRS points that are on power of 2",
Required: false,
EnvVar: common.PrefixEnvVar(envPrefix, "G1_POWER_OF_2_PATH"),
},
cli.StringFlag{
Name: G2PowerOf2PathFlagName,
Usage: "Path to G2 SRS points that are on power of 2",
Expand All @@ -104,7 +97,6 @@ func ReadCLIConfig(ctx *cli.Context) EncoderConfig {
cfg.NumWorker = ctx.GlobalUint64(NumWorkerFlagName)
cfg.Verbose = ctx.GlobalBool(VerboseFlagName)
cfg.PreloadEncoder = ctx.GlobalBool(PreloadEncoderFlagName)
cfg.G1PowerOf2Path = ctx.GlobalString(G1PowerOf2PathFlagName)
cfg.G2PowerOf2Path = ctx.GlobalString(G2PowerOf2PathFlagName)

return EncoderConfig{
Expand Down
5 changes: 4 additions & 1 deletion inabox/deploy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (env *Config) generateOperatorVars(ind int, name, key, churnerUrl, logPath,
}

env.applyDefaults(&v, "NODE", "opr", ind)
v.NODE_G2_PATH = ""
v.NODE_G2_PATH = ""
return v

}
Expand All @@ -336,6 +336,7 @@ func (env *Config) generateRetrieverVars(ind int, key string, graphUrl, logPath,

RETRIEVER_G1_PATH: "",
RETRIEVER_G2_PATH: "",
RETRIEVER_G2_POWER_OF_2_PATH: "",
RETRIEVER_CACHE_PATH: "",
RETRIEVER_SRS_ORDER: "",
RETRIEVER_SRS_LOAD: "",
Expand All @@ -350,6 +351,8 @@ func (env *Config) generateRetrieverVars(ind int, key string, graphUrl, logPath,
RETRIEVER_LOG_PATH: logPath,
}

v.RETRIEVER_G2_PATH = ""

env.applyDefaults(&v, "RETRIEVER", "retriever", ind)

return v
Expand Down
4 changes: 2 additions & 2 deletions inabox/deploy/env_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ type OperatorVars struct {

NODE_G2_PATH string

NODE_G1_POWER_OF_2_PATH string

NODE_G2_POWER_OF_2_PATH string

NODE_CACHE_PATH string
Expand Down Expand Up @@ -329,6 +327,8 @@ type RetrieverVars struct {

RETRIEVER_G2_PATH string

RETRIEVER_G2_POWER_OF_2_PATH string

RETRIEVER_CACHE_PATH string

RETRIEVER_SRS_ORDER string
Expand Down
1 change: 1 addition & 0 deletions inabox/tests/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func setupRetrievalClient(testConfig *deploy.Config) error {
KzgConfig: kzgEncoder.KzgConfig{
G1Path: testConfig.Retriever.RETRIEVER_G1_PATH,
G2Path: testConfig.Retriever.RETRIEVER_G2_PATH,
G2PowerOf2Path: testConfig.Retriever.RETRIEVER_G2_POWER_OF_2_PATH,
CacheDir: testConfig.Retriever.RETRIEVER_CACHE_PATH,
NumWorker: 1,
SRSOrder: uint64(srsOrder),
Expand Down
9 changes: 9 additions & 0 deletions pkg/encoding/kzgEncoder/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func NewKzgEncoderGroup(config *KzgConfig, loadG2Points bool) (*KzgEncoderGroup,

// PreloadEncoder is by default not used by operator node, PreloadEncoder
if loadG2Points {
if len(config.G2Path) == 0 {
return nil, fmt.Errorf("G2Path is empty. However, object needs to load G2Points")
}

s2, err = utils.ReadG2Points(config.G2Path, config.SRSNumberToLoad, config.NumWorker)
if err != nil {
log.Println("failed to read G2 points", err)
Expand All @@ -91,6 +95,11 @@ func NewKzgEncoderGroup(config *KzgConfig, loadG2Points bool) (*KzgEncoderGroup,
if err != nil {
return nil, err
}
} else {
// todo, there are better ways to handle it
if len(config.G2PowerOf2Path) == 0 {
return nil, fmt.Errorf("G2PowerOf2Path is empty. However, object needs to load G2Points")
}
}

srs, err := kzg.NewSrs(s1, s2)
Expand Down

0 comments on commit e26b937

Please sign in to comment.