From fec904811f2e9a2b119f6185935059752df10a74 Mon Sep 17 00:00:00 2001 From: Noam Spiegelstein Date: Sun, 15 Dec 2024 13:58:22 +0200 Subject: [PATCH] chore(starknet_state_sync): add default port for state sync network config --- crates/papyrus_p2p_sync/src/client/mod.rs | 3 ++- crates/starknet_integration_tests/src/utils.rs | 17 ++++------------- crates/starknet_state_sync/src/config.rs | 4 +++- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/crates/papyrus_p2p_sync/src/client/mod.rs b/crates/papyrus_p2p_sync/src/client/mod.rs index 01e13465f72..42bbe18739a 100644 --- a/crates/papyrus_p2p_sync/src/client/mod.rs +++ b/crates/papyrus_p2p_sync/src/client/mod.rs @@ -43,7 +43,7 @@ use starknet_api::transaction::FullTransaction; use state_diff::StateDiffStreamBuilder; use stream_builder::{DataStreamBuilder, DataStreamResult}; use tokio_stream::StreamExt; -use tracing::instrument; +use tracing::{info, instrument}; use transaction::TransactionStreamFactory; const STEP: u64 = 1; const ALLOWED_SIGNATURES_LENGTH: usize = 1; @@ -240,6 +240,7 @@ impl P2PSyncClient { #[instrument(skip(self), level = "debug", err)] pub async fn run(mut self) -> Result<(), P2PSyncClientError> { + info!("Starting P2P sync client"); let mut data_stream = self.p2p_sync_channels.create_stream(self.storage_reader.clone(), self.config); diff --git a/crates/starknet_integration_tests/src/utils.rs b/crates/starknet_integration_tests/src/utils.rs index f54e7a4d61e..e99928ab3fc 100644 --- a/crates/starknet_integration_tests/src/utils.rs +++ b/crates/starknet_integration_tests/src/utils.rs @@ -10,7 +10,6 @@ use papyrus_consensus::config::ConsensusConfig; use papyrus_consensus::types::{ValidatorId, DEFAULT_VALIDATOR_ID}; use papyrus_network::network_manager::test_utils::create_network_configs_connected_to_broadcast_channels; use papyrus_network::network_manager::BroadcastTopicChannels; -use papyrus_network::NetworkConfig; use papyrus_protobuf::consensus::{ProposalPart, StreamMessage}; use papyrus_storage::StorageConfig; use starknet_api::block::BlockNumber; @@ -35,9 +34,6 @@ use starknet_sequencer_node::config::test_utils::RequiredParams; use starknet_state_sync::config::StateSyncConfig; use starknet_types_core::felt::Felt; -// TODO(Tsabary): Get rid of this constant once we have a better way to set the port for testing. -const STATE_SYNC_NETWORK_CONFIG_TCP_PORT_FOR_TESTING: u16 = 12345; - pub fn create_chain_info() -> ChainInfo { let mut chain_info = ChainInfo::create_for_testing(); // Note that the chain_id affects hashes of transactions and blocks, therefore affecting the @@ -286,13 +282,8 @@ pub fn create_state_sync_config( state_sync_storage_config: StorageConfig, sequencer_index: usize, ) -> StateSyncConfig { - StateSyncConfig { - storage_config: state_sync_storage_config, - network_config: NetworkConfig { - tcp_port: STATE_SYNC_NETWORK_CONFIG_TCP_PORT_FOR_TESTING - + u16::try_from(sequencer_index).unwrap(), - ..Default::default() - }, - ..Default::default() - } + let mut config = + StateSyncConfig { storage_config: state_sync_storage_config, ..Default::default() }; + config.network_config.tcp_port += u16::try_from(sequencer_index).unwrap(); + config } diff --git a/crates/starknet_state_sync/src/config.rs b/crates/starknet_state_sync/src/config.rs index cb0a371accc..985f2d124eb 100644 --- a/crates/starknet_state_sync/src/config.rs +++ b/crates/starknet_state_sync/src/config.rs @@ -10,6 +10,8 @@ use papyrus_storage::StorageConfig; use serde::{Deserialize, Serialize}; use validator::Validate; +const STATE_SYNC_TCP_PORT: u16 = 12345; + #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Validate)] pub struct StateSyncConfig { #[validate] @@ -44,7 +46,7 @@ impl Default for StateSyncConfig { ..Default::default() }, p2p_sync_client_config: Default::default(), - network_config: Default::default(), + network_config: NetworkConfig { tcp_port: STATE_SYNC_TCP_PORT, ..Default::default() }, } } }