Skip to content

Commit

Permalink
Fix Prefer Builder Flag (#4622)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethDreamer committed Aug 18, 2023
1 parent c7e978b commit 945d6f6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 21 deletions.
2 changes: 0 additions & 2 deletions beacon_node/client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ pub struct Config {
pub monitoring_api: Option<monitoring_api::Config>,
pub slasher: Option<slasher::Config>,
pub logger_config: LoggerConfig,
pub always_prefer_builder_payload: bool,
pub beacon_processor: BeaconProcessorConfig,
}

Expand Down Expand Up @@ -108,7 +107,6 @@ impl Default for Config {
validator_monitor_pubkeys: vec![],
validator_monitor_individual_tracking_threshold: DEFAULT_INDIVIDUAL_TRACKING_THRESHOLD,
logger_config: LoggerConfig::default(),
always_prefer_builder_payload: false,
beacon_processor: <_>::default(),
}
}
Expand Down
7 changes: 3 additions & 4 deletions beacon_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ pub fn get_config<E: EthSpec>(
el_config.default_datadir = client_config.data_dir().clone();
el_config.builder_profit_threshold =
clap_utils::parse_required(cli_args, "builder-profit-threshold")?;
el_config.always_prefer_builder_payload =
cli_args.is_present("always-prefer-builder-payload");

let execution_timeout_multiplier =
clap_utils::parse_required(cli_args, "execution-timeout-multiplier")?;
el_config.execution_timeout_multiplier = Some(execution_timeout_multiplier);
Expand Down Expand Up @@ -801,10 +804,6 @@ pub fn get_config<E: EthSpec>(
if cli_args.is_present("genesis-backfill") {
client_config.chain.genesis_backfill = true;
}
// Payload selection configs
if cli_args.is_present("always-prefer-builder-payload") {
client_config.always_prefer_builder_payload = true;
}

// Backfill sync rate-limiting
client_config.beacon_processor.enable_backfill_rate_limiting =
Expand Down
47 changes: 32 additions & 15 deletions lighthouse/tests/beacon_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,21 +366,6 @@ fn genesis_backfill_with_historic_flag() {
.with_config(|config| assert_eq!(config.chain.genesis_backfill, true));
}

#[test]
fn always_prefer_builder_payload_flag() {
CommandLineTest::new()
.flag("always-prefer-builder-payload", None)
.run_with_zero_port()
.with_config(|config| assert!(config.always_prefer_builder_payload));
}

#[test]
fn no_flag_sets_always_prefer_builder_payload_to_false() {
CommandLineTest::new()
.run_with_zero_port()
.with_config(|config| assert!(!config.always_prefer_builder_payload));
}

// Tests for Eth1 flags.
#[test]
fn dummy_eth1_flag() {
Expand Down Expand Up @@ -735,6 +720,38 @@ fn builder_fallback_flags() {
);
},
);
run_payload_builder_flag_test_with_config(
"builder",
"http://meow.cats",
Some("always-prefer-builder-payload"),
None,
|config| {
assert_eq!(
config
.execution_layer
.as_ref()
.unwrap()
.always_prefer_builder_payload,
true
);
},
);
run_payload_builder_flag_test_with_config(
"builder",
"http://meow.cats",
None,
None,
|config| {
assert_eq!(
config
.execution_layer
.as_ref()
.unwrap()
.always_prefer_builder_payload,
false
);
},
);
}

#[test]
Expand Down

0 comments on commit 945d6f6

Please sign in to comment.