Skip to content

Commit

Permalink
Undo some CLI flag breakages (#5902)
Browse files Browse the repository at this point in the history
* Undo some CLI breakages

* Update CLI book docs
  • Loading branch information
michaelsproul authored Jun 7, 2024
1 parent 22fe0a6 commit 947e2e8
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
2 changes: 2 additions & 0 deletions beacon_node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,8 @@ pub fn cli_app() -> Command {
[Enabled by default].")
.action(ArgAction::Set)
.default_value("true")
.num_args(0..=1)
.default_missing_value("true")
.display_order(0)
)
.arg(
Expand Down
2 changes: 1 addition & 1 deletion book/src/help_bn.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ Options:
--slasher-backend <DATABASE>
Set the database backend to be used by the slasher. [possible values:
lmdb, disabled]
--slasher-broadcast <slasher-broadcast>
--slasher-broadcast [<slasher-broadcast>]
Broadcast slashings found by the slasher to the rest of the network
[Enabled by default]. [default: true]
--slasher-chunk-size <EPOCHS>
Expand Down
15 changes: 15 additions & 0 deletions lighthouse/tests/beacon_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,21 @@ fn slasher_broadcast_flag_no_default() {
});
}
#[test]
fn slasher_broadcast_flag_no_argument() {
CommandLineTest::new()
.flag("slasher", None)
.flag("slasher-max-db-size", Some("1"))
.flag("slasher-broadcast", None)
.run_with_zero_port()
.with_config(|config| {
let slasher_config = config
.slasher
.as_ref()
.expect("Unable to parse Slasher config");
assert!(slasher_config.broadcast);
});
}
#[test]
fn slasher_broadcast_flag_true() {
CommandLineTest::new()
.flag("slasher", None)
Expand Down
12 changes: 11 additions & 1 deletion lighthouse/tests/validator_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,14 +593,24 @@ fn wrong_broadcast_flag() {
}

#[test]
fn latency_measurement_service() {
fn disable_latency_measurement_service() {
CommandLineTest::new()
.flag("disable-latency-measurement-service", None)
.run()
.with_config(|config| {
assert!(!config.enable_latency_measurement_service);
});
}
#[test]
fn latency_measurement_service() {
// This flag is DEPRECATED so has no effect, but should still be accepted.
CommandLineTest::new()
.flag("latency-measurement-service", Some("false"))
.run()
.with_config(|config| {
assert!(config.enable_latency_measurement_service);
});
}

#[test]
fn validator_registration_batch_size() {
Expand Down
9 changes: 9 additions & 0 deletions validator_client/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ pub fn cli_app() -> Command {
.help_heading(FLAG_HEADER)
.display_order(0)
)
.arg(
Arg::new("latency-measurement-service")
.long("latency-measurement-service")
.help("DEPRECATED")
.action(ArgAction::Set)
.help_heading(FLAG_HEADER)
.display_order(0)
.hide(true)
)
.arg(
Arg::new("validator-registration-batch-size")
.long("validator-registration-batch-size")
Expand Down
11 changes: 11 additions & 0 deletions validator_client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,17 @@ impl Config {
config.enable_latency_measurement_service =
!cli_args.get_flag("disable-latency-measurement-service");

if cli_args
.get_one::<String>("latency-measurement-service")
.is_some()
{
warn!(
log,
"latency-measurement-service flag";
"note" => "deprecated flag has no effect and should be removed"
);
}

config.validator_registration_batch_size =
parse_required(cli_args, "validator-registration-batch-size")?;
if config.validator_registration_batch_size == 0 {
Expand Down

0 comments on commit 947e2e8

Please sign in to comment.