diff --git a/crates/starknet_integration_tests/src/config_utils.rs b/crates/starknet_integration_tests/src/config_utils.rs index 90b7471a67..27ebe9e3b7 100644 --- a/crates/starknet_integration_tests/src/config_utils.rs +++ b/crates/starknet_integration_tests/src/config_utils.rs @@ -125,13 +125,10 @@ pub fn get_local_with_remote_enabled_component_config( } pub async fn get_http_only_component_config(gateway_socket: SocketAddr) -> ComponentConfig { - let monitoring_endpoint_socket = get_available_socket().await; ComponentConfig { http_server: ReactiveComponentExecutionConfig::http_server_default_config(), gateway: get_remote_component_config(gateway_socket), - monitoring_endpoint: get_local_with_remote_enabled_component_config( - monitoring_endpoint_socket, - ), + monitoring_endpoint: Default::default(), batcher: get_disabled_component_config(), consensus_manager: get_disabled_component_config(), mempool: get_disabled_component_config(), @@ -141,12 +138,9 @@ pub async fn get_http_only_component_config(gateway_socket: SocketAddr) -> Compo } pub async fn get_non_http_component_config(gateway_socket: SocketAddr) -> ComponentConfig { - let monitoring_endpoint_socket = get_available_socket().await; ComponentConfig { http_server: get_disabled_component_config(), - monitoring_endpoint: get_local_with_remote_enabled_component_config( - monitoring_endpoint_socket, - ), + monitoring_endpoint: Default::default(), gateway: get_local_with_remote_enabled_component_config(gateway_socket), ..ComponentConfig::default() } diff --git a/crates/starknet_sequencer_node/src/components.rs b/crates/starknet_sequencer_node/src/components.rs index 4186acf073..8342049755 100644 --- a/crates/starknet_sequencer_node/src/components.rs +++ b/crates/starknet_sequencer_node/src/components.rs @@ -12,7 +12,10 @@ use starknet_monitoring_endpoint::monitoring_endpoint::{ }; use crate::clients::SequencerNodeClients; -use crate::config::component_execution_config::ReactiveComponentExecutionMode; +use crate::config::component_execution_config::{ + ActiveComponentExecutionMode, + ReactiveComponentExecutionMode, +}; use crate::config::node_config::SequencerNodeConfig; use crate::version::VERSION_FULL; @@ -106,11 +109,11 @@ pub fn create_node_components( }; let monitoring_endpoint = match config.components.monitoring_endpoint.execution_mode { - ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled => Some( - create_monitoring_endpoint(config.monitoring_endpoint_config.clone(), VERSION_FULL), - ), - ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled => None, - ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None, + ActiveComponentExecutionMode::Enabled => Some(create_monitoring_endpoint( + config.monitoring_endpoint_config.clone(), + VERSION_FULL, + )), + ActiveComponentExecutionMode::Disabled => None, }; SequencerNodeComponents { diff --git a/crates/starknet_sequencer_node/src/config/component_config.rs b/crates/starknet_sequencer_node/src/config/component_config.rs index 6373d07806..d3aaaf18bd 100644 --- a/crates/starknet_sequencer_node/src/config/component_config.rs +++ b/crates/starknet_sequencer_node/src/config/component_config.rs @@ -5,11 +5,15 @@ use papyrus_config::{ParamPath, SerializedParam}; use serde::{Deserialize, Serialize}; use validator::Validate; -use crate::config::component_execution_config::ReactiveComponentExecutionConfig; +use crate::config::component_execution_config::{ + ActiveComponentExecutionConfig, + ReactiveComponentExecutionConfig, +}; /// The components configuration. #[derive(Clone, Debug, Serialize, Deserialize, Validate, PartialEq)] pub struct ComponentConfig { + // Reactive component configs. #[validate] pub batcher: ReactiveComponentExecutionConfig, #[validate] @@ -23,9 +27,10 @@ pub struct ComponentConfig { #[validate] pub mempool_p2p: ReactiveComponentExecutionConfig, #[validate] - pub monitoring_endpoint: ReactiveComponentExecutionConfig, - #[validate] pub state_sync: ReactiveComponentExecutionConfig, + + // Reactive component configs. + pub monitoring_endpoint: ActiveComponentExecutionConfig, } impl Default for ComponentConfig { @@ -37,9 +42,9 @@ impl Default for ComponentConfig { http_server: ReactiveComponentExecutionConfig::http_server_default_config(), mempool: ReactiveComponentExecutionConfig::mempool_default_config(), mempool_p2p: ReactiveComponentExecutionConfig::mempool_p2p_default_config(), - monitoring_endpoint: - ReactiveComponentExecutionConfig::monitoring_endpoint_default_config(), state_sync: ReactiveComponentExecutionConfig::state_sync_default_config(), + // Reactive component configs. + monitoring_endpoint: Default::default(), } } } 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 1757c8b1f6..6f6312987e 100644 --- a/crates/starknet_sequencer_node/src/config/component_execution_config.rs +++ b/crates/starknet_sequencer_node/src/config/component_execution_config.rs @@ -115,18 +115,6 @@ impl ReactiveComponentExecutionConfig { } } - // TODO(Tsabary/Lev): There's a bug here: the monitoring endpoint component does not - // need a local nor a remote config. However, the validation function requires that at least - // one of them is set. As a workaround I've set the local one, but this should be addressed. - pub fn monitoring_endpoint_default_config() -> Self { - Self { - execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteEnabled, - local_server_config: Some(LocalServerConfig::default()), - remote_client_config: None, - remote_server_config: Some(RemoteServerConfig::default()), - } - } - pub fn mempool_default_config() -> Self { Self { execution_mode: ReactiveComponentExecutionMode::LocalExecutionWithRemoteDisabled, diff --git a/crates/starknet_sequencer_node/src/servers.rs b/crates/starknet_sequencer_node/src/servers.rs index b1eb61cfcd..b4e974c520 100644 --- a/crates/starknet_sequencer_node/src/servers.rs +++ b/crates/starknet_sequencer_node/src/servers.rs @@ -25,7 +25,10 @@ use tracing::error; use crate::clients::SequencerNodeClients; use crate::communication::SequencerNodeCommunication; use crate::components::SequencerNodeComponents; -use crate::config::component_execution_config::ReactiveComponentExecutionMode; +use crate::config::component_execution_config::{ + ActiveComponentExecutionMode, + ReactiveComponentExecutionMode, +}; use crate::config::node_config::SequencerNodeConfig; // Component servers that can run locally. @@ -211,6 +214,20 @@ macro_rules! create_wrapper_server { }; } +// 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( + $component.take().expect(concat!(stringify!($component), " is not initialized.")), + ))), + ActiveComponentExecutionMode::Disabled => None, + } + }; +} + fn create_local_servers( config: &SequencerNodeConfig, communication: &mut SequencerNodeCommunication, @@ -296,7 +313,7 @@ fn create_wrapper_servers( components.http_server ); - let monitoring_endpoint_server = create_wrapper_server!( + let monitoring_endpoint_server = create_wrapper_server_for_active_component!( &config.components.monitoring_endpoint.execution_mode, components.monitoring_endpoint );