From 3314e89a81be6834404d21af4decba4e552cdec8 Mon Sep 17 00:00:00 2001 From: nadin-Starkware Date: Wed, 13 Nov 2024 18:49:28 +0200 Subject: [PATCH] chore: rename getters for shared clients commit-id:9bfa6756 --- .../src/flow_test_setup.rs | 2 +- crates/starknet_sequencer_node/src/clients.rs | 14 ++++--- .../starknet_sequencer_node/src/components.rs | 39 ++++++++++--------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/crates/starknet_integration_tests/src/flow_test_setup.rs b/crates/starknet_integration_tests/src/flow_test_setup.rs index dfd683f6cb4..c8750ec5324 100644 --- a/crates/starknet_integration_tests/src/flow_test_setup.rs +++ b/crates/starknet_integration_tests/src/flow_test_setup.rs @@ -79,7 +79,7 @@ impl FlowTestSetup { task_executor, add_tx_http_client, batcher_storage_file_handle: storage_for_test.batcher_storage_handle, - batcher_client: clients.get_batcher_client().unwrap(), + batcher_client: clients.get_batcher_shared_client().unwrap(), rpc_storage_file_handle: storage_for_test.rpc_storage_handle, sequencer_node_handle, consensus_proposals_channels, diff --git a/crates/starknet_sequencer_node/src/clients.rs b/crates/starknet_sequencer_node/src/clients.rs index 0518b251ee8..084acf25db0 100644 --- a/crates/starknet_sequencer_node/src/clients.rs +++ b/crates/starknet_sequencer_node/src/clients.rs @@ -65,11 +65,11 @@ pub struct SequencerNodeClients { /// // Assuming `SequencerNodeClients` struct has fields `batcher_client` and `mempool_client`, /// // each with methods `get_local_client()` and `get_remote_client()`. /// impl SequencerNodeClients { -/// pub fn get_batcher_client(&self) -> Option> { +/// pub fn get_batcher_shared_client(&self) -> Option> { /// get_shared_client!(self, batcher_client) /// } /// -/// pub fn get_mempool_client(&self) -> Option> { +/// pub fn get_mempool_shared_client(&self) -> Option> { /// get_shared_client!(self, mempool_client) /// } /// } @@ -97,19 +97,21 @@ macro_rules! get_shared_client { } impl SequencerNodeClients { - pub fn get_batcher_client(&self) -> Option { + pub fn get_batcher_shared_client(&self) -> Option { get_shared_client!(self, batcher_client) } - pub fn get_mempool_client(&self) -> Option { + pub fn get_mempool_shared_client(&self) -> Option { get_shared_client!(self, mempool_client) } - pub fn get_gateway_client(&self) -> Option { + pub fn get_gateway_shared_client(&self) -> Option { get_shared_client!(self, gateway_client) } - pub fn get_mempool_p2p_propagator_client(&self) -> Option { + pub fn get_mempool_p2p_propagator_shared_client( + &self, + ) -> Option { get_shared_client!(self, mempool_p2p_propagator_client) } } diff --git a/crates/starknet_sequencer_node/src/components.rs b/crates/starknet_sequencer_node/src/components.rs index f021cfbb168..266f37f15ed 100644 --- a/crates/starknet_sequencer_node/src/components.rs +++ b/crates/starknet_sequencer_node/src/components.rs @@ -35,7 +35,7 @@ pub fn create_node_components( ComponentExecutionMode::LocalExecutionWithRemoteDisabled | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let mempool_client = - clients.get_mempool_client().expect("Mempool Client should be available"); + clients.get_mempool_shared_client().expect("Mempool Client should be available"); Some(create_batcher(config.batcher_config.clone(), mempool_client)) } ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None, @@ -44,7 +44,7 @@ pub fn create_node_components( ComponentExecutionMode::LocalExecutionWithRemoteDisabled | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let batcher_client = - clients.get_batcher_client().expect("Batcher Client should be available"); + clients.get_batcher_shared_client().expect("Batcher Client should be available"); Some(ConsensusManager::new(config.consensus_manager_config.clone(), batcher_client)) } ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None, @@ -53,7 +53,7 @@ pub fn create_node_components( ComponentExecutionMode::LocalExecutionWithRemoteDisabled | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let mempool_client = - clients.get_mempool_client().expect("Mempool Client should be available"); + clients.get_mempool_shared_client().expect("Mempool Client should be available"); Some(create_gateway( config.gateway_config.clone(), @@ -68,33 +68,34 @@ pub fn create_node_components( ComponentExecutionMode::LocalExecutionWithRemoteDisabled | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let gateway_client = - clients.get_gateway_client().expect("Gateway Client should be available"); + clients.get_gateway_shared_client().expect("Gateway Client should be available"); Some(create_http_server(config.http_server_config.clone(), gateway_client)) } ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => None, }; - let (mempool_p2p_propagator, mempool_p2p_runner) = - match config.components.mempool_p2p.execution_mode { - ComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { - let gateway_client = - clients.get_gateway_client().expect("Gateway Client should be available"); - let (mempool_p2p_propagator, mempool_p2p_runner) = create_p2p_propagator_and_runner( - config.mempool_p2p_config.clone(), - gateway_client, - ); - (Some(mempool_p2p_propagator), Some(mempool_p2p_runner)) - } - ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => (None, None), - }; + let (mempool_p2p_propagator, mempool_p2p_runner) = match config + .components + .mempool_p2p + .execution_mode + { + ComponentExecutionMode::LocalExecutionWithRemoteDisabled + | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { + let gateway_client = + clients.get_gateway_shared_client().expect("Gateway Client should be available"); + let (mempool_p2p_propagator, mempool_p2p_runner) = + create_p2p_propagator_and_runner(config.mempool_p2p_config.clone(), gateway_client); + (Some(mempool_p2p_propagator), Some(mempool_p2p_runner)) + } + ComponentExecutionMode::Disabled | ComponentExecutionMode::Remote => (None, None), + }; let mempool = match config.components.mempool.execution_mode { ComponentExecutionMode::LocalExecutionWithRemoteDisabled | ComponentExecutionMode::LocalExecutionWithRemoteEnabled => { let mempool_p2p_propagator_client = clients - .get_mempool_p2p_propagator_client() + .get_mempool_p2p_propagator_shared_client() .expect("Propagator Client should be available"); let mempool = create_mempool(mempool_p2p_propagator_client); Some(mempool)