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 <104614073+GeemoCandama@users.noreply.github.com>
Co-authored-by: Michael Sproul <micsproul@gmail.com>
This commit is contained in:
GeemoCandama 2022-11-11 00:38:28 +00:00
parent d99bfcf1a5
commit c591fcd201
5 changed files with 38 additions and 5 deletions

View File

@ -45,6 +45,8 @@ pub struct ChainConfig {
pub paranoid_block_proposal: bool,
/// Whether to strictly count unrealized justified votes.
pub count_unrealized_full: CountUnrealizedFull,
/// Optionally set timeout for calls to checkpoint sync endpoint.
pub checkpoint_sync_url_timeout: u64,
}
impl Default for ChainConfig {
@ -65,6 +67,7 @@ impl Default for ChainConfig {
always_reset_payload_statuses: false,
paranoid_block_proposal: false,
count_unrealized_full: CountUnrealizedFull::default(),
checkpoint_sync_url_timeout: 60,
}
}
}

View File

@ -40,9 +40,6 @@ use types::{
/// Interval between polling the eth1 node for genesis information.
pub const ETH1_GENESIS_UPDATE_INTERVAL_MILLIS: u64 = 7_000;
/// Timeout for checkpoint sync HTTP requests.
pub const CHECKPOINT_SYNC_HTTP_TIMEOUT: Duration = Duration::from_secs(60);
/// Builds a `Client` instance.
///
/// ## Notes
@ -273,8 +270,12 @@ where
"remote_url" => %url,
);
let remote =
BeaconNodeHttpClient::new(url, Timeouts::set_all(CHECKPOINT_SYNC_HTTP_TIMEOUT));
let remote = BeaconNodeHttpClient::new(
url,
Timeouts::set_all(Duration::from_secs(
config.chain.checkpoint_sync_url_timeout,
)),
);
let slots_per_epoch = TEthSpec::slots_per_epoch();
let deposit_snapshot = if config.sync_eth1_chain {

View File

@ -714,6 +714,14 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(true)
.conflicts_with("checkpoint-state")
)
.arg(
Arg::with_name("checkpoint-sync-url-timeout")
.long("checkpoint-sync-url-timeout")
.help("Set the timeout for checkpoint sync calls to remote beacon node HTTP endpoint.")
.value_name("SECONDS")
.takes_value(true)
.default_value("60")
)
.arg(
Arg::with_name("reconstruct-historic-states")
.long("reconstruct-historic-states")

View File

@ -441,6 +441,8 @@ pub fn get_config<E: EthSpec>(
.extend_from_slice(boot_nodes)
}
}
client_config.chain.checkpoint_sync_url_timeout =
clap_utils::parse_required::<u64>(cli_args, "checkpoint-sync-url-timeout")?;
client_config.genesis = if let Some(genesis_state_bytes) =
eth2_network_config.genesis_state_bytes.clone()

View File

@ -132,6 +132,25 @@ fn fork_choice_before_proposal_timeout_zero() {
.with_config(|config| assert_eq!(config.chain.fork_choice_before_proposal_timeout_ms, 0));
}
#[test]
fn checkpoint_sync_url_timeout_flag() {
CommandLineTest::new()
.flag("checkpoint-sync-url-timeout", Some("300"))
.run_with_zero_port()
.with_config(|config| {
assert_eq!(config.chain.checkpoint_sync_url_timeout, 300);
});
}
#[test]
fn checkpoint_sync_url_timeout_default() {
CommandLineTest::new()
.run_with_zero_port()
.with_config(|config| {
assert_eq!(config.chain.checkpoint_sync_url_timeout, 60);
});
}
#[test]
fn paranoid_block_proposal_default() {
CommandLineTest::new()