Skip to content

Commit

Permalink
fix(config): sec instead of ms for sleep duration (#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-starkware authored Sep 7, 2023
1 parent 7ca05da commit 880301e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
8 changes: 4 additions & 4 deletions config/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down
20 changes: 8 additions & 12 deletions crates/papyrus_sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 880301e

Please sign in to comment.