diff --git a/crates/starknet_sequencer_node/src/config/component_execution_config.rs b/crates/starknet_sequencer_node/src/config/component_execution_config.rs index dbe10a55e0c..b7a289da465 100644 --- a/crates/starknet_sequencer_node/src/config/component_execution_config.rs +++ b/crates/starknet_sequencer_node/src/config/component_execution_config.rs @@ -227,3 +227,21 @@ fn validate_active_component_execution_config( _ => Ok(()), } } + +// There are components that are described with a reactive mode setting, however, result in the +// creation of two components: one reactive and one active. The defined behavior is such that +// the active component is active if and only if the local component is running locally. The +// following function applies this logic. +impl From for ActiveComponentExecutionMode { + fn from(mode: ReactiveComponentExecutionMode) -> Self { + match mode { + ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => { + ActiveComponentExecutionMode::Disabled + } + ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled + | ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled => { + ActiveComponentExecutionMode::Enabled + } + } + } +} diff --git a/crates/starknet_sequencer_node/src/servers.rs b/crates/starknet_sequencer_node/src/servers.rs index e1749a658f6..690edc2fc88 100644 --- a/crates/starknet_sequencer_node/src/servers.rs +++ b/crates/starknet_sequencer_node/src/servers.rs @@ -197,27 +197,6 @@ macro_rules! create_local_server { /// } /// ``` macro_rules! create_wrapper_server { - ($execution_mode:expr, $component:expr) => { - match *$execution_mode { - ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled - | ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => { - Some(Box::new(WrapperServer::new( - $component - .take() - .expect(concat!(stringify!($component), " is not initialized.")), - ))) - } - ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => { - None - } - } - }; -} - -// TODO(Tsabary): the following macro is a copy-pasted version of `create_wrapper_server!` macro, -// with the execution mode types changed. Once all active components have been marked as such, unify -// these. -macro_rules! create_wrapper_server_for_active_component { ($execution_mode:expr, $component:expr) => { match *$execution_mode { ActiveComponentExecutionMode::Enabled => Some(Box::new(WrapperServer::new( @@ -304,22 +283,22 @@ fn create_wrapper_servers( config: &SequencerNodeConfig, components: &mut SequencerNodeComponents, ) -> WrapperServers { - let consensus_manager_server = create_wrapper_server_for_active_component!( + let consensus_manager_server = create_wrapper_server!( &config.components.consensus_manager.execution_mode, components.consensus_manager ); - let http_server = create_wrapper_server_for_active_component!( + let http_server = create_wrapper_server!( &config.components.http_server.execution_mode, components.http_server ); - let monitoring_endpoint_server = create_wrapper_server_for_active_component!( + let monitoring_endpoint_server = create_wrapper_server!( &config.components.monitoring_endpoint.execution_mode, components.monitoring_endpoint ); let mempool_p2p_runner_server = create_wrapper_server!( - &config.components.mempool_p2p.execution_mode, + &config.components.mempool_p2p.execution_mode.clone().into(), components.mempool_p2p_runner ); WrapperServers {