Skip to content

Commit

Permalink
chore(papyrus_p2p_sync): remove stop sync at block feat
Browse files Browse the repository at this point in the history
  • Loading branch information
eitanm-starkware committed Dec 19, 2024
1 parent d8114ea commit acb4568
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 59 deletions.
10 changes: 0 additions & 10 deletions config/papyrus/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,6 @@
"privacy": "Public",
"value": 10000
},
"p2p_sync.stop_sync_at_block_number": {
"description": "Stops the sync at given block number and closes the node cleanly. Used to run profiling on the node.",
"privacy": "Public",
"value": 1000
},
"p2p_sync.stop_sync_at_block_number.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": true
},
"p2p_sync.wait_period_for_new_data": {
"description": "Time in millisseconds to wait when a query returned with partial data before sending a new query",
"privacy": "Public",
Expand Down
10 changes: 0 additions & 10 deletions config/sequencer/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1064,16 +1064,6 @@
"privacy": "Public",
"value": 10000
},
"state_sync_config.p2p_sync_client_config.stop_sync_at_block_number": {
"description": "Stops the sync at given block number and closes the node cleanly. Used to run profiling on the node.",
"privacy": "Public",
"value": 1000
},
"state_sync_config.p2p_sync_client_config.stop_sync_at_block_number.#is_none": {
"description": "Flag for an optional field.",
"privacy": "TemporaryValue",
"value": true
},
"state_sync_config.p2p_sync_client_config.wait_period_for_new_data": {
"description": "Time in millisseconds to wait when a query returned with partial data before sending a new query",
"privacy": "Public",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,18 +416,6 @@ expression: dumped_default_config
},
"privacy": "Public"
},
"p2p_sync.stop_sync_at_block_number": {
"description": "Stops the sync at given block number and closes the node cleanly. Used to run profiling on the node.",
"value": {
"$serde_json::private::Number": "1000"
},
"privacy": "Public"
},
"p2p_sync.stop_sync_at_block_number.#is_none": {
"description": "Flag for an optional field.",
"value": true,
"privacy": "TemporaryValue"
},
"p2p_sync.wait_period_for_new_data": {
"description": "Time in millisseconds to wait when a query returned with partial data before sending a new query",
"value": {
Expand Down
21 changes: 3 additions & 18 deletions crates/papyrus_p2p_sync/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use futures::Stream;
use header::HeaderStreamBuilder;
use papyrus_common::pending_classes::ApiContractClass;
use papyrus_config::converters::deserialize_milliseconds_to_duration;
use papyrus_config::dumping::{ser_optional_param, ser_param, SerializeConfig};
use papyrus_config::dumping::{ser_param, SerializeConfig};
use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam};
use papyrus_network::network_manager::SqmrClientSender;
use papyrus_protobuf::sync::{
Expand Down Expand Up @@ -62,12 +62,11 @@ pub struct P2PSyncClientConfig {
#[serde(deserialize_with = "deserialize_milliseconds_to_duration")]
pub wait_period_for_new_data: Duration,
pub buffer_size: usize,
pub stop_sync_at_block_number: Option<BlockNumber>,
}

impl SerializeConfig for P2PSyncClientConfig {
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
let mut config = BTreeMap::from_iter([
BTreeMap::from_iter([
ser_param(
"num_headers_per_query",
&self.num_headers_per_query,
Expand Down Expand Up @@ -106,16 +105,7 @@ impl SerializeConfig for P2PSyncClientConfig {
"Size of the buffer for read from the storage and for incoming responses.",
ParamPrivacyInput::Public,
),
]);
config.extend(ser_optional_param(
&self.stop_sync_at_block_number,
BlockNumber(1000),
"stop_sync_at_block_number",
"Stops the sync at given block number and closes the node cleanly. Used to run \
profiling on the node.",
ParamPrivacyInput::Public,
));
config
])
}
}

Expand All @@ -131,7 +121,6 @@ impl Default for P2PSyncClientConfig {
wait_period_for_new_data: Duration::from_millis(50),
// TODO(eitan): split this by protocol
buffer_size: 100000,
stop_sync_at_block_number: None,
}
}
}
Expand Down Expand Up @@ -190,7 +179,6 @@ impl P2PSyncClientChannels {
None,
config.wait_period_for_new_data,
config.num_headers_per_query,
config.stop_sync_at_block_number,
);

let state_diff_stream = StateDiffStreamBuilder::create_stream(
Expand All @@ -199,7 +187,6 @@ impl P2PSyncClientChannels {
None,
config.wait_period_for_new_data,
config.num_block_state_diffs_per_query,
config.stop_sync_at_block_number,
);

let transaction_stream = TransactionStreamFactory::create_stream(
Expand All @@ -208,7 +195,6 @@ impl P2PSyncClientChannels {
None,
config.wait_period_for_new_data,
config.num_block_transactions_per_query,
config.stop_sync_at_block_number,
);

let class_stream = ClassStreamBuilder::create_stream(
Expand All @@ -217,7 +203,6 @@ impl P2PSyncClientChannels {
None,
config.wait_period_for_new_data,
config.num_block_classes_per_query,
config.stop_sync_at_block_number,
);

header_stream.merge(state_diff_stream).merge(transaction_stream).merge(class_stream)
Expand Down
7 changes: 0 additions & 7 deletions crates/papyrus_p2p_sync/src/client/stream_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ where
_internal_block_receiver: Option<Receiver<(BlockNumber, Self::Output)>>,
wait_period_for_new_data: Duration,
num_blocks_per_query: u64,
stop_sync_at_block_number: Option<BlockNumber>,
) -> BoxStream<'static, DataStreamResult>
where
TQuery: From<Query> + Send + 'static,
Expand Down Expand Up @@ -134,12 +133,6 @@ where
}
info!("Added {:?} for block {}.", Self::TYPE_DESCRIPTION, current_block_number);
current_block_number = current_block_number.unchecked_next();
if stop_sync_at_block_number.is_some_and(|stop_sync_at_block_number| {
current_block_number >= stop_sync_at_block_number
}) {
info!("{:?} hit the stop sync block number.", Self::TYPE_DESCRIPTION);
return;
}
}

// Consume the None message signaling the end of the query.
Expand Down
2 changes: 0 additions & 2 deletions crates/papyrus_p2p_sync/src/client/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ lazy_static! {
num_block_classes_per_query: CLASS_DIFF_QUERY_LENGTH,
wait_period_for_new_data: WAIT_PERIOD_FOR_NEW_DATA,
buffer_size: BUFFER_SIZE,
stop_sync_at_block_number: None,
};
}
pub(crate) type HeaderTestPayload =
Expand Down Expand Up @@ -174,7 +173,6 @@ pub async fn run_test(max_query_lengths: HashMap<DataType, u64>, actions: Vec<Ac
num_block_classes_per_query: max_query_lengths.get(&DataType::Class).cloned().unwrap_or(1),
wait_period_for_new_data: WAIT_PERIOD_FOR_NEW_DATA,
buffer_size: BUFFER_SIZE,
stop_sync_at_block_number: None,
};
let buffer_size = p2p_sync_config.buffer_size;
let ((storage_reader, storage_writer), _temp_dir) = get_test_storage();
Expand Down

0 comments on commit acb4568

Please sign in to comment.