Skip to content

Commit

Permalink
chore(starknet_state_sync): add default port for state sync network c…
Browse files Browse the repository at this point in the history
…onfig
  • Loading branch information
noamsp-starkware committed Dec 15, 2024
1 parent 98ba6c1 commit fec9048
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
3 changes: 2 additions & 1 deletion crates/papyrus_p2p_sync/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
17 changes: 4 additions & 13 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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
}
4 changes: 3 additions & 1 deletion crates/starknet_state_sync/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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() },
}
}
}

0 comments on commit fec9048

Please sign in to comment.