-
Notifications
You must be signed in to change notification settings - Fork 128
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
refactor: aggregator uses flags instead of config-file #60
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,15 +61,31 @@ type IncredibleSquaringContractsRaw struct { | |
OperatorStateRetrieverAddr string `json:"operatorStateRetriever"` | ||
} | ||
|
||
// NewConfig parses config file to read from from flags or environment variables | ||
// NewConfig parses config file to read from flags or environment variables | ||
// Note: This config is shared by challenger and aggregator and so we put in the core. | ||
// Operator has a different config and is meant to be used by the operator CLI. | ||
func NewConfig(ctx *cli.Context) (*Config, error) { | ||
|
||
var configRaw ConfigRaw | ||
configFilePath := ctx.GlobalString(ConfigFileFlag.Name) | ||
if configFilePath != "" { | ||
sdkutils.ReadYamlConfig(configFilePath, &configRaw) | ||
|
||
environment := ctx.GlobalString(EnvironmentFlag.Name) | ||
if environment != "" { | ||
configRaw.Environment = sdklogging.LogLevel(environment) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need to use configRaw anymore. Remove it. |
||
} | ||
|
||
ethRpcUrl := ctx.GlobalString(EthRpcUrlFlag.Name) | ||
if ethRpcUrl != "" { | ||
configRaw.EthRpcUrl = ethRpcUrl | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these feel like bugs. What if the ethRpcUrl is set to ""? You should probably return an error. |
||
|
||
ethWsUrl := ctx.GlobalString(EthWsUrlFlag.Name) | ||
if ethWsUrl != "" { | ||
configRaw.EthWsUrl = ethWsUrl | ||
} | ||
|
||
aggregatorServerIpPortAddr := ctx.GlobalString(AggregatorServerIpPortAddressFlag.Name) | ||
if aggregatorServerIpPortAddr != "" { | ||
configRaw.AggregatorServerIpPortAddr = aggregatorServerIpPortAddr | ||
} | ||
|
||
var credibleSquaringDeploymentRaw IncredibleSquaringDeploymentRaw | ||
|
@@ -164,6 +180,26 @@ var ( | |
Required: true, | ||
Usage: "Load configuration from `FILE`", | ||
} | ||
EnvironmentFlag = cli.StringFlag{ | ||
Name: "environment", | ||
Required: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set to not required and give default value of development |
||
Usage: "Set the environment (production or development)", | ||
} | ||
EthRpcUrlFlag = cli.StringFlag{ | ||
Name: "eth-rpc-url", | ||
Required: true, | ||
Usage: "Ethereum RPC URL", | ||
} | ||
EthWsUrlFlag = cli.StringFlag{ | ||
Name: "eth-ws-url", | ||
Required: true, | ||
Usage: "Ethereum WS URL", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add EnvVar flags to these? See how eigenDA does it: https://github.com/Layr-Labs/eigenda/blob/e7ec7fa7f8dddda8fd64ec77435694d1c5dc9851/disperser/cmd/batcher/flags/flags.go#L25 |
||
} | ||
AggregatorServerIpPortAddressFlag = cli.StringFlag{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this was the old variable name, but don't like it anymore. Can we separate into two separate flags, Also you can make the default ListenHost 0.0.0.0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So which one of them should I pass in |
||
Name: "aggregator-server-ip-port-address", | ||
Required: true, | ||
Usage: "Aggregator server IP PORT address", | ||
} | ||
CredibleSquaringDeploymentFileFlag = cli.StringFlag{ | ||
Name: "credible-squaring-deployment", | ||
Required: true, | ||
|
@@ -179,7 +215,10 @@ var ( | |
) | ||
|
||
var requiredFlags = []cli.Flag{ | ||
ConfigFileFlag, | ||
EnvironmentFlag, | ||
EthRpcUrlFlag, | ||
EthWsUrlFlag, | ||
AggregatorServerIpPortAddressFlag, | ||
CredibleSquaringDeploymentFileFlag, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this flag There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean move them from |
||
EcdsaPrivateKeyFlag, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to get out of hands. Let's move the config variables to a .env file that users can source before running make commands. ALso this way we can have an anvil.env file and a holesky.env file, etc.