From 25d4b933167b2af63384164d755ec9f874080c3f Mon Sep 17 00:00:00 2001 From: Hansie Odendaal Date: Thu, 16 May 2024 13:59:35 +0200 Subject: [PATCH] Adjust block sync timeouts Adjusted block sync timeouts to enable block sync over tor when we have many full blocks. Previous values were unrealistic and unfeasible. --- base_layer/core/src/base_node/sync/config.rs | 11 +++++---- .../sync/horizon_state_sync/synchronizer.rs | 2 +- common/config/presets/c_base_node_c.toml | 23 +++++++++++-------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/base_layer/core/src/base_node/sync/config.rs b/base_layer/core/src/base_node/sync/config.rs index cb9afb1528..187de3aca9 100644 --- a/base_layer/core/src/base_node/sync/config.rs +++ b/base_layer/core/src/base_node/sync/config.rs @@ -50,19 +50,20 @@ pub struct BlockchainSyncConfig { pub validation_concurrency: usize, /// The RPC deadline to set on sync clients. If this deadline is reached, a new sync peer will be selected for /// sync. + #[serde(with = "serializers::seconds")] pub rpc_deadline: Duration, } impl Default for BlockchainSyncConfig { fn default() -> Self { Self { - initial_max_sync_latency: Duration::from_secs(15), - max_latency_increase: Duration::from_secs(2), - ban_period: Duration::from_secs(60 * 60 * 2), // 2 hours - short_ban_period: Duration::from_secs(240), // 4 mins + initial_max_sync_latency: Duration::from_secs(240), // Syncing many full blocks over tor require this + max_latency_increase: Duration::from_secs(10), // Syncing many full blocks over tor require this + ban_period: Duration::from_secs(60 * 60 * 2), // 2 hours + short_ban_period: Duration::from_secs(240), // 4 mins forced_sync_peers: Default::default(), validation_concurrency: 6, - rpc_deadline: Duration::from_secs(15), + rpc_deadline: Duration::from_secs(240), // Syncing many full blocks over tor require this } } } diff --git a/base_layer/core/src/base_node/sync/horizon_state_sync/synchronizer.rs b/base_layer/core/src/base_node/sync/horizon_state_sync/synchronizer.rs index 6e12642639..6c40bd7756 100644 --- a/base_layer/core/src/base_node/sync/horizon_state_sync/synchronizer.rs +++ b/base_layer/core/src/base_node/sync/horizon_state_sync/synchronizer.rs @@ -251,7 +251,7 @@ impl<'a, B: BlockchainBackend + 'static> HorizonStateSynchronization<'a, B> { let config = RpcClient::builder() .with_deadline(self.config.rpc_deadline) - .with_deadline_grace_period(Duration::from_secs(3)); + .with_deadline_grace_period(Duration::from_secs(5)); let mut client = conn .connect_rpc_using_builder::(config) diff --git a/common/config/presets/c_base_node_c.toml b/common/config/presets/c_base_node_c.toml index c125d4e4cd..61b9650adc 100644 --- a/common/config/presets/c_base_node_c.toml +++ b/common/config/presets/c_base_node_c.toml @@ -83,20 +83,25 @@ track_reorgs = true #service.block_sync_trigger = 5 [base_node.state_machine] -# The initial max sync latency. If a peer fails to stream a header/block within this deadline another sync peer will be -# selected. If there are no further peers the sync will be restarted with an increased by `max_latency_increase`. -#blockchain_sync_config.initial_max_sync_latency = 15 -# If all sync peers exceed latency increase allowed latency by this value -#blockchain_sync_config.max_latency_increase =2 -# Longer ban period for potentially malicious infractions (protocol violations etc.) +# The initial max sync latency (seconds). If a peer fails to stream a header/block within this deadline another sync +# peer will be selected. If there are no further peers the sync will be restarted with an increased by +# `max_latency_increase`. [default = 240] +blockchain_sync_config.initial_max_sync_latency = 240 +# If all sync peers exceed latency increase allowed latency by this value (seconds) [default = 10] +blockchain_sync_config.max_latency_increase = 10 +# Longer ban period (seconds) for potentially malicious infractions (protocol violations etc.) [default = 2 hours] #blockchain_sync_config.ban_period = 7_200 # 2 * 60 * 60 -# Short ban period for infractions that are likely not malicious (slow to respond spotty connections etc) +# Short ban period (seconds) for infractions that are likely not malicious (slow to respond spotty connections etc) +# [default = 4 minutes] #blockchain_sync_config.short_ban_period = 240 # An allowlist of sync peers from which to sync. No other peers will be selected for sync. If empty sync peers -# are chosen based on their advertised chain metadata. +# are chosen based on their advertised chain metadata. [default = []] #blockchain_sync_config.forced_sync_peers = [] -# Number of threads to use for validation +# Number of threads to use for validation [default = 6] #blockchain_sync_config.validation_concurrency = 6 +# The RPC deadline to set on sync clients. If this deadline is reached, a new sync peer will be selected for sync. +# [default = 240] +blockchain_sync_config.rpc_deadline = 240 # The maximum amount of VMs that RandomX will be use (default = 0) #max_randomx_vms = 0