Skip to content

feat(test-bins): show config options #346

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Dodecahedr0x
Copy link

@Dodecahedr0x Dodecahedr0x commented Apr 15, 2025

Adds a CLI to start the validator. It has a -h command to display configuration and default values. The original interface is preserved to avoid breaking integrations.

CLOSES: #318

Greptile Summary

Based on the provided information, I'll create a summary of the pull request and its context:

Adds a CLI interface to the MagicBlock validator to display configuration options and default values, while maintaining backward compatibility with existing configuration methods.

  • Added -h flag in /test-bins/src/rpc.rs to display configuration options and defaults, avoiding full clap implementation per maintainer feedback
  • Configuration should be consolidated from config.toml and environment variables rather than adding duplicate CLI arguments
  • Suggestion to create a well-documented config.toml template that includes related environment variable mappings
  • Need to implement manual arg parsing for -h flag instead of pulling in clap dependency
  • Should preserve existing configuration methods (config.toml and env vars) to avoid breaking current integrations

The maintainer's feedback suggests pivoting from a full CLI implementation to a simpler approach focused on documentation and configuration discoverability through a template config file.

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

#[arg(
long,
value_name = "COMPONENTS",
default_value = "(accounts,transactions)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: default_value is set but the type is Option<String> - this will always contain a value and never be None

Comment on lines 106 to 117
// Set environment variables from CLI arguments
if let Some(keypair) = cli.keypair {
std::env::set_var("VALIDATOR_KEYPAIR", keypair);
}

if let Some(disable_geyser) = cli.disable_geyser {
std::env::set_var("GEYSER_DISABLE", disable_geyser);
}

if let Some(disable_cache) = cli.disable_geyser_cache {
std::env::set_var("GEYSER_CACHE_DISABLE", disable_cache);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: setting env vars after parsing them from CLI args could cause issues with override_from_envs() later picking up these modified values unexpectedly

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Collaborator

@thlorenz thlorenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for the PR.
I'm not sure that in the long run this makes sense since we're now starting to duplicate some configs that we can either provide via the config file or env vars.

I thought we agreed at some point to find a way to not have to repeat ourselves, but to generate args/env vars + config from one common source so we can maintain that in one place.
I realize that the issue doesn't explain that part at all, but I don't think it's a good idea to add an args implementation that we'll replace most likely fairly soon.

If you want a stop gap for now I think it'd be more useful to create a heavily documented config toml which also mentions the related env vars.
You could then also print that when the user passes -h.

And for that one arg (-h) we don't need to pull in clap, but can manually parse the args for that.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 26 to 27
/// Path to the configuration file
config: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: config parameter needs a long flag (--config) and better help text for discoverability

Comment on lines 168 to 169
Keypair::from_base58_string(&keypair)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: from_base58_string() can panic - needs error handling for invalid base58 strings

Suggested change
Keypair::from_base58_string(&keypair)
} else {
Keypair::from_base58_string(&keypair).unwrap_or_else(|_| {
panic!("Invalid base58 string provided for validator keypair");
})
} else {

#[command(about = "Runs a MagicBlock validator node")]
struct Cli {
/// Path to the configuration file
config: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clap shall support PathBuf. Also I would propose to consider config_path.

Copy link
Contributor

@bmuddha bmuddha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good 👍🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: support -h to show configurations options
4 participants