Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sync): add poll_pending_data to sync config #515

Merged
merged 6 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/papyrus/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,11 @@
"privacy": "Public",
"value": 1000
},
"sync.collect_pending_data": {
"description": "Whether to collect data on pending blocks.",
"privacy": "Public",
"value": false
},
"sync.recoverable_error_sleep_duration": {
"description": "Waiting time in seconds before restarting synchronization after a recoverable error.",
"privacy": "Public",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ expression: dumped_default_config
},
"privacy": "Public"
},
"sync.collect_pending_data": {
"description": "Whether to collect data on pending blocks.",
"value": false,
"privacy": "Public"
},
"sync.recoverable_error_sleep_duration": {
"description": "Waiting time in seconds before restarting synchronization after a recoverable error.",
"value": {
Expand Down
12 changes: 11 additions & 1 deletion crates/papyrus_sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub struct SyncConfig {
pub blocks_max_stream_size: u32,
pub state_updates_max_stream_size: u32,
pub verify_blocks: bool,
pub collect_pending_data: bool,
}

impl SerializeConfig for SyncConfig {
Expand Down Expand Up @@ -112,6 +113,12 @@ impl SerializeConfig for SyncConfig {
"Whether to verify incoming blocks.",
ParamPrivacyInput::Public,
),
ser_param(
"collect_pending_data",
&self.collect_pending_data,
"Whether to collect data on pending blocks.",
ParamPrivacyInput::Public,
),
])
}
}
Expand All @@ -125,6 +132,7 @@ impl Default for SyncConfig {
blocks_max_stream_size: 1000,
state_updates_max_stream_size: 1000,
verify_blocks: true,
collect_pending_data: false,
}
}
}
Expand Down Expand Up @@ -306,6 +314,7 @@ impl<
self.pending_data.clone(),
self.pending_classes.clone(),
self.config.block_propagation_sleep_duration,
self.config.collect_pending_data,
PENDING_SLEEP_DURATION,
self.config.blocks_max_stream_size,
)
Expand Down Expand Up @@ -664,6 +673,7 @@ fn stream_new_blocks<
pending_data: Arc<RwLock<PendingData>>,
pending_classes: Arc<RwLock<PendingClasses>>,
block_propagation_sleep_duration: Duration,
collect_pending_data: bool,
pending_sleep_duration: Duration,
max_stream_size: u32,
) -> impl Stream<Item = Result<SyncEvent, StateSyncError>> {
Expand All @@ -680,7 +690,7 @@ fn stream_new_blocks<
);
if header_marker == central_block_marker {
// Only if the node have the last block and state (without casms), sync pending data.
if reader.begin_ro_txn()?.get_state_marker()? == header_marker{
if collect_pending_data && reader.begin_ro_txn()?.get_state_marker()? == header_marker{
// Here is the only place we update the pending data.
debug!("Start polling for pending data.");
sync_pending_data(
Expand Down
1 change: 1 addition & 0 deletions crates/papyrus_sync/src/sources/central_sync_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ fn get_test_sync_config(verify_blocks: bool) -> SyncConfig {
blocks_max_stream_size: STREAM_SIZE,
state_updates_max_stream_size: STREAM_SIZE,
verify_blocks,
collect_pending_data: false,
}
}

Expand Down
Loading