From d0efb6b18af9a274e4059b6bc953f470f00c18b1 Mon Sep 17 00:00:00 2001 From: pinkiebell <40266861+pinkiebell@users.noreply.github.com> Date: Wed, 19 Oct 2022 22:55:49 +0000 Subject: [PATCH] beacon_node: add --disable-deposit-contract-sync flag (#3597) Overrides any previous option that enables the eth1 service. Useful for operating a `light` beacon node. Co-authored-by: Michael Sproul --- beacon_node/client/src/builder.rs | 4 +++- beacon_node/src/cli.rs | 8 ++++++++ beacon_node/src/config.rs | 5 +++++ lighthouse/tests/beacon_node.rs | 34 +++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/beacon_node/client/src/builder.rs b/beacon_node/client/src/builder.rs index a46d91ad1..efd91cfdf 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 0b7518b95..81a7c6bbe 100644 --- a/beacon_node/src/cli.rs +++ b/beacon_node/src/cli.rs @@ -852,4 +852,12 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> { failure caused by the execution layer.") .takes_value(false) ) + .arg( + 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 depends 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 7666134b4..3b94c3129 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -668,6 +668,11 @@ pub fn get_config( client_config.chain.enable_lock_timeouts = false; } + // 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; + } + if let Some(timeout) = clap_utils::parse_optional(cli_args, "fork-choice-before-proposal-timeout")? { diff --git a/lighthouse/tests/beacon_node.rs b/lighthouse/tests/beacon_node.rs index 34041a82c..b1498f109 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)); +}