From 880301e8bbdca2778a7b6592c53258ea5de73a75 Mon Sep 17 00:00:00 2001 From: dan-starkware <56217775+dan-starkware@users.noreply.github.com> Date: Thu, 7 Sep 2023 09:30:27 +0300 Subject: [PATCH] fix(config): sec instead of ms for sleep duration (#1136) --- config/default_config.json | 8 ++++---- ...fig__config_test__dump_default_config.snap | 8 ++++---- crates/papyrus_sync/src/lib.rs | 20 ++++++++----------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/config/default_config.json b/config/default_config.json index 29907d3216..89bbee1390 100644 --- a/config/default_config.json +++ b/config/default_config.json @@ -184,16 +184,16 @@ "value": 10 }, "sync.block_propagation_sleep_duration": { - "description": "Time in milliseconds before checking for a new block after the node is synchronized.", - "value": 2000 + "description": "Time in seconds before checking for a new block after the node is synchronized.", + "value": 2 }, "sync.blocks_max_stream_size": { "description": "Max amount of blocks to download in a stream.", "value": 1000 }, "sync.recoverable_error_sleep_duration": { - "description": "Waiting time in milliseconds before restarting synchronization after a recoverable error.", - "value": 3000 + "description": "Waiting time in seconds before restarting synchronization after a recoverable error.", + "value": 3 }, "sync.state_updates_max_stream_size": { "description": "Max amount of state updates to download in a stream.", diff --git a/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap b/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap index 5ef1edbd72..112a28bed9 100644 --- a/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap +++ b/crates/papyrus_node/src/config/snapshots/papyrus_node__config__config_test__dump_default_config.snap @@ -240,9 +240,9 @@ expression: dumped_default_config } }, "sync.block_propagation_sleep_duration": { - "description": "Time in milliseconds before checking for a new block after the node is synchronized.", + "description": "Time in seconds before checking for a new block after the node is synchronized.", "value": { - "$serde_json::private::Number": "2000" + "$serde_json::private::Number": "2" } }, "sync.blocks_max_stream_size": { @@ -252,9 +252,9 @@ expression: dumped_default_config } }, "sync.recoverable_error_sleep_duration": { - "description": "Waiting time in milliseconds before restarting synchronization after a recoverable error.", + "description": "Waiting time in seconds before restarting synchronization after a recoverable error.", "value": { - "$serde_json::private::Number": "3000" + "$serde_json::private::Number": "3" } }, "sync.state_updates_max_stream_size": { diff --git a/crates/papyrus_sync/src/lib.rs b/crates/papyrus_sync/src/lib.rs index 1500dc16c7..1860bc1709 100644 --- a/crates/papyrus_sync/src/lib.rs +++ b/crates/papyrus_sync/src/lib.rs @@ -18,10 +18,7 @@ use chrono::{TimeZone, Utc}; use futures_util::{pin_mut, select, Stream, StreamExt}; use indexmap::IndexMap; use papyrus_common::{metrics as papyrus_metrics, BlockHashAndNumber}; -use papyrus_config::converters::{ - deserialize_milliseconds_to_duration, - deserialize_seconds_to_duration, -}; +use papyrus_config::converters::deserialize_seconds_to_duration; use papyrus_config::dumping::{ser_param, SerializeConfig}; use papyrus_config::{ParamPath, SerializedParam}; use papyrus_storage::base_layer::BaseLayerStorageWriter; @@ -48,11 +45,11 @@ const SLEEP_TIME_SYNC_PROGRESS: Duration = Duration::from_secs(300); #[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq)] pub struct SyncConfig { - #[serde(deserialize_with = "deserialize_milliseconds_to_duration")] + #[serde(deserialize_with = "deserialize_seconds_to_duration")] pub block_propagation_sleep_duration: Duration, #[serde(deserialize_with = "deserialize_seconds_to_duration")] pub base_layer_propagation_sleep_duration: Duration, - #[serde(deserialize_with = "deserialize_milliseconds_to_duration")] + #[serde(deserialize_with = "deserialize_seconds_to_duration")] pub recoverable_error_sleep_duration: Duration, pub blocks_max_stream_size: u32, pub state_updates_max_stream_size: u32, @@ -63,9 +60,8 @@ impl SerializeConfig for SyncConfig { BTreeMap::from_iter([ ser_param( "block_propagation_sleep_duration", - &self.block_propagation_sleep_duration.as_millis(), - "Time in milliseconds before checking for a new block after the node is \ - synchronized.", + &self.block_propagation_sleep_duration.as_secs(), + "Time in seconds before checking for a new block after the node is synchronized.", ), ser_param( "base_layer_propagation_sleep_duration", @@ -74,9 +70,9 @@ impl SerializeConfig for SyncConfig { ), ser_param( "recoverable_error_sleep_duration", - &self.recoverable_error_sleep_duration.as_millis(), - "Waiting time in milliseconds before restarting synchronization after a \ - recoverable error.", + &self.recoverable_error_sleep_duration.as_secs(), + "Waiting time in seconds before restarting synchronization after a recoverable \ + error.", ), ser_param( "blocks_max_stream_size",