Skip to content

Commit

Permalink
chore: return vector of SequencerNodeConfig in create config function
Browse files Browse the repository at this point in the history
commit-id:c0d54930
  • Loading branch information
nadin-Starkware committed Dec 11, 2024
1 parent 147879b commit bc7f74f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
30 changes: 21 additions & 9 deletions crates/starknet_integration_tests/src/flow_test_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::utils::{
create_chain_info,
create_config,
create_consensus_manager_configs_and_channels,
get_http_server_config,
};

const SEQUENCER_0: usize = 0;
Expand Down Expand Up @@ -95,7 +96,7 @@ pub struct SequencerSetup {
// Handle of the sequencer node.
pub sequencer_node_handles: Vec<JoinHandle<Result<(), anyhow::Error>>>,

pub config: SequencerNodeConfig,
pub configs: Vec<SequencerNodeConfig>,
}

impl SequencerSetup {
Expand All @@ -120,7 +121,7 @@ impl SequencerSetup {
.await;

// Derive the configuration for the sequencer node.
let (config, _required_params) = create_config(
let (configs, _required_params) = create_config(
sequencer_index,
chain_info,
rpc_server_addr,
Expand All @@ -129,16 +130,27 @@ impl SequencerSetup {
)
.await;

debug!("Sequencer config: {:#?}", config);
debug!("Sequencer configs: {:#?}", configs);

let (_clients, servers) = create_node_modules(&config);
let mut all_clients = vec![];
let mut all_servers = vec![];
for config in configs.iter() {
let (clients, servers) = create_node_modules(config);
all_clients.push(clients);
all_servers.push(servers);
}

let HttpServerConfig { ip, port } = config.http_server_config;
let add_tx_http_client = HttpTestClient::new(SocketAddr::from((ip, port)));
let HttpServerConfig { ip, port } =
get_http_server_config(&configs).expect("No matching HttpServerConfig found");
let add_tx_http_client = HttpTestClient::new(SocketAddr::from((*ip, *port)));

// Build and run the sequencer node.
let sequencer_node_future = run_component_servers(servers);
let sequencer_node_handles = vec![task_executor.spawn_with_handle(sequencer_node_future)];
let mut sequencer_node_handles = vec![];
for server in all_servers {
let sequencer_node_future = run_component_servers(server);
let sequencer_node_handle = task_executor.spawn_with_handle(sequencer_node_future);
sequencer_node_handles.push(sequencer_node_handle);
}

// Wait for server to spin up.
// TODO(Gilad): Replace with a persistent Client with a built-in retry to protect against CI
Expand All @@ -151,7 +163,7 @@ impl SequencerSetup {
batcher_storage_file_handle: storage_for_test.batcher_storage_handle,
rpc_storage_file_handle: storage_for_test.rpc_storage_handle,
sequencer_node_handles,
config,
configs,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl IntegrationTestSetup {
create_consensus_manager_configs_and_channels(SEQUENCER_INDICES.len());

// Derive the configuration for the sequencer node.
let (config, required_params) = create_config(
let (configs, required_params) = create_config(
SEQUENCER_INDEX,
chain_info,
rpc_server_addr,
Expand All @@ -66,9 +66,11 @@ impl IntegrationTestSetup {
)
.await;

let config = &configs[0];

let node_config_dir_handle = tempdir().unwrap();
let node_config_path = dump_config_file_changes(
&config,
config,
required_params,
node_config_dir_handle.path().to_path_buf(),
);
Expand All @@ -84,7 +86,7 @@ impl IntegrationTestSetup {
add_tx_http_client,
is_alive_test_client,
batcher_storage_handle: storage_for_test.batcher_storage_handle,
batcher_storage_config: config.batcher_config.storage,
batcher_storage_config: config.batcher_config.storage.clone(),
rpc_storage_handle: storage_for_test.rpc_storage_handle,
node_config_dir_handle,
node_config_path,
Expand Down
6 changes: 3 additions & 3 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub async fn create_config(
rpc_server_addr: SocketAddr,
batcher_storage_config: StorageConfig,
mut consensus_manager_config: ConsensusManagerConfig,
) -> (SequencerNodeConfig, RequiredParams) {
) -> (Vec<SequencerNodeConfig>, RequiredParams) {
set_validator_id(&mut consensus_manager_config, sequencer_index);
let fee_token_addresses = chain_info.fee_token_addresses.clone();
let batcher_config = create_batcher_config(batcher_storage_config, chain_info.clone());
Expand All @@ -62,7 +62,7 @@ pub async fn create_config(
let monitoring_endpoint_config = create_monitoring_endpoint_config(sequencer_index);

(
SequencerNodeConfig {
vec![SequencerNodeConfig {
batcher_config,
consensus_manager_config,
gateway_config,
Expand All @@ -71,7 +71,7 @@ pub async fn create_config(
mempool_p2p_config,
monitoring_endpoint_config,
..Default::default()
},
}],
RequiredParams {
chain_id: chain_info.chain_id,
eth_fee_token_address: fee_token_addresses.eth_fee_token_address,
Expand Down

0 comments on commit bc7f74f

Please sign in to comment.