From 0a2282cccbcdb0b0be2da526401b612f65481211 Mon Sep 17 00:00:00 2001 From: pinkiebell <40266861+pinkiebell@users.noreply.github.com> Date: Tue, 27 Sep 2022 16:12:53 +0000 Subject: [PATCH 1/4] beacon_node: add --disable-eth1-sync flag Overrides any previous option that enables the eth1 service. --- beacon_node/client/src/builder.rs | 4 +++- beacon_node/src/cli.rs | 7 +++++++ beacon_node/src/config.rs | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/beacon_node/client/src/builder.rs b/beacon_node/client/src/builder.rs index a46d91ad1e1..efd91cfdf67 100644 --- a/beacon_node/client/src/builder.rs +++ b/beacon_node/client/src/builder.rs @@ -457,7 +457,9 @@ where ClientGenesis::FromStore => builder.resume_from_db().map(|v| (v, None))?, }; - self.eth1_service = eth1_service_option; + if config.sync_eth1_chain { + self.eth1_service = eth1_service_option; + } self.beacon_chain_builder = Some(beacon_chain_builder); Ok(self) } diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index 0b7518b9577..234fcb65c88 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -852,4 +852,11 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { failure caused by the execution layer.") .takes_value(false) ) + .arg( + Arg::with_name("disable-eth1-sync") + .long("disable-eth1-sync") + .help("Explictly disables the eth1 service. \ + Useful if you intend to run a non-validating beacon node.") + .takes_value(false) + ) } diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index 7666134b415..c8809c6b185 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -668,6 +668,10 @@ pub fn get_config( client_config.chain.enable_lock_timeouts = false; } + if cli_args.is_present("disable-eth1-sync") { + client_config.sync_eth1_chain = false; + } + if let Some(timeout) = clap_utils::parse_optional(cli_args, "fork-choice-before-proposal-timeout")? { From 83fb1161a1bce10b4f01fbfe41722e001b6cf874 Mon Sep 17 00:00:00 2001 From: pinkiebell <40266861+pinkiebell@users.noreply.github.com> Date: Tue, 18 Oct 2022 09:37:22 +0000 Subject: [PATCH 2/4] add tests, rename config flag --- beacon_node/src/cli.rs | 5 +++-- beacon_node/src/config.rs | 3 ++- lighthouse/tests/beacon_node.rs | 34 +++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index 234fcb65c88..71847a9f266 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -853,9 +853,10 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { .takes_value(false) ) .arg( - Arg::with_name("disable-eth1-sync") - .long("disable-eth1-sync") + Arg::with_name("disable-deposit-contract-sync") + .long("disable-deposit-contract-sync") .help("Explictly disables the eth1 service. \ + This overrides any previous option that depend on it. \ Useful if you intend to run a non-validating beacon node.") .takes_value(false) ) diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index c8809c6b185..3b94c312901 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -668,7 +668,8 @@ pub fn get_config( client_config.chain.enable_lock_timeouts = false; } - if cli_args.is_present("disable-eth1-sync") { + // Note: This overrides any previous flags that enable this option. + if cli_args.is_present("disable-deposit-contract-sync") { client_config.sync_eth1_chain = false; } diff --git a/lighthouse/tests/beacon_node.rs b/lighthouse/tests/beacon_node.rs index 34041a82c80..b1498f109d6 100644 --- a/lighthouse/tests/beacon_node.rs +++ b/lighthouse/tests/beacon_node.rs @@ -1527,3 +1527,37 @@ fn enabled_disable_log_timestamp_flag() { assert!(config.logger_config.disable_log_timestamp); }); } + +#[test] +fn sync_eth1_chain_default() { + CommandLineTest::new() + .run_with_zero_port() + .with_config(|config| assert_eq!(config.sync_eth1_chain, false)); +} + +#[test] +fn sync_eth1_chain_execution_endpoints_flag() { + let dir = TempDir::new().expect("Unable to create temporary directory"); + CommandLineTest::new() + .flag("execution-endpoints", Some("http://localhost:8551/")) + .flag( + "execution-jwt", + dir.path().join("jwt-file").as_os_str().to_str(), + ) + .run_with_zero_port() + .with_config(|config| assert_eq!(config.sync_eth1_chain, true)); +} + +#[test] +fn sync_eth1_chain_disable_deposit_contract_sync_flag() { + let dir = TempDir::new().expect("Unable to create temporary directory"); + CommandLineTest::new() + .flag("disable-deposit-contract-sync", None) + .flag("execution-endpoints", Some("http://localhost:8551/")) + .flag( + "execution-jwt", + dir.path().join("jwt-file").as_os_str().to_str(), + ) + .run_with_zero_port() + .with_config(|config| assert_eq!(config.sync_eth1_chain, false)); +} From 5c212039af049f3fa7cd34b03e743b54fa7793d2 Mon Sep 17 00:00:00 2001 From: pinkiebell <40266861+pinkiebell@users.noreply.github.com> Date: Wed, 19 Oct 2022 14:33:36 +0000 Subject: [PATCH 3/4] change help text --- beacon_node/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index 71847a9f266..aa723ac9b31 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -855,7 +855,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { .arg( Arg::with_name("disable-deposit-contract-sync") .long("disable-deposit-contract-sync") - .help("Explictly disables the eth1 service. \ + .help("Explictly disables syncing of deposit logs from the execution node. \ This overrides any previous option that depend on it. \ Useful if you intend to run a non-validating beacon node.") .takes_value(false) From 90b883e40b37f93a53bc32ead5b6d4b445d5079d Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Thu, 20 Oct 2022 09:54:49 +1100 Subject: [PATCH 4/4] Fix pluralisation in help text --- beacon_node/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beacon_node/src/cli.rs b/beacon_node/src/cli.rs index aa723ac9b31..81a7c6bbeb3 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -856,7 +856,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { Arg::with_name("disable-deposit-contract-sync") .long("disable-deposit-contract-sync") .help("Explictly disables syncing of deposit logs from the execution node. \ - This overrides any previous option that depend on it. \ + This overrides any previous option that depends on it. \ Useful if you intend to run a non-validating beacon node.") .takes_value(false) )