Skip to content

Commit

Permalink
feat(starknet_integration_tests): enable state sync in integration test
Browse files Browse the repository at this point in the history
commit-id:0a4937c9
  • Loading branch information
nadin-Starkware committed Jan 12, 2025
1 parent 8d1e28d commit 2c4dc5e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
10 changes: 9 additions & 1 deletion crates/starknet_integration_tests/src/flow_test_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use crate::utils::{
create_consensus_manager_configs_from_network_configs,
create_mempool_p2p_configs,
create_node_config,
create_state_sync_configs,
spawn_success_recorder,
};

Expand Down Expand Up @@ -134,13 +135,20 @@ impl FlowSequencerSetup {

let component_config = ComponentConfig::default();

let state_sync_config = create_state_sync_configs(
storage_for_test.state_sync_storage_config,
available_ports.get_next_ports(1),
)
.pop()
.unwrap();

// Derive the configuration for the sequencer node.
let (node_config, _required_params) = create_node_config(
&mut available_ports,
SequencerExecutionId::new(sequencer_index, 0),
chain_info,
storage_for_test.batcher_storage_config,
storage_for_test.state_sync_storage_config,
state_sync_config,
consensus_manager_config,
mempool_p2p_config,
component_config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use starknet_monitoring_endpoint::test_utils::MonitoringClient;
use starknet_sequencer_infra::test_utils::AvailablePorts;
use starknet_sequencer_node::config::component_config::ComponentConfig;
use starknet_sequencer_node::test_utils::node_runner::NodeRunner;
use starknet_state_sync::config::StateSyncConfig;
use tempfile::{tempdir, TempDir};
use tracing::instrument;

Expand Down Expand Up @@ -71,6 +72,7 @@ pub struct SequencerSetup {
}

// TODO(Tsabary/ Nadin): reduce number of args.
#[allow(clippy::too_many_arguments)]
impl SequencerSetup {
#[instrument(skip(accounts, chain_info, consensus_manager_config), level = "debug")]
pub async fn new(
Expand All @@ -79,6 +81,7 @@ impl SequencerSetup {
chain_info: ChainInfo,
mut consensus_manager_config: ConsensusManagerConfig,
mempool_p2p_config: MempoolP2pConfig,
state_sync_config: StateSyncConfig,
mut available_ports: AvailablePorts,
component_config: ComponentConfig,
) -> Self {
Expand All @@ -94,7 +97,7 @@ impl SequencerSetup {
sequencer_execution_id,
chain_info,
storage_for_test.batcher_storage_config,
storage_for_test.state_sync_storage_config,
state_sync_config,
consensus_manager_config,
mempool_p2p_config,
component_config,
Expand Down
11 changes: 10 additions & 1 deletion crates/starknet_integration_tests/src/sequencer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ use tokio::task::JoinHandle;
use tracing::info;

use crate::integration_test_setup::{SequencerExecutionId, SequencerSetup};
use crate::state_reader::StorageTestSetup;
use crate::test_identifiers::TestIdentifier;
use crate::utils::{
create_chain_info,
create_consensus_manager_configs_from_network_configs,
create_mempool_p2p_configs,
create_state_sync_configs,
send_account_txs,
};

Expand Down Expand Up @@ -218,6 +220,11 @@ pub(crate) async fn get_sequencer_setup_configs(
create_connected_network_configs(available_ports.get_next_ports(n_distributed_sequencers)),
);

let state_sync_configs = create_state_sync_configs(
StorageTestSetup::new(accounts.to_vec(), &chain_info).state_sync_storage_config,
available_ports.get_next_ports(n_distributed_sequencers),
);

let mempool_p2p_configs = create_mempool_p2p_configs(
chain_info.chain_id.clone(),
available_ports.get_next_ports(n_distributed_sequencers),
Expand All @@ -243,7 +250,7 @@ pub(crate) async fn get_sequencer_setup_configs(
// needs only one of them, but the current setup creates one per part. Need to refactor.

stream::iter(
izip!(indexed_component_configs, consensus_manager_configs, mempool_p2p_configs)
izip!(indexed_component_configs, consensus_manager_configs, mempool_p2p_configs, state_sync_configs)
.enumerate(),
)
.then(
Expand All @@ -253,6 +260,7 @@ pub(crate) async fn get_sequencer_setup_configs(
(sequencer_execution_id, component_config),
consensus_manager_config,
mempool_p2p_config,
state_sync_config,
),
)| {
let chain_info = chain_info.clone();
Expand All @@ -263,6 +271,7 @@ pub(crate) async fn get_sequencer_setup_configs(
chain_info,
consensus_manager_config,
mempool_p2p_config,
state_sync_config,
AvailablePorts::new(test_unique_id.into(), index.try_into().unwrap()),
component_config.clone(),
)
Expand Down
6 changes: 1 addition & 5 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub async fn create_node_config(
sequencer_execution_id: SequencerExecutionId,
chain_info: ChainInfo,
batcher_storage_config: StorageConfig,
state_sync_storage_config: StorageConfig,
state_sync_config: StateSyncConfig,
mut consensus_manager_config: ConsensusManagerConfig,
mempool_p2p_config: MempoolP2pConfig,
component_config: ComponentConfig,
Expand All @@ -89,10 +89,6 @@ pub async fn create_node_config(
create_http_server_config(available_ports.get_next_local_host_socket());
let monitoring_endpoint_config =
MonitoringEndpointConfig { port: available_ports.get_next_port(), ..Default::default() };
// TODO(Nadin): get a single state_sync_config as an argument.
let state_sync_config =
create_state_sync_configs(state_sync_storage_config, available_ports.get_next_ports(1))
.remove(0);

(
SequencerNodeConfig {
Expand Down

0 comments on commit 2c4dc5e

Please sign in to comment.