Skip to content

Commit c591fcd

Browse files
add checkpoint-sync-url-timeout flag (#3710)
## Issue Addressed #3702 Which issue # does this PR address? #3702 ## Proposed Changes Added checkpoint-sync-url-timeout flag to cli. Added timeout field to ClientGenesis::CheckpointSyncUrl to utilize timeout set ## Additional Info Please provide any additional information. For example, future considerations or information useful for reviewers. Co-authored-by: GeemoCandama <[email protected]> Co-authored-by: Michael Sproul <[email protected]>
1 parent d99bfcf commit c591fcd

File tree

5 files changed

+38
-5
lines changed

5 files changed

+38
-5
lines changed

beacon_node/beacon_chain/src/chain_config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ pub struct ChainConfig {
4545
pub paranoid_block_proposal: bool,
4646
/// Whether to strictly count unrealized justified votes.
4747
pub count_unrealized_full: CountUnrealizedFull,
48+
/// Optionally set timeout for calls to checkpoint sync endpoint.
49+
pub checkpoint_sync_url_timeout: u64,
4850
}
4951

5052
impl Default for ChainConfig {
@@ -65,6 +67,7 @@ impl Default for ChainConfig {
6567
always_reset_payload_statuses: false,
6668
paranoid_block_proposal: false,
6769
count_unrealized_full: CountUnrealizedFull::default(),
70+
checkpoint_sync_url_timeout: 60,
6871
}
6972
}
7073
}

beacon_node/client/src/builder.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ use types::{
4040
/// Interval between polling the eth1 node for genesis information.
4141
pub const ETH1_GENESIS_UPDATE_INTERVAL_MILLIS: u64 = 7_000;
4242

43-
/// Timeout for checkpoint sync HTTP requests.
44-
pub const CHECKPOINT_SYNC_HTTP_TIMEOUT: Duration = Duration::from_secs(60);
45-
4643
/// Builds a `Client` instance.
4744
///
4845
/// ## Notes
@@ -273,8 +270,12 @@ where
273270
"remote_url" => %url,
274271
);
275272

276-
let remote =
277-
BeaconNodeHttpClient::new(url, Timeouts::set_all(CHECKPOINT_SYNC_HTTP_TIMEOUT));
273+
let remote = BeaconNodeHttpClient::new(
274+
url,
275+
Timeouts::set_all(Duration::from_secs(
276+
config.chain.checkpoint_sync_url_timeout,
277+
)),
278+
);
278279
let slots_per_epoch = TEthSpec::slots_per_epoch();
279280

280281
let deposit_snapshot = if config.sync_eth1_chain {

beacon_node/src/cli.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,14 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
714714
.takes_value(true)
715715
.conflicts_with("checkpoint-state")
716716
)
717+
.arg(
718+
Arg::with_name("checkpoint-sync-url-timeout")
719+
.long("checkpoint-sync-url-timeout")
720+
.help("Set the timeout for checkpoint sync calls to remote beacon node HTTP endpoint.")
721+
.value_name("SECONDS")
722+
.takes_value(true)
723+
.default_value("60")
724+
)
717725
.arg(
718726
Arg::with_name("reconstruct-historic-states")
719727
.long("reconstruct-historic-states")

beacon_node/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ pub fn get_config<E: EthSpec>(
441441
.extend_from_slice(boot_nodes)
442442
}
443443
}
444+
client_config.chain.checkpoint_sync_url_timeout =
445+
clap_utils::parse_required::<u64>(cli_args, "checkpoint-sync-url-timeout")?;
444446

445447
client_config.genesis = if let Some(genesis_state_bytes) =
446448
eth2_network_config.genesis_state_bytes.clone()

lighthouse/tests/beacon_node.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,25 @@ fn fork_choice_before_proposal_timeout_zero() {
132132
.with_config(|config| assert_eq!(config.chain.fork_choice_before_proposal_timeout_ms, 0));
133133
}
134134

135+
#[test]
136+
fn checkpoint_sync_url_timeout_flag() {
137+
CommandLineTest::new()
138+
.flag("checkpoint-sync-url-timeout", Some("300"))
139+
.run_with_zero_port()
140+
.with_config(|config| {
141+
assert_eq!(config.chain.checkpoint_sync_url_timeout, 300);
142+
});
143+
}
144+
145+
#[test]
146+
fn checkpoint_sync_url_timeout_default() {
147+
CommandLineTest::new()
148+
.run_with_zero_port()
149+
.with_config(|config| {
150+
assert_eq!(config.chain.checkpoint_sync_url_timeout, 60);
151+
});
152+
}
153+
135154
#[test]
136155
fn paranoid_block_proposal_default() {
137156
CommandLineTest::new()

0 commit comments

Comments
 (0)